Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/hostname Remove options added in 1.18, commitid: UhxHPgt...



details:   https://anonhg.NetBSD.org/src/rev/db4b433acb45
branches:  trunk
changeset: 793431:db4b433acb45
user:      elric <elric%NetBSD.org@localhost>
date:      Thu Feb 13 12:00:29 2014 +0000

description:
Remove options added in 1.18, commitid: UhxHPgtT2Pzeg4Yw due to some
level of controversy about their inclusion.

diffstat:

 bin/hostname/hostname.1 |   34 ++----------
 bin/hostname/hostname.c |  124 +++--------------------------------------------
 2 files changed, 15 insertions(+), 143 deletions(-)

diffs (240 lines):

diff -r 152d50711a40 -r db4b433acb45 bin/hostname/hostname.1
--- a/bin/hostname/hostname.1   Thu Feb 13 11:08:46 2014 +0000
+++ b/bin/hostname/hostname.1   Thu Feb 13 12:00:29 2014 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: hostname.1,v 1.19 2013/07/19 11:19:23 wiz Exp $
+.\"    $NetBSD: hostname.1,v 1.20 2014/02/13 12:00:29 elric Exp $
 .\"
 .\" Copyright (c) 1983, 1988, 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"    @(#)hostname.1  8.2 (Berkeley) 4/28/95
 .\"
-.Dd July 19, 2013
+.Dd April 28, 1995
 .Dt HOSTNAME 1
 .Os
 .Sh NAME
@@ -37,7 +37,7 @@
 .Nd set or print name of current host system
 .Sh SYNOPSIS
 .Nm
-.Op Fl AadfIis
+.Op Fl s
 .Op Ar name-of-host
 .Sh DESCRIPTION
 .Nm
@@ -50,36 +50,14 @@
 .Pp
 Options:
 .Bl -tag -width flag
-.It Fl A
-Display the FQDN of each address on all interfaces.
-.It Fl a
-Display alias name(s) of the host.
-.It Fl d
-Display the DNS domain.
-.It Fl f
-Display the FQDN for the hostname.
-.It Fl I
-Display each IP address on all interfaces.
-.It Fl i
-Display the IP address(es) for the hostname.
 .It Fl s
-Display the short hostname.
+Trims off any domain information from the printed
+name.
 .El
-.Sh NOTES
-With the exception of
-.Fl I
-and
-.Fl s ,
-the other options will retrieve their results from the resolver.
 .Sh SEE ALSO
 .Xr domainname 1 ,
-.Xr getaddrinfo 3 ,
-.Xr gethostbyname 3 ,
 .Xr gethostname 3 ,
-.Xr getifaddrs 3 ,
-.Xr getnameinfo 3 ,
-.Xr sethostname 3 ,
-.Xr hosts 5
+.Xr sethostname 3
 .Sh HISTORY
 The
 .Nm
diff -r 152d50711a40 -r db4b433acb45 bin/hostname/hostname.c
--- a/bin/hostname/hostname.c   Thu Feb 13 11:08:46 2014 +0000
+++ b/bin/hostname/hostname.c   Thu Feb 13 12:00:29 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hostname.c,v 1.20 2013/07/19 15:53:00 christos Exp $ */
+/* $NetBSD: hostname.c,v 1.21 2014/02/13 12:00:29 elric Exp $ */
 
 /*
  * Copyright (c) 1988, 1993
@@ -39,19 +39,13 @@
 #if 0
 static char sccsid[] = "@(#)hostname.c 8.2 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: hostname.c,v 1.20 2013/07/19 15:53:00 christos Exp $");
+__RCSID("$NetBSD: hostname.c,v 1.21 2014/02/13 12:00:29 elric Exp $");
 #endif
 #endif /* not lint */
 
 #include <sys/param.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-#include <netinet/in.h>
 
 #include <err.h>
-#include <ifaddrs.h>
-#include <netdb.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -62,36 +56,13 @@
 int
 main(int argc, char *argv[])
 {
-       int ch, Aflag, aflag, dflag, Iflag, iflag, fflag, sflag, i;
+       int ch, sflag;
        char *p, hostname[MAXHOSTNAMELEN + 1];
-       struct addrinfo hints, *ainfos, *ai;
-       struct hostent *hent;
-       struct ifaddrs *ifa, *ifp;
-       struct sockaddr_in6 *sin6;
-       char buf[MAX(MAXHOSTNAMELEN + 1, INET6_ADDRSTRLEN)];
 
        setprogname(argv[0]);
-       Aflag = aflag = dflag = Iflag = iflag = fflag = sflag = 0;
-       while ((ch = getopt(argc, argv, "AadIifs")) != -1)
+       sflag = 0;
+       while ((ch = getopt(argc, argv, "s")) != -1)
                switch (ch) {
-               case 'A':
-                       Aflag = 1;
-                       break;
-               case 'a':
-                       aflag = 1;
-                       break;
-               case 'd':
-                       dflag = 1;
-                       break;
-               case 'I':
-                       Iflag = 1;
-                       break;
-               case 'i':
-                       iflag = 1;
-                       break;
-               case 'f':
-                       fflag = 1;
-                       break;
                case 's':
                        sflag = 1;
                        break;
@@ -108,90 +79,13 @@
        if (*argv) {
                if (sethostname(*argv, strlen(*argv)))
                        err(1, "sethostname");
-       } else if (Aflag || Iflag) {
-               if (getifaddrs(&ifa) == -1)
-                       err(1, "getifaddrs");
-               for (ifp = ifa; ifp; ifp = ifp->ifa_next) {
-                       if (ifp->ifa_addr == NULL ||
-                           ifp->ifa_flags & IFF_LOOPBACK ||
-                           !(ifp->ifa_flags & IFF_UP))
-                               continue;
-
-                       switch(ifp->ifa_addr->sa_family) {
-                       case AF_INET:
-                               break;
-                       case AF_INET6:
-                               /* Skip link local addresses */
-                               sin6 = (struct sockaddr_in6 *)ifp->ifa_addr;
-                               if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) ||
-                                   IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr))
-                                       continue;
-                               break;
-                       default:
-                               /* We only translate IPv4 or IPv6 addresses */
-                               continue;
-                       }
-                       i = getnameinfo(ifp->ifa_addr, ifp->ifa_addr->sa_len,
-                           buf, sizeof(buf), NULL, 0,
-                           Iflag ? NI_NUMERICHOST: NI_NAMEREQD);
-                       if (i) {
-                               if (Iflag && i != EAI_NONAME)
-                                       errx(1, "getnameinfo: %s",
-                                           gai_strerror(i));
-                       } else
-                               printf("%s\n", buf);
-               }
-               freeifaddrs(ifa);
        } else {
                if (gethostname(hostname, sizeof(hostname)))
                        err(1, "gethostname");
                hostname[sizeof(hostname) - 1] = '\0';
-               if (aflag) {
-                       if ((hent = gethostbyname(hostname)) == NULL)
-                               errx(1, "gethostbyname: %s",
-                                   hstrerror(h_errno));
-                       for (i = 0; hent->h_aliases[i]; i++)
-                               printf("%s\n", hent->h_aliases[i]);
-               } else if (dflag || iflag || fflag) {
-                       memset(&hints, 0, sizeof(hints));
-                       hints.ai_family = AF_UNSPEC;
-                       hints.ai_socktype = SOCK_DGRAM;
-                       hints.ai_flags = AI_CANONNAME;
-                       i = getaddrinfo(hostname, NULL, &hints, &ainfos);
-                       if (i)
-                               errx(1, "getaddrinfo: %s", gai_strerror(i));
-                       if (ainfos) {
-                               if (dflag) {
-                                       if ((p = strchr(ainfos->ai_canonname,
-                                           '.')))
-                                               printf("%s\n", p + 1);
-                               } else if (iflag) {
-                                       for (ai = ainfos; ai; ai = ai->ai_next)
-                                       {
-                                               i = getnameinfo(ai->ai_addr,
-                                                   ai->ai_addrlen,
-                                                   buf, sizeof(buf), NULL, 0,
-                                                   NI_NUMERICHOST);
-                                               if (i)
-                                                       errx(1,
-                                                           "getnameinfo: %s",
-                                                           gai_strerror(i));
-                                               printf("%s\n", buf);
-                                       }
-                               } else {
-                                       if (sflag &&
-                                           (p = strchr(ainfos->ai_canonname,
-                                           '.')))
-                                               *p = '\0';
-                                       printf("%s\n", ainfos->ai_canonname);
-                               }
-                               freeaddrinfo(ainfos);
-                       }
-               } else {
-                       if (sflag && (p = strchr(hostname, '.')))
-                               *p = '\0';
-                       printf("%s\n", hostname);
-               }
+               if (sflag && (p = strchr(hostname, '.')))
+                       *p = '\0';
+               (void)printf("%s\n", hostname);
        }
        exit(0);
        /* NOTREACHED */
@@ -200,7 +94,7 @@
 static void
 usage(void)
 {
-       (void)fprintf(stderr, "usage: %s [-AadfIis] [name-of-host]\n",
+       (void)fprintf(stderr, "usage: %s [-s] [name-of-host]\n",
            getprogname());
        exit(1);
        /* NOTREACHED */



Home | Main Index | Thread Index | Old Index