Commit Graph

74 Commits

Author SHA1 Message Date
Pedro F. Giffuni
8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Warner Losh
fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Tony Finch
3997df0cde More robust handling of whois referrals from RIRs.
An example problem case is 163.1.0.0 (University of Oxford)
which is in an APNIC ERX address range. Previously we assumed
that ARIN has the correct information for all ERX allocations,
but in this case ARIN refers back to APNIC, rather than referring
to RIPE. This caused whois to loop.

Whois will no longer loop back and forth forever between two RIRs
that don't have an answer, but instead try the other RIRs in turn.
2016-11-17 15:19:06 +00:00
Tony Finch
751af43e1c Send whois queries for gov.uk names to JANET. 2016-05-25 13:09:06 +00:00
Conrad Meyer
c24375a7de 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
2016-05-11 18:03:51 +00:00
Conrad Meyer
68c47fcfad 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
2016-05-11 17:52:06 +00:00
Tony Finch
42e88fe650 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.
2016-04-08 11:43:22 +00:00
Tony Finch
8efb5aa133 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".
2016-03-31 12:13:01 +00:00
Tony Finch
f537d420bf 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.
2016-01-23 01:20:58 +00:00
Tony Finch
6f4d88df9f 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.
2016-01-23 00:28:18 +00:00
Tony Finch
de80c945d2 Update whois synopsis and usage with new options 2016-01-22 19:06:43 +00:00
Tony Finch
52517c0a57 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.
2016-01-22 16:43:49 +00:00
Xin LI
9242719ed3 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
2015-08-23 08:22:00 +00:00
Tony Finch
60214b7ff6 whois: add an option to query the PeeringDB 2015-05-14 11:37:36 +00:00
Tony Finch
dfef6b156d whois: alphabetize whois server list 2015-05-14 10:33:51 +00:00
Tony Finch
35859f3a2f 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.
2015-05-14 10:33:33 +00:00
Tony Finch
1326bf51e6 whois: try whois.nic.TLD if TLD.whois-servers.net does not exist
Based on an idea from OpenBSD.
2015-05-14 10:33:01 +00:00
Tony Finch
0279f129c6 whois: check WHOIS_SERVER as well as RA_SERVER environment variables
WHOIS_SERVER is used by Debian's whois client.
2015-05-14 10:32:35 +00:00
Tony Finch
298383b080 whois: code cleanup
Remove deprecated options.

Use pedantically correct types.
2015-05-14 10:32:05 +00:00
Tony Finch
c343f06104 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.
2015-05-14 10:31:37 +00:00
Xin LI
3cddd28ef1 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
2015-04-25 00:51:44 +00:00
Hajimu UMEMOTO
f35f40c51f Introduce $RA_SERVER to set default whois server.
Requested by:	nork
Reviewed by:	nork
MFC after:	1 week
2014-06-25 15:39:08 +00:00
Kevin Lo
372ab06ee7 The whois() function is called in a loop so make sure we close the
socket to the whois server before returning.

Obtained from:	OpenBSD
2014-01-04 15:51:52 +00:00
Ed Schouten
e5ec905575 Mark global functions and/or variables in whois(1) static where possible.
This allows compilers and static analyzers to more thorough analysis.
2011-11-06 18:50:33 +00:00
Joel Dahl
da52b4caaf 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
2010-12-11 08:32:16 +00:00
Edwin Groothuis
04961257f8 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
2010-01-14 10:56:54 +00:00
Edwin Groothuis
3b81fe7712 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
2010-01-14 10:40:54 +00:00
Doug Barton
85f67d6972 The 6bone was decommissioned on 6/6/06, so remove references to it. 2009-10-03 02:37:21 +00:00
Andrey A. Chernov
b79aefd3e9 Use proper type cast for ctype macro 2007-04-14 14:32:48 +00:00
Poul-Henning Kamp
64b4073914 Make DK-HOSTMASTER show contact info for .dk domains.
Submitted by:	Søren Hansen <shan@soeren-hansen.dk>
2007-01-19 08:13:17 +00:00
John Hay
23639a23a8 Add AfriNIC as a RIR.
PR:		80421
Submitted by:	Adrian Frith <adrian at frith.homelinux.org>
MFC after:	6 days
2006-01-23 13:49:39 +00:00
Philippe Charnier
a8cf0aaf75 Reduce compiler warning: variable might be used uninitialized, by giving
an initial value.
2005-05-29 15:49:53 +00:00
Ceri Davies
876b0a88dd 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
2004-12-11 13:14:07 +00:00
Martin Blapp
be460b9467 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
2004-08-25 15:34:44 +00:00
Bruce M Simpson
7714734ac9 Add -b to usage.
Pointed out by:	ceri
Pointy hat to:	bms
2004-06-14 19:29:37 +00:00
Bruce M Simpson
fb6dad913a Add whois.abuse.net to whois(1).
Submitted by:	ceri (with cleanups)
2004-06-14 17:30:46 +00:00
Bruce M Simpson
7138e3fe15 Add whois.iana.org to the whois(1) utility, under the -I option.
PR:		bin/48914
Submitted by:	James Raftery
2004-06-14 14:03:10 +00:00
Andrey A. Chernov
e5637075a3 Back out .SU workaround - people at whois-servers.net set up
su.whois-servers.net
2003-06-29 23:56:31 +00:00
Andrey A. Chernov
1d07f642df While there is no su.whois-servers.net, use fallback to
ru.whois-servers.net for su domain or country
2003-06-24 15:08:24 +00:00
Eivind Eklund
058543317c Add support for identifying NORID (norwegian top level registry) handles.
Reviewed by:	mike (with slight changes based on feedback afterwards)
2003-03-25 17:00:03 +00:00
Mike Barcroft
80473671e8 Fix style bugs in previous commit. 2003-02-24 17:10:32 +00:00
Ollivier Robert
96db12517f 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
2003-01-31 21:57:10 +00:00
Mike Barcroft
a5d96e6d20 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
2002-11-10 16:58:56 +00:00
Mike Barcroft
d0505643e5 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
2002-09-18 07:51:46 +00:00
Mike Barcroft
064692095c Leave the `copyright' variable exposed, since the main purpose of it
is to put a copyright in the object file.

Submitted by:	bde
2002-03-07 10:06:00 +00:00
Kris Kennaway
01d7192418 Mark a function as __printflike()
MFC after:	1 week
2002-02-04 02:12:49 +00:00
Mike Barcroft
f971bd0623 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
2002-02-03 07:35:32 +00:00
Mike Barcroft
3334b16966 Add support for Brazilian IP Addresses. Example `whois 200.236.70.0'.
PR:	30676
2001-12-08 21:22:42 +00:00
Mike Barcroft
d335cbd39f Remove some EOL whitespace. Update usage() to current reality. 2001-10-17 16:28:12 +00:00
Mike Barcroft
42ab40e52d 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
2001-10-12 17:39:36 +00:00