diff -uNr qmail-1.03/qmail-remote.c qmail-1.03-modified/qmail-remote.c --- qmail-1.03/qmail-remote.c Tue Aug 17 17:22:27 2004 +++ qmail-1.03-modified/qmail-remote.c Tue Aug 17 17:56:10 2004 @@ -51,14 +51,19 @@ static stralloc sauninit = {0}; stralloc helohost = {0}; +/* XXX-noxa */ +stralloc outgoingip = {0}; +/* XXX-noxa */ stralloc routes = {0}; struct constmap maproutes; stralloc host = {0}; stralloc sender = {0}; +#if 0 /* XXX-noxa */ struct sockaddr_in slocal; /* XXX-noxa */ +#endif stralloc auth_smtp_user = {0}; stralloc auth_smtp_pass = {0}; @@ -66,6 +71,9 @@ saa reciplist = {0}; struct ip_address partner; +/* XXX-noxa */ +struct ip_address outip; +/* XXX-noxa */ void out(s) char *s; { if (substdio_puts(subfdoutsmall,s) == -1) _exit(0); } void zero() { if (substdio_put(subfdoutsmall,"\0",1) == -1) _exit(0); } @@ -75,6 +83,9 @@ ch = sa->s[i]; if (ch < 33) ch = '?'; if (ch > 126) ch = '?'; if (substdio_put(subfdoutsmall,&ch,1) == -1) _exit(0); } } +/* XXX-noxa */ +void temp_noip() { out("Zinvalid ipaddr in control/outgoingip (#4.3.0)\n"); zerodie(); } +/* XXX-noxa */ void temp_nomem() { out("ZOut of memory. (#4.3.0)\n"); zerodie(); } void temp_oserr() { out("Z\ System resources temporarily unavailable. (#4.3.0)\n"); zerodie(); } @@ -716,10 +727,15 @@ void getcontrols() { +#if 0 /* XXX-noxa */ stralloc iplocalstr={0}; struct ip_address iplocal; /* XXX-noxa */ +#endif + /* XXX-noxa */ + int r; + /* XXX-noxa */ if (control_init() == -1) temp_control(); if (control_readint(&timeout,"control/timeoutremote") == -1) temp_control(); @@ -741,6 +757,7 @@ if(!stralloc_0(&tlsclientciphers)) temp_nomem(); #endif +#if 0 /* XXX-noxa */ switch(control_readline(&iplocalstr,"control/outgoingip")) { case -1: @@ -760,6 +777,18 @@ * XXX-noxa -- see * http://www.mail-archive.com/qmail-ldap@argus.pipeline.ch/msg05076.html */ +#endif + + /* + * XXX-noxa + */ + r = control_readline(&outgoingip,"control/outgoingip"); + if (-1 == r) { if (errno == error_nomem) temp_nomem(); temp_control(); } + if (0 == r && !stralloc_copys(&outgoingip, "0.0.0.0")) temp_nomem(); + if (str_equal(outgoingip.s, "0.0.0.0")) + { outip.d[0]=outip.d[1]=outip.d[2]=outip.d[3]=(unsigned long) 0; } + else if (!ip_scan(outgoingip.s, &outip)) temp_noip(); + /* XXX-noxa */ } void main(argc,argv) @@ -867,6 +896,7 @@ smtpfd = socket(AF_INET,SOCK_STREAM,0); if (smtpfd == -1) temp_oserr(); +#if 0 /* XXX-noxa */ if (slocal.sin_family == AF_INET) { if (bind(smtpfd,(struct sockaddr *) &slocal,sizeof(slocal)) == -1) { @@ -877,9 +907,12 @@ * XXX-noxa -- see * http://www.mail-archive.com/qmail-ldap@argus.pipeline.ch/msg05076.html */ +#endif if (qmtp_priority(ip.ix[i].pref)) { - if (timeoutconn(smtpfd,&ip.ix[i].ip,(unsigned int) qmtp_port,timeoutconnect) == 0) { + /* XXX-noxa ...... */ + if (timeoutconn(smtpfd,&ip.ix[i].ip,&outip,(unsigned int) qmtp_port,timeoutconnect) == 0) { + /* XXX-noxa ^^^^^^ */ tcpto_err(&ip.ix[i].ip,0); partner = ip.ix[i].ip; qmtp(); /* does not return */ @@ -888,7 +921,9 @@ smtpfd = socket(AF_INET,SOCK_STREAM,0); if (smtpfd == -1) temp_oserr(); } - if (timeoutconn(smtpfd,&ip.ix[i].ip,(unsigned int) smtp_port,timeoutconnect) == 0) { + /* XXX-noxa ...... */ + if (timeoutconn(smtpfd,&ip.ix[i].ip,&outip,(unsigned int) smtp_port,timeoutconnect) == 0) { + /* XXX-noxa ^^^^^^ */ tcpto_err(&ip.ix[i].ip,0); partner = ip.ix[i].ip; #ifdef TLS diff -uNr qmail-1.03/qmail-showctl.c qmail-1.03-modified/qmail-showctl.c --- qmail-1.03/qmail-showctl.c Tue Aug 17 17:22:25 2004 +++ qmail-1.03-modified/qmail-showctl.c Tue Aug 17 17:56:53 2004 @@ -251,6 +251,9 @@ do_str("localiphost",1,"localiphost","Local IP address becomes "); do_lst("locals","Messages for me are delivered locally.","Messages for "," are delivered locally."); do_str("me",0,"undefined! Uh-oh","My name is "); + /* XXX-noxa */ + do_str("outgoingip",0,"0.0.0.0","Outgoing IP address is "); + /* XXX-noxa */ do_lst("percenthack","The percent hack is not allowed.","The percent hack is allowed for user%host@","."); do_str("plusdomain",1,"plusdomain","Plus domain name is "); do_lst("qmqpservers","No QMQP servers.","QMQP server: ","."); diff -uNr qmail-1.03/remoteinfo.c qmail-1.03-modified/remoteinfo.c --- qmail-1.03/remoteinfo.c Mon Jun 15 10:53:16 1998 +++ qmail-1.03-modified/remoteinfo.c Tue Aug 17 17:59:44 2004 @@ -44,12 +44,17 @@ s = socket(AF_INET,SOCK_STREAM,0); if (s == -1) return 0; - byte_zero(&sin,sizeof(sin)); +/* + * XXX-noxa + */ +/* byte_zero(&sin,sizeof(sin)); sin.sin_family = AF_INET; byte_copy(&sin.sin_addr,4,ipl); sin.sin_port = 0; - if (bind(s,(struct sockaddr *) &sin,sizeof(sin)) == -1) { close(s); return 0; } - if (timeoutconn(s,ipr,113,timeout) == -1) { close(s); return 0; } + if (bind(s,(struct sockaddr *) &sin,sizeof(sin)) == -1) { close(s); return 0; } */ + if (timeoutconn(s,ipr,ipl,113,timeout) == -1) { close(s); return 0; } + /* XXX-noxa ^^^ */ + fcntl(s,F_SETFL,fcntl(s,F_GETFL,0) & ~O_NDELAY); len = 0; diff -uNr qmail-1.03/timeoutconn.c qmail-1.03-modified/timeoutconn.c --- qmail-1.03/timeoutconn.c Mon Jun 15 10:53:16 1998 +++ qmail-1.03-modified/timeoutconn.c Tue Aug 17 18:03:11 2004 @@ -10,9 +10,17 @@ #include "byte.h" #include "timeoutconn.h" -int timeoutconn(s,ip,port,timeout) +/* + * XXX-noxa + * ..... */ +int timeoutconn(s,ip,outip,port,timeout) int s; struct ip_address *ip; + +/* XXX-noxa */ +struct ip_address *outip; +/* XXX-noxa */ + unsigned int port; int timeout; { @@ -21,7 +29,18 @@ char *x; fd_set wfds; struct timeval tv; - + + /* + * XXX-noxa + */ + /* bind() an outgoing ipaddr */ + byte_zero(&sin,sizeof(sin)); + byte_copy(&sin.sin_addr.s_addr,4,outip); + sin.sin_family = AF_INET; + + if (-1 == bind(s,(struct sockaddr *) &sin,sizeof(sin))) return -1; + /* XXX-noxa */ + byte_zero(&sin,sizeof(sin)); byte_copy(&sin.sin_addr,4,ip); x = (char *) &sin.sin_port;