diff -ur qmail-1.03/Makefile qmail-1.03-sg2/Makefile --- qmail-1.03/Makefile Mon Jun 15 06:53:16 1998 +++ qmail-1.03-sg2/Makefile Sun Sep 16 04:01:13 2001 @@ -787,9 +787,9 @@ ./compile ipme.c ipmeprint: \ -load ipmeprint.o ipme.o ip.o ipalloc.o stralloc.a alloc.a substdio.a \ +load ipmeprint.o ipme.o ip.o ipalloc.o open.a getln.a stralloc.a alloc.a substdio.a \ error.a str.a fs.a socket.lib - ./load ipmeprint ipme.o ip.o ipalloc.o stralloc.a alloc.a \ + ./load ipmeprint ipme.o ip.o ipalloc.o open.a getln.a stralloc.a alloc.a \ substdio.a error.a str.a fs.a `cat socket.lib` ipmeprint.o: \ diff -ur qmail-1.03/ipme.c qmail-1.03-sg2/ipme.c --- qmail-1.03/ipme.c Mon Jun 15 06:53:16 1998 +++ qmail-1.03-sg2/ipme.c Sun Sep 16 04:07:09 2001 @@ -5,6 +5,7 @@ #include #include #include +#include #ifndef SIOCGIFCONF /* whatever works */ #include #endif @@ -14,6 +15,7 @@ #include "ipalloc.h" #include "stralloc.h" #include "ipme.h" +#include "substdio.h" static int ipmeok = 0; ipalloc ipme = {0}; @@ -40,12 +42,19 @@ int len; int s; struct ip_mx ix; + int moreipme_fd; if (ipmeok) return 1; if (!ipalloc_readyplus(&ipme,0)) return 0; ipme.len = 0; ix.pref = 0; + /* 0.0.0.0 is a special address which always refers to + * "this host, this network", according to RFC 1122, Sec. 3.2.1.3a. + */ + byte_copy(&ix.ip,4,"\0\0\0\0"); + if (!ipalloc_append(&ipme,&ix)) { return 0; } + if ((s = socket(AF_INET,SOCK_STREAM,0)) == -1) return -1; len = 256; @@ -90,6 +99,34 @@ x += len; } close(s); + + /* Now see if there are any supplemental IPs */ + if ( (moreipme_fd = open_read("control/moreipme")) != -1) + { + char inbuf[1024]; + substdio ss; + stralloc l = {0}; + int match; + + substdio_fdbuf(&ss, read, moreipme_fd, inbuf, sizeof(inbuf)); + while (1) + { + if (getln(&ss, &l, &match, '\n') == -1) + { + break; + } + if (!match && !l.len) + { + break; + } + l.len--; + if (!stralloc_0(&l)) { close(moreipme_fd); return 0; } + if (!ip_scan(l.s, &ix.ip)) { continue; } + if (!ipalloc_append(&ipme,&ix)) { close(moreipme_fd); return 0; } + } + } + close(moreipme_fd); + ipmeok = 1; return 1; }