[dovecot-cvs] dovecot/src/imap-login client-authenticate.c, 1.31,
1.32 client.c, 1.30, 1.31
cras at dovecot.org
cras at dovecot.org
Mon Oct 18 04:13:27 EEST 2004
Update of /var/lib/cvs/dovecot/src/imap-login
In directory talvi:/tmp/cvs-serv24063/src/imap-login
Modified Files:
client-authenticate.c client.c
Log Message:
Implemented support for LOGIN-REFERRALS using "referral" and "reason"
parameters from auth server.
Index: client-authenticate.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap-login/client-authenticate.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- client-authenticate.c 13 Oct 2004 16:38:34 -0000 1.31
+++ client-authenticate.c 18 Oct 2004 01:13:25 -0000 1.32
@@ -76,8 +76,54 @@
safe_memset(line, 0, strlen(line));
}
+static int client_handle_success_args(struct imap_client *client,
+ const char *const *args, int nologin)
+{
+ const char *reason = NULL, *referral = NULL;
+ string_t *reply;
+
+ for (; *args != NULL; args++) {
+ if (strcmp(*args, "nologin") == 0)
+ nologin = TRUE;
+ else if (strncmp(*args, "reason=", 7) == 0)
+ reason = *args + 7;
+ else if (strncmp(*args, "referral=", 9) == 0)
+ referral = *args + 9;
+ }
+
+ if (!nologin && referral == NULL)
+ return FALSE;
+
+ reply = t_str_new(128);
+ str_append(reply, nologin ? "NO " : "OK ");
+ if (referral != NULL)
+ str_printfa(reply, "[REFERRAL %s] ", referral);
+
+ if (reason != NULL)
+ str_append(reply, reason);
+ else if (!nologin)
+ str_append(reply, "Logged in.");
+ else if (referral != NULL)
+ str_append(reply, "Try this server instead.");
+ else
+ str_append(reply, "Login disabled.");
+
+ client_send_tagline(client, str_c(reply));
+ if (!nologin) {
+ client_destroy(client, t_strconcat(
+ "Login: ", client->common.virtual_user, NULL));
+ } else {
+ /* get back to normal client input. */
+ if (client->io != NULL)
+ io_remove(client->io);
+ client->io = io_add(client->common.fd, IO_READ,
+ client_input, client);
+ }
+ return TRUE;
+}
+
static void sasl_callback(struct client *_client, enum sasl_server_reply reply,
- const char *data)
+ const char *data, const char *const *args)
{
struct imap_client *client = (struct imap_client *)_client;
struct const_iovec iov[3];
@@ -86,11 +132,21 @@
switch (reply) {
case SASL_SERVER_REPLY_SUCCESS:
+ if (args != NULL) {
+ if (client_handle_success_args(client, args, FALSE))
+ break;
+ }
+
client_send_tagline(client, "OK Logged in.");
client_destroy(client, t_strconcat(
"Login: ", client->common.virtual_user, NULL));
break;
case SASL_SERVER_REPLY_AUTH_FAILED:
+ if (args != NULL) {
+ if (client_handle_success_args(client, args, TRUE))
+ break;
+ }
+
if (data == NULL)
client_send_tagline(client, "Authentication failed");
else {
Index: client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap-login/client.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- client.c 11 Oct 2004 17:14:26 -0000 1.30
+++ client.c 18 Oct 2004 01:13:25 -0000 1.31
@@ -483,6 +483,7 @@
o_stream_unref(client->output);
i_free(client->common.virtual_user);
+ i_free(client->common.auth_mech_name);
i_free(client);
main_unref();
More information about the dovecot-cvs
mailing list