Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 56744 - QMAIL: the ability to configure/assign outbound email ip address
Summary: QMAIL: the ability to configure/assign outbound email ip address
Status: RESOLVED DUPLICATE of bug 98961
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Gentoo Linux bug wranglers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-11 18:59 UTC by Arnvid L. Karstad
Modified: 2005-08-27 07:30 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arnvid L. Karstad 2004-07-11 18:59:44 UTC
would it be possible to get gentoo portage qmail to have the patch that
allows the server admin to specify the sending ip addresse of outbound
mail?

Reproducible: Always
Steps to Reproduce:
1.
2.
3.




patch that allows this behaviour can be found at www-1.isd.no/outgoingip.patch

patch is also below... please note that this patch is not by me, but it is one 
I'm using on my slack mail servers ;)


Index: qmail-control.9
===================================================================
RCS file: /home/software/CVSREPOS/qmail/qmail-control.9,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -u -r1.2 -r1.3
--- qmail-control.9     2001/08/14 17:35:30     1.2
+++ qmail-control.9     2003/07/04 09:02:58     1.3
@@ -57,6 +57,7 @@
 .I locals      \fIme   \fRqmail-send
 .I mfcheck     \fR0    \fRqmail-smtpd
 .I morercpthosts       \fR(none)       \fRqmail-smtpd
+.I outgoingip  \fR0.0.0.0      \fRqmail-remote
 .I percenthack \fR(none)       \fRqmail-send
 .I plusdomain  \fIme   \fRqmail-inject
 .I qmqpservers \fR(none)       \fRqmail-qmqpc
Index: qmail-remote.8
===================================================================
RCS file: /home/software/CVSREPOS/qmail/qmail-remote.8,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -u -r1.1.1.1 -r1.2
--- qmail-remote.8      2001/05/30 16:55:45     1.1.1.1
+++ qmail-remote.8      2003/07/04 09:02:58     1.2
@@ -124,6 +124,13 @@
 .B qmail-remote
 refuses to run.
 .TP 5
+.I outgoingip
+IP address to be used on outgoing connections.
+Default: system-defined.
+The value
+.IR 0.0.0.0
+is equivalent to the system default.
+.TP 5
 .I smtproutes
 Artificial SMTP routes.
 Each route has the form
Index: qmail-remote.c
===================================================================
RCS file: /home/software/CVSREPOS/qmail/qmail-remote.c,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -u -r1.1.1.1 -r1.3
--- qmail-remote.c      2001/05/30 16:55:46     1.1.1.1
+++ qmail-remote.c      2003/07/04 11:38:57     1.3
@@ -39,6 +39,7 @@
 static stralloc sauninit = {0};

 stralloc helohost = {0};
+stralloc outgoingip = {0};
 stralloc routes = {0};
 struct constmap maproutes;
 stralloc host = {0};
@@ -47,6 +48,7 @@
 saa reciplist = {0};

 struct ip_address partner;
+struct ip_address outip;

 void out(s) char *s; { if (substdio_puts(subfdoutsmall,s) == -1) _exit(0); }
 void zero() { if (substdio_put(subfdoutsmall,"\0",1) == -1) _exit(0); }
@@ -56,6 +58,7 @@
 ch = sa->s[i]; if (ch < 33) ch = '?'; if (ch > 126) ch = '?';
 if (substdio_put(subfdoutsmall,&ch,1) == -1) _exit(0); } }

+void temp_noip() { out("Zinvalid ipaddr in control/outgoingip (#4.3.0)\n"); 
zerodie(); }
 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(); }
@@ -310,6 +313,7 @@

 void getcontrols()
 {
+  int r;
   if (control_init() == -1) temp_control();
   if (control_readint(&timeout,"control/timeoutremote") == -1) temp_control();
   if (control_readint(&timeoutconnect,"control/timeoutconnect") == -1)
@@ -324,6 +328,12 @@
     case 1:
       if (!constmap_init(&maproutes,routes.s,routes.len,1)) temp_nomem(); 
break;
   }
+ 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();
 }

 void main(argc,argv)
@@ -414,7 +424,7 @@
     smtpfd = socket(AF_INET,SOCK_STREAM,0);
     if (smtpfd == -1) temp_oserr();

