auth-master.c revision 61767c7537efe3eb51f80d37cda12d69c67f3c05
5f5870385cff47efd2f58e7892f251cf13761528Timo Sirainen/* Copyright (c) 2005-2011 Dovecot authors, see the included COPYING file */
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen#define DEFAULT_USERDB_LOOKUP_PREFIX "userdb lookup"
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen bool (*reply_callback)(const char *cmd, const char *const *args,
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen const char **fields;
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen const char *const *user_strings;
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainenstatic void auth_input(struct auth_master_connection *conn);
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainenauth_master_init(const char *auth_socket_path, enum auth_master_flags flags)
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen conn = i_new(struct auth_master_connection, 1);
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen conn->auth_socket_path = i_strdup(auth_socket_path);
eef20a55e19a239244b14963d716cf0d070fe1bbTimo Sirainenstatic void auth_connection_close(struct auth_master_connection *conn)
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen i_error("close(%s) failed: %m", conn->auth_socket_path);
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainenvoid auth_master_deinit(struct auth_master_connection **_conn)
eef20a55e19a239244b14963d716cf0d070fe1bbTimo Sirainenstatic void auth_request_lookup_abort(struct auth_master_connection *conn)
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainenstatic int auth_input_handshake(struct auth_master_connection *conn)
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen while ((line = i_stream_next_line(conn->input)) != NULL) {
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen if (strcmp(tmp[1], dec2str(AUTH_PROTOCOL_MAJOR)) != 0) {
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen "Auth protocol version mismatch "
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainenstatic int parse_reply(const char *cmd, const char *const *args,
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen const char *expected_reply, const char *user, bool debug)
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen } else if (debug) {
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen i_debug("user %s: Auth %s lookup returned temporary failure: %s",
const char *p, *p2;
return args;
void *context)
unsigned int i, len;
for (i = 0; i < len; i++)
for (i = 0; i < len; i++) {
if (debug) {
return TRUE;
args++;
return FALSE;
const char *line;
bool ret;
T_BEGIN {
} T_END;
if (!ret)
int fd;
return FALSE;
return TRUE;
const char *cmd)
const char *str;
const char *const **fields_r)
void *context)
const char *user;
return TRUE;
return TRUE;
return FALSE;
struct auth_master_user_list_ctx *
const char *str;
return ctx;
return NULL;
return ret;