dovecot-2.2: lib-master: master_auth_request_full() now supports...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Nov 17 15:27:25 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/8fa5d235065b
changeset: 19383:8fa5d235065b
user: Timo Sirainen <tss at iki.fi>
date: Tue Nov 17 17:23:31 2015 +0200
description:
lib-master: master_auth_request_full() now supports per-request path.
diffstat:
src/lib-master/master-auth.c | 26 +++++++++++++++-----------
src/lib-master/master-auth.h | 2 ++
2 files changed, 17 insertions(+), 11 deletions(-)
diffs (122 lines):
diff -r b4a406dce5b8 -r 8fa5d235065b src/lib-master/master-auth.c
--- a/src/lib-master/master-auth.c Tue Nov 17 17:11:05 2015 +0200
+++ b/src/lib-master/master-auth.c Tue Nov 17 17:23:31 2015 +0200
@@ -18,6 +18,7 @@
struct master_auth *auth;
unsigned int tag;
+ char *path;
int fd;
struct io *io;
struct timeout *to;
@@ -33,7 +34,7 @@
struct master_service *service;
pool_t pool;
- const char *path;
+ const char *default_path;
unsigned int tag_counter;
HASH_TABLE(void *, struct master_auth_connection *) connections;
@@ -49,7 +50,7 @@
auth = p_new(pool, struct master_auth, 1);
auth->pool = pool;
auth->service = service;
- auth->path = p_strdup(pool, path);
+ auth->default_path = p_strdup(pool, path);
hash_table_create_direct(&auth->connections, pool, 0);
return auth;
}
@@ -74,9 +75,10 @@
io_remove(&conn->io);
if (conn->fd != -1) {
if (close(conn->fd) < 0)
- i_fatal("close(%s) failed: %m", conn->auth->path);
+ i_fatal("close(%s) failed: %m", conn->path);
conn->fd = -1;
}
+ i_free(conn->path);
i_free(conn);
}
@@ -110,11 +112,11 @@
if (ret == 0 || errno == ECONNRESET) {
i_error("read(%s) failed: Remote closed connection "
"(destination service { process_limit } reached?)",
- conn->auth->path);
+ conn->path);
} else {
if (errno == EAGAIN)
return;
- i_error("read(%s) failed: %m", conn->auth->path);
+ i_error("read(%s) failed: %m", conn->path);
}
master_auth_connection_deinit(&conn);
return;
@@ -130,7 +132,7 @@
if (conn->tag != reply->tag)
i_error("master(%s): Received reply with unknown tag %u",
- conn->auth->path, reply->tag);
+ conn->path, reply->tag);
else if (conn->callback == NULL) {
/* request aborted */
} else {
@@ -143,7 +145,7 @@
static void master_auth_connection_timeout(struct master_auth_connection *conn)
{
i_error("master(%s): Auth request timed out (received %u/%u bytes)",
- conn->auth->path, conn->buf_pos,
+ conn->path, conn->buf_pos,
(unsigned int)sizeof(conn->buf));
master_auth_connection_deinit(&conn);
}
@@ -166,6 +168,8 @@
conn->auth = auth;
conn->callback = callback;
conn->context = context;
+ conn->path = params->socket_path != NULL ?
+ i_strdup(params->socket_path) : i_strdup(auth->default_path);
req = params->request;
req.tag = ++auth->tag_counter;
@@ -181,11 +185,11 @@
buffer_append(buf, &req, sizeof(req));
buffer_append(buf, params->data, req.data_size);
- conn->fd = net_connect_unix_with_retries(auth->path,
+ conn->fd = net_connect_unix_with_retries(conn->path,
SOCKET_CONNECT_RETRY_MSECS);
if (conn->fd == -1) {
i_error("net_connect_unix(%s) failed: %m%s",
- auth->path, errno != EAGAIN ? "" :
+ conn->path, errno != EAGAIN ? "" :
" - http://wiki2.dovecot.org/SocketUnavailable");
master_auth_connection_deinit(&conn);
return;
@@ -193,11 +197,11 @@
ret = fd_send(conn->fd, params->client_fd, buf->data, buf->used);
if (ret < 0) {
- i_error("fd_send(%s, %d) failed: %m", auth->path,
+ i_error("fd_send(%s, %d) failed: %m", conn->path,
params->client_fd);
} else if ((size_t)ret != buf->used) {
i_error("fd_send(%s) sent only %d of %d bytes",
- auth->path, (int)ret, (int)buf->used);
+ conn->path, (int)ret, (int)buf->used);
ret = -1;
}
if (ret < 0) {
diff -r b4a406dce5b8 -r 8fa5d235065b src/lib-master/master-auth.h
--- a/src/lib-master/master-auth.h Tue Nov 17 17:11:05 2015 +0200
+++ b/src/lib-master/master-auth.h Tue Nov 17 17:23:31 2015 +0200
@@ -70,6 +70,8 @@
/* Client fd to transfer to post-login process or -1 if no fd is
wanted to be transferred. */
int client_fd;
+ /* Override master_auth->default_path if non-NULL */
+ const char *socket_path;
/* Authentication request that is sent to post-login process.
tag is ignored. */
More information about the dovecot-cvs
mailing list