summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--qmail-remote.c28
-rw-r--r--qmail-rspawn.c22
3 files changed, 50 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 70df80d..be8a15e 100644
--- a/Makefile
+++ b/Makefile
@@ -1509,13 +1509,15 @@ qmail-remote: \
1509load qmail-remote.o control.o constmap.o timeoutread.o timeoutwrite.o \ 1509load qmail-remote.o control.o constmap.o timeoutread.o timeoutwrite.o \
1510timeoutconn.o tcpto.o now.o dns.o ip.o ipalloc.o ipme.o quote.o \ 1510timeoutconn.o tcpto.o now.o dns.o ip.o ipalloc.o ipme.o quote.o \
1511ndelay.a case.a sig.a open.a lock.a seek.a getln.a stralloc.a alloc.a \ 1511ndelay.a case.a sig.a open.a lock.a seek.a getln.a stralloc.a alloc.a \
1512substdio.a error.a str.a fs.a auto_qmail.o base64.o dns.lib socket.lib 1512substdio.a error.a env.a str.a fs.a auto_qmail.o base64.o \
1513dns.lib socket.lib
1513 ./load qmail-remote control.o constmap.o timeoutread.o \ 1514 ./load qmail-remote control.o constmap.o timeoutread.o \
1514 timeoutwrite.o timeoutconn.o tcpto.o now.o dns.o ip.o \ 1515 timeoutwrite.o timeoutconn.o tcpto.o now.o dns.o ip.o \
1515 tls.o ssl_timeoutio.o -L/usr/local/ssl/lib -lssl -lcrypto \ 1516 tls.o ssl_timeoutio.o -L/usr/local/ssl/lib -lssl -lcrypto \
1516 ipalloc.o ipme.o quote.o ndelay.a case.a sig.a open.a \ 1517 ipalloc.o ipme.o quote.o ndelay.a case.a sig.a open.a \
1517 lock.a seek.a getln.a stralloc.a alloc.a substdio.a error.a \ 1518 lock.a seek.a getln.a stralloc.a alloc.a substdio.a error.a \
1518 str.a fs.a auto_qmail.o base64.o `cat dns.lib` `cat socket.lib` 1519 env.a str.a fs.a auto_qmail.o base64.o \
1520 `cat dns.lib` `cat socket.lib`
1519 1521
1520qmail-remote.0: \ 1522qmail-remote.0: \
1521qmail-remote.8 1523qmail-remote.8
@@ -1526,7 +1528,7 @@ compile qmail-remote.c sig.h stralloc.h gen_alloc.h substdio.h \
1526subfd.h substdio.h scan.h case.h error.h auto_qmail.h control.h dns.h \ 1528subfd.h substdio.h scan.h case.h error.h auto_qmail.h control.h dns.h \
1527alloc.h quote.h ip.h ipalloc.h ip.h gen_alloc.h ipme.h ip.h ipalloc.h \ 1529alloc.h quote.h ip.h ipalloc.h ip.h gen_alloc.h ipme.h ip.h ipalloc.h \
1528gen_alloc.h gen_allocdefs.h str.h now.h datetime.h exit.h constmap.h \ 1530gen_alloc.h gen_allocdefs.h str.h now.h datetime.h exit.h constmap.h \
1529tcpto.h readwrite.h timeoutconn.h timeoutread.h timeoutwrite.h 1531tcpto.h readwrite.h timeoutconn.h timeoutread.h timeoutwrite.h env.h
1530 ./compile qmail-remote.c 1532 ./compile qmail-remote.c
1531 1533
1532qmail-rspawn: \ 1534qmail-rspawn: \
diff --git a/qmail-remote.c b/qmail-remote.c
index b865b4d..b5b93d5 100644
--- a/qmail-remote.c
+++ b/qmail-remote.c
@@ -31,6 +31,7 @@
31#include "timeoutread.h" 31#include "timeoutread.h"
32#include "timeoutwrite.h" 32#include "timeoutwrite.h"
33#include "base64.h" 33#include "base64.h"
34#include "env.h"
34 35
35#define HUGESMTPTEXT 5000 36#define HUGESMTPTEXT 5000
36 37
@@ -65,6 +66,7 @@ struct ip_address partner;
65 66
66int tls_init(); 67int tls_init();
67const char *ssl_err_str = 0; 68const char *ssl_err_str = 0;
69char **myargv;
68#endif 70#endif
69 71
70void out(s) char *s; { if (substdio_puts(subfdoutsmall,s) == -1) _exit(0); } 72void out(s) char *s; { if (substdio_puts(subfdoutsmall,s) == -1) _exit(0); }
@@ -400,6 +402,7 @@ int tls_init()
400 return 0; 402 return 0;
401 } 403 }
402 alloc_free(tmp.s); 404 alloc_free(tmp.s);
405 if (env_get("NOTLS")) return 0;
403 } 406 }
404 } 407 }
405 408
@@ -476,8 +479,25 @@ int tls_init()
476 } 479 }
477 480
478 ssl = myssl; 481 ssl = myssl;
479 if (ssl_timeoutconn(timeout, smtpfd, smtpfd, ssl) <= 0) 482 if (ssl_timeoutconn(timeout, smtpfd, smtpfd, ssl) <= 0) {
480 tls_quit("ZTLS connect failed", ssl_error_str()); 483 if (servercert)
484 tls_quit("ZTLS connect failed", ssl_error_str());
485 else {
486 /* shouldn't talk to the client unless in an appropriate state */
487 int state = ssl ? ssl->state : SSL_ST_BEFORE;
488 if (state & SSL_ST_OK || (!smtps && state & SSL_ST_BEFORE))
489 substdio_putsflush(&smtpto,"QUIT\r\n");
490
491 out("lTLS connect failed: ");
492 out(ssl_error_str());
493 out("; retrying without TLS\n");
494 zero();
495 substdio_flush(subfdoutsmall);
496
497 env_put("NOTLS=1");
498 execvp(*myargv, myargv);
499 }
500 }
481 501
482 if (servercert) { 502 if (servercert) {
483 X509 *peercert; 503 X509 *peercert;
@@ -847,6 +867,10 @@ char **argv;
847 char **recips; 867 char **recips;
848 unsigned long prefme; 868 unsigned long prefme;
849 char *relayhost; 869 char *relayhost;
870
871#ifdef TLS
872 myargv = argv;
873#endif
850 874
851 sig_pipeignore(); 875 sig_pipeignore();
852 if (argc < 4) perm_usage(); 876 if (argc < 4) perm_usage();
diff --git a/qmail-rspawn.c b/qmail-rspawn.c
index 9d838e6..40e5d52 100644
--- a/qmail-rspawn.c
+++ b/qmail-rspawn.c
@@ -25,6 +25,7 @@ int len;
25 int k; 25 int k;
26 int result; 26 int result;
27 int orr; 27 int orr;
28 int l;
28 29
29 if (wait_crashed(wstat)) 30 if (wait_crashed(wstat))
30 { substdio_puts(ss,"Zqmail-remote crashed.\n"); return; } 31 { substdio_puts(ss,"Zqmail-remote crashed.\n"); return; }
@@ -48,8 +49,16 @@ int len;
48 j = k + 1; 49 j = k + 1;
49 } 50 }
50 51
52 j = 0;
53 for (k = 0;k < len;++k)
54 if (!s[k])
55 {
56 if (s[j] != 'l') break;
57 j = k + 1;
58 }
59
51 orr = result; 60 orr = result;
52 switch(s[0]) 61 switch(s[j])
53 { 62 {
54 case 's': orr = 0; break; 63 case 's': orr = 0; break;
55 case 'h': orr = -1; 64 case 'h': orr = -1;
@@ -62,10 +71,17 @@ int len;
62 case -1: substdio_put(ss,"D",1); break; 71 case -1: substdio_put(ss,"D",1); break;
63 } 72 }
64 73
65 for (k = 1;k < len;) 74 for (k = l = 1;k < j;++k)
75 if (!s[k])
76 {
77 substdio_puts(ss,s + l);
78 l = k + 2;
79 }
80
81 for (k = j+1;k < len;)
66 if (!s[k++]) 82 if (!s[k++])
67 { 83 {
68 substdio_puts(ss,s + 1); 84 substdio_puts(ss,s + j + 1);
69 if (result <= orr) 85 if (result <= orr)
70 if (k < len) 86 if (k < len)
71 switch(s[k]) 87 switch(s[k])