J'ai fini par faire marcher mod_auth_imap2 avec ce farceur de dovecot (et surtout avec l'aide precieuse d'ofredj). Pour ceux qui galerent encore, voici le patch.
yom--- mod_auth_imap2-2.2.0.orig/mod_auth_imap.c 2006-05-08 01:22:43.000000000 +0200
+++ mod_auth_imap2-2.2.0/mod_auth_imap.c 2008-11-06 18:11:28.000000000 +0100
@@ -44,8 +44,6 @@
#define _OK 1
-int Sock;
-
/*******************************************************************************
* tcp_gets
@@ -141,6 +139,7 @@
char result[512],buf[512];
int ret=0;
int port;
+ int Sock; // Don't know why it used to be global, but having it local solved *all* my problems
port=atoi(cport);
@@ -163,20 +162,14 @@
sprintf(buf,"A001 CAPABILITY\r\n");
tcp_puts(Sock,buf);
- //get the capability line...
- tcp_gets(Sock,result,500);
-
- //get the "A001 OK CAPABILITY completed" line..
- tcp_gets(Sock,result,500);
-
//skip lines that start with "*"
- if (strncmp(result,"* ",2 == 0)) {
+ do {
tcp_gets(Sock,result,500);
- }
+ } while (strncmp(result,"* ",2) == 0);
- //Verify that it supports the CAPABILITY command
+ //Verify that it supports the CAPABILITY command (is this really needed ?)
if (strncmp(result,"A001 OK", 7) != 0) {
- ap_log_rerror(APLOG_MARK,APLOG_WARNING|APLOG_NOERRNO,0,r,"mod_auth_imap: Server does not support imap CAPABILITY.");
+ ap_log_rerror(APLOG_MARK,APLOG_WARNING|APLOG_NOERRNO,0,r,"mod_auth_imap: Server does not support imap CAPABILITY");
ret=!_OK;
clean_up(Sock);
return ret; //BAIL!
@@ -186,7 +179,11 @@
memset(buf,0,500);
sprintf(buf,"A002 LOGIN %s \"%s\"\r\n", username, pass);
tcp_puts(Sock,buf);
- tcp_gets(Sock,result,500);
+
+ //skip lines that start with "*" (sometimes needed with dovecot)
+ do {
+ tcp_gets(Sock,result,500);
+ } while (strncmp(result,"* ",2) == 0);
if (strncmp(result,"A002 OK",7) == 0) {
if (logflag) {
@@ -197,7 +194,6 @@
} else if (strncmp(result,"A002 NO",7) == 0) {
if (logflag) {
ap_log_rerror(APLOG_MARK,APLOG_WARNING|APLOG_NOERRNO,0,r,"mod_auth_imap: Login failed for user %s.", username);
- ap_log_rerror(APLOG_MARK,APLOG_WARNING|APLOG_NOERRNO,0,r,"mod_auth_imap: Server said: %s", result);
}
ret=!_OK;
@@ -205,7 +201,6 @@
//it must have told us BYE and disconnected
if (logflag) {
ap_log_rerror(APLOG_MARK,APLOG_WARNING|APLOG_NOERRNO,0,r,"mod_auth_imap: Premature server disconnect for user %s.", username);
- ap_log_rerror(APLOG_MARK,APLOG_WARNING|APLOG_NOERRNO,0,r,"mod_auth_imap: Server said: %s", result);
}
ret=!_OK;
@@ -218,11 +213,11 @@
sprintf(buf,"A003 LOGOUT\r\n");
tcp_puts(Sock,buf);
- //read the BYE line
- tcp_gets(Sock,result,500);
+ //read the BYE line, skip lines that start with "*"
+ do {
+ tcp_gets(Sock,result,500);
+ } while (strncmp(result,"* ",2) == 0);
- //read the OK LOGOUT
- tcp_gets(Sock,result,500);
if (strncmp(result,"A003 OK",7) == 0) {
if (logflag) {
@@ -233,7 +228,6 @@
} else {
if (logflag) {
ap_log_rerror(APLOG_MARK,APLOG_WARNING|APLOG_NOERRNO,0,r,"mod_auth_imap: Error in logout for %s.", username);
- ap_log_rerror(APLOG_MARK,APLOG_WARNING|APLOG_NOERRNO,0,r,"mod_auth_imap: Server said: %s", result);
}
ret=!_OK;