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)
struct auth_master_connection {
char *auth_socket_path;
+ enum auth_master_flags flags;
int fd;
struct ioloop *ioloop;
void *context);
void *reply_context;
- unsigned int debug:1;
unsigned int sent_handshake:1;
unsigned int handshaked:1;
unsigned int aborted:1;
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;
}
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;
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)
#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;
};
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 */
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);
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;
/* 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 {
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()) {