]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Idle-disconnecting auth master connections is now optional. LMTP no longer does it.
authorTimo Sirainen <tss@iki.fi>
Wed, 16 Dec 2009 01:27:07 +0000 (20:27 -0500)
committerTimo Sirainen <tss@iki.fi>
Wed, 16 Dec 2009 01:27:07 +0000 (20:27 -0500)
--HG--
branch : HEAD

src/doveadm/doveadm-auth.c
src/lib-auth/auth-master.c
src/lib-auth/auth-master.h
src/lib-storage/mail-storage-service.c
src/lib-storage/mail-storage-service.h
src/lmtp/main.c

index 2077b6e2bf5173566bb0059e20177c56c447ffb5..8c38051db0742ccdc95f2c649b00e7a94a273c5b 100644 (file)
@@ -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)
index 2b65ff5a017cf720e52880ff086e0f51212510a8..ee7d99bfe18624eeda3b67a8e941b5c71b46ad8b 100644 (file)
@@ -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)
index 4eaf578b9707ea5bf0039dc5c0ad7488cee44b07..b6c8a1835341981a18923c293bd6677df3694dc4 100644 (file)
@@ -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 */
index fe987ecaa9add72fe7c3cc0830a5c6311fd58a8f..16d494fe1d143367bf243e9443e3dac5c04fd4fa 100644 (file)
@@ -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;
index 1a0c8ce3db669d2b0e00a5fdbf0fcd5cb5dc8eef..bb6539eb89d66f25c029ea07abc170f4446e09c8 100644 (file)
@@ -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 {
index 8708610258062a37e84ecdce2bee4b39b897320d..d1bf6be312535ed656aa3de889585cf94fbf945f 100644 (file)
@@ -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()) {