nm4 2008/05/16 13:22:08 BST
Modified files:
exim-src/src/auths dovecot.c
exim-doc/doc-txt ChangeLog
Log:
Better implementation of Dovecot authenticator using patch from Jan Srzednicki. Fixes: #598
Revision Changes Path
1.548 +3 -0 exim/exim-doc/doc-txt/ChangeLog
1.10 +34 -20 exim/exim-src/src/auths/dovecot.c
Index: dovecot.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/auths/dovecot.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- dovecot.c 6 Feb 2008 12:44:59 -0000 1.9
+++ dovecot.c 16 May 2008 12:22:08 -0000 1.10
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/auths/dovecot.c,v 1.9 2008/02/06 12:44:59 nm4 Exp $ */
+/* $Cambridge: exim/exim-src/src/auths/dovecot.c,v 1.10 2008/05/16 12:22:08 nm4 Exp $ */
/*
* Copyright (c) 2004 Andrey Panin <pazke@???>
@@ -101,7 +101,7 @@
goto out; \
if (nargs - 1 < (arg_min)) \
goto out; \
- if (nargs - 1 > (arg_max)) \
+ if ( (arg_max != -1) && (nargs - 1 > (arg_max)) ) \
goto out; \
} while (0)
@@ -277,6 +277,9 @@
Subsequently, the command was modified to add "secured" and "valid-client-
cert" when relevant.
+
+ The auth protocol is documented here:
+ http://wiki.dovecot.org/Authentication_Protocol
****************************************************************************/
auth_command = string_sprintf("VERSION\t%d\t%d\nCPID\t%d\n"
@@ -293,6 +296,9 @@
while (1) {
uschar *temp;
+ uschar *auth_id_pre = NULL;
+ int i;
+
if (dc_gets(buffer, sizeof(buffer), fd) == NULL) {
auth_defer_msg = US"authentication socket read error or premature eof";
goto out;
@@ -329,16 +335,16 @@
break;
case 'F':
- CHECK_COMMAND("FAIL", 1, 2);
+ CHECK_COMMAND("FAIL", 1, -1);
- /* FIXME: add proper response handling */
- if (args[2]) {
- uschar *p = Ustrchr(args[2], '=');
- if (p) {
- ++p;
+ for (i=2; (i<nargs) && (auth_id_pre == NULL); i++)
+ {
+ if ( Ustrncmp(args[i], US"user=", 5) == 0 )
+ {
+ auth_id_pre = args[i]+5;
expand_nstring[1] = auth_vars[0] =
- string_copy(p); /* PH */
- expand_nlength[1] = Ustrlen(p);
+ string_copy(auth_id_pre); /* PH */
+ expand_nlength[1] = Ustrlen(auth_id_pre);
expand_nmax = 1;
}
}
@@ -347,19 +353,27 @@
goto out;
case 'O':
- CHECK_COMMAND("OK", 2, 2);
+ CHECK_COMMAND("OK", 2, -1);
+
+ /*
+ * Search for the "user=$USER" string in the args array
+ * and return the proper value.
+ */
+ for (i=2; (i<nargs) && (auth_id_pre == NULL); i++)
{
- /* FIXME: add proper response handling */
- uschar *p = Ustrchr(args[2], '=');
- if (!p)
- OUT("authentication socket protocol error, username missing");
-
- p++;
- expand_nstring[1] = auth_vars[0] =
- string_copy(p); /* PH */
- expand_nlength[1] = Ustrlen(p);
- expand_nmax = 1;
+ if ( Ustrncmp(args[i], US"user=", 5) == 0 )
+ {
+ auth_id_pre = args[i]+5;
+ expand_nstring[1] = auth_vars[0] =
+ string_copy(auth_id_pre); /* PH */
+ expand_nlength[1] = Ustrlen(auth_id_pre);
+ expand_nmax = 1;
+ }
}
+
+ if (auth_id_pre == NULL)
+ OUT("authentication socket protocol error, username missing");
+
ret = OK;
/* fallthrough */
Index: ChangeLog
===================================================================
RCS file: /home/cvs/exim/exim-doc/doc-txt/ChangeLog,v
retrieving revision 1.547
retrieving revision 1.548
diff -u -r1.547 -r1.548
--- ChangeLog 16 May 2008 12:02:19 -0000 1.547
+++ ChangeLog 16 May 2008 12:22:08 -0000 1.548
@@ -1,4 +1,4 @@
-$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.547 2008/05/16 12:02:19 nm4 Exp $
+$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.548 2008/05/16 12:22:08 nm4 Exp $
Change log file for Exim from version 4.21
-------------------------------------------
@@ -51,6 +51,9 @@
NM/05 Bugzilla 437: Prevent Maildix aux files being created with mode 000
+NM/05 Bugzilla 598: Improvedment to Dovecot authenticator handling.
+ Patch provided by Jan Srzednicki
+