auth-master.c revision 69d60dcff2614c4bfc8ad59e8fdc09e39c9dd0dc
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes/* Copyright (c) 2005-2009 Dovecot authors, see the included COPYING file */
70953fb44a7140fe206c3a5f011e24209c8c5c6abnicholes#define DEFAULT_USERDB_LOOKUP_PREFIX "userdb lookup"
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes const char *prefix;
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes bool (*reply_callback)(const char *cmd, const char *const *args,
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes const char *user;
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes const char *const *user_strings;
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesstatic void auth_input(struct auth_master_connection *conn);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesauth_master_init(const char *auth_socket_path, bool debug)
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes conn->auth_socket_path = i_strdup(auth_socket_path);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesstatic void auth_connection_close(struct auth_master_connection *conn)
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes i_error("close(%s) failed: %m", conn->auth_socket_path);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesvoid auth_master_deinit(struct auth_master_connection **_conn)
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesstatic void auth_request_lookup_abort(struct auth_master_connection *conn)
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesstatic void auth_parse_input(struct auth_master_user_lookup_ctx *ctx,
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes const char *const *args)
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes p_array_init(&reply->extra_fields, ctx->pool, 64);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesstatic int auth_input_handshake(struct auth_master_connection *conn)
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes while ((line = i_stream_next_line(conn->input)) != NULL) {
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes if (strcmp(tmp[1], dec2str(AUTH_PROTOCOL_MAJOR)) != 0) {
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes "Auth protocol version mismatch "
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesstatic bool auth_user_reply_callback(const char *cmd, const char *const *args,
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes struct auth_master_user_lookup_ctx *ctx = context;
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes i_error("userdb lookup(%s) failed: %s", ctx->user,
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesauth_handle_line(struct auth_master_connection *conn, const char *line)
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes return conn->reply_callback(cmd, args, conn->reply_context);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes "It should be a master socket.",
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes i_error("%s: BUG: Unexpected input: %s", conn->prefix, line);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesstatic void auth_input(struct auth_master_connection *conn)
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes const char *line;
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes /* disconnected */
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes /* buffer full */
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes while ((line = i_stream_next_line(conn->input)) != NULL) {
return FALSE;
return TRUE;
const char *cmd)
const char *str;
const char *str;
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;