Lines Matching refs:state
13 /* void psc_early_tests(state)
14 /* PSC_STATE *state;
63 static void psc_allowlist_non_dnsbl(PSC_STATE *state)
78 if ((state->flags & PSC_STATE_MASK_ANY_FAIL) == 0
79 && state->dnsbl_score < var_psc_dnsbl_thresh
81 && state->dnsbl_score <= var_psc_dnsbl_althresh) {
86 if ((state->flags & PSC_STATE_FLAG_BYTINDX_TODO(tindx))
87 && !(state->flags & PSC_STATE_FLAG_BYTINDX_PASS(tindx))) {
90 psc_test_name(tindx), PSC_CLIENT_ADDR_PORT(state));
92 state->flags |= PSC_STATE_FLAG_BYTINDX_DONE(tindx);
94 state->flags |= PSC_STATE_FLAG_BYTINDX_PASS(tindx);
97 if (state->client_info->expire_time[tindx] < now + state->dnsbl_ttl)
98 state->client_info->expire_time[tindx] = now + state->dnsbl_ttl;
108 PSC_STATE *state = (PSC_STATE *) context;
109 time_t *expire_time = state->client_info->expire_time;
117 event, vstream_fileno(state->smtp_client_stream),
118 state->smtp_client_addr, state->smtp_client_port,
119 psc_print_state_flags(state->flags, myname));
121 PSC_CLEAR_EVENT_REQUEST(vstream_fileno(state->smtp_client_stream),
146 if ((state->flags & PSC_STATE_FLAG_PREGR_TODO) != 0
147 && (state->flags & PSC_STATE_MASK_PREGR_FAIL_DONE) == 0) {
149 PSC_PASS_SESSION_STATE(state, "pregreet test",
152 if ((state->flags & PSC_STATE_FLAG_PREGR_FAIL)
154 PSC_UNFAIL_SESSION_STATE(state, PSC_STATE_FLAG_PREGR_FAIL);
170 if (state->flags & PSC_STATE_FLAG_DNSBL_TODO) {
171 if (state->dnsbl_score == NO_DNSBL_SCORE) {
172 state->dnsbl_score =
173 psc_dnsbl_retrieve(state->smtp_client_addr,
174 &state->dnsbl_name,
175 state->dnsbl_index,
176 &state->dnsbl_ttl);
178 psc_allowlist_non_dnsbl(state);
180 if (state->dnsbl_score < var_psc_dnsbl_thresh) {
181 expire_time[PSC_TINDX_DNSBL] = event_time() + state->dnsbl_ttl;
182 PSC_PASS_SESSION_STATE(state, "dnsbl test",
186 state->dnsbl_score, PSC_CLIENT_ADDR_PORT(state));
187 PSC_FAIL_SESSION_STATE(state, PSC_STATE_FLAG_DNSBL_FAIL);
190 state->dnsbl_reply = vstring_sprintf(vstring_alloc(100),
192 state->smtp_client_addr,
193 state->dnsbl_name);
194 PSC_DROP_SESSION_STATE(state, STR(state->dnsbl_reply));
197 state->dnsbl_reply = vstring_sprintf(vstring_alloc(100),
199 state->smtp_client_addr,
200 state->dnsbl_name);
201 PSC_ENFORCE_SESSION_STATE(state, STR(state->dnsbl_reply));
204 PSC_UNFAIL_SESSION_STATE(state, PSC_STATE_FLAG_DNSBL_FAIL);
219 if ((state->flags & PSC_STATE_FLAG_NOFORWARD) != 0
220 || ((state->flags & PSC_STATE_MASK_SMTPD_PASS)
221 != PSC_STATE_FLAGS_TODO_TO_PASS(state->flags & PSC_STATE_MASK_SMTPD_TODO)))
222 psc_smtpd_tests(state);
224 psc_conclude(state);
233 if ((read_count = recv(vstream_fileno(state->smtp_client_stream),
236 if (state->dnsbl_score == NO_DNSBL_SCORE
237 && (state->flags & PSC_STATE_FLAG_DNSBL_TODO))
238 (void) psc_dnsbl_retrieve(state->smtp_client_addr,
239 &state->dnsbl_name,
240 state->dnsbl_index,
241 &state->dnsbl_ttl);
243 psc_hangup_event(state);
249 psc_format_delta_time(psc_temp, state->start_time, &elapsed),
250 PSC_CLIENT_ADDR_PORT(state), STR(psc_escape_buf));
251 PSC_FAIL_SESSION_STATE(state, PSC_STATE_FLAG_PREGR_FAIL);
255 if (state->dnsbl_score == NO_DNSBL_SCORE
256 && (state->flags & PSC_STATE_FLAG_DNSBL_TODO))
257 (void) psc_dnsbl_retrieve(state->smtp_client_addr,
258 &state->dnsbl_name,
259 state->dnsbl_index,
260 &state->dnsbl_ttl);
261 PSC_DROP_SESSION_STATE(state, "521 5.5.1 Protocol error\r\n");
265 PSC_ENFORCE_SESSION_STATE(state, "550 5.5.1 Protocol error\r\n");
285 state->flags |= PSC_STATE_FLAG_PREGR_DONE;
287 || ((state->flags & PSC_STATE_MASK_EARLY_DONE)
288 == PSC_STATE_FLAGS_TODO_TO_DONE(state->flags & PSC_STATE_MASK_EARLY_TODO)))
302 PSC_STATE *state = (PSC_STATE *) context;
305 msg_info("%s: notify [%s]:%s", myname, PSC_CLIENT_ADDR_PORT(state));
310 state->dnsbl_score =
311 psc_dnsbl_retrieve(state->smtp_client_addr, &state->dnsbl_name,
312 state->dnsbl_index, &state->dnsbl_ttl);
314 psc_allowlist_non_dnsbl(state);
321 state->flags |= PSC_STATE_FLAG_DNSBL_DONE;
322 if ((state->flags & PSC_STATE_MASK_EARLY_DONE)
323 == PSC_STATE_FLAGS_TODO_TO_DONE(state->flags & PSC_STATE_MASK_EARLY_TODO))
329 void psc_early_tests(PSC_STATE *state)
336 PSC_BEGIN_TESTS(state, "tests before SMTP handshake");
342 if ((state->flags & PSC_STATE_FLAG_PREGR_TODO) != 0
344 && PSC_SEND_REPLY(state, psc_teaser_greeting) != 0) {
345 psc_hangup_event(state);
352 if ((state->flags & PSC_STATE_FLAG_DNSBL_TODO) != 0)
353 state->dnsbl_index =
354 psc_dnsbl_request(state->smtp_client_addr, psc_early_dnsbl_event,
355 (void *) state);
357 state->dnsbl_index = -1;
358 state->dnsbl_score = NO_DNSBL_SCORE;
363 if ((state->flags & PSC_STATE_FLAG_PREGR_TODO) != 0)
364 PSC_READ_EVENT_REQUEST(vstream_fileno(state->smtp_client_stream),
365 psc_early_event, (void *) state, PSC_EFF_GREET_WAIT);
367 event_request_timer(psc_early_event, (void *) state, PSC_EFF_GREET_WAIT);