tentative attempts to print UNIX domain sockets properly
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Thu, 21 Oct 1993 23:20:14 +0000 (15:20 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Thu, 21 Oct 1993 23:20:14 +0000 (15:20 -0800)
SCCS-vsn: usr.sbin/sendmail/src/daemon.c 8.18

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

index 259883d..a689f28 100644 (file)
@@ -12,9 +12,9 @@
 
 #ifndef lint
 #ifdef DAEMON
 
 #ifndef lint
 #ifdef DAEMON
-static char sccsid[] = "@(#)daemon.c   8.17 (Berkeley) %G% (with daemon mode)";
+static char sccsid[] = "@(#)daemon.c   8.18 (Berkeley) %G% (with daemon mode)";
 #else
 #else
-static char sccsid[] = "@(#)daemon.c   8.17 (Berkeley) %G% (without daemon mode)";
+static char sccsid[] = "@(#)daemon.c   8.18 (Berkeley) %G% (without daemon mode)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -882,7 +882,7 @@ anynet_ntoa(sap)
        register char *bp;
        register char *ap;
        int l;
        register char *bp;
        register char *ap;
        int l;
-       static char buf[80];
+       static char buf[100];
 
        /* check for null/zero family */
        if (sap == NULL)
 
        /* check for null/zero family */
        if (sap == NULL)
@@ -890,11 +890,27 @@ anynet_ntoa(sap)
        if (sap->sa.sa_family == 0)
                return "0";
 
        if (sap->sa.sa_family == 0)
                return "0";
 
+       switch (sap->sa.sa_family)
+       {
+#ifdef MAYBENEXTRELEASE                /*** UNTESTED *** UNTESTED *** UNTESTED ***/
+         case AF_UNIX:
+               if (sap->sun.sun_path[0] != '\0')
+                       sprintf(buf, "[UNIX: %.64s]", sap->sun.sun_path);
+               else
+                       sprintf(buf, "[UNIX: localhost]");
+               return buf;
+#endif
+
 #ifdef NETINET
 #ifdef NETINET
-       if (sap->sa.sa_family == AF_INET)
+         case AF_INET:
                return inet_ntoa(((struct sockaddr_in *) sap)->sin_addr);
 #endif
 
                return inet_ntoa(((struct sockaddr_in *) sap)->sin_addr);
 #endif
 
+         default:
+               /* this case is only to ensure syntactic correctness */
+               break;
+       }
+
        /* unknown family -- just dump bytes */
        (void) sprintf(buf, "Family %d: ", sap->sa.sa_family);
        bp = &buf[strlen(buf)];
        /* unknown family -- just dump bytes */
        (void) sprintf(buf, "Family %d: ", sap->sa.sa_family);
        bp = &buf[strlen(buf)];
@@ -925,10 +941,9 @@ hostnamebyanyaddr(sap)
        register SOCKADDR *sap;
 {
        register struct hostent *hp;
        register SOCKADDR *sap;
 {
        register struct hostent *hp;
-
-#ifdef NAMED_BIND
        int saveretry;
 
        int saveretry;
 
+#ifdef NAMED_BIND
        /* shorten name server timeout to avoid higher level timeouts */
        saveretry = _res.retry;
        _res.retry = 3;
        /* shorten name server timeout to avoid higher level timeouts */
        saveretry = _res.retry;
        _res.retry = 3;
@@ -952,6 +967,12 @@ hostnamebyanyaddr(sap)
                break;
 #endif
 
                break;
 #endif
 
+#ifdef MAYBENEXTRELEASE                /*** UNTESTED *** UNTESTED *** UNTESTED ***/
+         case AF_UNIX:
+               hp = NULL;
+               break;
+#endif
+
          default:
                hp = gethostbyaddr(sap->sa.sa_data,
                           sizeof sap->sa.sa_data,
          default:
                hp = gethostbyaddr(sap->sa.sa_data,
                           sizeof sap->sa.sa_data,