clean up setting of numeric IP addresses (and debug them properly)
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 15 May 1994 23:16:38 +0000 (15:16 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 15 May 1994 23:16:38 +0000 (15:16 -0800)
SCCS-vsn: usr.sbin/sendmail/src/main.c 8.56
SCCS-vsn: usr.sbin/sendmail/src/daemon.c 8.50

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

index 243c599..74cc979 100644 (file)
@@ -12,9 +12,9 @@
 
 #ifndef lint
 #ifdef DAEMON
 
 #ifndef lint
 #ifdef DAEMON
-static char sccsid[] = "@(#)daemon.c   8.49 (Berkeley) %G% (with daemon mode)";
+static char sccsid[] = "@(#)daemon.c   8.50 (Berkeley) %G% (with daemon mode)";
 #else
 #else
-static char sccsid[] = "@(#)daemon.c   8.49 (Berkeley) %G% (without daemon mode)";
+static char sccsid[] = "@(#)daemon.c   8.50 (Berkeley) %G% (without daemon mode)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -463,7 +463,7 @@ gothostent:
 **             Adds numeric codes to $=w.
 */
 
 **             Adds numeric codes to $=w.
 */
 
-char **
+struct hostent *
 myhostname(hostbuf, size)
        char hostbuf[];
        int size;
 myhostname(hostbuf, size)
        char hostbuf[];
        int size;
@@ -502,24 +502,7 @@ myhostname(hostbuf, size)
                }
        }
 #endif
                }
        }
 #endif
-
-       if (hp->h_addrtype == AF_INET && hp->h_length == 4)
-       {
-               register int i;
-
-               for (i = 0; hp->h_addr_list[i] != NULL; i++)
-               {
-                       char ipbuf[100];
-
-                       sprintf(ipbuf, "[%s]",
-                               inet_ntoa(*((struct in_addr *) hp->h_addr_list[i])));
-                       if (tTd(0, 4))
-                               printf("\ta.k.a.: %s\n", ipbuf);
-                       setclass('w', ipbuf);
-               }
-       }
-
-       return (hp->h_aliases);
+       return (hp);
 }
 \f/*
 **  GETAUTHINFO -- get the real host name asociated with a file descriptor
 }
 \f/*
 **  GETAUTHINFO -- get the real host name asociated with a file descriptor
index 1703b3b..53f4916 100644 (file)
@@ -13,12 +13,13 @@ static char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     8.55 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     8.56 (Berkeley) %G%";
 #endif /* not lint */
 
 #define        _DEFINE
 
 #include "sendmail.h"
 #endif /* not lint */
 
 #define        _DEFINE
 
 #include "sendmail.h"
+#include <netdb.h>
 #if NAMED_BIND
 #include <arpa/nameser.h>
 #include <resolv.h>
 #if NAMED_BIND
 #include <arpa/nameser.h>
 #include <resolv.h>
@@ -117,13 +118,14 @@ main(argc, argv, envp)
        char *argv0 = argv[0];
        struct passwd *pw;
        struct stat stb;
        char *argv0 = argv[0];
        struct passwd *pw;
        struct stat stb;
+       struct hostent *hp;
        char jbuf[MAXHOSTNAMELEN];      /* holds MyHostName */
        extern int DtableSize;
        extern int optind;
        extern time_t convtime();
        extern putheader(), putbody();
        extern void intsig();
        char jbuf[MAXHOSTNAMELEN];      /* holds MyHostName */
        extern int DtableSize;
        extern int optind;
        extern time_t convtime();
        extern putheader(), putbody();
        extern void intsig();
-       extern char **myhostname();
+       extern struct hostent *myhostname();
        extern char *arpadate();
        extern char *getauthinfo();
        extern char *getcfname();
        extern char *arpadate();
        extern char *getauthinfo();
        extern char *getcfname();
@@ -314,7 +316,7 @@ main(argc, argv, envp)
        define('v', Version, CurEnv);
 
        /* hostname */
        define('v', Version, CurEnv);
 
        /* hostname */
-       av = myhostname(jbuf, sizeof jbuf);
+       hp = myhostname(jbuf, sizeof jbuf);
        if (jbuf[0] != '\0')
        {
                struct  utsname utsname;
        if (jbuf[0] != '\0')
        {
                struct  utsname utsname;
@@ -352,17 +354,35 @@ main(argc, argv, envp)
                        p = jbuf;
                }
                if (tTd(0, 4))
                        p = jbuf;
                }
                if (tTd(0, 4))
-                       printf("UUCP nodename: %s\n", p);
+                       printf(" UUCP nodename: %s\n", p);
                p = newstr(p);
                define('k', p, CurEnv);
                setclass('k', p);
                setclass('w', p);
        }
                p = newstr(p);
                define('k', p, CurEnv);
                setclass('k', p);
                setclass('w', p);
        }
-       while (av != NULL && *av != NULL)
+       if (hp != NULL)
        {
        {
-               if (tTd(0, 4))
-                       printf("\ta.k.a.: %s\n", *av);
-               setclass('w', *av++);
+               for (av = hp->h_aliases; av != NULL && *av != NULL; av++)
+               {
+                       if (tTd(0, 4))
+                               printf("\ta.k.a.: %s\n", *av);
+                       setclass('w', *av);
+               }
+               if (hp->h_addrtype == AF_INET && hp->h_length == 4)
+               {
+                       register int i;
+
+                       for (i = 0; hp->h_addr_list[i] != NULL; i++)
+                       {
+                               char ipbuf[100];
+
+                               sprintf(ipbuf, "[%s]",
+                                       inet_ntoa(*((struct in_addr *) hp->h_addr_list[i])));
+                               if (tTd(0, 4))
+                                       printf("\ta.k.a.: %s\n", ipbuf);
+                               setclass('w', ipbuf);
+                       }
+               }
        }
 
        /* current time */
        }
 
        /* current time */
@@ -1392,7 +1412,7 @@ auth_warning(e, msg, va_alist)
        {
                register char *p;
                static char hostbuf[48];
        {
                register char *p;
                static char hostbuf[48];
-               extern char **myhostname();
+               extern struct hostent *myhostname();
 
                if (hostbuf[0] == '\0')
                        (void) myhostname(hostbuf, sizeof hostbuf);
 
                if (hostbuf[0] == '\0')
                        (void) myhostname(hostbuf, sizeof hostbuf);