ident fix for multihomed host
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 24 Oct 1993 09:19:02 +0000 (01:19 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 24 Oct 1993 09:19:02 +0000 (01:19 -0800)
SCCS-vsn: usr.sbin/sendmail/src/daemon.c 8.19

usr/src/usr.sbin/sendmail/src/daemon.c

index a689f28..8850a28 100644 (file)
@@ -12,9 +12,9 @@
 
 #ifndef lint
 #ifdef DAEMON
 
 #ifndef lint
 #ifdef DAEMON
-static char sccsid[] = "@(#)daemon.c   8.18 (Berkeley) %G% (with daemon mode)";
+static char sccsid[] = "@(#)daemon.c   8.19 (Berkeley) %G% (with daemon mode)";
 #else
 #else
-static char sccsid[] = "@(#)daemon.c   8.18 (Berkeley) %G% (without daemon mode)";
+static char sccsid[] = "@(#)daemon.c   8.19 (Berkeley) %G% (without daemon mode)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -601,7 +601,7 @@ getauthinfo(fd)
                ntohs(fa.sin.sin_port), ntohs(la.sin.sin_port));
 
        /* create local address */
                ntohs(fa.sin.sin_port), ntohs(la.sin.sin_port));
 
        /* create local address */
-       bzero(&la, sizeof la);
+       la.sin.sin_port = 0;
 
        /* create foreign address */
        sp = getservbyname("auth", "tcp");
 
        /* create foreign address */
        sp = getservbyname("auth", "tcp");
@@ -621,14 +621,15 @@ getauthinfo(fd)
        /* put a timeout around the whole thing */
        ev = setevent(TimeOuts.to_ident, authtimeout, 0);
 
        /* put a timeout around the whole thing */
        ev = setevent(TimeOuts.to_ident, authtimeout, 0);
 
-       /* connect to foreign IDENT server */
+       /* connect to foreign IDENT server using same address as SMTP socket */
        s = socket(AF_INET, SOCK_STREAM, 0);
        if (s < 0)
        {
                clrevent(ev);
                goto noident;
        }
        s = socket(AF_INET, SOCK_STREAM, 0);
        if (s < 0)
        {
                clrevent(ev);
                goto noident;
        }
-       if (connect(s, &fa.sa, sizeof fa.sin) < 0)
+       if (bind(s, &la.sa, sizeof la.sin) < 0 ||
+           connect(s, &fa.sa, sizeof fa.sin) < 0)
        {
 closeident:
                (void) close(s);
        {
 closeident:
                (void) close(s);