-    if (timeoutconn(smtpfd,&ip.ix[i].ip,(unsigned int) port,timeoutconnect) == 
0) {
+    if (timeoutconn(smtpfd,&ip.ix[i].ip,&outip,(unsigned int) 
port,timeoutconnect) == 0) {
       tcpto_err(&ip.ix[i].ip,0);
       partner = ip.ix[i].ip;
       smtp(); /* does not return */
Index: qmail-showctl.c
===================================================================
RCS file: /home/software/CVSREPOS/qmail/qmail-showctl.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -u -r1.1.1.1 -r1.2
--- qmail-showctl.c     2001/05/30 16:55:46     1.1.1.1
+++ qmail-showctl.c     2003/07/04 11:45:48     1.2
@@ -230,6 +230,7 @@
   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 ");
+  do_str("outgoingip",0,"0.0.0.0","Outgoing IP address is ");
   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: ",".");
Index: remoteinfo.c
===================================================================
RCS file: /home/software/CVSREPOS/qmail/remoteinfo.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -u -r1.1.1.1 -r1.2
--- remoteinfo.c        2001/05/30 16:55:47     1.1.1.1
+++ remoteinfo.c        2003/07/03 22:28:50     1.2
@@ -44,12 +44,12 @@
   s = socket(AF_INET,SOCK_STREAM,0);
   if (s == -1) return 0;

-  byte_zero(&sin,sizeof(sin));
+/*  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; }
   fcntl(s,F_SETFL,fcntl(s,F_GETFL,0) & ~O_NDELAY);

   len = 0;
Index: timeoutconn.c
===================================================================
RCS file: /home/software/CVSREPOS/qmail/timeoutconn.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -u -r1.1.1.1 -r1.2
--- timeoutconn.c       2001/05/30 16:55:47     1.1.1.1
+++ timeoutconn.c       2003/07/03 22:28:50     1.2
@@ -10,9 +10,10 @@
 #include "byte.h"
 #include "timeoutconn.h"

-int timeoutconn(s,ip,port,timeout)
+int timeoutconn(s,ip,outip,port,timeout)
 int s;
 struct ip_address *ip;
+struct ip_address *outip;
 unsigned int port;
 int timeout;
 {
@@ -22,6 +23,13 @@
   fd_set wfds;
   struct timeval tv;

+  /* 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;
+
   byte_zero(&sin,sizeof(sin));
   byte_copy(&sin.sin_addr,4,ip);
   x = (char *) &sin.sin_port;
Comment 1 Arnvid L. Karstad 2004-07-12 03:15:00 UTC
The previous patch does not cleanly apply to the portage'd qmail. I've fixed this to work with qmail-1.03-r13 files.

New diff:
www-1.isd.no/qmail-1.03-outgoing.ip-gentoo.diff

portage diff's:
--- files/digest-qmail-1.03-r13       2004-05-30 12:50:13.000000000 +0200
+++ files/digest-qmail-1.03-r99       2004-07-12 12:10:29.748969619 +0200
@@ -18,3 +18,4 @@
 MD5 58d912de1ede57062fa8a3e2e0e75abf qmail-popupnofd2close.patch 401
 MD5 d7151dcbeb02eea1c24c1dedffe20e0b qmail-1.03-reread-concurrency.2.patch 1129
 MD5 ad597c93426c0938fdb36d853fbcf40d 08-capa.diff 1323
+MD5 9fc7d99c44aa001381883b331f4c8443 qmail-1.03-outgoing.ip-gentoo.diff 6235


--- qmail-1.03-r13.ebuild       2004-07-01 22:06:46.000000000 +0200
+++ qmail-1.03-r99.ebuild       2004-07-12 12:05:37.178388689 +0200
@@ -29,6 +29,7 @@
        http://www.dataloss.nl/software/patches/qmail-popupnofd2close.patch
        http://js.hu/package/qmail/qmail-1.03-reread-concurrency.2.patch
        http://www.mcmilk.de/qmail/dl/djb-qmail/patches/08-capa.diff
+       http://www-1.isd.no/qmail-1.03-outgoing.ip-gentoo.diff
        "
 # broken stuffs
 #http://www.qcc.ca/~charlesc/software/misc/nullenvsender-recipcount.patch
@@ -157,6 +158,9 @@
        # TODO REDIFF
        #EPATCH_SINGLE_MSG="qmail-pop3d reports erroneous figures on STAT after a DELE" \
        #epatch ${DISTDIR}/qmail-pop3d-stat.patch
+
+       # arnvid - tmp portage fixage - sender ip
+       epatch ${DISTDIR}/qmail-1.03-outgoing.ip-gentoo.diff

        echo -n "$(gcc-getCC) ${CFLAGS}" >${S}/conf-cc
        if use ssl; then
Comment 2 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-07-12 04:52:26 UTC
please post all patches against -r15
Comment 3 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-09-15 02:20:21 UTC
clearing up my bug tracking
Comment 4 Arnvid L. Karstad 2004-09-26 15:46:53 UTC
.
Comment 5 Arnvid L. Karstad 2004-09-26 15:47:28 UTC
.
Comment 6 Andrej Kacian (RETIRED) gentoo-dev 2004-09-26 15:53:03 UTC
Reopening, I think this can be fixed.
Comment 7 Arnvid L. Karstad 2004-09-26 16:37:10 UTC
Why, nobody really wanted to look at what I did either... just nagged about that it wasn't for the right release ;)
Comment 8 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-09-26 18:22:23 UTC
arnvid: I want patches that will apply cleanly on -r15.
-r16 is turning into a massively delayed behomoth of qmail :-(.
Comment 9 Sergiy Borodych 2005-04-03 12:24:27 UTC
any progress ?
Comment 10 Michael Hanselmann (hansmi) (RETIRED) gentoo-dev 2005-08-27 07:29:49 UTC
reopen
Comment 11 Michael Hanselmann (hansmi) (RETIRED) gentoo-dev 2005-08-27 07:30:28 UTC

*** This bug has been marked as a duplicate of 98961 ***