Lines Matching refs:state
11 /* void smtpd_sasl_state_init(state)
12 /* SMTPD_STATE *state;
16 /* void smtpd_sasl_activate(state, sasl_opts_name, sasl_opts_val)
17 /* SMTPD_STATE *state;
21 /* char *smtpd_sasl_authenticate(state, sasl_method, init_response)
22 /* SMTPD_STATE *state;
26 /* void smtpd_sasl_logout(state)
27 /* SMTPD_STATE *state;
29 /* void smtpd_sasl_login(state, sasl_username, sasl_method)
30 /* SMTPD_STATE *state;
34 /* void smtpd_sasl_deactivate(state)
35 /* SMTPD_STATE *state;
37 /* int smtpd_sasl_is_active(state)
38 /* SMTPD_STATE *state;
40 /* int smtpd_sasl_set_inactive(state)
41 /* SMTPD_STATE *state;
46 /* smtpd_sasl_state_init() performs minimal server state
65 /* state structure members:
86 /* if the SMTP server session state is between smtpd_sasl_activate()
90 /* state before the first smtpd_sasl_activate() call.
93 /* .IP state
200 void smtpd_sasl_activate(SMTPD_STATE *state, const char *sasl_opts_name,
211 if (smtpd_sasl_is_active(state))
215 * Initialize SASL-specific state variables. Use long-lived storage for
220 state->sasl_reply = vstring_alloc(20);
221 state->sasl_mechanism_list = 0;
227 tls_flag = state->tls_context != 0;
234 if ((state->sasl_server =
236 stream = state->client,
237 addr_family = state->addr_family,
238 server_addr = ADDR_OR_EMPTY(state->dest_addr,
240 server_port = ADDR_OR_EMPTY(state->dest_port,
242 client_addr = ADDR_OR_EMPTY(state->addr,
244 client_port = ADDR_OR_EMPTY(state->port,
256 xsasl_server_get_mechanism_list(state->sasl_server)) == 0)
263 state->sasl_mechanism_list = mystrdup(filtered_mechanism_list);
266 /* smtpd_sasl_state_init - initialize state to allow extern authentication. */
268 void smtpd_sasl_state_init(SMTPD_STATE *state)
271 state->sasl_username = 0;
272 state->sasl_method = 0;
273 state->sasl_sender = 0;
278 void smtpd_sasl_deactivate(SMTPD_STATE *state)
280 if (state->sasl_reply) {
281 vstring_free(state->sasl_reply);
282 state->sasl_reply = 0;
284 if (state->sasl_mechanism_list) {
285 myfree(state->sasl_mechanism_list);
286 state->sasl_mechanism_list = 0;
288 if (state->sasl_username) {
289 myfree(state->sasl_username);
290 state->sasl_username = 0;
292 if (state->sasl_method) {
293 myfree(state->sasl_method);
294 state->sasl_method = 0;
296 if (state->sasl_sender) {
297 myfree(state->sasl_sender);
298 state->sasl_sender = 0;
300 if (state->sasl_server) {
301 xsasl_server_free(state->sasl_server);
302 state->sasl_server = 0;
308 int smtpd_sasl_authenticate(SMTPD_STATE *state,
319 for (status = xsasl_server_first(state->sasl_server, sasl_method,
320 init_response, state->sasl_reply);
322 status = xsasl_server_next(state->sasl_server, STR(state->buffer),
323 state->sasl_reply)) {
328 smtpd_chat_reply(state, "334 %s", STR(state->sasl_reply));
333 if (!smtpd_chat_query_limit(state, var_smtpd_sasl_resp_limit)) {
334 smtpd_chat_reply(state, "500 5.5.6 SASL response limit exceeded");
337 if (strcmp(STR(state->buffer), "*") == 0) {
339 state->namaddr, sasl_method);
340 smtpd_chat_reply(state, "501 5.7.0 Authentication aborted");
345 sasl_username = xsasl_server_get_username(state->sasl_server);
347 state->namaddr, sasl_method, *STR(state->sasl_reply) ?
348 STR(state->sasl_reply) : "(reason unavailable)",
352 smtpd_chat_reply(state, "454 4.7.0 Temporary authentication failure: %s",
353 STR(state->sasl_reply));
355 smtpd_chat_reply(state, "535 5.7.8 Error: authentication failed: %s",
356 STR(state->sasl_reply));
360 smtpd_chat_reply(state, "235 2.7.0 Authentication successful");
361 if ((sasl_username = xsasl_server_get_username(state->sasl_server)) == 0)
363 state->sasl_username = mystrdup(sasl_username);
364 printable(state->sasl_username, '?');
365 state->sasl_method = mystrdup(sasl_method);
366 printable(state->sasl_method, '?');
373 void smtpd_sasl_logout(SMTPD_STATE *state)
375 if (state->sasl_username) {
376 myfree(state->sasl_username);
377 state->sasl_username = 0;
379 if (state->sasl_method) {
380 myfree(state->sasl_method);
381 state->sasl_method = 0;
387 void smtpd_sasl_login(SMTPD_STATE *state, const char *sasl_username,
390 if (state->sasl_username)
391 myfree(state->sasl_username);
392 state->sasl_username = mystrdup(sasl_username);
393 if (state->sasl_method)
394 myfree(state->sasl_method);
395 state->sasl_method = mystrdup(sasl_method);