Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/whois Merge in changes from OpenBSD 6.6 whois(1).



details:   https://anonhg.NetBSD.org/src/rev/235e8df99ecc
branches:  trunk
changeset: 969760:235e8df99ecc
user:      sevan <sevan%NetBSD.org@localhost>
date:      Sun Mar 01 02:19:43 2020 +0000

description:
Merge in changes from OpenBSD 6.6 whois(1).
This improves recursion support and querying whois servers.

diffstat:

 usr.bin/whois/whois.1 |   66 +++++++++++++-----------
 usr.bin/whois/whois.c |  135 ++++++++++++++++++++++++++++++++-----------------
 2 files changed, 125 insertions(+), 76 deletions(-)

diffs (truncated from 434 to 300 lines):

diff -r 1dae6a5860e4 -r 235e8df99ecc usr.bin/whois/whois.1
--- a/usr.bin/whois/whois.1     Sat Feb 29 22:09:29 2020 +0000
+++ b/usr.bin/whois/whois.1     Sun Mar 01 02:19:43 2020 +0000
@@ -1,8 +1,8 @@
-.\"     $NetBSD: whois.1,v 1.26 2012/03/15 22:35:03 njoly Exp $
-.\"    $OpenBSD: whois.1,v 1.22 2003/09/02 18:50:07 jmc Exp $
+.\"     $NetBSD: whois.1,v 1.27 2020/03/01 02:19:43 sevan Exp $
+.\"     $OpenBSD: whois.1,v 1.36 2016/02/20 20:52:50 naddy Exp $
 .\"
 .\" Copyright (c) 1985, 1990, 1993
-.\"    The Regents of the University of California.  All rights reserved.
+.\"    The Regents of the University of California.  All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -30,7 +30,7 @@
 .\"
 .\"     @(#)whois.1    8.2 (Berkeley) 6/20/94
 .\"
-.Dd September 9, 2007
+.Dd March 1, 2020
 .Dt WHOIS 1
 .Os
 .Sh NAME
@@ -38,12 +38,12 @@
 .Nd Internet domain name and network number directory service
 .Sh SYNOPSIS
 .Nm whois
-.Op Fl 6AadfgilmQRr
+.Op Fl AadfgIilmPQRr
 .Oo
 .Fl c Ar country-code | Fl h Ar host
 .Oc
 .Op Fl p Ar port
-.Ar name Op Ar ...
+.Ar name ...
 .Sh DESCRIPTION
 The
 .Nm
@@ -53,11 +53,6 @@
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
-.It Fl 6
-Use the IPv6 Resource Center
-.Pq Tn 6bone
-database.
-It contains network names and addresses for the IPv6 network.
 .It Fl A
 Use the Asia/Pacific Network Information Center
 .Pq Tn APNIC
@@ -69,11 +64,11 @@
 .Pq Tn ARIN
 database.
 It contains network numbers used in those parts of the world
-not covered by
+covered neither by
 .Tn AfriNIC ,
 .Tn APNIC ,
-.Tn LACNIC
-or by
+.Tn LACNIC ,
+nor by
 .Tn RIPE .
 .Pp
 (Hint: All point of contact handles in the
@@ -107,8 +102,11 @@
 .Nm
 constructs the name of a whois server to use from the top-level domain
 .Pq Tn TLD
-of the supplied (single) argument, and appending
-.Qq Li .whois-servers.net .
+of the supplied (single) argument.
+For newer generic domains (gTLDs), a lookup for whois.nic.tld is attempted.
+For other TLDs, or if this lookup fails,
+.Qq Li .whois-servers.net
+is appended to the TLD.
 This effectively allows a suitable whois server to be selected
 automatically for a large number of
 .Tn TLDs .
@@ -131,6 +129,11 @@
 .Nm
 will fall back to
 .Pa whois.crsnic.net .
+.It Fl I
+Use the Internet Assigned Numbers Authority
+.Pq whois.iana.org
+root zone database.
+It contains information about top-level domains.
 .It Fl i
 Use the Network Solutions Registry for Internet Numbers
 .Pq Tn whois.networksolutions.com
@@ -175,6 +178,10 @@
 database.
 It contains route policy specifications for a large
 number of operators' networks.
+.It Fl P
+Use the PeeringDB database of AS numbers.
+It contains details about presence at internet peering points
+for many network operators.
 .It Fl p Ar port
 Connect to the whois server on
 .Ar port .
@@ -277,15 +284,6 @@
 .Tn TLDs
 can be queried by using a similar syntax.)
 .Pp
-The following example demonstrates how to obtain information about an
-.Tn IPv6
-address or hostname using the
-.Fl 6
-option, which directs the query to
-.Tn 6bone .
-.Pp
-.Dl "whois -6 IPv6-IP-Address"
-.Pp
 The following example demonstrates how to query
 a whois server using a non-standard port, where
 .Dq Li query-data
@@ -296,13 +294,21 @@
 (written numerically as 4321).
 .Pp
 .Dl "whois -h whois.example.com -p rwhois query-data"
-.Sh SEE ALSO
+.Sh STANDARDS
 .Rs
-.%A Ken Harrenstien
-.%A Vic White
+.%A K. Harrenstien
+.%A M. Stahl
+.%A E. Feinler
+.%D October 1985
+.%R RFC 954
 .%T NICNAME/WHOIS
-.%D 1 March 1982
-.%O RFC 812
+.Re
+.Pp
+.Rs
+.%A L. Daigle
+.%D September 2004
+.%R RFC 3912
+.%T WHOIS Protocol Specification
 .Re
 .Sh HISTORY
 The
