summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chkspawn.c4
-rw-r--r--conf-spawn2
-rw-r--r--qmail-send.c27
-rw-r--r--spawn.c22
4 files changed, 35 insertions, 20 deletions
diff --git a/chkspawn.c b/chkspawn.c
index d19259e..3f97f5a 100644
--- a/chkspawn.c
+++ b/chkspawn.c
@@ -22,8 +22,8 @@ void main()
22 _exit(1); 22 _exit(1);
23 } 23 }
24 24
25 if (auto_spawn > 255) { 25 if (auto_spawn > 65000) {
26 substdio_puts(subfderr,"Oops. You have set conf-spawn higher than 255.\n"); 26 substdio_puts(subfderr,"Oops. You have set conf-spawn higher than 65000.\n");
27 substdio_flush(subfderr); 27 substdio_flush(subfderr);
28 _exit(1); 28 _exit(1);
29 } 29 }
diff --git a/conf-spawn b/conf-spawn
index d6a4256..cc11d5c 100644
--- a/conf-spawn
+++ b/conf-spawn
@@ -1,4 +1,4 @@
1120 11000
2 2
3This is a silent concurrency limit. You can't set it above 255. On some 3This is a silent concurrency limit. You can't set it above 255. On some
4systems you can't set it above 125. qmail will refuse to compile if the 4systems you can't set it above 125. qmail will refuse to compile if the
diff --git a/qmail-send.c b/qmail-send.c
index 7e6a8ac..ef8fe30 100644
--- a/qmail-send.c
+++ b/qmail-send.c
@@ -262,6 +262,8 @@ char *recip;
262 while (!stralloc_copys(&comm_buf[c],"")) nomem(); 262 while (!stralloc_copys(&comm_buf[c],"")) nomem();
263 ch = delnum; 263 ch = delnum;
264 while (!stralloc_append(&comm_buf[c],&ch)) nomem(); 264 while (!stralloc_append(&comm_buf[c],&ch)) nomem();
265 ch = delnum >> 8;
266 while (!stralloc_append(&comm_buf[c],&ch)) nomem();
265 fnmake_split(id); 267 fnmake_split(id);
266 while (!stralloc_cats(&comm_buf[c],fn.s)) nomem(); 268 while (!stralloc_cats(&comm_buf[c],fn.s)) nomem();
267 while (!stralloc_0(&comm_buf[c])) nomem(); 269 while (!stralloc_0(&comm_buf[c])) nomem();
@@ -906,41 +908,42 @@ int c;
906 dline[c].len = REPORTMAX; 908 dline[c].len = REPORTMAX;
907 /* qmail-lspawn and qmail-rspawn are responsible for keeping it short */ 909 /* qmail-lspawn and qmail-rspawn are responsible for keeping it short */
908 /* but from a security point of view, we don't trust rspawn */ 910 /* but from a security point of view, we don't trust rspawn */
909 if (!ch && (dline[c].len > 1)) 911 if (!ch && (dline[c].len > 2))
910 { 912 {
911 delnum = (unsigned int) (unsigned char) dline[c].s[0]; 913 delnum = (unsigned int) (unsigned char) dline[c].s[0];
914 delnum += (unsigned int) ((unsigned int) dline[c].s[1]) << 8;
912 if ((delnum < 0) || (delnum >= concurrency[c]) || !d[c][delnum].used) 915 if ((delnum < 0) || (delnum >= concurrency[c]) || !d[c][delnum].used)
913 log1("warning: internal error: delivery report out of range\n"); 916 log1("warning: internal error: delivery report out of range\n");
914 else 917 else
915 { 918 {
916 strnum3[fmt_ulong(strnum3,d[c][delnum].delid)] = 0; 919 strnum3[fmt_ulong(strnum3,d[c][delnum].delid)] = 0;
917 if (dline[c].s[1] == 'Z') 920 if (dline[c].s[2] == 'Z')
918 if (jo[d[c][delnum].j].flagdying) 921 if (jo[d[c][delnum].j].flagdying)
919 { 922 {
920 dline[c].s[1] = 'D'; 923 dline[c].s[2] = 'D';
921 --dline[c].len; 924 --dline[c].len;
922 while (!stralloc_cats(&dline[c],"I'm not going to try again; this message has been in the queue too long.\n")) nomem(); 925 while (!stralloc_cats(&dline[c],"I'm not going to try again; this message has been in the queue too long.\n")) nomem();
923 while (!stralloc_0(&dline[c])) nomem(); 926 while (!stralloc_0(&dline[c])) nomem();
924 } 927 }
925 switch(dline[c].s[1]) 928 switch(dline[c].s[2])
926 { 929 {
927 case 'K': 930 case 'K':
928 log3("delivery ",strnum3,": success: "); 931 log3("delivery ",strnum3,": success: ");
929 logsafe(dline[c].s + 2); 932 logsafe(dline[c].s + 3);
930 log1("\n"); 933 log1("\n");
931 markdone(c,jo[d[c][delnum].j].id,d[c][delnum].mpos); 934 markdone(c,jo[d[c][delnum].j].id,d[c][delnum].mpos);
932 --jo[d[c][delnum].j].numtodo; 935 --jo[d[c][delnum].j].numtodo;
933 break; 936 break;
934 case 'Z': 937 case 'Z':
935 log3("delivery ",strnum3,": deferral: "); 938 log3("delivery ",strnum3,": deferral: ");
936 logsafe(dline[c].s + 2); 939 logsafe(dline[c].s + 3);
937 log1("\n"); 940 log1("\n");
938 break; 941 break;
939 case 'D': 942 case 'D':
940 log3("delivery ",strnum3,": failure: "); 943 log3("delivery ",strnum3,": failure: ");
941 logsafe(dline[c].s + 2); 944 logsafe(dline[c].s + 3);
942 log1("\n"); 945 log1("\n");
943 addbounce(jo[d[c][delnum].j].id,d[c][delnum].recip.s,dline[c].s + 2); 946 addbounce(jo[d[c][delnum].j].id,d[c][delnum].recip.s,dline[c].s + 3);
944 markdone(c,jo[d[c][delnum].j].id,d[c][delnum].mpos); 947 markdone(c,jo[d[c][delnum].j].id,d[c][delnum].mpos);
945 --jo[d[c][delnum].j].numtodo; 948 --jo[d[c][delnum].j].numtodo;
946 break; 949 break;
@@ -1538,7 +1541,7 @@ void main()
1538 numjobs = 0; 1541 numjobs = 0;
1539 for (c = 0;c < CHANNELS;++c) 1542 for (c = 0;c < CHANNELS;++c)
1540 { 1543 {
1541 char ch; 1544 char ch, ch1;
1542 int u; 1545 int u;
1543 int r; 1546 int r;
1544 do 1547 do
@@ -1546,7 +1549,13 @@ void main()
1546 while ((r == -1) && (errno == error_intr)); 1549 while ((r == -1) && (errno == error_intr));
1547 if (r < 1) 1550 if (r < 1)
1548 { log1("alert: cannot start: hath the daemon spawn no fire?\n"); _exit(111); } 1551 { log1("alert: cannot start: hath the daemon spawn no fire?\n"); _exit(111); }
1552 do
1553 r = read(chanfdin[c],&ch1,1);
1554 while ((r == -1) && (errno == error_intr));
1555 if (r < 1)
1556 { log1("alert: cannot start: hath the daemon spawn no fire?\n"); _exit(111); }
1549 u = (unsigned int) (unsigned char) ch; 1557 u = (unsigned int) (unsigned char) ch;
1558 u += (unsigned int) ((unsigned char) ch1) << 8;
1550 if (concurrency[c] > u) concurrency[c] = u; 1559 if (concurrency[c] > u) concurrency[c] = u;
1551 numjobs += concurrency[c]; 1560 numjobs += concurrency[c];
1552 } 1561 }
diff --git a/spawn.c b/spawn.c
index b2aee78..1672d57 100644
--- a/spawn.c
+++ b/spawn.c
@@ -63,7 +63,7 @@ int okwrite(fd,buf,n) int fd; char *buf; int n;
63int flagreading = 1; 63int flagreading = 1;
64char outbuf[1024]; substdio ssout; 64char outbuf[1024]; substdio ssout;
65 65
66int stage = 0; /* reading 0:delnum 1:messid 2:sender 3:recip */ 66int stage = 0; /* reading 0:delnum 1:delnum2 2:messid 3:sender 4:recip */
67int flagabort = 0; /* if 1, everything except delnum is garbage */ 67int flagabort = 0; /* if 1, everything except delnum is garbage */
68int delnum; 68int delnum;
69stralloc messid = {0}; 69stralloc messid = {0};
@@ -73,6 +73,7 @@ stralloc recip = {0};
73void err(s) char *s; 73void err(s) char *s;
74{ 74{
75 char ch; ch = delnum; substdio_put(&ssout,&ch,1); 75 char ch; ch = delnum; substdio_put(&ssout,&ch,1);
76 ch = delnum >> 8; substdio_put(&ssout,&ch,1);
76 substdio_puts(&ssout,s); substdio_putflush(&ssout,"",1); 77 substdio_puts(&ssout,s); substdio_putflush(&ssout,"",1);
77} 78}
78 79
@@ -155,16 +156,19 @@ void getcmd()
155 { 156 {
156 case 0: 157 case 0:
157 delnum = (unsigned int) (unsigned char) ch; 158 delnum = (unsigned int) (unsigned char) ch;
158 messid.len = 0; stage = 1; break; 159 stage = 1; break;
159 case 1: 160 case 1:
161 delnum += (unsigned int) ((unsigned int) ch) << 8;
162 messid.len = 0; stage = 2; break;
163 case 2:
160 if (!stralloc_append(&messid,&ch)) flagabort = 1; 164 if (!stralloc_append(&messid,&ch)) flagabort = 1;
161 if (ch) break; 165 if (ch) break;
162 sender.len = 0; stage = 2; break; 166 sender.len = 0; stage = 3; break;
163 case 2: 167 case 3:
164 if (!stralloc_append(&sender,&ch)) flagabort = 1; 168 if (!stralloc_append(&sender,&ch)) flagabort = 1;
165 if (ch) break; 169 if (ch) break;
166 recip.len = 0; stage = 3; break; 170 recip.len = 0; stage = 4; break;
167 case 3: 171 case 4:
168 if (!stralloc_append(&recip,&ch)) flagabort = 1; 172 if (!stralloc_append(&recip,&ch)) flagabort = 1;
169 if (ch) break; 173 if (ch) break;
170 docmd(); 174 docmd();
@@ -201,7 +205,8 @@ char **argv;
201 205
202 initialize(argc,argv); 206 initialize(argc,argv);
203 207
204 ch = auto_spawn; substdio_putflush(&ssout,&ch,1); 208 ch = auto_spawn; substdio_put(&ssout,&ch,1);
209 ch = auto_spawn >> 8; substdio_putflush(&ssout,&ch,1);
205 210
206 for (i = 0;i < auto_spawn;++i) { d[i].used = 0; d[i].output.s = 0; } 211 for (i = 0;i < auto_spawn;++i) { d[i].used = 0; d[i].output.s = 0; }
207 212
@@ -236,7 +241,8 @@ char **argv;
236 continue; /* read error on a readable pipe? be serious */ 241 continue; /* read error on a readable pipe? be serious */
237 if (r == 0) 242 if (r == 0)
238 { 243 {
239 ch = i; substdio_put(&ssout,&ch,1); 244 char ch; ch = i; substdio_put(&ssout,&ch,1);
245 ch = i >> 8; substdio_put(&ssout,&ch,1);
240 report(&ssout,d[i].wstat,d[i].output.s,d[i].output.len); 246 report(&ssout,d[i].wstat,d[i].output.s,d[i].output.len);
241 substdio_put(&ssout,"",1); 247 substdio_put(&ssout,"",1);
242 substdio_flush(&ssout); 248 substdio_flush(&ssout);