[dovecot-cvs]
dovecot/src/login-common Makefile.am,1.4,1.5 auth-common.c,1.4,1.5
auth-common.h,1.1,1.2 client-common.h,1.3,1.4 common.h,1.2,1.3
main.c,1.12,1.13 master.c,1.6,1.7 master.h,1.3,1.4
auth-connection.c,1.13,NONE auth-connection.h,1.4,NONE
cras at procontrol.fi
cras at procontrol.fi
Fri Aug 22 06:42:15 EEST 2003
- Previous message: [dovecot-cvs] dovecot/src/auth auth-client-connection.c,NONE,1.1
auth-client-connection.h,NONE,1.1 auth-client-interface.h,NONE,1.1
auth-master-connection.c,NONE,1.1 auth-master-connection.h,NONE,1.1
Makefile.am,1.20,1.21 auth-master-interface.h,1.2,1.3
main.c,1.20,1.21 mech-anonymous.c,1.1,1.2
mech-digest-md5.c,1.12,1.13 mech-plain.c,1.13,1.14 mech.c,1.11,1.12
mech.h,1.9,1.10 auth-login-interface.h,1.5,NONE
login-connection.c,1.24,NONE login-connection.h,1.4,NONE
master-connection.c,1.11,NONE master-connection.h,1.1,NONE
- Next message: [dovecot-cvs] dovecot/src/imap-login Makefile.am,1.2,1.3
client-authenticate.c,1.8,1.9 client.c,1.16,1.17 client.h,1.4,1.5
common.h,1.1,NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/login-common
In directory danu:/tmp/cvs-serv8684/src/login-common
Modified Files:
Makefile.am auth-common.c auth-common.h client-common.h
common.h main.c master.c master.h
Removed Files:
auth-connection.c auth-connection.h
Log Message:
Moved client side code for auth process handling to lib-auth. Some other login process cleanups.
Index: Makefile.am
===================================================================
RCS file: /home/cvs/dovecot/src/login-common/Makefile.am,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Makefile.am 4 Mar 2003 22:38:08 -0000 1.4
+++ Makefile.am 22 Aug 2003 02:42:13 -0000 1.5
@@ -2,12 +2,12 @@
INCLUDES = \
-I$(top_srcdir)/src/lib \
+ -I$(top_srcdir)/src/lib-auth \
-DPKG_RUNDIR=\""$(localstatedir)/run/$(PACKAGE)"\" \
-DSBINDIR=\""$(sbindir)"\"
liblogin_common_a_SOURCES = \
auth-common.c \
- auth-connection.c \
main.c \
master.c \
ssl-proxy.c \
@@ -16,7 +16,6 @@
noinst_HEADERS = \
auth-common.h \
- auth-connection.h \
client-common.h \
common.h \
master.h \
Index: auth-common.c
===================================================================
RCS file: /home/cvs/dovecot/src/login-common/auth-common.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- auth-common.c 18 Feb 2003 19:11:26 -0000 1.4
+++ auth-common.c 22 Aug 2003 02:42:13 -0000 1.5
@@ -3,11 +3,11 @@
#include "common.h"
#include "ioloop.h"
#include "client-common.h"
-#include "auth-connection.h"
+#include "auth-client.h"
#include "auth-common.h"
-static const char *auth_login_get_str(struct auth_login_reply *reply,
- const unsigned char *data, size_t idx)
+static const char *auth_client_get_str(struct auth_client_request_reply *reply,
+ const unsigned char *data, size_t idx)
{
size_t stop;
@@ -20,47 +20,44 @@
return t_strndup(data + idx, stop);
}
-int auth_callback(struct auth_request *request, struct auth_login_reply *reply,
+int auth_callback(struct auth_request *request,
+ struct auth_client_request_reply *reply,
const unsigned char *data, struct client *client,
- master_callback_t *master_callback, const char **error)
+ master_callback_t *master_callback, const char **error_r)
{
const char *user;
- *error = NULL;
+ *error_r = NULL;
if (reply == NULL) {
/* failed */
- if (client->auth_request != NULL) {
- auth_request_unref(client->auth_request);
- client->auth_request = NULL;
- }
- *error = "Authentication process died.";
+ client->auth_request = NULL;
+ *error_r = "Authentication process died.";
return -1;
}
switch (reply->result) {
- case AUTH_LOGIN_RESULT_CONTINUE:
+ case AUTH_CLIENT_RESULT_CONTINUE:
if (client->auth_request != NULL) {
i_assert(client->auth_request == request);
} else {
i_assert(client->auth_request == NULL);
client->auth_request = request;
- auth_request_ref(client->auth_request);
}
return 0;
- case AUTH_LOGIN_RESULT_SUCCESS:
- auth_request_unref(client->auth_request);
+ case AUTH_CLIENT_RESULT_SUCCESS:
client->auth_request = NULL;
- user = auth_login_get_str(reply, data, reply->username_idx);
+ user = auth_client_get_str(reply, data, reply->username_idx);
i_free(client->virtual_user);
client->virtual_user = i_strdup(user);
- master_request_imap(client, master_callback,
- request->conn->pid, request->id);
+ master_request_login(client, master_callback,
+ auth_client_request_get_server_pid(request),
+ auth_client_request_get_id(request));
/* disable IO until we're back from master */
if (client->io != NULL) {
@@ -69,14 +66,13 @@
}
return 1;
- case AUTH_LOGIN_RESULT_FAILURE:
+ case AUTH_CLIENT_RESULT_FAILURE:
/* see if we have error message */
- auth_request_unref(client->auth_request);
client->auth_request = NULL;
if (reply->data_size > 0 && data[reply->data_size-1] == '\0') {
- *error = t_strconcat("Authentication failed: ",
- (const char *) data, NULL);
+ *error_r = t_strconcat("Authentication failed: ",
+ (const char *) data, NULL);
}
return -1;
}
Index: auth-common.h
===================================================================
RCS file: /home/cvs/dovecot/src/login-common/auth-common.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- auth-common.h 2 Feb 2003 10:46:20 -0000 1.1
+++ auth-common.h 22 Aug 2003 02:42:13 -0000 1.2
@@ -1,9 +1,10 @@
#ifndef __AUTH_COMMON_H
#define __AUTH_COMMON_H
-int auth_callback(struct auth_request *request, struct auth_login_reply *reply,
+int auth_callback(struct auth_request *request,
+ struct auth_client_request_reply *reply,
const unsigned char *data, struct client *client,
- master_callback_t *master_callback, const char **error);
+ master_callback_t *master_callback, const char **error_r);
#endif
Index: client-common.h
===================================================================
RCS file: /home/cvs/dovecot/src/login-common/client-common.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- client-common.h 4 Mar 2003 22:38:08 -0000 1.3
+++ client-common.h 22 Aug 2003 02:42:13 -0000 1.4
@@ -10,7 +10,8 @@
int fd;
struct io *io;
- struct auth_request *auth_request;
+ struct auth_request *auth_request;
+ unsigned int master_tag;
master_callback_t *master_callback;
char *virtual_user;
@@ -20,7 +21,7 @@
struct client *client_create(int fd, struct ip_addr *ip, int ssl);
unsigned int clients_get_count(void);
-void clients_notify_auth_process(void);
+void clients_notify_auth_connected(void);
void clients_destroy_all(void);
void clients_init(void);
Index: common.h
===================================================================
RCS file: /home/cvs/dovecot/src/login-common/common.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- common.h 23 Feb 2003 19:44:47 -0000 1.2
+++ common.h 22 Aug 2003 02:42:13 -0000 1.3
@@ -2,12 +2,12 @@
#define __COMMON_H
#include "lib.h"
-#include "../auth/auth-login-interface.h"
extern int disable_plaintext_auth, process_per_connection, verbose_proctitle;
extern int verbose_ssl;
extern unsigned int max_logging_users;
extern unsigned int login_process_uid;
+extern struct auth_client *auth_client;
void main_ref(void);
void main_unref(void);
Index: main.c
===================================================================
RCS file: /home/cvs/dovecot/src/login-common/main.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- main.c 16 Jul 2003 06:37:04 -0000 1.12
+++ main.c 22 Aug 2003 02:42:13 -0000 1.13
@@ -7,9 +7,9 @@
#include "restrict-process-size.h"
#include "process-title.h"
#include "fd-close-on-exec.h"
-#include "auth-connection.h"
#include "master.h"
#include "client-common.h"
+#include "auth-client.h"
#include "ssl-proxy.h"
#include <stdlib.h>
@@ -20,6 +20,7 @@
int verbose_ssl;
unsigned int max_logging_users;
unsigned int login_process_uid;
+struct auth_client *auth_client;
static struct ioloop *ioloop;
static struct io *io_listen, *io_ssl_listen;
@@ -113,6 +114,13 @@
(void)client_create(fd_ssl, &ip, TRUE);
}
+static void auth_connect_notify(struct auth_client *client __attr_unused__,
+ int connected, void *context __attr_unused__)
+{
+ if (connected)
+ clients_notify_auth_connected();
+}
+
static void open_logfile(const char *name)
{
if (getenv("USE_SYSLOG") != NULL)
@@ -140,6 +148,7 @@
/* Refuse to run as root - we should never need it and it's
dangerous with SSL. */
restrict_access_by_env(TRUE);
+ sleep(5);
/* make sure we can't fork() */
restrict_process_size((unsigned int)-1, 1);
@@ -169,7 +178,8 @@
closing_down = FALSE;
main_refcount = 0;
- auth_connection_init();
+ auth_client = auth_client_new((unsigned int)getpid());
+ auth_client_set_connect_notify(auth_client, auth_connect_notify, NULL);
clients_init();
io_listen = io_ssl_listen = NULL;
@@ -209,7 +219,7 @@
ssl_proxy_deinit();
- auth_connection_deinit();
+ auth_client_free(auth_client);
clients_deinit();
master_deinit();
Index: master.c
===================================================================
RCS file: /home/cvs/dovecot/src/login-common/master.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- master.c 4 Mar 2003 22:38:08 -0000 1.6
+++ master.c 22 Aug 2003 02:42:13 -0000 1.7
@@ -16,6 +16,7 @@
static int master_fd;
static struct io *io_master;
static struct hash_table *master_requests;
+static unsigned int master_tag_counter;
static unsigned int master_pos;
static char master_buf[sizeof(struct master_login_reply)];
@@ -33,15 +34,17 @@
hash_remove(master_requests, POINTER_CAST(reply->tag));
}
-void master_request_imap(struct client *client, master_callback_t *callback,
- unsigned int auth_pid, unsigned int auth_id)
+void master_request_login(struct client *client, master_callback_t *callback,
+ unsigned int auth_pid, unsigned int auth_id)
{
struct master_login_request req;
i_assert(auth_pid != 0);
memset(&req, 0, sizeof(req));
- req.tag = client->fd;
+ req.tag = ++master_tag_counter;
+ if (req.tag == 0)
+ req.tag = ++master_tag_counter;
req.auth_pid = auth_pid;
req.auth_id = auth_id;
req.ip = client->ip;
@@ -49,8 +52,18 @@
if (fd_send(master_fd, client->fd, &req, sizeof(req)) != sizeof(req))
i_fatal("fd_send(%d) failed: %m", client->fd);
+ client->master_tag = req.tag;
client->master_callback = callback;
+
hash_insert(master_requests, POINTER_CAST(req.tag), client);
+}
+
+void master_request_abort(struct client *client)
+{
+ client->master_tag = 0;
+ client->master_callback = NULL;
+
+ hash_remove(master_requests, POINTER_CAST(client->master_tag));
}
void master_notify_finished(void)
Index: master.h
===================================================================
RCS file: /home/cvs/dovecot/src/login-common/master.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- master.h 4 Mar 2003 22:38:08 -0000 1.3
+++ master.h 22 Aug 2003 02:42:13 -0000 1.4
@@ -7,8 +7,9 @@
typedef void master_callback_t(struct client *client, int success);
-void master_request_imap(struct client *client, master_callback_t *callback,
- unsigned int auth_pid, unsigned int auth_id);
+void master_request_login(struct client *client, master_callback_t *callback,
+ unsigned int auth_pid, unsigned int auth_id);
+void master_request_abort(struct client *client);
/* Notify master that we're not listening for new connections anymore. */
void master_notify_finished(void);
--- auth-connection.c DELETED ---
--- auth-connection.h DELETED ---
- Previous message: [dovecot-cvs] dovecot/src/auth auth-client-connection.c,NONE,1.1
auth-client-connection.h,NONE,1.1 auth-client-interface.h,NONE,1.1
auth-master-connection.c,NONE,1.1 auth-master-connection.h,NONE,1.1
Makefile.am,1.20,1.21 auth-master-interface.h,1.2,1.3
main.c,1.20,1.21 mech-anonymous.c,1.1,1.2
mech-digest-md5.c,1.12,1.13 mech-plain.c,1.13,1.14 mech.c,1.11,1.12
mech.h,1.9,1.10 auth-login-interface.h,1.5,NONE
login-connection.c,1.24,NONE login-connection.h,1.4,NONE
master-connection.c,1.11,NONE master-connection.h,1.1,NONE
- Next message: [dovecot-cvs] dovecot/src/imap-login Makefile.am,1.2,1.3
client-authenticate.c,1.8,1.9 client.c,1.16,1.17 client.h,1.4,1.5
common.h,1.1,NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list