diff -r 1dae6a5860e4 -r 235e8df99ecc usr.bin/whois/whois.c
--- a/usr.bin/whois/whois.c     Sat Feb 29 22:09:29 2020 +0000
+++ b/usr.bin/whois/whois.c     Sun Mar 01 02:19:43 2020 +0000
@@ -1,5 +1,5 @@
-/*      $NetBSD: whois.c,v 1.36 2013/02/20 09:27:52 ws Exp $   */
-/*     $OpenBSD: whois.c,v 1.28 2003/09/18 22:16:15 fgsch Exp $        */
+/*      $NetBSD: whois.c,v 1.37 2020/03/01 02:19:43 sevan Exp $    */
+/*      $OpenBSD: whois.c,v 1.58 2018/06/19 11:28:11 jca Exp $   */
 
 /*
  * Copyright (c) 1980, 1993
@@ -41,7 +41,7 @@
 #if 0
 static const char sccsid[] = "@(#)whois.c      8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: whois.c,v 1.36 2013/02/20 09:27:52 ws Exp $");
+__RCSID("$NetBSD: whois.c,v 1.37 2020/03/01 02:19:43 sevan Exp $");
 #endif
 #endif /* not lint */
 
@@ -66,18 +66,19 @@
 #define        DNICHOST        "whois.nic.mil"
 #define        FNICHOST        "whois.afrinic.net"
 #define        GNICHOST        "whois.nic.gov"
+#define        IANAHOST        "whois.iana.org"
 #define        INICHOST        "whois.networksolutions.com"
 #define        LNICHOST        "whois.lacnic.net"
 #define        MNICHOST        "whois.ra.net"
 #define        NICHOST         "whois.crsnic.net"
+#define        PDBHOST         "whois.peeringdb.com"
 #define        PNICHOST        "whois.apnic.net"
 #define        QNICHOST_TAIL   ".whois-servers.net"
 #define        RNICHOST        "whois.ripe.net"
 #define        RUNICHOST       "whois.ripn.net"
-#define        SNICHOST        "whois.6bone.net"
 
 #define        WHOIS_PORT      "whois"
-#define        WHOIS_SERVER_ID "Whois Server:"
+#define        WHOIS_SERVER_ID "Registrar WHOIS Server:"
 
 #define WHOIS_RECURSE          0x01
 #define WHOIS_QUICK            0x02
@@ -88,7 +89,7 @@
 
 static void usage(void) __dead;
 static int whois(const char *, const char *, const char *, int);
-static const char *choose_server(const char *, const char *);
+static const char *choose_server(const char *, const char *, char **);
 
 int
 main(int argc, char *argv[])
@@ -96,13 +97,10 @@
        int ch, flags, rval;
        const char *host, *name, *country;
 
-#ifdef SOCKS
-       SOCKSinit(argv[0]);
-#endif
        country = host = NULL;
        flags = rval = 0;
-       while ((ch = getopt(argc, argv, "6Aac:dfgh:ilmp:qQRr")) != -1)
-               switch(ch) {
+       while ((ch = getopt(argc, argv, "aAc:dfgh:Iilmp:PqQRr")) != -1)
+               switch (ch) {
                case 'a':
                        host = ANICHOST;
                        break;
@@ -127,6 +125,9 @@
                case 'i':
                        host = INICHOST;
                        break;
+               case 'I':
+                       host = IANAHOST;
+                       break;
                case 'l':
                        host = LNICHOST;
                        break;
@@ -136,6 +137,9 @@
                case 'p':
                        port_whois = optarg;
                        break;
+               case 'P':
+                       host = PDBHOST;
+                       break;
                case 'q':
                        /* deprecated, now the default */
                        break;
@@ -148,9 +152,6 @@
                case 'R':
                        host = RUNICHOST;
                        break;
-               case '6':
-                       host = SNICHOST;
-                       break;
                default:
                        usage();
                }
@@ -162,16 +163,20 @@
 
        if (host == NULL && country == NULL && !(flags & WHOIS_QUICK))
                flags |= WHOIS_RECURSE;
-       for (name = *argv; (name = *argv) != NULL; argv++)
-               rval += whois(name, host ? host : choose_server(name, country),
-                   port_whois, flags);
-       return rval;
+       for (name = *argv; (name = *argv) != NULL; argv++) {
+               char *tofree = NULL;
+               const char *server =
+                   host ? host : choose_server(name, country, &tofree);
+               rval += whois(name, server, port_whois, flags);
+               free(tofree);
+       }
+       return (rval);
 }
 
 static int
 whois(const char *query, const char *server, const char *port, int flags)
 {
-       FILE *sfi, *sfo;
+       FILE *fp;
        char *buf, *p, *nhost, *nbuf = NULL;
        size_t len;
        int i, s, error;
@@ -184,7 +189,10 @@
        hints.ai_socktype = SOCK_STREAM;
        error = getaddrinfo(server, port, &hints, &res);
        if (error) {
-               warnx("%s: %s", server, gai_strerror(error));
+               if (error == EAI_SERVICE)
+                       warnx("%s: bad port", port);
+               else
+                       warnx("%s: %s", server, gai_strerror(error));
                return (1);
        }
 
@@ -204,30 +212,32 @@
                }
                break;  /*okay*/
        }
+       freeaddrinfo(res);
        if (s < 0) {
                if (reason) {
                        errno = error;
                        warn("%s: %s", server, reason);
                } else
                        warnx("Unknown error in connection attempt");
-               freeaddrinfo(res);
                return (1);
        }
 
        if (strcmp(server, "whois.denic.de") == 0 ||
-           strcmp(server, "de.whois-servers.net") == 0)
+           strcmp(server, "de" QNICHOST_TAIL) == 0)
                fmt = "-T dn,ace -C ISO-8859-1 ";



Home | Main Index | Thread Index | Old Index