History log of /freebsd-11-stable/usr.bin/whois/whois.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 331722 29-Mar-2018 eadler

Revert r330897:

This was intended to be a non-functional change. It wasn't. The commit
message was thus wrong. In addition it broke arm, and merged crypto
related code.

Revert with prejudice.

This revert skips files touched in r316370 since that commit was since
MFCed. This revert also skips files that require $FreeBSD$ property
changes.

Thank you to those who helped me get out of this mess including but not
limited to gonzo, kevans, rgrimes.

Requested by: gjb (re)


# 330897 14-Mar-2018 eadler

Partial merge of the SPDX changes

These changes are incomplete but are making it difficult
to determine what other changes can/should be merged.

No objections from: pfg


# 302408 07-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/cddl
/freebsd-11-stable/cddl/contrib/opensolaris
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/zfs
/freebsd-11-stable/cddl/contrib/opensolaris/lib/libzfs
/freebsd-11-stable/contrib/amd
/freebsd-11-stable/contrib/apr
/freebsd-11-stable/contrib/apr-util
/freebsd-11-stable/contrib/atf
/freebsd-11-stable/contrib/binutils
/freebsd-11-stable/contrib/bmake
/freebsd-11-stable/contrib/byacc
/freebsd-11-stable/contrib/bzip2
/freebsd-11-stable/contrib/com_err
/freebsd-11-stable/contrib/compiler-rt
/freebsd-11-stable/contrib/dialog
/freebsd-11-stable/contrib/dma
/freebsd-11-stable/contrib/dtc
/freebsd-11-stable/contrib/ee
/freebsd-11-stable/contrib/elftoolchain
/freebsd-11-stable/contrib/elftoolchain/ar
/freebsd-11-stable/contrib/elftoolchain/brandelf
/freebsd-11-stable/contrib/elftoolchain/elfdump
/freebsd-11-stable/contrib/expat
/freebsd-11-stable/contrib/file
/freebsd-11-stable/contrib/gcc
/freebsd-11-stable/contrib/gcclibs/libgomp
/freebsd-11-stable/contrib/gdb
/freebsd-11-stable/contrib/gdtoa
/freebsd-11-stable/contrib/groff
/freebsd-11-stable/contrib/ipfilter
/freebsd-11-stable/contrib/ldns
/freebsd-11-stable/contrib/ldns-host
/freebsd-11-stable/contrib/less
/freebsd-11-stable/contrib/libarchive
/freebsd-11-stable/contrib/libarchive/cpio
/freebsd-11-stable/contrib/libarchive/libarchive
/freebsd-11-stable/contrib/libarchive/libarchive_fe
/freebsd-11-stable/contrib/libarchive/tar
/freebsd-11-stable/contrib/libc++
/freebsd-11-stable/contrib/libc-vis
/freebsd-11-stable/contrib/libcxxrt
/freebsd-11-stable/contrib/libexecinfo
/freebsd-11-stable/contrib/libpcap
/freebsd-11-stable/contrib/libstdc++
/freebsd-11-stable/contrib/libucl
/freebsd-11-stable/contrib/libxo
/freebsd-11-stable/contrib/llvm
/freebsd-11-stable/contrib/llvm/projects/libunwind
/freebsd-11-stable/contrib/llvm/tools/clang
/freebsd-11-stable/contrib/llvm/tools/lldb
/freebsd-11-stable/contrib/llvm/tools/llvm-dwarfdump
/freebsd-11-stable/contrib/llvm/tools/llvm-lto
/freebsd-11-stable/contrib/mdocml
/freebsd-11-stable/contrib/mtree
/freebsd-11-stable/contrib/ncurses
/freebsd-11-stable/contrib/netcat
/freebsd-11-stable/contrib/ntp
/freebsd-11-stable/contrib/nvi
/freebsd-11-stable/contrib/one-true-awk
/freebsd-11-stable/contrib/openbsm
/freebsd-11-stable/contrib/openpam
/freebsd-11-stable/contrib/openresolv
/freebsd-11-stable/contrib/pf
/freebsd-11-stable/contrib/sendmail
/freebsd-11-stable/contrib/serf
/freebsd-11-stable/contrib/sqlite3
/freebsd-11-stable/contrib/subversion
/freebsd-11-stable/contrib/tcpdump
/freebsd-11-stable/contrib/tcsh
/freebsd-11-stable/contrib/tnftp
/freebsd-11-stable/contrib/top
/freebsd-11-stable/contrib/top/install-sh
/freebsd-11-stable/contrib/tzcode/stdtime
/freebsd-11-stable/contrib/tzcode/zic
/freebsd-11-stable/contrib/tzdata
/freebsd-11-stable/contrib/unbound
/freebsd-11-stable/contrib/vis
/freebsd-11-stable/contrib/wpa
/freebsd-11-stable/contrib/xz
/freebsd-11-stable/crypto/heimdal
/freebsd-11-stable/crypto/openssh
/freebsd-11-stable/crypto/openssl
/freebsd-11-stable/gnu/lib
/freebsd-11-stable/gnu/usr.bin/binutils
/freebsd-11-stable/gnu/usr.bin/cc/cc_tools
/freebsd-11-stable/gnu/usr.bin/gdb
/freebsd-11-stable/lib/libc/locale/ascii.c
/freebsd-11-stable/sys/cddl/contrib/opensolaris
/freebsd-11-stable/sys/contrib/dev/acpica
/freebsd-11-stable/sys/contrib/ipfilter
/freebsd-11-stable/sys/contrib/libfdt
/freebsd-11-stable/sys/contrib/octeon-sdk
/freebsd-11-stable/sys/contrib/x86emu
/freebsd-11-stable/sys/contrib/xz-embedded
/freebsd-11-stable/usr.sbin/bhyve/atkbdc.h
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.c
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.h
/freebsd-11-stable/usr.sbin/bhyve/console.c
/freebsd-11-stable/usr.sbin/bhyve/console.h
/freebsd-11-stable/usr.sbin/bhyve/pci_fbuf.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.h
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.c
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.h
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.c
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.h
/freebsd-11-stable/usr.sbin/bhyve/rfb.c
/freebsd-11-stable/usr.sbin/bhyve/rfb.h
/freebsd-11-stable/usr.sbin/bhyve/sockstream.c
/freebsd-11-stable/usr.sbin/bhyve/sockstream.h
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.c
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.h
/freebsd-11-stable/usr.sbin/bhyve/usb_mouse.c
/freebsd-11-stable/usr.sbin/bhyve/vga.c
/freebsd-11-stable/usr.sbin/bhyve/vga.h
# 300678 25-May-2016 fanf

