diff options
author | Marco d'Itri <md@linux.it> | 2009-03-01 19:39:42 +0100 |
---|---|---|
committer | Marco d'Itri <md@linux.it> | 2013-03-30 02:31:37 +0100 |
commit | 95229c98ad35c7038bdc1fb7002fa2e5e016741e (patch) | |
tree | 23750febef50600bc3943ec2ecc1df9727cf6d6f | |
parent | bd702922f8ffa8f135896fa3807aa06ee7a11428 (diff) | |
download | whois-95229c98ad35c7038bdc1fb7002fa2e5e016741e.tar.gz |
Imported Debian version 4.7.31v4.7.31
-rw-r--r-- | as_del_list | 1 | ||||
-rw-r--r-- | config.h | 2 | ||||
-rw-r--r-- | debian/changelog | 11 | ||||
-rw-r--r-- | ip_del_list | 9 | ||||
-rwxr-xr-x | make_tld_serv.pl | 1 | ||||
-rw-r--r-- | po/de.po | 2 | ||||
-rw-r--r-- | tld_serv_list | 3 | ||||
-rw-r--r-- | utils.h | 4 | ||||
-rw-r--r-- | whois.c | 140 | ||||
-rw-r--r-- | whois.h | 2 | ||||
-rw-r--r-- | whois.spec | 2 |
11 files changed, 155 insertions, 22 deletions
diff --git a/as_del_list b/as_del_list index 347207f..db0ed60 100644 --- a/as_del_list +++ b/as_del_list @@ -1,5 +1,6 @@ # http://www.iana.org/assignments/as-numbers +248 251 ripe 306 371 whois.nic.mil 379 508 whois.nic.mil 1101 1200 ripe @@ -1,5 +1,5 @@ /* Program version */ -#define VERSION "4.7.30" +#define VERSION "4.7.31" /* Configurable features */ diff --git a/debian/changelog b/debian/changelog index 9115ce9..6b15e2a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,14 @@ +whois (4.7.31) unstable; urgency=low + + * Implemented a 10 seconds timeout on connect(2) to allow querying + servers with broken IPv6 connectivity. (Closes: #408096) + * Added support for automatically determining the server for in-addr.arpa + domains. + * Added new IPv4 allocations. + * Fixed a typo in de.po. (Closes: #514619) + + -- Marco d'Itri <md@linux.it> Sun, 01 Mar 2009 19:39:42 +0100 + whois (4.7.30) unstable; urgency=high * Updated the .gi, .lc and .mn TLD servers. diff --git a/ip_del_list b/ip_del_list index 4e531b6..7c7392d 100644 --- a/ip_del_list +++ b/ip_del_list @@ -24,14 +24,20 @@ 78.0.0.0/7 ripe 80.0.0.0/4 ripe # => 95.255.255.255 96.0.0.0/6 arin # => 99.255.255.255 +108.0.0.0/8 arin +109.0.0.0/8 ripe 110.0.0.0/7 apnic +96.0.0.0/4 UNALLOCATED # => 112.215.255.255 +118.32.0.0/11 whois.nic.or.kr +119.192.0.0/11 whois.nic.or.kr +115.0.0.0/12 whois.nic.or.kr +115.16.0.0/13 whois.nic.or.kr 112.0.0.0/5 apnic 121.128.0.0/10 whois.nic.or.kr 125.128.0.0/11 whois.nic.or.kr 120.0.0.0/6 apnic 124.0.0.0/7 apnic 126.0.0.0/8 apnic -96.0.0.0/3 UNALLOCATED # => 127.215.255.255 0.0.0.0/1 arin # all other A class addresses are managed by ARIN 133.0.0.0/8 whois.nic.ad.jp 139.20.0.0/14 ripe @@ -83,6 +89,7 @@ 169.208.0.0/12 apnic 171.16.0.0/12 ripe 171.32.0.0/15 ripe +178.0.0.0/8 ripe # 175 -> 185 reserved 186.0.0.0/7 lacnic 188.0.0.0/8 ripe # transferred from ARIN to to RIPE diff --git a/make_tld_serv.pl b/make_tld_serv.pl index 6d72e63..b9ad913 100755 --- a/make_tld_serv.pl +++ b/make_tld_serv.pl @@ -16,6 +16,7 @@ while (<>) { $b = "\\x07" if $b eq 'PIR'; $b = "\\x08" if $b eq 'AFILIAS'; $b = "\\x09" if $b eq 'NICCC'; + $b = "\\x0C" if $b eq 'ARPA'; print " \"$a\",\t\"$b\",\n"; } @@ -250,7 +250,7 @@ msgid "" "\n" msgstr "" "Aufruf: mkpasswd [OPTIONEN] ... [PASSWORT] [SALT]]\n" -"Verschluesselt das PASWORT mit crypt(3).\n" +"Verschluesselt das PASSWORT mit crypt(3).\n" "\n" #: ../mkpasswd.c:366 diff --git a/tld_serv_list b/tld_serv_list index ad304ec..1819e12 100644 --- a/tld_serv_list +++ b/tld_serv_list @@ -35,7 +35,8 @@ .int whois.iana.org .mil NONE -.e164.arpa whois.ripe.net +.e164.arpa whois.ripe.net +.in-addr.arpa ARPA .arpa whois.iana.org .aero whois.aero @@ -20,6 +20,10 @@ # define AI_IDN 0 #endif +#ifndef AI_ADDRCONFIG +# define AI_ADDRCONFIG 0 +#endif + #ifdef HAVE_GETOPT_LONG # define GETOPT_LONGISH(c, v, o, l, i) getopt_long(c, v, o, l, i) #else @@ -1,8 +1,10 @@ -/* Copyright 1999-2008 by Marco d'Itri <md@linux.it>. +/* + * Copyright 1999-2009 by Marco d'Itri <md@linux.it>. * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. */ /* for AI_IDN */ @@ -21,6 +23,7 @@ #include <netinet/in.h> #include <netdb.h> #include <errno.h> +#include <fcntl.h> #include <signal.h> #ifdef HAVE_GETOPT_LONG #include <getopt.h> @@ -258,6 +261,10 @@ const char *handle_query(const char *hserver, const char *hport, server = whichwhois(p); qstring = p ; break; + case 0x0C: + p = convert_inaddr(qstring); + server = whichwhois(p); + break; default: break; } @@ -327,7 +334,7 @@ const char *match_config_file(const char *s) err_quit(_("Cannot parse this line: %s"), p); #ifdef HAVE_REGEXEC - i = regcomp(&re, pattern, REG_EXTENDED|REG_ICASE|REG_NOSUB); + i = regcomp(&re, pattern, REG_EXTENDED | REG_ICASE | REG_NOSUB); if (i != 0) { char m[1024]; regerror(i, &re, m, sizeof(m)); @@ -761,6 +768,7 @@ const char *query_afilias(const int sock, const char *query) int openconn(const char *server, const char *port) { int fd = -1; + int timeout = 10; #ifdef HAVE_GETADDRINFO int err; struct addrinfo hints, *res, *ai; @@ -776,14 +784,24 @@ int openconn(const char *server, const char *port) memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_IDN; + hints.ai_flags = AI_ADDRCONFIG | AI_IDN; + + if ((err = getaddrinfo(server, port ? port : "nicname", &hints, &res)) + != 0) { + if (err == EAI_SYSTEM) + err_sys("getaddrinfo(%s)", server); + else + err_quit("getaddrinfo(%s): %s", server, gai_strerror(err)); + } - if ((err = getaddrinfo(server, port ? port : "nicname", &hints, &res)) != 0) - err_quit("getaddrinfo(%s): %s", server, gai_strerror(err)); for (ai = res; ai; ai = ai->ai_next) { + /* no timeout for the last address. is this a good idea? */ + if (!ai->ai_next) + timeout = 0; if ((fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) < 0) continue; /* ignore */ - if (connect(fd, (struct sockaddr *)ai->ai_addr, ai->ai_addrlen) == 0) + if (connect_with_timeout(fd, (struct sockaddr *)ai->ai_addr, + ai->ai_addrlen, timeout) == 0) break; /* success */ close(fd); } @@ -806,21 +824,75 @@ int openconn(const char *server, const char *port) err_quit(_("%s/tcp: unknown service"), port); saddr.sin_port = servinfo->s_port; } - if (connect(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) + if (connect_with_timeout(fd, (struct sockaddr *)&saddr, sizeof(saddr), + timeout) < 0) err_sys("connect"); #endif - /* - * Now we are connected and the query is supposed to complete quickly. - * This will help people who run whois ... | less - */ - /* Disabled, because in the real world this is not true. :-( - alarm(0); - */ - return fd; } +int connect_with_timeout(int fd, const struct sockaddr *addr, + socklen_t addrlen, int timeout) +{ + int savedflags, rc, connect_errno, opt; + fd_set fd_w; + struct timeval tv; + size_t len; + + if (timeout <= 0) + return (connect(fd, addr, addrlen)); + + if ((savedflags = fcntl(fd, F_GETFL, 0)) < 0) + return -1; + + /* set the socket non-blocking, so connect(2) will return immediately */ + if (fcntl(fd, F_SETFL, savedflags | O_NONBLOCK) < 0) + return -1; + + rc = connect(fd, addr, addrlen); + + /* set the socket to block again */ + connect_errno = errno; + if (fcntl(fd, F_SETFL, savedflags) < 0) + return -1; + errno = connect_errno; + + if (rc == 0 || errno != EINPROGRESS) + return rc; + + FD_ZERO(&fd_w); + FD_SET(fd, &fd_w); + tv.tv_sec = timeout; + tv.tv_usec = 0; + + /* loop until an error or the timeout has expired */ + do { + rc = select(fd + 1, NULL, &fd_w, NULL, &tv); + } while (rc == -1 && errno == EINTR); + + if (rc == 0) { /* timed out */ + errno = ETIMEDOUT; + return -1; + } + + if (rc < 0 || rc > 1) /* select failed */ + return rc; + + /* rc == 1: success. check for errors */ + len = sizeof(opt); + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &opt, &len) < 0) + return -1; + + /* and report them */ + if (opt != 0) { + errno = (int) &opt; + return -1; + } + + return 0; +} + void alarm_handler(int signum) { close(sockfd); @@ -961,6 +1033,40 @@ char *convert_teredo(const char *s) return new; } +char *convert_inaddr(const char *s) +{ + char *new = malloc(sizeof("255.255.255.255")); + char *endptr; + unsigned int a, b, c; + + errno = 0; + + a = strtol(s, &endptr, 10); + if (errno || a < 0 || a > 255 || *endptr != '.') + return (char *) "0.0.0.0"; + + if (domcmp(endptr + 1, ".in-addr.arpa")) { + b = strtol(endptr + 1, &endptr, 10); /* 1.2. */ + if (errno || b < 0 || b > 255 || *endptr != '.') + return (char *) "0.0.0.0"; + + if (domcmp(endptr + 1, ".in-addr.arpa")) { + c = strtol(endptr + 1, &endptr, 10); /* 1.2.3. */ + if (errno || c < 0 || c > 255 || *endptr != '.') + return (char *) "0.0.0.0"; + + if (domcmp(endptr + 1, ".in-addr.arpa")) + return (char *) "0.0.0.0"; + + sprintf(new, "%d.%d.%d.0", c, b, a); + } else + sprintf(new, "%d.%d.0.0", b, a); + } else + sprintf(new, "%d.0.0.0", a); + + return new; +} + unsigned long myinet_aton(const char *s) { unsigned long a, b, c, d; @@ -20,6 +20,7 @@ const char *query_crsnic(const int, const char *); const char *query_pir(const int, const char *); const char *query_afilias(const int, const char *); int openconn(const char *, const char *); +int connect_with_timeout(int, const struct sockaddr *, socklen_t, int); void usage(void); void alarm_handler(int); void sighandler(int); @@ -31,6 +32,7 @@ int domfind(const char *, const char *[]); char *normalize_domain(const char *); char *convert_6to4(const char *); char *convert_teredo(const char *); +char *convert_inaddr(const char *); const char *handle_query(const char *server, const char *port, const char *qstring, const char *fstring); void split_server_port(const char *const input, const char **server, @@ -1,6 +1,6 @@ Summary: Enhanced WHOIS client Name: whois -Version: 4.7.30 +Version: 4.7.31 Release: 1 License: GPL Vendor: Marco d'Itri <md@linux.it> |