Download | Plain Text | No Line Numbers


  1. --- Makefile.orig Tue Jan 2 04:45:17 2007
  2. +++ Makefile Tue Jan 2 04:49:30 2007
  3. @@ -1611,14 +1611,14 @@
  4. timeoutwrite.o ip.o ipme.o ipalloc.o strsalloc.o control.o constmap.o \
  5. received.o date822fmt.o now.o qmail.o spf.o dns.o cdb.a fd.a wait.a \
  6. datetime.a getln.a open.a sig.a case.a env.a stralloc.a alloc.a substdio.a \
  7. -error.a str.a fs.a auto_qmail.o base64.o qmail-spp.o socket.lib dns.lib $(SMTPD_CHKUSER_OBJ)
  8. +error.a strerr.a str.a fs.a auto_qmail.o base64.o qmail-spp.o socket.lib dns.lib $(SMTPD_CHKUSER_OBJ)
  9. ./load qmail-smtpd $(SMTPD_CHKUSER_OBJ) rcpthosts.o commands.o timeoutread.o \
  10. timeoutwrite.o ip.o ipme.o ipalloc.o strsalloc.o control.o \
  11. tls.o ssl_timeoutio.o ndelay.a -L/usr/lib -lssl -lcrypto \
  12. constmap.o received.o date822fmt.o now.o qmail.o spf.o dns.o cdb.a \
  13. fd.a wait.a datetime.a getln.a open.a sig.a case.a qmail-spp.o env.a stralloc.a \
  14. alloc.a substdio.a error.a fs.a auto_qmail.o base64.o \
  15. - str.a `cat socket.lib` $(VPOPMAIL_LIBS) `cat dns.lib`
  16. + strerr.a str.a `cat socket.lib` $(VPOPMAIL_LIBS) `cat dns.lib`
  17.  
  18. qmail-smtpd.0: \
  19. qmail-smtpd.8
  20. @@ -1628,7 +1628,7 @@
  21. compile qmail-smtpd.c chkuser.h sig.h readwrite.h stralloc.h gen_alloc.h \
  22. substdio.h alloc.h auto_qmail.h control.h received.h constmap.h \
  23. error.h ipme.h ip.h ipalloc.h strsalloc.h ip.h gen_alloc.h ip.h qmail.h qmail-spp.h \
  24. -substdio.h str.h fmt.h scan.h byte.h case.h env.h now.h datetime.h \
  25. +substdio.h strerr.h str.h fmt.h scan.h byte.h case.h env.h now.h datetime.h \
  26. exit.h rcpthosts.h timeoutread.h timeoutwrite.h commands.h base64.h spf.h
  27. ./compile qmail-smtpd.c
  28.  
  29. --- qmail-smtpd.c.orig 2006-12-31 02:11:02.000000000 +0100
  30. +++ qmail-smtpd.c 2006-12-31 02:35:31.000000000 +0100
  31. @@ -12,6 +12,7 @@
  32. #include "ip.h"
  33. #include "qmail.h"
  34. #include "str.h"
  35. +#include "strerr.h"
  36. #include "fmt.h"
  37. #include "scan.h"
  38. #include "byte.h"
  39. @@ -44,6 +44,8 @@
  40.  
  41. #define MAXHOPS 100
  42. unsigned int databytes = 0;
  43. +unsigned int greetdelay = 0;
  44. +unsigned int drop_pre_greet = 0;
  45. int timeout = 1200;
  46. unsigned int spfbehavior = 0;
  47.  
  48. @@ -134,6 +136,7 @@
  49. void die_control() { out("421 unable to read controls (#4.3.0)\r\n"); flush(); _exit(1); }
  50. void die_ipme() { out("421 unable to figure out my IP addresses (#4.3.0)\r\n"); flush(); _exit(1); }
  51. void straynewline() { out("451 See http://pobox.com/~djb/docs/smtplf.html.\r\n"); flush(); _exit(1); }
  52. +void die_pre_greet() { out("554 SMTP protocol violation\r\n"); flush(); _exit(1); }
  53.  
  54. void err_size() { out("552 sorry, that message size exceeds my databytes limit (#5.3.4)\r\n"); }
  55. void err_bmf() { out("553 sorry, your envelope sender is in my badmailfrom list (#5.7.1)\r\n"); }
  56. @@ -282,6 +285,11 @@
  57. die_control();
  58. if (!stralloc_0(&spfexp)) die_nomem();
  59.  
  60. + x = env_get("GREETDELAY");
  61. + if (x) { scan_ulong(x, &u); greetdelay = u; }
  62. + x = env_get("DROP_PRE_GREET");
  63. + if (x) { scan_ulong(x, &u); drop_pre_greet = u; }
  64. +
  65. remoteip = env_get("TCPREMOTEIP");
  66. if (!remoteip) remoteip = "unknown";
  67. local = env_get("TCPLOCALHOST");
  68. @@ -1308,12 +1316,40 @@
  69. int argc;
  70. char **argv;
  71. {
  72. + int n, m;
  73. childargs = argv + 1;
  74. sig_pipeignore();
  75. if (chdir(auto_qmail) == -1) die_control();
  76. setup();
  77. if (ipme_init() != 1) die_ipme();
  78. if (spp_connect()) {
  79. + if (!relayclient && greetdelay) {
  80. + if (drop_pre_greet) {
  81. + n = timeoutread(greetdelay ? greetdelay : 1, 0, ssinbuf, sizeof(ssinbuf));
  82. + if(n == -1) {
  83. + if (errno != error_timeout)
  84. + strerr_die3sys(1, "GREETDELAY from ", remoteip, ": ");
  85. + } else if (n == 0) {
  86. + strerr_die3x(1, "GREETDELAY from ", remoteip, ": client disconnected");
  87. + } else {
  88. + strerr_warn3("GREETDELAY from ", remoteip, ": client sent data before greeting", 0);
  89. + die_pre_greet();
  90. + }
  91. + }
  92. + else {
  93. + sleep(greetdelay);
  94. + m = 0;
  95. + for (;;) {
  96. + n = timeoutread(0, 0, ssinbuf, sizeof(ssinbuf));
  97. + if (n <= 0)
  98. + break;
  99. + if (n > 0 && m == 0) {
  100. + strerr_warn3("GREETDELAY from ", remoteip, ": client sent data before greeting. ignoring", 0);
  101. + m = 1;
  102. + }
  103. + }
  104. + }
  105. + }
  106. smtp_greet("220 ");
  107. out(" ESMTP\r\n");
  108. }
  109.