Send whois queries for gov.uk names to JANET.


# 299476 11-May-2016 cem

whois(1): Fix potential double-close and logic mistakes

Close the fd the poll error was detected on, rather than the last opened fd, to
fix the double-close.

Use -1 to make it explict which int variables no longer own socket file
descriptors.

Actually shrink, rather than grow, the poll timeout to match comment.

Reported by: Coverity
CID: 1304860, 1305616
Sponsored by: EMC / Isilon Storage Division


# 299473 11-May-2016 cem

whois(1): Pull out async multiple host connection code into a routine

This logic was added to the whois() function in r281959, but could easily be
its own routine. In this case, I think the abstraction makes both functions
easier to reason about.

This precedes some Coverity-suggested cleanup.

Sponsored by: EMC / Isilon Storage Division


# 297708 08-Apr-2016 fanf

Handle whois referrals between RIRs

This is rather ugly, because the RIPE and APNIC whois servers do
not provide referrals for address blocks that they do not manage.
However ARIN is usually the right place or knows the right place
so we try there.

The particular instance which clued me in to this bug is U.Mich.
141.211.0.0/16 for which the referral chain should be IANA ->
RIPE -> ARIN. RIPE's RDAP does provide useful redirects (for
example try `curl -I http://rdap.db.ripe.net/ip/141.211.0.0)
so maybe their whois server can be improved.

AfriNIC's whois server gives more direct referrals, but they are
designed to be human-readable. Ugly, but we can manage.

The issue of referrals between RIRs is likely to become more important
in the future whith the increasing number of cross-region IP address
block transfers increases.


# 297449 31-Mar-2016 fanf

Fix whois queries for ARIN AS numbers.

The ARIN whois server likes AS number queries to be in the form
"a 8075" rather than "as7085".


# 294613 22-Jan-2016 fanf

Fix a regression in the .de and .dk whois special cases

Ensure the special cases trigger whether we come via a referral
or via the -c option. Match host names case-insensitively.

Use the default character set supported by .de (UTF-8) since that
is more compatible with the modern world than ISO 8859-1. Persuade
them to give us a useful answer whether an internationalized
domain name is given in UTF-8 or in punycode.


# 294611 22-Jan-2016 fanf

A lot of the cleverness in whois is no longer needed!

The IANA whois server has the right referral information for domain
names, IP addresses, and AS numbers, so whois does not need to be
able to choose servers itself (except for a few cases where referrals
do not work). We can delete a chunk of code, which is always fun.

This change improves the referral handling to be less sensitive to
all the various formats, and to allow multi-hop referral chains,
such as IANA -> registry -> registrar.

ARIN queries have the "+" flag added if no flags are present, so we
get full details if the query matches multiple objects. The Verisign
anti-spam logic is also now suppressed if the user provided a non-
trivial query string.

Uninformative rubric is now trimmed by default. The -S option
turns off trimming, and disables query fettling.

The -i option is back to its traditional pre-1999 hostname, since
whois.internic.net is more useful than whois.networksolutions.com.
Note that the old fallback/default server whois.crsnic.net is an
alias for whois.internic.net.

The manual is more informative about query syntax.


# 294591 22-Jan-2016 fanf

Update whois synopsis and usage with new options


# 294575 22-Jan-2016 fanf

A few `whois` usability improvements

Look up AS numbers at ARIN.

Handle more referral formats.

Suppress spammy nameserver objects when querying the .com and .net
whois servers by explicitly querying for domain names by default.


# 287030 23-Aug-2015 delphij

Although the website [1] says US-ASCII is accepted, ISO-8859-1 seems to
be the only accepted character that is close enough to US-ASCII (and
this is also done on OpenBSD; the alternative would be to use UTF-8).

[1] http://www.denic.de/en/domains/technik/denic_whois-server/index.html

MFC after: 2 weeks


# 282893 14-May-2015 fanf

whois: add an option to query the PeeringDB


# 282889 14-May-2015 fanf

whois: alphabetize whois server list


# 282888 14-May-2015 fanf

whois: do not clobber command-line flags when tweaking O_NONBLOCK

This can make whois fail to follow referrals when it should.
The bug was introduced in r281959.


# 282887 14-May-2015 fanf

whois: try whois.nic.TLD if TLD.whois-servers.net does not exist

Based on an idea from OpenBSD.


# 282886 14-May-2015 fanf

whois: check WHOIS_SERVER as well as RA_SERVER environment variables

WHOIS_SERVER is used by Debian's whois client.


# 282885 14-May-2015 fanf

whois: code cleanup

Remove deprecated options.

Use pedantically correct types.


# 282884 14-May-2015 fanf

whois: special case certain query suffixes

This extends the existing support for -NORID handles
to include -NICAT, -ARIN, and -RIPE handles.

The suffix machinery is also used to work around a problem with
lack of referrals from the Nominet server for .uk: names under
.ac.uk need to be queried directly at JANET's whois server.


# 281959 24-Apr-2015 delphij

Try alternate addresses more agressively.

Attempt to connect to alternate addresses if the connect doesn't
succeed in 180ms, and cut wait time between connection attempts
in half for each additional, if no connection was established.

Take the first connection to succeed and close the others.

This makes whois more responsive when e.g. IPv6 service took long
time or fail to respond.

PR: 158125
Submitted by: Mark Andrews <marka isc org> (with changes from me)
MFC after: 2 weeks


# 267871 25-Jun-2014 ume

Introduce $RA_SERVER to set default whois server.

Requested by: nork
Reviewed by: nork
MFC after: 1 week


# 260259 04-Jan-2014 kevlo

The whois() function is called in a loop so make sure we close the
socket to the whois server before returning.

Obtained from: OpenBSD


# 227246 06-Nov-2011 ed

Mark global functions and/or variables in whois(1) static where possible.

This allows compilers and static analyzers to more thorough analysis.


# 216370 11-Dec-2010 joel

Remove the advertising clause from UCB copyrighted files in usr.bin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change

Also add $FreeBSD$ to a few files to keep svn happy.

Discussed with: imp, rwatson


# 202281 14-Jan-2010 edwin

Make whois capable of searching for IPv6 addresses just like it can
do for IPv4 addresses without having to explicetly specify that the
ARIN server should be used to get the initial information

PR: bin/128725
Submitted by: "Matt D. Harris" <mdh_lists@yahoo.com>
MFC after: 1 week


# 202280 14-Jan-2010 edwin

Remove -d option, whois.nic.mil doesn't exist anymore.

PR: bin/142507
Submitted by: Dan Mahoney <danm@prime.gushi.org>
MFC after: 1 week


# 197725 03-Oct-2009 dougb

The 6bone was decommissioned on 6/6/06, so remove references to it.


# 168721 14-Apr-2007 ache

Use proper type cast for ctype macro


# 166103 19-Jan-2007 phk

Make DK-HOSTMASTER show contact info for .dk domains.

Submitted by: Søren Hansen <shan@soeren-hansen.dk>


# 154710 23-Jan-2006 jhay

Add AfriNIC as a RIR.

PR: 80421
Submitted by: Adrian Frith <adrian at frith.homelinux.org>
MFC after: 6 days


# 146752 29-May-2005 charnier

Reduce compiler warning: variable might be used uninitialized, by giving
an initial value.


# 138681 11-Dec-2004 ceri

Add a -k flag for querying whois.krnic.net (the National Internet
Development Agency of Korea) which hold details of IP address
allocations within Korea.

Approved by: bms


# 134294 25-Aug-2004 mbr

Add special case for the german whois nameserver. Without the
'-T dn,ace -C US-ASCII' option one does only get:

$ whois nic.de

domain: nic.de
status: connect

More information available on:

http://www.denic.de/en/domains/technik/denic_whois-server/index.html

MFC: 3 days


# 130487 14-Jun-2004 bms

Add -b to usage.

Pointed out by: ceri
Pointy hat to: bms


# 130479 14-Jun-2004 bms

Add whois.abuse.net to whois(1).

Submitted by: ceri (with cleanups)


# 130466 14-Jun-2004 bms

Add whois.iana.org to the whois(1) utility, under the -I option.

PR: bin/48914
Submitted by: James Raftery


# 117050 29-Jun-2003 ache

Back out .SU workaround - people at whois-servers.net set up
su.whois-servers.net


# 116783 24-Jun-2003 ache

While there is no su.whois-servers.net, use fallback to
ru.whois-servers.net for su domain or country


# 112617 25-Mar-2003 eivind

Add support for identifying NORID (norwegian top level registry) handles.

Reviewed by: mike (with slight changes based on feedback afterwards)


# 111430 24-Feb-2003 mike

Fix style bugs in previous commit.


# 110159 31-Jan-2003 roberto

The newly appointed .org registrar has a pecular output format so
whois doesn't follow the link to the authoritative registrar. Fix it.

PR: bin/47770
Submitted by: Alain Thivillon <at@rominet.net>
MFC after: 7 days


# 106735 10-Nov-2002 mike

Add support for the Latin American and Caribbean IP address Regional
Registry (LACNIC) with the -l option and support for recursive IP
address searches.

PR: 44448
Submitted by: David Wolfskill <david@catwhisker.org>
MFC after: 1 week


# 103530 18-Sep-2002 mike

ARIN has annoyingly started using caps when referencing
whois.apnic.net. To properly receive hints for recursive IP searches,
we convert a buffer to lowercase before searching for magic words.

PR: 42834
Submitted by: Andre Albsmeier <andre.albsmeier@mchp.siemens.de> (mostly)
X-MFC-After: re approval


# 91792 07-Mar-2002 mike

Leave the `copyright' variable exposed, since the main purpose of it
is to put a copyright in the object file.

