updated on Thu Jan 12 04:00:44 UTC 2012
[aur-mirror.git] / netqmail / qmail-queue-custom-error-mod.patch
blob778c28c7111901d42b77078a6ba8e0c4ef179138
1 --- qmail-queue.8.orig 2008-08-21 22:22:59.007351087 +0400
2 +++ qmail-queue.8 2008-08-21 22:25:04.846922397 +0400
3 @@ -149,6 +149,16 @@
4 .B 81
5 Internal bug; e.g., segmentation fault.
6 .TP
7 +.B 82
8 +Custom error (=bounce) messages.
9 +You have to write the error message to file descriptor 6
10 +and exit 82, in order to use the custom message.
11 +Format of the message:
13 +Dthis is a custom fatal error message
15 +Zthis is a custom temporary failure message
16 +.TP
17 .B 91
18 Envelope format error.
19 .SH "SEE ALSO"
20 --- qmail.c.orig 2008-08-21 22:22:59.040684449 +0400
21 +++ qmail.c 2008-08-21 22:33:33.936870949 +0400
22 @@ -23,22 +23,31 @@
24 int pim[2];
25 int pie[2];
26 + int pierr[2];
28 setup_qqargs();
30 if (pipe(pim) == -1) return -1;
31 if (pipe(pie) == -1) { close(pim[0]); close(pim[1]); return -1; }
32 + if (pipe(pierr) == -1) {
33 + close(pim[0]); close(pim[1]);
34 + close(pie[0]); close(pie[1]);
35 + return -1;
36 + }
38 switch(qq->pid = vfork()) {
39 case -1:
40 close(pim[0]); close(pim[1]);
41 close(pie[0]); close(pie[1]);
42 + close(pierr[0]); close(pierr[1]);
43 return -1;
44 case 0:
45 close(pim[1]);
46 close(pie[1]);
47 + close(pierr[0]); /* we want to receive data */
48 if (fd_move(0,pim[0]) == -1) _exit(120);
49 if (fd_move(1,pie[0]) == -1) _exit(120);
50 + if (fd_move(6,pierr[1]) == -1) _exit(120);
51 if (chdir(auto_qmail) == -1) _exit(61);
52 execv(*binqqargs,binqqargs);
53 _exit(120);
54 @@ -46,6 +55,7 @@
56 qq->fdm = pim[1]; close(pim[0]);
57 qq->fde = pie[1]; close(pie[0]);
58 + qq->fderr = pierr[0]; close(pierr[1]);
59 substdio_fdbuf(&qq->ss,write,qq->fdm,qq->buf,sizeof(qq->buf));
60 qq->flagerr = 0;
61 return 0;
62 @@ -93,10 +103,21 @@
64 int wstat;
65 int exitcode;
66 + int match;
67 + char ch;
68 + static char errstr[256];
69 + int len = 0;
71 qmail_put(qq,"",1);
72 if (!qq->flagerr) if (substdio_flush(&qq->ss) == -1) qq->flagerr = 1;
73 close(qq->fde);
74 + substdio_fdbuf(&qq->ss,read,qq->fderr,qq->buf,sizeof(qq->buf));
75 + while (substdio_bget(&qq->ss,&ch,1) && len < 255) {
76 + errstr[len]=ch;
77 + len++;
78 + }
79 + if (len > 0) errstr[len]='\0'; /* add str-term */
80 + close(qq->fderr);
82 if (wait_pid(&wstat,qq->pid) != qq->pid)
83 return "Zqq waitpid surprise (#4.3.0)";
84 @@ -129,6 +150,8 @@
85 case 81: return "Zqq internal bug (#4.3.0)";
86 case 120: return "Zunable to exec qq (#4.3.0)";
87 default:
88 + if (exitcode == 82 && len > 2)
89 + return errstr;
90 if ((exitcode >= 11) && (exitcode <= 40))
91 return "Dqq permanent problem (#5.3.0)";
92 return "Zqq temporary problem (#4.3.0)";
93 --- qmail.h.orig 2008-08-21 22:22:59.040684449 +0400
94 +++ qmail.h 2008-08-21 22:33:50.590203369 +0400
95 @@ -8,6 +8,7 @@
96 unsigned long pid;
97 int fdm;
98 int fde;
99 + int fderr;
100 substdio ss;
101 char buf[1024];