[Courier-imap] PATCH: Log source port.
Enclosed is a patch that makes imapd log originating port number in addition to ip. This is due to new legislation in Denmark, requiring ISPs and hosting companies to log the originating port of all traffic. This has been successfully applied to 0.53.3 and 0.56.0. Adam --- imapd.c.old 2006-05-30 02:30:35.0 +0200 +++ imapd.c 2007-09-18 15:17:52.0 +0200 @@ -6186,7 +6186,7 @@ } #endif -static void chkdisabled(const char *ip) +static void chkdisabled(const char *ip, const char *port) { if (auth_getoptionenvint("disableimap")) { @@ -6195,8 +6195,8 @@ exit(0); } - fprintf(stderr, "INFO: LOGIN, user=%s, ip=[%s], protocol=%s\n", - getenv("AUTHENTICATED"), ip, + fprintf(stderr, "INFO: LOGIN, user=%s, ip=[%s], port=[%s], protocol=%s\n", + getenv("AUTHENTICATED"), ip, port, protocol); } @@ -6205,6 +6205,7 @@ const char *ip; const char *p; const char *tag; + const char *port; mode_t oldumask; time(&start_time); @@ -6259,6 +6260,8 @@ ip=getenv("TCPREMOTEIP"); if (!ip || !*ip)exit(0); + port=getenv("TCPREMOTEPORT"); + protocol=getenv("PROTOCOL"); if (!protocol || !*protocol) @@ -6280,8 +6283,8 @@ if ( stat(".", &buf) < 0 || buf.st_mode & S_ISVTX) { - fprintf(stderr, "INFO: LOCKED, user=%s, ip=[%s]\n", - getenv("AUTHENTICATED"), ip); + fprintf(stderr, "INFO: LOCKED, user=%s, ip=[%s], port=[%s]\n", + getenv("AUTHENTICATED"), ip, port); writes("* BYE Your account is temporarily unavailable (+t bit set on home directory).\r\n"); writeflush(); exit(0); @@ -6374,7 +6377,7 @@ libmail_kwVerbotten=KEYWORD_SMAPVERBOTTEN; libmail_kwCaseSensitive=1; - chkdisabled(ip); + chkdisabled(ip, port); smap(); logoutmsg(); emptytrash(); @@ -6390,7 +6393,7 @@ else writes("* PREAUTH Ready.\r\n"); writeflush(); - chkdisabled(ip); + chkdisabled(ip, port); imapscan_init(¤t_maildir_info); mainloop(); bye(); - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Courier-imap mailing list Courier-imap@lists.sourceforge.net Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-imap
Re: [Courier-imap] PATCH: Log source port.
Adam Hasselbalch Hansen skrev, on 18-09-2007 16:06: > Enclosed is a patch that makes imapd log originating port number in > addition to ip. > > This is due to new legislation in Denmark, requiring ISPs and hosting > companies to log the originating port of all traffic. I've read about that in the Norwegian papers and hear the almost daily worry from Danish political party spokespeople about terrorism/integration in Denmark on the Norwegian radio. Had this been a discussion forum, I'd ask you what you think about it. > This has been successfully applied to 0.53.3 and 0.56.0. What >= 0.53 would that be, I'm running 4.1.3. Best, --Tonni -- Tony Earnshaw Email: tonni at hetnet dot nl - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Courier-imap mailing list Courier-imap@lists.sourceforge.net Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-imap
Re: [Courier-imap] PATCH: Log source port.
Tony Earnshaw wrote: >> This has been successfully applied to 0.53.3 and 0.56.0. > > What >= 0.53 would that be, I'm running 4.1.3. Oh. Sorry. I'm patching against the entire courier-package. Those would be 4.1.1 and 4.1.3, respectively. /Adam - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Courier-imap mailing list Courier-imap@lists.sourceforge.net Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-imap
Re: [Courier-imap] PATCH: Log source port.
Adam Hasselbalch Hansen skrev, on 18-09-2007 17:05: >>> This has been successfully applied to 0.53.3 and 0.56.0. >> What >= 0.53 would that be, I'm running 4.1.3. > > Oh. Sorry. I'm patching against the entire courier-package. Those would > be 4.1.1 and 4.1.3, respectively. Did you test it against Courier IMAP 4.1? In the past, it has been stressed that Courier imapd on the MTA and IMAP packages are completely different animals. --Tonni -- Tony Earnshaw Email: tonni at hetnet dot nl - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Courier-imap mailing list Courier-imap@lists.sourceforge.net Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-imap
Re: [Courier-imap] PATCH: Log source port.
Tony Earnshaw wrote: > Did you test it against Courier IMAP 4.1? In the past, it has been > stressed that Courier imapd on the MTA and IMAP packages are completely > different animals. According to courier-mta.org/imap: "This is the same IMAP server that's included in the Courier mail server." Or what? /Adam - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Courier-imap mailing list Courier-imap@lists.sourceforge.net Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-imap
Re: [Courier-imap] PATCH: Log source port.
Adam Hasselbalch Hansen skrev, on 19-09-2007 12:07: >> Did you test it against Courier IMAP 4.1? In the past, it has been >> stressed that Courier imapd on the MTA and IMAP packages are >> completely different animals. > > According to courier-mta.org/imap: > > "This is the same IMAP server that's included in the Courier mail server." > > Or what? I wouldn't know, my sites run Postfix. The author of them both or someone more knowledgeable than me would have to answer this for certain. --Tonni -- Tony Earnshaw Email: tonni at hetnet dot nl - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Courier-imap mailing list Courier-imap@lists.sourceforge.net Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-imap
Re: [Courier-imap] PATCH: Log source port.
Adam Hasselbalch Hansen skrev, on 19-09-2007 12:07: >> Did you test it against Courier IMAP 4.1? In the past, it has been >> stressed that Courier imapd on the MTA and IMAP packages are >> completely different animals. > > According to courier-mta.org/imap: > > "This is the same IMAP server that's included in the Courier mail server." > > Or what? I wouldn't know, my sites run Postfix. The author of them both or someone more knowledgeable than me would have to answer this for certain. --Tonni -- Tony Earnshaw Email: tonni at hetnet dot nl - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Courier-imap mailing list Courier-imap@lists.sourceforge.net Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-imap
Re: [Courier-imap] PATCH: Log source port.
Adam Hasselbalch Hansen wrote: Enclosed is a patch that makes imapd log originating port number in addition to ip. This is due to new legislation in Denmark, requiring ISPs and hosting companies to log the originating port of all traffic. This has been successfully applied to 0.53.3 and 0.56.0. I forgot the pop-part. It is enclosed. /Adam --- courier-0.56.0/imap/pop3dserver.c 2007-09-20 16:04:10.0 +0200 +++ courier-0.56.0-new/imap/pop3dserver.c 2007-09-20 16:04:20.0 +0200 @@ -62,7 +62,7 @@ extern void pop3dcapa(); static void acctout(const char *disc); -static const char *authaddr, *remoteip; +static const char *authaddr, *remoteip, *remoteport; struct msglist { struct msglist *next; @@ -794,6 +794,7 @@ { static const char msg2[]=", user="; static const char msg3[]=", ip=["; + static const char msgport[]="], port=["; static const char msg4[]="], top="; static const char msg5[]=", retr="; static const char msg6[]=", time="; @@ -816,7 +817,7 @@ libmail_str_size_t(bytes_received_count, numAR); libmail_str_size_t(bytes_sent_count, numAS); - p=malloc(strlen(authaddr)+strlen(remoteip)+strlen(disc)+ + p=malloc(strlen(authaddr)+strlen(remoteip)+strlen(remoteport)+strlen(disc)+ strlen(num1)+strlen(num2)+strlen(num3)+ strlen(numAR)+strlen(numAS)+200); /* Should be enough */ @@ -825,6 +826,8 @@ strcat(p, authaddr); strcat(p, msg3); strcat(p, remoteip); + strcat(p, msgport); + strcat(p, remoteport); strcat(p, msg4); strcat(p, num1); strcat(p, msg5); @@ -1020,13 +1023,15 @@ if ((remoteip=getenv("TCPREMOTEIP")) == NULL) remoteip="127.0.0.1"; + remoteport=getenv("TCPREMOTEPORT"); + { struct stat buf; if ( stat(".", &buf) < 0 || buf.st_mode & S_ISVTX) { - fprintf(stderr, "INFO: LOCKED, user=%s, ip=[%s]\n", -authaddr, remoteip); + fprintf(stderr, "INFO: LOCKED, user=%s, ip=[%s], port=[%s]\n", + authaddr, remoteip, remoteport); printed(printf("-ERR Your account is temporarily unavailable (+t bit set on home directory).\r\n")); exit(0); } @@ -1057,9 +1062,10 @@ exit(1); } - fprintf(stderr, "INFO: LOGIN, user=%s, ip=[%s]\n", + fprintf(stderr, "INFO: LOGIN, user=%s, ip=[%s], port=[%s]\n", authaddr, - remoteip); + remoteip, + remoteport); fflush(stderr); msglist_cnt=0; - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Courier-imap mailing list Courier-imap@lists.sourceforge.net Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-imap
Re: [Courier-imap] PATCH: Log source port.
Adam Hasselbalch Hansen writes: Tony Earnshaw wrote: Did you test it against Courier IMAP 4.1? In the past, it has been stressed that Courier imapd on the MTA and IMAP packages are completely different animals. According to courier-mta.org/imap: "This is the same IMAP server that's included in the Courier mail server." Or what? This is correct. They are different packages, technically but the source code is the same. The only difference of note is the location of the configuration files. Source patches for one are no different than the other. pgp1Nmw9Jn2De.pgp Description: PGP signature - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Courier-imap mailing list Courier-imap@lists.sourceforge.net Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-imap