[courier-users] change to imap/pop3login.c
Brought to you by:
mrsam
From: Colin C. <sg...@ci...> - 2002-10-10 01:49:22
|
Hi, I know this is very presumptuous of me to arrive on the list and request a change, but that's what I am going to do. I installed courier-imap-1.5.3.20020921 to work with postfix and was trying to do some testing to verify that having creating the userdb for authentication, I had in fact followed the instructions correctly. I was testing using telnet to the POP3 port (since I don't speak IMAP that well :-). Anyway, I could not under any circumstances authenticate successfully. Eventually I relented and tried an IMAP login and to my delight/confusion succeeded. I did a bit of searching through the mailing list archives and saw people with similar (pop and telnet) problems but no resolution. That got me digging through strace output from all sorts of daemons and reading code and eventually I worked out that the problem was, in part, caused by the telnet client. During the POP3 conversation, eg # telnet 0 110 Trying 0.0.0.0... Connected to 0. Escape character is '^]'. +OK Hello there. USER fred +OK Password required. PASS blahblah .... the telnet client sends its input literally as follows: USER fred\r\n and PASS blahblah\r\n When pop3login passed this to authdaemon it sends something like: AUTH 41\npop3\nlogin\nfred\r\nblahblah\r\n\n so when authdaemon splits it up it gets user = fred\r pass = blahblah\r This of course fails the lookup. I started hunting around in the code for the "best" place to "fix" this problem and decided it was in pop3login.c. I would like to propose that pop3login.c be changed to tokenise the input after "USER" and "PASS" using delimiters "\r\n" instead of "\n". There is some precedent for this - the lines are first tokenised using " \t\r". The changes to imap/pop3login.c are as follows: --- pop3login.c.orig Wed Oct 9 16:01:29 2002 +++ pop3login.c Wed Oct 9 16:05:00 2002 @@ -190,7 +190,7 @@ continue; } - p=strtok(0, "\n"); + p=strtok(0, "\r\n"); if (p) { if (user) free(user); @@ -257,7 +257,7 @@ } } else if (strcmp(p, "PASS") == 0) { - p=strtok(0, "\n"); + p=strtok(0, "\r\n"); if (!user || p == 0) { Would such changes break anything? I can't (from my uneducated standpoint) see how they would. I know they certainly help in debugging POP. Colin -- Colin Campbell Unix Support/Postmaster/Hostmaster CITEC +61 7 3227 6334 |