updated on Mon Jan 16 00:01:41 UTC 2012
[aur-mirror.git] / qmail / qmail-1.03-bind-interface.patch
blob6da82caca356e61eec5972fcf7cc211985946aff
1 diff -u qmail-1.03-orig/Makefile qmail-1.03/Makefile
2 --- qmail-1.03-orig/Makefile Mon Jun 15 04:53:16 1998
3 +++ qmail-1.03/Makefile Thu Jun 25 23:12:16 1998
4 @@ -1333,10 +1333,10 @@
6 qmail-qmqpc: \
7 load qmail-qmqpc.o slurpclose.o timeoutread.o timeoutwrite.o \
8 -timeoutconn.o ip.o control.o auto_qmail.o sig.a ndelay.a open.a \
9 +timeoutconn.o constmap.o case.a ip.o control.o auto_qmail.o sig.a ndelay.a open.a \
10 getln.a substdio.a stralloc.a alloc.a error.a str.a fs.a socket.lib
11 ./load qmail-qmqpc slurpclose.o timeoutread.o \
12 - timeoutwrite.o timeoutconn.o ip.o control.o auto_qmail.o \
13 + timeoutwrite.o timeoutconn.o constmap.o case.a ip.o control.o auto_qmail.o \
14 sig.a ndelay.a open.a getln.a substdio.a stralloc.a alloc.a \
15 error.a str.a fs.a `cat socket.lib`
17 @@ -1438,12 +1438,12 @@
18 ./compile qmail-queue.c
20 qmail-remote: \
21 -load qmail-remote.o control.o constmap.o timeoutread.o timeoutwrite.o \
22 -timeoutconn.o tcpto.o now.o dns.o ip.o ipalloc.o ipme.o quote.o \
23 +load qmail-remote.o control.o timeoutread.o timeoutwrite.o \
24 +timeoutconn.o constmap.o tcpto.o now.o dns.o ip.o ipalloc.o ipme.o quote.o \
25 ndelay.a case.a sig.a open.a lock.a seek.a getln.a stralloc.a alloc.a \
26 substdio.a error.a str.a fs.a auto_qmail.o dns.lib socket.lib
27 - ./load qmail-remote control.o constmap.o timeoutread.o \
28 - timeoutwrite.o timeoutconn.o tcpto.o now.o dns.o ip.o \
29 + ./load qmail-remote control.o timeoutread.o \
30 + timeoutwrite.o timeoutconn.o constmap.o tcpto.o now.o dns.o ip.o \
31 ipalloc.o ipme.o quote.o ndelay.a case.a sig.a open.a \
32 lock.a seek.a getln.a stralloc.a alloc.a substdio.a error.a \
33 str.a fs.a auto_qmail.o `cat dns.lib` `cat socket.lib`
34 @@ -2067,8 +2067,10 @@
35 tcp-env: \
36 load tcp-env.o dns.o remoteinfo.o timeoutread.o timeoutwrite.o \
37 timeoutconn.o ip.o ipalloc.o case.a ndelay.a sig.a env.a getopt.a \
38 -stralloc.a alloc.a substdio.a error.a str.a fs.a dns.lib socket.lib
39 +stralloc.a alloc.a substdio.a error.a str.a fs.a dns.lib socket.lib \
40 +constmap.o control.o open.a getln.a
41 ./load tcp-env dns.o remoteinfo.o timeoutread.o \
42 + constmap.o control.o open.a getln.a \
43 timeoutwrite.o timeoutconn.o ip.o ipalloc.o case.a ndelay.a \
44 sig.a env.a getopt.a stralloc.a alloc.a substdio.a error.a \
45 str.a fs.a `cat dns.lib` `cat socket.lib`
46 diff -u qmail-1.03-orig/timeoutconn.c qmail-1.03/timeoutconn.c
47 --- qmail-1.03-orig/timeoutconn.c Mon Jun 15 04:53:16 1998
48 +++ qmail-1.03/timeoutconn.c Thu Jun 25 23:11:28 1998
49 @@ -10,6 +10,54 @@
50 #include "byte.h"
51 #include "timeoutconn.h"
53 +#define BIND_SOCKET 1 /* 0 to ignore bind fail, 1 to tempfail and requeue */
54 +#ifdef BIND_SOCKET
55 +#include "control.h"
56 +#include "constmap.h"
57 +#include "stralloc.h"
59 +int bind_socket(s,ip)
60 +int s;
61 +struct ip_address *ip;
63 + struct sockaddr_in salocal;
64 + struct ip_address iplocal;
65 + char *ipstr, ipstring[IPFMT+1];
66 + int iplen;
67 + stralloc routes = {0};
68 + struct constmap bindroutes;
69 + char *bindroute = (char *)0;
71 + /* Right, do we actually have any bind routes? */
72 + switch(control_readfile(&routes,"control/bindroutes",0))
73 + {
74 + case 0: return 0; /* no file, no bind to worry about */
75 + case -1: return -2; /* buggered up somewhere, urgh! */
76 + case 1: if (!constmap_init(&bindroutes,routes.s,routes.len,1)) return -3;
77 + }
79 + ipstring[0] = '.'; /* "cheating", but makes the loop check easier below! */
80 + ipstr = ipstring+1;
81 + iplen = ip_fmt(ipstr,ip); /* Well, Dan seems to trust its output! */
83 + /* check d.d.d.d, d.d.d., d.d., d., none */
84 + bindroute = constmap(&bindroutes,ipstr,iplen);
85 + if (!bindroute) while (iplen--) /* no worries - the lost char must be 0-9 */
86 + if (ipstring[iplen] == '.')
87 + if (bindroute = constmap(&bindroutes,ipstr,iplen)) break;
88 + if (!bindroute || !*bindroute) return 0; /* no bind required */
89 + if (!ip_scan(bindroute,&iplocal)) return -4; /* wasn't an ip returned */
91 + byte_zero(&salocal,sizeof(salocal));
92 + salocal.sin_family = AF_INET;
93 + byte_copy(&salocal.sin_addr,4,&iplocal);
95 + if (bind(s, (struct sockaddr *)&salocal,sizeof(salocal))) return BIND_SOCKET;
96 + return 0;
99 +#endif
101 int timeoutconn(s,ip,port,timeout)
102 int s;
103 struct ip_address *ip;
104 @@ -31,6 +79,9 @@
105 if (ndelay_on(s) == -1) return -1;
107 /* XXX: could bind s */
108 +#ifdef BIND_SOCKET
109 + if (ch = bind_socket(s,ip)) return ch;
110 +#endif
112 if (connect(s,(struct sockaddr *) &sin,sizeof(sin)) == 0) {
113 ndelay_off(s);