Hi,
qmail and qmail-ldap display timestamp in pop3 server greeting. Some email
clients assume that server supports APOP and use APOP authentication. I
think djb checkpassword and qmail-ldap auth_pop don't support APOP
authentication.
Attached patches allow to control display of timestamp in greeting.
Patched qmail-popup compiles on linux glibc 2.3.2 with gcc 3.3.5. Please
note that I am not C programmer and I can make mistakes in this patch. I
haven't added documentation and qmail-pop3d.rules updates. Patch can be
enhanced to require APOP and disable USER/PASS authentication. Patches are
made against qmail-ldap 20050401a.
Other possible issue - incorrect handling of APOP authentication failure.
According to rfc1939 '7. Optional POP3 Commands'
----
When the POP3 server receives the APOP command, it verifies the digest
provided. If the digest is correct, the POP3 server issues a positive
response, and the POP3 session enters the TRANSACTION state. Otherwise, a
negative response is issued and the POP3 session remains in the
AUTHORIZATION state.
----
Qmail and qmail-ldap drop connection after apop authentication failure. I
guess code follows rfc '4. The AUTHORIZATION State' chapter, but
connection drop is only suggested and not required there. If server
follows rfc1939 7th chapter, it should not drop connection after apop
failure.
--
Tomas
diff -urN qmail-1.03.ldap-20050401a/Makefile qmail-1.03/Makefile
--- qmail-1.03.ldap-20050401a/Makefile 2005-10-05 19:38:28.388053000 +0300
+++ qmail-1.03/Makefile 2005-10-05 19:29:41.332177672 +0300
@@ -1750,11 +1750,11 @@
qmail-popup: \
load qmail-popup.o commands.o timeoutread.o timeoutwrite.o now.o \
-case.a fd.a sig.a wait.a stralloc.a alloc.a substdio.a error.a str.a \
-fs.a socket.lib
+case.a fd.a sig.a wait.a stralloc.a alloc.a substdio.a error.a env.a \
+str.a fs.a socket.lib
./load qmail-popup commands.o timeoutread.o timeoutwrite.o \
now.o case.a fd.a sig.a wait.a stralloc.a alloc.a \
- substdio.a error.a str.a fs.a `cat socket.lib`
+ substdio.a error.a env.a str.a fs.a `cat socket.lib`
qmail-popup.0: \
qmail-popup.8
@@ -1763,7 +1763,7 @@
qmail-popup.o: \
compile qmail-popup.c commands.h fd.h sig.h stralloc.h gen_alloc.h \
substdio.h alloc.h wait.h str.h byte.h now.h datetime.h fmt.h exit.h \
-readwrite.h timeoutread.h timeoutwrite.h
+readwrite.h timeoutread.h timeoutwrite.h env.h
./compile $(DEBUG) qmail-popup.c
qmail-pw2u: \
diff -urN qmail-1.03.ldap-20050401a/qmail-popup.c qmail-1.03/qmail-popup.c
--- qmail-1.03.ldap-20050401a/qmail-popup.c 2005-10-05 19:25:57.000000000 +0300
+++ qmail-1.03/qmail-popup.c 2005-10-05 19:44:22.804173560 +0300
@@ -14,6 +14,7 @@
#include "readwrite.h"
#include "timeoutread.h"
#include "timeoutwrite.h"
+#include "env.h"
void die(void) { _exit(1); }
@@ -159,17 +160,25 @@
void pop3_greet(void)
{
- char *s;
- s = unique;
- s += fmt_uint(s,getpid());
- *s++ = '.';
- s += fmt_ulong(s,(unsigned long) now());
- *s++ = '@';
- *s++ = 0;
- putstr("+OK <");
- putstr(unique);
- putstr(hostname);
- putstr(">\r\n");
+ if (env_get("APOP")) {
+ /* add APOP timestamp to greeting if environment variable is set */
+ char *s;
+ s = unique;
+ s += fmt_uint(s,getpid());
+ *s++ = '.';
+ s += fmt_ulong(s,(unsigned long) now());
+ *s++ = '@';
+ *s++ = 0;
+ putstr("+OK <");
+ putstr(unique);
+ putstr(hostname);
+ putstr(">\r\n");
+ } else {
+ /* Don't declare APOP support */
+ putstr("+OK POP3 ");
+ putstr(hostname);
+ putstr(" ready.\r\n");
+ }
flush();
}
void pop3_user(char *arg)
@@ -188,11 +197,16 @@
}
void pop3_apop(char *arg)
{
- char *space;
- space = arg + str_chr(arg,' ');
- if (!*space) { err_syntax(); return; }
- *space++ = 0;
- doanddie(arg,space - arg,space);
+ if (env_get("APOP")) {
+ char *space;
+ space = arg + str_chr(arg,' ');
+ if (!*space) { err_syntax(); return; }
+ *space++ = 0;
+ /* FIXME: don't drop connection on APOP error */
+ doanddie(arg,space - arg,space);
+ } else {
+ err("APOP authentication is not supported.");
+ }
}
struct commands pop3commands[] = {diff -uwrN qmail-1.03.ldap-20050401a/Makefile qmail-1.03/Makefile
--- qmail-1.03.ldap-20050401a/Makefile 2005-10-05 19:38:28.388053000 +0300
+++ qmail-1.03/Makefile 2005-10-05 19:29:41.332177672 +0300
@@ -1750,11 +1750,11 @@
qmail-popup: \
load qmail-popup.o commands.o timeoutread.o timeoutwrite.o now.o \
-case.a fd.a sig.a wait.a stralloc.a alloc.a substdio.a error.a str.a \
-fs.a socket.lib
+case.a fd.a sig.a wait.a stralloc.a alloc.a substdio.a error.a env.a \
+str.a fs.a socket.lib
./load qmail-popup commands.o timeoutread.o timeoutwrite.o \
now.o case.a fd.a sig.a wait.a stralloc.a alloc.a \
- substdio.a error.a str.a fs.a `cat socket.lib`
+ substdio.a error.a env.a str.a fs.a `cat socket.lib`
qmail-popup.0: \
qmail-popup.8
@@ -1763,7 +1763,7 @@
qmail-popup.o: \
compile qmail-popup.c commands.h fd.h sig.h stralloc.h gen_alloc.h \
substdio.h alloc.h wait.h str.h byte.h now.h datetime.h fmt.h exit.h \
-readwrite.h timeoutread.h timeoutwrite.h
+readwrite.h timeoutread.h timeoutwrite.h env.h
./compile $(DEBUG) qmail-popup.c
qmail-pw2u: \
diff -uwrN qmail-1.03.ldap-20050401a/qmail-popup.c qmail-1.03/qmail-popup.c
--- qmail-1.03.ldap-20050401a/qmail-popup.c 2005-10-05 19:25:57.000000000 +0300
+++ qmail-1.03/qmail-popup.c 2005-10-05 19:44:22.804173560 +0300
@@ -14,6 +14,7 @@
#include "readwrite.h"
#include "timeoutread.h"
#include "timeoutwrite.h"
+#include "env.h"
void die(void) { _exit(1); }
@@ -159,6 +160,8 @@
void pop3_greet(void)
{
+ if (env_get("APOP")) {
+ /* add APOP timestamp to greeting if environment variable is set */
char *s;
s = unique;
s += fmt_uint(s,getpid());
@@ -170,6 +173,12 @@
putstr(unique);
putstr(hostname);
putstr(">\r\n");
+ } else {
+ /* Don't declare APOP support */
+ putstr("+OK POP3 ");
+ putstr(hostname);
+ putstr(" ready.\r\n");
+ }
flush();
}
void pop3_user(char *arg)
@@ -188,11 +197,16 @@
}
void pop3_apop(char *arg)
{
+ if (env_get("APOP")) {
char *space;
space = arg + str_chr(arg,' ');
if (!*space) { err_syntax(); return; }
*space++ = 0;
+ /* FIXME: don't drop connection on APOP error */
doanddie(arg,space - arg,space);
+ } else {
+ err("APOP authentication is not supported.");
+ }
}
struct commands pop3commands[] = {