Submitted by: bde


# 90163 04-Feb-2002 kris

Mark a function as __printflike()

MFC after: 1 week


# 90131 03-Feb-2002 mike

Use new ID scheme.

Fix a bug that caused .br domains to be queried twice, by only
recursively following ARIN referrals when querying ARIN.

PR: 34291
MFC after: 7 days


# 87536 08-Dec-2001 mike

Add support for Brazilian IP Addresses. Example `whois 200.236.70.0'.

PR: 30676


# 85067 17-Oct-2001 mike

Remove some EOL whitespace. Update usage() to current reality.


# 84852 12-Oct-2001 mike

o Treat a buffer as a non-NUL terminated string, because the whois
server may not return a new line character on the final line.
o Remove the whois.networksolutions.com fallback code, which is no
longer needed.
o Instead of determining a hostname by terminating it when we see
whitespace, only allow hostname characters and terminate the string
when it's not such a character.
o Add a small optimization in a for loop.

PR: 30968
Reviewed by: -audit
MFC after: 4 days


# 81165 05-Aug-2001 mike

o Move APNIC flag from -p to -A. Since, -p is usually associated
with specifying a port.
o Add the -p flag for specifying a port. (PR: 28790) This is
useful for querying rwhois servers. Example:
whois -h rwhois.exodus.net -p rwhois 216.136.180.0
o Add the -c flag which allows one to get the same whois server
that would normally be determined if no arguments were specified.
(Concept based on work by phantom, requested by ache) Example:
whois -c ru TCNET-MNT-RIPN
o Deprecate -R flag in favour of -c ru.

PR: 28790
Reviewed by: -audit, ache, phantom


# 80155 22-Jul-2001 mike

Fix a bug I introduced in Rev. 1.21 that prevented 'whois test' from
working.

Reviewed by: des
Approved by: des


# 80050 20-Jul-2001 mike

o Add phantom's gethostinfo() function to reduce duplicated code.
o Increase readability by creating a wrapper for asprintf(3).
o Cast isdigit(3) argument to unsigned char for future locale
changes.

Submitted by: phantom
Reviewed by: -audit, des
Approved by: des


# 79835 17-Jul-2001 mike

Re-write the logic that finds the whois server to query.
[This fixes a bug where one would type 'whois foo.bar.'
and get an error because of the trailing period.]

PR: 28880
Approved by: des


# 78900 27-Jun-2001 dd

Implement recursive IP address searches based on the results of a
query to ARIN.

PR: 28426
Submitted by: Mike Barcroft <mike@q9media.com>


# 78581 21-Jun-2001 des

Stylify, ANSIfy, silence warnings, plug a memory leak, don't assume the
server is well-behaved wrt. line endings.

PR: bin/28082
Submitted by: Mike Barcroft <mike@q9media.com>


# 77585 01-Jun-2001 ume

Do retry next entry in addrinfo during connect.

MFC after: 1 week


# 77368 28-May-2001 phk

Direct queries for IP numbers to ARIN. It would be nice if we could
send them to APNIC/RIPE intelligently, but we can't at this time so
fallback to ARIN and depend on them telling the user where to look.

Maybe we need a .whoisrc file...

PR: 24707
Submitted by: Mike Barcroft mike@q9media.com
MFC after: 1 week


# 62756 07-Jul-2000 kris

Enable whois queries over IPv6

Obtained from: KAME


# 54227 06-Dec-1999 joe

Add braces ({}) to all the places that they're missing.


# 54172 05-Dec-1999 joe

Added a -6 option to lookup information using the whois.6bone.net
database.

PR: misc/10803 misc/10804


# 54088 03-Dec-1999 ache

Change -i host to whois.networksolutions.com


# 53294 17-Nov-1999 ache

purity change for name length checking code


# 53291 17-Nov-1999 ache

Merge with OpenBSD whois (with bugfixes missed there)

New features are:
Automatic lookup using *.whois-servers.net
Recursive lookup using Registrar's name
Fallback to InterNIC for non-domains
-m for RADB database
-Q to turn recursion/fallback off

Obtained from: OpenBSD


# 53048 09-Nov-1999 ache

Change default to whois.crsnic.net - new Central Shared Registry for domains
Move InterNIC to -i option


# 50477 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 43520 01-Feb-1999 ache

Add -R for .RU domains


# 43506 01-Feb-1999 wollman

Update the -d flag to use the new .MIL NIC address (from PR 9802)
and add a -g flag to use the new .GOV NIC. Also convert the
SEE ALSO reference into a proper bibliographic one.

PR: 9802 (in part)


# 36913 12-Jun-1998 peter

#include <arpa/inet.h>


# 33626 19-Feb-1998 wollman

Make it more convenient to query NICs other than InterNIC. Explain in the
man page what each database contains.


# 28792 26-Aug-1997 charnier

Use err(3).


# 24360 29-Mar-1997 imp

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# 15359 23-Apr-1996 pst

Add support for SOCKS if enabled.
Remove a useless bind() call (why did that ever get in there?)


# 1591 27-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1590,
which included commits to RCS files with non-trunk default branches.


# 1590 27-May-1994 rgrimes

BSD 4.4 Lite Usr.bin Sources