--- qmail-1.03/qmail-remote.c 2004-08-12 15:49:39.540754608 +0200 +++ qmail-1.03-noxa/qmail-remote.c 2004-08-12 15:48:08.000000000 +0200 @@ -55,6 +55,11 @@ struct constmap maproutes; stralloc host = {0}; stralloc sender = {0}; + +/* XXX-noxa */ +struct sockaddr_in slocal; +/* XXX-noxa */ + stralloc auth_smtp_user = {0}; stralloc auth_smtp_pass = {0}; @@ -711,6 +716,11 @@ void getcontrols() { + /* XXX-noxa */ + stralloc iplocalstr={0}; + struct ip_address iplocal; + /* XXX-noxa */ + if (control_init() == -1) temp_control(); if (control_readint(&timeout,"control/timeoutremote") == -1) temp_control(); if (control_readint(&timeoutconnect,"control/timeoutconnect") == -1) @@ -730,6 +740,26 @@ temp_control(); if(!stralloc_0(&tlsclientciphers)) temp_nomem(); #endif + + /* XXX-noxa */ + switch(control_readline(&iplocalstr,"control/outgoingip")) { + case -1: + temp_control(); + case 0: + slocal.sin_family = 0; + break; + case 1: + if (!ip_scan(iplocalstr.s, &iplocal)) { + slocal.sin_family=0; break; } + slocal.sin_family = AF_INET; + slocal.sin_port=0; + byte_copy(&iplocal,4,&slocal.sin_addr); + break; + } + /* + * XXX-noxa -- see + * http://www.mail-archive.com/qmail-ldap@argus.pipeline.ch/msg05076.html + */ } void main(argc,argv) @@ -745,6 +775,7 @@ int flagalias; char *relayhost; + #ifdef TLS sig_alarmcatch(sigalrm); #endif @@ -835,6 +866,17 @@ smtpfd = socket(AF_INET,SOCK_STREAM,0); if (smtpfd == -1) temp_oserr(); + + /* XXX-noxa */ + if (slocal.sin_family == AF_INET) { + if (bind(smtpfd,(struct sockaddr *) &slocal,sizeof(slocal)) == -1) { + temp_oserr(); + } + } + /* + * XXX-noxa -- see + * http://www.mail-archive.com/qmail-ldap@argus.pipeline.ch/msg05076.html + */ if (qmtp_priority(ip.ix[i].pref)) { if (timeoutconn(smtpfd,&ip.ix[i].ip,(unsigned int) qmtp_port,timeoutconnect) == 0) {