From a8ec2376dca7b1d7cb840fe39e5cac7a008b2123 Mon Sep 17 00:00:00 2001 From: Eric Allman Date: Sun, 15 May 1994 15:16:38 -0800 Subject: [PATCH] clean up setting of numeric IP addresses (and debug them properly) 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 | 25 +++-------------- usr/src/usr.sbin/sendmail/src/main.c | 38 ++++++++++++++++++++------ 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/usr/src/usr.sbin/sendmail/src/daemon.c b/usr/src/usr.sbin/sendmail/src/daemon.c index 243c59937e..74cc9794e8 100644 --- a/usr/src/usr.sbin/sendmail/src/daemon.c +++ b/usr/src/usr.sbin/sendmail/src/daemon.c @@ -12,9 +12,9 @@ #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 -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 */ @@ -463,7 +463,7 @@ gothostent: ** Adds numeric codes to $=w. */ -char ** +struct hostent * myhostname(hostbuf, size) char hostbuf[]; int size; @@ -502,24 +502,7 @@ myhostname(hostbuf, size) } } #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); } /* ** GETAUTHINFO -- get the real host name asociated with a file descriptor diff --git a/usr/src/usr.sbin/sendmail/src/main.c b/usr/src/usr.sbin/sendmail/src/main.c index 1703b3b737..53f49168b8 100644 --- a/usr/src/usr.sbin/sendmail/src/main.c +++ b/usr/src/usr.sbin/sendmail/src/main.c @@ -13,12 +13,13 @@ static char copyright[] = #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" +#include #if NAMED_BIND #include #include @@ -117,13 +118,14 @@ main(argc, argv, envp) 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(); - extern char **myhostname(); + extern struct hostent *myhostname(); extern char *arpadate(); extern char *getauthinfo(); extern char *getcfname(); @@ -314,7 +316,7 @@ main(argc, argv, envp) define('v', Version, CurEnv); /* hostname */ - av = myhostname(jbuf, sizeof jbuf); + hp = myhostname(jbuf, sizeof jbuf); if (jbuf[0] != '\0') { struct utsname utsname; @@ -352,17 +354,35 @@ main(argc, argv, envp) 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); } - 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 */ @@ -1392,7 +1412,7 @@ auth_warning(e, msg, va_alist) { register char *p; static char hostbuf[48]; - extern char **myhostname(); + extern struct hostent *myhostname(); if (hostbuf[0] == '\0') (void) myhostname(hostbuf, sizeof hostbuf); -- 2.20.1