From: Timo Sirainen Date: Wed, 16 Dec 2009 01:27:07 +0000 (-0500) Subject: Idle-disconnecting auth master connections is now optional. LMTP no longer does it. X-Git-Tag: 2.0.beta2~122 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c5a6a6565be93224fc26522eda855b0990f256e8;p=thirdparty%2Fdovecot%2Fcore.git Idle-disconnecting auth master connections is now optional. LMTP no longer does it. --HG-- branch : HEAD --- diff --git a/src/doveadm/doveadm-auth.c b/src/doveadm/doveadm-auth.c index 2077b6e2bf..8c38051db0 100644 --- a/src/doveadm/doveadm-auth.c +++ b/src/doveadm/doveadm-auth.c @@ -34,7 +34,7 @@ cmd_user_input(const char *auth_socket_path, const struct authtest_input *input) pool = pool_alloconly_create("auth master lookup", 1024); - conn = auth_master_init(auth_socket_path, FALSE); + conn = auth_master_init(auth_socket_path, 0); ret = auth_master_user_lookup(conn, input->username, &input->info, pool, &username, &fields); if (ret < 0) diff --git a/src/lib-auth/auth-master.c b/src/lib-auth/auth-master.c index 2b65ff5a01..ee7d99bfe1 100644 --- a/src/lib-auth/auth-master.c +++ b/src/lib-auth/auth-master.c @@ -27,6 +27,7 @@ struct auth_master_connection { char *auth_socket_path; + enum auth_master_flags flags; int fd; struct ioloop *ioloop; @@ -42,7 +43,6 @@ struct auth_master_connection { void *context); void *reply_context; - unsigned int debug:1; unsigned int sent_handshake:1; unsigned int handshaked:1; unsigned int aborted:1; @@ -69,14 +69,14 @@ struct auth_master_user_list_ctx { static void auth_input(struct auth_master_connection *conn); struct auth_master_connection * -auth_master_init(const char *auth_socket_path, bool debug) +auth_master_init(const char *auth_socket_path, enum auth_master_flags flags) { struct auth_master_connection *conn; conn = i_new(struct auth_master_connection, 1); conn->auth_socket_path = i_strdup(auth_socket_path); conn->fd = -1; - conn->debug = debug; + conn->flags = flags; conn->prefix = DEFAULT_USERDB_LOOKUP_PREFIX; return conn; } @@ -167,7 +167,7 @@ static bool auth_lookup_reply_callback(const char *cmd, const char *const *args, ctx->fields = p_new(ctx->pool, const char *, len + 1); for (i = 0; i < len; i++) ctx->fields[i] = p_strdup(ctx->pool, args[i]); - if (ctx->conn->debug) + if ((ctx->conn->flags & AUTH_MASTER_FLAG_DEBUG) != 0) i_debug("auth input: %s", t_strarray_join(args, " ")); } return TRUE; @@ -302,8 +302,10 @@ static void auth_master_unset_io(struct auth_master_connection *conn, o_stream_unref(&conn->output); io_loop_destroy(&conn->ioloop); - conn->to = timeout_add(1000*AUTH_MASTER_IDLE_SECS, - auth_idle_timeout, conn); + if ((conn->flags & AUTH_MASTER_FLAG_NO_IDLE_TIMEOUT) == 0) { + conn->to = timeout_add(1000*AUTH_MASTER_IDLE_SECS, + auth_idle_timeout, conn); + } } static bool is_valid_string(const char *str) diff --git a/src/lib-auth/auth-master.h b/src/lib-auth/auth-master.h index 4eaf578b97..b6c8a18353 100644 --- a/src/lib-auth/auth-master.h +++ b/src/lib-auth/auth-master.h @@ -3,6 +3,13 @@ #include "network.h" +enum auth_master_flags { + /* Enable logging debug information */ + AUTH_MASTER_FLAG_DEBUG = 0x01, + /* Don't disconnect from auth socket when idling */ + AUTH_MASTER_FLAG_NO_IDLE_TIMEOUT = 0x02 +}; + struct auth_user_info { const char *service; struct ip_addr local_ip, remote_ip; @@ -17,7 +24,7 @@ struct auth_user_reply { }; struct auth_master_connection * -auth_master_init(const char *auth_socket_path, bool debug); +auth_master_init(const char *auth_socket_path, enum auth_master_flags flags); void auth_master_deinit(struct auth_master_connection **conn); /* Do a USER lookup. Returns -1 = error, 0 = user not found, 1 = ok */ diff --git a/src/lib-storage/mail-storage-service.c b/src/lib-storage/mail-storage-service.c index fe987ecaa9..16d494fe1d 100644 --- a/src/lib-storage/mail-storage-service.c +++ b/src/lib-storage/mail-storage-service.c @@ -630,6 +630,7 @@ mail_storage_service_first_init(struct mail_storage_service_ctx *ctx, const struct mail_user_settings *user_set) { const struct mail_storage_settings *mail_set; + enum auth_master_flags flags = 0; i_assert(ctx->conn == NULL); @@ -637,8 +638,11 @@ mail_storage_service_first_init(struct mail_storage_service_ctx *ctx, MAIL_STORAGE_SET_DRIVER_NAME); ctx->debug = mail_set->mail_debug; - ctx->conn = auth_master_init(user_set->auth_socket_path, - ctx->debug); + if (ctx->debug) + flags |= AUTH_MASTER_FLAG_DEBUG; + if ((ctx->flags & MAIL_STORAGE_SERVICE_FLAG_NO_IDLE_TIMEOUT) != 0) + flags |= AUTH_MASTER_FLAG_NO_IDLE_TIMEOUT; + ctx->conn = auth_master_init(user_set->auth_socket_path, flags); i_assert(mail_user_auth_master_conn == NULL); mail_user_auth_master_conn = ctx->conn; diff --git a/src/lib-storage/mail-storage-service.h b/src/lib-storage/mail-storage-service.h index 1a0c8ce3db..bb6539eb89 100644 --- a/src/lib-storage/mail-storage-service.h +++ b/src/lib-storage/mail-storage-service.h @@ -24,7 +24,9 @@ enum mail_storage_service_flags { /* Don't initialize logging or change log prefixes */ MAIL_STORAGE_SERVICE_NO_LOG_INIT = 0x80, /* Don't load plugins in _service_lookup() */ - MAIL_STORAGE_SERVICE_NO_PLUGINS = 0x100 + MAIL_STORAGE_SERVICE_NO_PLUGINS = 0x100, + /* Don't close auth connections because of idling. */ + MAIL_STORAGE_SERVICE_FLAG_NO_IDLE_TIMEOUT = 0x200 }; struct mail_storage_service_input { diff --git a/src/lmtp/main.c b/src/lmtp/main.c index 8708610258..d1bf6be312 100644 --- a/src/lmtp/main.c +++ b/src/lmtp/main.c @@ -57,7 +57,8 @@ int main(int argc, char *argv[]) MAIL_STORAGE_SERVICE_FLAG_DISALLOW_ROOT | MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP | MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP | - MAIL_STORAGE_SERVICE_NO_LOG_INIT; + MAIL_STORAGE_SERVICE_NO_LOG_INIT | + MAIL_STORAGE_SERVICE_FLAG_NO_IDLE_TIMEOUT; int c; if (IS_STANDALONE()) {