diff options
Diffstat (limited to 'qmail-smtpd.c')
| -rw-r--r-- | qmail-smtpd.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/qmail-smtpd.c b/qmail-smtpd.c index 9fb495b..76cedcb 100644 --- a/qmail-smtpd.c +++ b/qmail-smtpd.c | |||
| @@ -44,6 +44,8 @@ int spp_val; | |||
| 44 | #define MAXHOPS 100 | 44 | #define MAXHOPS 100 |
| 45 | unsigned int databytes = 0; | 45 | unsigned int databytes = 0; |
| 46 | unsigned int mfchk = 0; | 46 | unsigned int mfchk = 0; |
| 47 | unsigned int greetdelay = 0; | ||
| 48 | unsigned int drop_pre_greet = 0; | ||
| 47 | int timeout = 1200; | 49 | int timeout = 1200; |
| 48 | 50 | ||
| 49 | const char *protocol = "SMTP"; | 51 | const char *protocol = "SMTP"; |
| @@ -134,6 +136,7 @@ void straynewline() | |||
| 134 | out("451 See http://pobox.com/~djb/docs/smtplf.html.\r\n"); flush(); | 136 | out("451 See http://pobox.com/~djb/docs/smtplf.html.\r\n"); flush(); |
| 135 | eflush(); _exit(1); | 137 | eflush(); _exit(1); |
| 136 | } | 138 | } |
| 139 | void die_pre_greet() { out("554 SMTP protocol violation\r\n"); flush(); _exit(1); } | ||
| 137 | 140 | ||
| 138 | void err_size() { out("552 sorry, that message size exceeds my databytes limit (#5.3.4)\r\n"); } | 141 | void err_size() { out("552 sorry, that message size exceeds my databytes limit (#5.3.4)\r\n"); } |
| 139 | void err_bmf() { out("553 sorry, your envelope sender has been denied (#5.7.1)\r\n"); } | 142 | void err_bmf() { out("553 sorry, your envelope sender has been denied (#5.7.1)\r\n"); } |
| @@ -286,6 +289,11 @@ void setup() | |||
| 286 | if (x) { scan_ulong(x,&u); databytes = u; } | 289 | if (x) { scan_ulong(x,&u); databytes = u; } |
| 287 | if (!(databytes + 1)) --databytes; | 290 | if (!(databytes + 1)) --databytes; |
| 288 | 291 | ||
| 292 | x = env_get("GREETDELAY"); | ||
| 293 | if (x) { scan_ulong(x, &u); greetdelay = u; } | ||
| 294 | x = env_get("DROP_PRE_GREET"); | ||
| 295 | if (x) { scan_ulong(x, &u); drop_pre_greet = u; } | ||
| 296 | |||
| 289 | remoteip = env_get("TCPREMOTEIP"); | 297 | remoteip = env_get("TCPREMOTEIP"); |
| 290 | if (!remoteip) remoteip = "unknown"; | 298 | if (!remoteip) remoteip = "unknown"; |
| 291 | local = env_get("TCPLOCALHOST"); | 299 | local = env_get("TCPLOCALHOST"); |
| @@ -1331,12 +1339,40 @@ void main(argc,argv) | |||
| 1331 | int argc; | 1339 | int argc; |
| 1332 | char **argv; | 1340 | char **argv; |
| 1333 | { | 1341 | { |
| 1342 | int n, m; | ||
| 1334 | childargs = argv + 1; | 1343 | childargs = argv + 1; |
| 1335 | sig_pipeignore(); | 1344 | sig_pipeignore(); |
| 1336 | if (chdir(auto_qmail) == -1) die_control(); | 1345 | if (chdir(auto_qmail) == -1) die_control(); |
| 1337 | setup(); | 1346 | setup(); |
| 1338 | if (ipme_init() != 1) die_ipme(); | 1347 | if (ipme_init() != 1) die_ipme(); |
| 1339 | if (spp_connect()) { | 1348 | if (spp_connect()) { |
| 1349 | if (!relayclient && greetdelay) { | ||
| 1350 | if (drop_pre_greet) { | ||
| 1351 | n = timeoutread(greetdelay ? greetdelay : 1, 0, ssinbuf, sizeof(ssinbuf)); | ||
| 1352 | if(n == -1) { | ||
| 1353 | if (errno != error_timeout) | ||
| 1354 | strerr_die3sys(1, "GREETDELAY from ", remoteip, ": "); | ||
| 1355 | } else if (n == 0) { | ||
| 1356 | strerr_die3x(1, "GREETDELAY from ", remoteip, ": client disconnected"); | ||
| 1357 | } else { | ||
| 1358 | strerr_warn3("GREETDELAY from ", remoteip, ": client sent data before greeting", 0); | ||
| 1359 | die_pre_greet(); | ||
| 1360 | } | ||
| 1361 | } | ||
| 1362 | else { | ||
| 1363 | sleep(greetdelay); | ||
| 1364 | m = 0; | ||
| 1365 | for (;;) { | ||
| 1366 | n = timeoutread(0, 0, ssinbuf, sizeof(ssinbuf)); | ||
| 1367 | if (n <= 0) | ||
| 1368 | break; | ||
| 1369 | if (n > 0 && m == 0) { | ||
| 1370 | strerr_warn3("GREETDELAY from ", remoteip, ": client sent data before greeting. ignoring", 0); | ||
| 1371 | m = 1; | ||
| 1372 | } | ||
| 1373 | } | ||
| 1374 | } | ||
| 1375 | } | ||
| 1340 | smtp_greet("220 "); | 1376 | smtp_greet("220 "); |
| 1341 | out(" ESMTP\r\n"); | 1377 | out(" ESMTP\r\n"); |
| 1342 | } | 1378 | } |
