dovecot-2.2: lib-master: Added extensible master_auth_request_fu...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Nov 17 15:27:24 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/b4a406dce5b8
changeset: 19382:b4a406dce5b8
user: Timo Sirainen <tss at iki.fi>
date: Tue Nov 17 17:11:05 2015 +0200
description:
lib-master: Added extensible master_auth_request_full() call.
Only the API was changed, no changes to functionality.
diffstat:
src/lib-master/master-auth.c | 44 ++++++++++++++++++++++++++++-------------
src/lib-master/master-auth.h | 23 ++++++++++++++++++---
src/login-common/sasl-server.c | 10 +++++++-
3 files changed, 57 insertions(+), 20 deletions(-)
diffs (158 lines):
diff -r d39daee9d72c -r b4a406dce5b8 src/lib-master/master-auth.c
--- a/src/lib-master/master-auth.c Tue Nov 17 16:30:16 2015 +0200
+++ b/src/lib-master/master-auth.c Tue Nov 17 17:11:05 2015 +0200
@@ -148,11 +148,10 @@
master_auth_connection_deinit(&conn);
}
-void master_auth_request(struct master_auth *auth, int fd,
- const struct master_auth_request *request,
- const unsigned char *data,
- master_auth_callback_t *callback,
- void *context, unsigned int *tag_r)
+void master_auth_request_full(struct master_auth *auth,
+ const struct master_auth_request_params *params,
+ master_auth_callback_t *callback, void *context,
+ unsigned int *tag_r)
{
struct master_auth_connection *conn;
struct master_auth_request req;
@@ -160,27 +159,27 @@
struct stat st;
ssize_t ret;
- i_assert(request->client_pid != 0);
- i_assert(request->auth_pid != 0);
+ i_assert(params->request.client_pid != 0);
+ i_assert(params->request.auth_pid != 0);
conn = i_new(struct master_auth_connection, 1);
conn->auth = auth;
conn->callback = callback;
conn->context = context;
- req = *request;
+ req = params->request;
req.tag = ++auth->tag_counter;
if (req.tag == 0)
req.tag = ++auth->tag_counter;
- if (fstat(fd, &st) < 0)
+ if (fstat(params->client_fd, &st) < 0)
i_fatal("fstat(auth dest fd) failed: %m");
req.ino = st.st_ino;
buf = buffer_create_dynamic(pool_datastack_create(),
sizeof(req) + req.data_size);
buffer_append(buf, &req, sizeof(req));
- buffer_append(buf, data, req.data_size);
+ buffer_append(buf, params->data, req.data_size);
conn->fd = net_connect_unix_with_retries(auth->path,
SOCKET_CONNECT_RETRY_MSECS);
@@ -192,10 +191,11 @@
return;
}
- ret = fd_send(conn->fd, fd, buf->data, buf->used);
- if (ret < 0)
- i_error("fd_send(%s, %d) failed: %m", auth->path, fd);
- else if ((size_t)ret != buf->used) {
+ 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,
+ 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);
ret = -1;
@@ -215,6 +215,22 @@
*tag_r = req.tag;
}
+void master_auth_request(struct master_auth *auth, int fd,
+ const struct master_auth_request *request,
+ const unsigned char *data,
+ master_auth_callback_t *callback,
+ void *context, unsigned int *tag_r)
+{
+ struct master_auth_request_params params;
+
+ memset(¶ms, 0, sizeof(params));
+ params.client_fd = fd;
+ params.request = *request;
+ params.data = data;
+
+ master_auth_request_full(auth, ¶ms, callback, context, tag_r);
+}
+
void master_auth_request_abort(struct master_auth *auth, unsigned int tag)
{
struct master_auth_connection *conn;
diff -r d39daee9d72c -r b4a406dce5b8 src/lib-master/master-auth.h
--- a/src/lib-master/master-auth.h Tue Nov 17 16:30:16 2015 +0200
+++ b/src/lib-master/master-auth.h Tue Nov 17 17:11:05 2015 +0200
@@ -66,6 +66,18 @@
pid_t mail_pid;
};
+struct master_auth_request_params {
+ /* Client fd to transfer to post-login process or -1 if no fd is
+ wanted to be transferred. */
+ int client_fd;
+
+ /* Authentication request that is sent to post-login process.
+ tag is ignored. */
+ struct master_auth_request request;
+ /* Client input of size request.data_size */
+ const unsigned char *data;
+};
+
/* reply=NULL if the auth lookup was cancelled due to some error */
typedef void master_auth_callback_t(const struct master_auth_reply *reply,
void *context);
@@ -74,10 +86,13 @@
master_auth_init(struct master_service *service, const char *path);
void master_auth_deinit(struct master_auth **auth);
-/* Send an authentication request. The fd contains the file descriptor to
- transfer, or -1 if no fd is wanted to be transferred. Returns tag which can
- be used to abort the request (ie. ignore the reply from master).
- request->tag is ignored. */
+/* Send an authentication request. Returns tag which can be used to abort the
+ request (ie. ignore the reply from master). */
+void master_auth_request_full(struct master_auth *auth,
+ const struct master_auth_request_params *params,
+ master_auth_callback_t *callback, void *context,
+ unsigned int *tag_r);
+/* For backwards compatibility: */
void master_auth_request(struct master_auth *auth, int fd,
const struct master_auth_request *request,
const unsigned char *data,
diff -r d39daee9d72c -r b4a406dce5b8 src/login-common/sasl-server.c
--- a/src/login-common/sasl-server.c Tue Nov 17 16:30:16 2015 +0200
+++ b/src/login-common/sasl-server.c Tue Nov 17 17:11:05 2015 +0200
@@ -121,6 +121,7 @@
static void master_send_request(struct anvil_request *anvil_request)
{
struct client *client = anvil_request->client;
+ struct master_auth_request_params params;
struct master_auth_request req;
const unsigned char *data;
size_t size;
@@ -151,8 +152,13 @@
client->auth_finished = ioloop_time;
client->master_auth_id = req.auth_id;
- master_auth_request(master_auth, client->fd, &req, buf->data,
- master_auth_callback, client, &client->master_tag);
+
+ memset(¶ms, 0, sizeof(params));
+ params.client_fd = client->fd;
+ params.request = req;
+ params.data = buf->data;
+ master_auth_request_full(master_auth, ¶ms, master_auth_callback,
+ client, &client->master_tag);
}
static void ATTR_NULL(1)
More information about the dovecot-cvs
mailing list