[dovecot-cvs] dovecot/src/auth auth-master-connection.c, 1.30,
1.31 auth-request.c, 1.14, 1.15 auth-request.h, 1.12,
1.13 auth-worker-client.c, 1.3, 1.4
cras at dovecot.org
cras at dovecot.org
Mon Mar 7 22:21:56 EET 2005
Update of /var/lib/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv2502
Modified Files:
auth-master-connection.c auth-request.c auth-request.h
auth-worker-client.c
Log Message:
Handle USER requests from master connections.
Index: auth-master-connection.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-master-connection.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- auth-master-connection.c 7 Mar 2005 18:55:13 -0000 1.30
+++ auth-master-connection.c 7 Mar 2005 20:21:52 -0000 1.31
@@ -86,6 +86,44 @@
return TRUE;
}
+static void
+user_callback(const char *result, struct auth_request *auth_request)
+{
+ struct auth_master_connection *conn = auth_request->context;
+ string_t *str;
+
+ str = t_str_new(128);
+ if (result == NULL)
+ str_printfa(str, "NOTFOUND\t%u\n", auth_request->id);
+ else {
+ str_printfa(str, "USER\t%u\t", auth_request->id);
+ str_append(str, result);
+ str_append_c(str, '\n');
+ }
+ (void)o_stream_send(conn->output, str_data(str), str_len(str));
+}
+
+static int
+master_input_user(struct auth_master_connection *conn, const char *args)
+{
+ struct auth_request *auth_request;
+ const char *const *list;
+
+ /* <id> <userid> */
+ list = t_strsplit(args, "\t");
+ if (list[0] == NULL || list[1] == NULL) {
+ i_error("BUG: Master sent broken USER");
+ return FALSE;
+ }
+
+ auth_request = auth_request_new_dummy(conn->auth);
+ auth_request->id = (unsigned int)strtoul(list[0], NULL, 10);
+ auth_request->user = p_strdup(auth_request->pool, list[1]);
+ auth_request->context = conn;
+ auth_request_lookup_user(auth_request, user_callback);
+ return TRUE;
+}
+
static int
master_input_die(struct auth_master_connection *conn)
{
@@ -137,6 +175,8 @@
t_push();
if (strncmp(line, "REQUEST\t", 8) == 0)
ret = master_input_request(conn, line + 8);
+ else if (strncmp(line, "USER\t", 5) == 0)
+ ret = master_input_user(conn, line + 5);
else if (strcmp(line, "DIE") == 0)
ret = master_input_die(conn);
else {
Index: auth-request.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-request.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- auth-request.c 7 Mar 2005 18:55:13 -0000 1.14
+++ auth-request.c 7 Mar 2005 20:21:52 -0000 1.15
@@ -37,6 +37,24 @@
return request;
}
+struct auth_request *auth_request_new_dummy(struct auth *auth)
+{
+ struct auth_request *auth_request;
+ pool_t pool;
+
+ pool = pool_alloconly_create("auth_request", 256);
+ auth_request = p_new(pool, struct auth_request, 1);
+ auth_request->pool = pool;
+
+ auth_request->refcount = 1;
+ auth_request->created = ioloop_time;
+ auth_request->auth = auth;
+ auth_request->passdb = auth->passdbs;
+ auth_request->userdb = auth->userdbs;
+
+ return auth_request;
+}
+
void auth_request_success(struct auth_request *request,
const void *data, size_t data_size)
{
Index: auth-request.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-request.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- auth-request.h 7 Mar 2005 18:55:13 -0000 1.12
+++ auth-request.h 7 Mar 2005 20:21:52 -0000 1.13
@@ -62,6 +62,7 @@
struct auth_request *
auth_request_new(struct auth *auth, struct mech_module *mech,
mech_callback_t *callback, void *context);
+struct auth_request *auth_request_new_dummy(struct auth *auth);
void auth_request_ref(struct auth_request *request);
int auth_request_unref(struct auth_request *request);
Index: auth-worker-client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-worker-client.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- auth-worker-client.c 7 Mar 2005 19:16:15 -0000 1.3
+++ auth-worker-client.c 7 Mar 2005 20:21:52 -0000 1.4
@@ -45,17 +45,8 @@
{
struct auth_request *auth_request;
const char *key, *value, *const *tmp;
- pool_t pool;
-
- pool = pool_alloconly_create("auth_request", 256);
- auth_request = p_new(pool, struct auth_request, 1);
- auth_request->pool = pool;
- auth_request->refcount = 1;
- auth_request->created = ioloop_time;
- auth_request->auth = client->auth;
- auth_request->passdb = client->auth->passdbs;
- auth_request->userdb = client->auth->userdbs;
+ auth_request = auth_request_new_dummy(client->auth);
client->refcount++;
auth_request->context = client;
@@ -70,11 +61,13 @@
key = t_strdup_until(*tmp, value);
value++;
- if (strcmp(key, "user") == 0)
- auth_request->user = p_strdup(pool, value);
- else if (strcmp(key, "service") == 0)
- auth_request->service = p_strdup(pool, value);
- else if (strcmp(key, "lip") == 0)
+ if (strcmp(key, "user") == 0) {
+ auth_request->user =
+ p_strdup(auth_request->pool, value);
+ } else if (strcmp(key, "service") == 0) {
+ auth_request->service =
+ p_strdup(auth_request->pool, value);
+ } else if (strcmp(key, "lip") == 0)
net_addr2ip(value, &auth_request->local_ip);
else if (strcmp(key, "rip") == 0)
net_addr2ip(value, &auth_request->remote_ip);
More information about the dovecot-cvs
mailing list