Changeset 2167
- Timestamp:
- 04/08/08 20:57:23 (8 months ago)
- Files:
-
- psad/trunk/whois/Makefile (modified) (6 diffs)
- psad/trunk/whois/README (modified) (1 diff)
- psad/trunk/whois/VERSION (modified) (1 diff)
- psad/trunk/whois/as32_del.h (added)
- psad/trunk/whois/as32_del_list (added)
- psad/trunk/whois/as_del_list (modified) (3 diffs)
- psad/trunk/whois/config.h (modified) (3 diffs)
- psad/trunk/whois/data.h (modified) (5 diffs)
- psad/trunk/whois/debian/changelog (modified) (1 diff)
- psad/trunk/whois/debian/control (modified) (1 diff)
- psad/trunk/whois/debian/copyright (modified) (1 diff)
- psad/trunk/whois/debian/rules (modified) (4 diffs)
- psad/trunk/whois/ip6_del_list (modified) (3 diffs)
- psad/trunk/whois/ip_del_list (modified) (5 diffs)
- psad/trunk/whois/make_as32_del.pl (added)
- psad/trunk/whois/make_ip6_del.pl (modified) (1 diff)
- psad/trunk/whois/make_tld_serv.pl (modified) (1 diff)
- psad/trunk/whois/mkpasswd.1 (modified) (4 diffs)
- psad/trunk/whois/mkpasswd.c (modified) (13 diffs)
- psad/trunk/whois/po/Makefile (modified) (1 diff)
- psad/trunk/whois/po/cs.po (added)
- psad/trunk/whois/po/de.po (modified) (12 diffs)
- psad/trunk/whois/po/el.po (modified) (20 diffs)
- psad/trunk/whois/po/es.po (modified) (12 diffs)
- psad/trunk/whois/po/eu.po (added)
- psad/trunk/whois/po/fr.po (modified) (8 diffs)
- psad/trunk/whois/po/it.po (modified) (11 diffs)
- psad/trunk/whois/po/ja.po (modified) (13 diffs)
- psad/trunk/whois/po/no.po (modified) (9 diffs)
- psad/trunk/whois/po/pl.po (modified) (12 diffs)
- psad/trunk/whois/po/pt_BR.po (added)
- psad/trunk/whois/po/ru.po (modified) (15 diffs)
- psad/trunk/whois/tld_serv_list (modified) (21 diffs)
- psad/trunk/whois/utils.c (added)
- psad/trunk/whois/utils.h (added)
- psad/trunk/whois/whois.1 (modified) (2 diffs)
- psad/trunk/whois/whois.c (modified) (33 diffs)
- psad/trunk/whois/whois.h (modified) (4 diffs)
- psad/trunk/whois/whois.spec (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
psad/trunk/whois/Makefile
r1555 r2167 1 prefix ?= /usr/local1 prefix = /usr/local 2 2 3 3 OPTS := -O2 … … 15 15 ifdef HAVE_LIBIDN 16 16 whois_LDADD += -lidn 17 whois_CFLAGS += -DHAVE_LIBIDN17 CFLAGS += -DHAVE_LIBIDN 18 18 endif 19 19 20 20 ifdef HAVE_XCRYPT 21 21 mkpasswd_LDADD += -lxcrypt 22 mkpasswd_CFLAGS += -DHAVE_XCRYPT22 CFLAGS += -DHAVE_XCRYPT 23 23 else 24 24 mkpasswd_LDADD += -lcrypt … … 27 27 PERL := perl 28 28 29 all: whois#pos29 all: Makefile.depend whois mkpasswd #pos 30 30 31 whois: whois.c whois.h config.h data.h as_del.h ip_del.h ip6_del.h tld_serv.h 32 $(CC) $(CFLAGS) $(whois_CFLAGS) $(OPTS) whois.c -o whois \ 33 $(LDFLAGS) $(whois_LDADD)31 ############################################################################## 32 %.o: %.c 33 $(CC) $(CFLAGS) $(OPTS) -c $< 34 34 35 mkpasswd: mkpasswd.c 36 $(CC) $(CFLAGS) $(mkpasswd_CFLAGS) $(OPTS) mkpasswd.c -o mkpasswd \ 37 $(LDFLAGS) $(mkpasswd_LDADD) 35 whois: whois.o utils.o 36 $(CC) $(LDFLAGS) $(whois_LDADD) -o $@ $^ 38 37 38 mkpasswd: mkpasswd.o utils.o 39 $(CC) $(LDFLAGS) $(mkpasswd_LDADD) -o $@ $^ 40 41 ############################################################################## 39 42 as_del.h: as_del_list make_as_del.pl 40 $(PERL) -w make_as_del.pl < as_del_list > as_del.h 43 $(PERL) -w make_as_del.pl < as_del_list > $@ 44 45 as32_del.h: as32_del_list make_as32_del.pl 46 $(PERL) -w make_as32_del.pl < as32_del_list > $@ 41 47 42 48 ip_del.h: ip_del_list make_ip_del.pl 43 $(PERL) -w make_ip_del.pl < ip_del_list > ip_del.h49 $(PERL) -w make_ip_del.pl < ip_del_list > $@ 44 50 45 51 ip6_del.h: ip6_del_list make_ip6_del.pl 46 $(PERL) -w make_ip6_del.pl < ip6_del_list > ip6_del.h52 $(PERL) -w make_ip6_del.pl < ip6_del_list > $@ 47 53 48 54 tld_serv.h: tld_serv_list make_tld_serv.pl 49 $(PERL) -w make_tld_serv.pl < tld_serv_list > tld_serv.h55 $(PERL) -w make_tld_serv.pl < tld_serv_list > $@ 50 56 57 ############################################################################## 51 58 install: whois 59 install -d $(BASEDIR)$(prefix)/bin/ 60 install -d $(BASEDIR)$(prefix)/share/man/man1/ 52 61 install -m 0755 whois $(BASEDIR)$(prefix)/bin/ 53 62 install -m 0644 whois.1 $(BASEDIR)$(prefix)/share/man/man1/ … … 55 64 56 65 install-mkpasswd: mkpasswd 66 install -d $(BASEDIR)$(prefix)/bin/ 67 install -d $(BASEDIR)$(prefix)/share/man/man1/ 57 68 install -m 0755 mkpasswd $(BASEDIR)$(prefix)/bin/ 58 69 install -m 0644 mkpasswd.1 $(BASEDIR)$(prefix)/share/man/man1/ … … 62 73 63 74 clean: 64 rm -f as_del.h ip_del.h ip6_del.h tld_serv.h whois mkpasswd 75 rm -f Makefile.depend as_del.h ip_del.h ip6_del.h tld_serv.h \ 76 *.o whois mkpasswd 65 77 rm -f po/*.mo 66 78 … … 74 86 cd po && $(MAKE) 75 87 88 depend: Makefile.depend 89 Makefile.depend: 90 $(CC) $(CFLAGS) -MM -MG *.c > $@ 91 92 -include Makefile.depend psad/trunk/whois/README
r631 r2167 26 26 - http://www.iahc.org/dns-refs/registry.html 27 27 - http://www.iana.org/root-whois/xx.htm 28 - http://www.afrinic. org29 - http://www.aftld.org 28 - http://www.afrinic.net/ 29 - http://www.aftld.org/ 30 30 31 31 Marco d'Itri psad/trunk/whois/VERSION
r1555 r2167 1 4.7. 131 4.7.26 psad/trunk/whois/as_del_list
r1555 r2167 4 4 379 508 whois.nic.mil 5 5 1101 1200 ripe 6 1267 1275 ripe 6 7 1877 1901 ripe 7 8 2043 2043 ripe … … 28 29 9943 9982 whois.nic.or.kr 29 30 9990 10021 whois.nic.ad.jp 30 92 6110067 apnic31 9216 10067 apnic 31 32 10034 10073 whois.nic.or.kr 32 33 10154 10198 whois.nic.or.kr … … 59 60 37888 38911 apnic 60 61 38912 39935 ripe 62 40960 45055 ripe 63 45056 46079 apnic 61 64 62 65 # catch all: everything else comes from ARIN 63 1 39935arin66 1 40959 arin 64 67 psad/trunk/whois/config.h
r1555 r2167 1 1 /* Program version */ 2 2 /* not for the inetutils version */ 3 #define VERSION "4.7. 13"3 #define VERSION "4.7.26" 4 4 5 5 /* Configurable features */ … … 40 40 # define HAVE_GETADDRINFO 41 41 # endif 42 # if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 7 43 # define HAVE_SHA_CRYPT 44 # endif 42 45 #endif 43 46 … … 62 65 #endif 63 66 64 #ifdef HAVE_GETOPT_LONG65 # define GETOPT_LONGISH(c, v, o, l, i) getopt_long(c, v, o, l, i)66 #else67 # define GETOPT_LONGISH(c, v, o, l, i) getopt(c, v, o)68 #endif69 70 71 /* NLS stuff */72 #ifdef ENABLE_NLS73 # include <libintl.h>74 # include <locale.h>75 # define _(a) (gettext (a))76 # ifdef gettext_noop77 # define N_(a) gettext_noop (a)78 # else79 # define N_(a) (a)80 # endif81 #else82 # define _(a) (a)83 # define N_(a) a84 #endif85 psad/trunk/whois/data.h
r1555 r2167 11 11 "whois.apnic.net", 12 12 "whois.afrinic.net", 13 "whois.denic.de",14 13 "rr.arin.net", /* does not accept the old syntax */ 15 14 "whois.6bone.net", /* 3.0.0b1 */ 16 15 "whois.connect.com.au", /* 3.0.0b1 */ 17 16 "whois.nic.fr", 18 "whois.nic.it",19 17 "whois.telstra.net", 20 18 "whois.restena.lu", … … 26 24 "whois.nic.ck", 27 25 "whois.ra.net", 28 "whois.radb.net",29 26 NULL 30 27 }; … … 34 31 "TERMS OF USE: You are not", "", /* crsnic */ 35 32 "NOTICE: Access to .ORG WHOIS", "", 36 "NOTICE: Access to .INFO WHOIS", "",37 33 "NOTICE: Access to the .aero", "", 38 34 "This Registry database contains ONLY .EDU", "type: help", /* edu */ … … 61 57 "%% BookMyName Whois", "%% this policy", 62 58 "The .coop registry WHOIS", "VERIFICATION, NOR DO", 63 "Tralliance, Inc., the Registry", "", /* travel */59 "Tralliance, Inc., the Registry", "", /* .travel */ 64 60 "NOTICE: Access to the domains information", "", /* CORE */ 65 61 "%% puntCAT Whois Server", "%% any time.", 62 "Access to INFO WHOIS information is provided", "", /* Afilias */ 63 "Access to CCTLD WHOIS information is provided", "", /* Afilias */ 64 "DotAsia WHOIS LEGAL STATEMENT", "integrity of the database.", 65 "mTLD WHOIS LEGAL STATEMENT", "integrity of the database." /* .mobi */ 66 "Access to RegistryPro's Whois", "All rights", /* .pro */ 66 67 NULL, NULL 67 68 }; … … 121 122 }; 122 123 124 struct as32_del { 125 const unsigned long first; 126 const unsigned long last; 127 const char *serv; 128 }; 129 130 const struct as32_del as32_assign[] = { 131 #include "as32_del.h" 132 { 0, 0, NULL } 133 }; 134 123 135 const char *tld_serv[] = { 124 136 #include "tld_serv.h" psad/trunk/whois/debian/changelog
r1555 r2167 1 whois (4.7.26) unstable; urgency=medium 2 3 * Added support for passing command line options in the environment 4 variables WHOIS_OPTIONS and MKPASSWD_OPTIONS. (Closes: #324858) 5 * Updated the French translation. (Closes: #474307) 6 7 -- Marco d'Itri <md@linux.it> Sat, 05 Apr 2008 04:53:26 +0200 8 9 whois (4.7.25) unstable; urgency=low 10 11 * mkpasswd: added support for the SHA-256 and SHA-512 methods from 12 glibc 2.7. 13 * mkpasswd: added support for FreeBSD-style Blowfish and NT-Hash methods. 14 * mkpasswd: added support for variable-rounds methods (OpenBSD-style 15 Blowfish and SHA-256/SHA-512). 16 * mkpasswd: renamed -H/--hash to -m/--method. 17 * mkpasswd: finished support for libxcrypt (not enabled by default). 18 * Added NONE entries for the rest of .uk SLD. (Closes: #471963) 19 * Added the .bd, .gh, .lc, .sc, .ma, .me, .om and .rs TLD servers. 20 * Updated the .aero, .bb and .bz TLD servers. (Closes: #448683) 21 * Added another RIPE ERX ASN block. (Closes: #452328) 22 * Added a new ASN allocation. 23 * Added Basque and Czech translations. 24 25 -- Marco d'Itri <md@linux.it> Sun, 23 Mar 2008 19:18:34 +0100 26 27 whois (4.7.24) unstable; urgency=medium 28 29 * Added new ASN allocations. 30 * Added new IPv4 allocations. 31 * Added the .asia, .kp and .mq TLD servers. (Closes: #445747) 32 33 -- Marco d'Itri <md@linux.it> Tue, 30 Oct 2007 11:06:25 +0100 34 35 whois (4.7.23) unstable; urgency=medium 36 37 * Fixed myinet_aton to not reject CIDR networks. 38 * Added support for ASN32. 39 * Added the za.net and za.org pseudo-TLD servers. 40 41 -- Marco d'Itri <md@linux.it> Thu, 13 Sep 2007 03:28:21 +0200 42 43 whois (4.7.22) unstable; urgency=medium 44 45 * Added new IPv4 allocations. 46 * Added new ASN allocations. 47 * Updated the Polish translation. 48 * Updated the .jobs, .ai and .tn TLD and za.net servers. 49 * Added the za.net server. (Closes: #423549) 50 * Stop misparsing <as-set>:<hierarchical-name> as an IPv6 address. 51 * Stop mangling IDN queries with in-query flags. (Closes: #422895) 52 53 -- Marco d'Itri <md@linux.it> Sat, 28 Jul 2007 23:53:00 +0200 54 55 whois (4.7.21) unstable; urgency=medium 56 57 * Improved myinet_aton to not parse addresses with trailing junk 58 * Added APNIC and RIPE allocations. 59 * Updated the name of the Verio whois server. (Closes: #410449) 60 * Removed references to whois.nic.mil, which apparently is gone. 61 * Removed whois.nic.it from ripe_servers, because it does not even 62 pretend to be one anymore. 63 64 -- Marco d'Itri <md@linux.it> Mon, 02 Apr 2007 04:23:45 +0200 65 66 whois (4.7.20) unstable; urgency=medium 67 68 * Added more krnic allocations. 69 * Added support for -sixxs NIC handles. 70 * Added again 26[12]0:0000::/23 which had been mistakenly removed. 71 72 -- Marco d'Itri <md@linux.it> Fri, 24 Nov 2006 09:34:01 +0100 73 74 whois (4.7.19) unstable; urgency=medium 75 76 * Added new IPv4 and IPv6 allocations. 77 78 -- Marco d'Itri <md@linux.it> Sun, 22 Oct 2006 09:32:45 +0200 79 80 whois (4.7.18) unstable; urgency=medium 81 82 * whois.radb.net does not understand the RIPE protocol anymore. 83 * Added support for IPv6 Teredo addresses, contributed by Rémi 84 Denis-Courmont. (Closes: #384373) 85 * Updated the .mobi and .gs TLD servers. (Closes: #389880, 391447) 86 * Added the .gd TLD server. 87 88 -- Marco d'Itri <md@linux.it> Fri, 6 Oct 2006 18:47:53 +0200 89 90 whois (4.7.17) unstable; urgency=medium 91 92 * 4.7.16 did not ask whois.denic.de for the complete data. Fixed. 93 94 -- Marco d'Itri <md@linux.it> Tue, 19 Sep 2006 11:24:46 +0200 95 96 whois (4.7.16) unstable; urgency=medium 97 98 * Added new IPv4 and IPv6 allocations. 99 * Strip the CIDR prefix length from queries to whois.arin.net. 100 * whois.denic.de does not understand the RIPE protocol anymore. 101 102 -- Marco d'Itri <md@linux.it> Fri, 15 Sep 2006 00:07:49 +0200 103 104 whois (4.7.15) unstable; urgency=high 105 106 * Fixed the parsing of hostname+port, which was broken by 4.7.14. 107 * Added the .gp, .ni and .tn TLD servers. 108 * Updated the .bh, .bn, .ec, .gy, .im, .kw, .mu, .ph, .pr, .py, .ve and .vu 109 TLD servers. 110 111 -- Marco d'Itri <md@linux.it> Wed, 19 Jul 2006 21:01:32 +0200 112 113 whois (4.7.14) unstable; urgency=medium 114 115 * Added the .coop, .mobi TLD and e164.arpa servers. 116 * Added new ASN allocations. (Closes: #377953) 117 * Added support for resolution of IDN server hostnames using AI_IDN. 118 * Fixed the parsing of IPv6 server addresses on the command line. 119 * Use the official "nicname" service name instead of "whois". 120 * Added whois.pot to the source package. 121 * Fixed a typo in the german translation. (Closes: #363550) 122 * Do not FTBFS on binNMUs. (Closes: #360741) 123 124 -- Marco d'Itri <md@linux.it> Sat, 15 Jul 2006 19:22:42 +0200 125 1 126 whois (4.7.13) unstable; urgency=medium 2 127 psad/trunk/whois/debian/control
r1555 r2167 3 3 Priority: standard 4 4 Maintainer: Marco d'Itri <md@linux.it> 5 Standards-Version: 3. 6.2.15 Standards-Version: 3.7.3 6 6 Build-Depends: debhelper (>= 4), gettext, libidn11-dev 7 7 psad/trunk/whois/debian/copyright
r631 r2167 2 2 Sun Oct 3 19:46:30 CEST 1999. 3 3 4 It was written by Marco d'Itri.4 Copyright 1999-2008 by Marco d'Itri <md@linux.it>. 5 5 6 Copyright: GPL (please see /usr/share/common-licenses/GPL-2).6 License: GPL (please see /usr/share/common-licenses/GPL-2). 7 7 psad/trunk/whois/debian/rules
r1555 r2167 6 6 D := $(shell pwd)/debian/whois 7 7 8 VERSION := $(shell dpkg-parsechangelog | sed -n ' /^Version/s/.* //p')8 VERSION := $(shell dpkg-parsechangelog | sed -n 's/\+.*$$//; /^Version/s/.* //p') 9 9 10 10 build: 11 11 dh_testdir 12 make whois mkpasswd\12 $(MAKE) \ 13 13 OPTS="-O2 -g -DCONFIG_FILE=\\\"/etc/whois.conf\\\"" \ 14 14 HAVE_LIBIDN=1 15 cd po && $(MAKE) whois.pot 15 16 touch $@ 16 17 … … 18 19 dh_testdir 19 20 -rm -f build 20 -makedistclean21 $(MAKE) distclean 21 22 dh_clean 22 23 … … 30 31 dh_installdirs usr/bin 31 32 install whois mkpasswd $D/usr/bin/ 32 cd po && makeinstall BASEDIR=$D33 cd po && $(MAKE) install BASEDIR=$D 33 34 dh_installman whois.1 mkpasswd.1 34 35 dh_installdocs README … … 44 45 binary: binary-arch 45 46 47 binary-indep: 48 46 49 checkroot: 47 50 test root = "`whoami`" psad/trunk/whois/ip6_del_list
r1560 r2167 3 3 # addresses. It does not deal with networks == 0 or > 24 bit. 4 4 5 2001:0000::/32 teredo 5 6 2001:0200::/23 apnic 6 7 2001:0400::/23 arin … … 17 18 2001:2000::/19 ripe 18 19 2001:4000::/23 ripe 19 2001:4200::/23 a rin20 2001:4200::/23 afrinic 20 21 2001:4400::/23 apnic 21 22 2001:4600::/23 ripe … … 34 35 2003:0000::/18 ripe 35 36 36 2400:0000::/18 apnic 37 2404:0000::/23 apnic 38 37 2400:0000::/20 whois.nic.or.kr 38 2400:0000::/12 apnic 39 39 2600:0000::/12 arin 40 #2600:0000::/22 arin41 #2604:0000::/22 arin42 #2608:0000::/22 arin43 #260C:0000::/22 arin44 40 2610:0000::/23 arin 45 46 2800:0000::/23 lacnic 47 48 2A00:0000::/21 ripe 49 2A01:0000::/16 ripe 41 2620:0000::/23 arin 42 2800:0000::/12 lacnic 43 2A00:0000::/12 ripe 44 2C00:0000::/12 afrinic 50 45 51 46 3FFE:0000::/16 6bone psad/trunk/whois/ip_del_list
r1555 r2167 10 10 41.0.0.0/8 afrinic 11 11 43.0.0.0/8 v6nic 12 # whois -r -K -h whois.apnic.net -i admin-c IM76-AP 13 59.0.0.0/11 whois.nic.or.kr 12 14 58.0.0.0/7 apnic 13 15 61.72.0.0/13 whois.nic.or.kr … … 19 21 60.0.0.0/7 apnic 20 22 62.0.0.0/8 ripe 21 80.0.0.0/5 ripe # => 87.255.255.255 22 88.0.0.0/6 ripe # => 91.255.255.254 23 121.0.0.0/8 apnic 24 122.0.0.0/7 apnic 23 77.0.0.0/8 ripe 24 78.0.0.0/7 ripe 25 80.0.0.0/4 ripe # => 95.255.255.255 26 96.0.0.0/6 arin 27 114.0.0.0/7 apnic 28 116.0.0.0/6 apnic 29 121.128.0.0/10 whois.nic.or.kr 30 125.128.0.0/11 whois.nic.or.kr 31 120.0.0.0/6 apnic 25 32 124.0.0.0/7 apnic 26 33 126.0.0.0/8 apnic 27 34 96.0.0.0/3 UNALLOCATED # => 127.215.255.255 28 0.0.0.0/1 arin # all other A class es are managed by ARIN35 0.0.0.0/1 arin # all other A class addresses are managed by ARIN 29 36 133.0.0.0/8 whois.nic.ad.jp 30 37 139.20.0.0/14 ripe … … 77 84 171.16.0.0/12 ripe 78 85 171.32.0.0/15 ripe 79 # 173 -> 187 reserved 86 # 173 -> 185 reserved 87 186.0.0.0/7 lacnic 80 88 188.0.0.0/8 ripe # transferred from ARIN to to RIPE 81 89 189.0.0.0/8 lacnic … … 132 140 203.224.0.0/11 whois.nic.or.kr # => 203.255.255.255 133 141 202.0.0.0/7 apnic 134 204.0.0.0/14 verio# rwhois too142 204.0.0.0/14 rwhois.gin.ntt.net # rwhois too 135 143 204.0.0.0/6 arin 136 144 208.0.0.0/7 arin … … 183 191 218.40.0.0/13 whois.nic.ad.jp 184 192 218.48.0.0/13 whois.nic.or.kr 193 219.96.0.0/11 whois.nic.ad.jp 185 194 218.144.0.0/12 whois.nic.or.kr 186 195 218.160.0.0/12 twnic psad/trunk/whois/make_ip6_del.pl
r1560 r2167 27 27 } elsif ($s eq '6to4') { 28 28 print "\\x0A"; 29 } elsif ($s eq 'teredo') { 30 print "\\x0B"; 29 31 } elsif ($s eq 'UNALLOCATED') { 30 32 print "\\006"; psad/trunk/whois/make_tld_serv.pl
r767 r2167 15 15 $b = "\\x04" if $b eq 'CRSNIC'; 16 16 $b = "\\x07" if $b eq 'PIR'; 17 $b = "\\x08" if $b eq 'AFILIAS'; 17 18 $b = "\\x09" if $b eq 'NICCC'; 18 19 print " \"$a\",\t\"$b\",\n"; psad/trunk/whois/mkpasswd.1
r1246 r2167 1 .TH MKPASSWD 1 " 11 October 2002" "Marco d'Itri" "Debian GNU/Linux"1 .TH MKPASSWD 1 "21 March 2008" "Marco d'Itri" "Debian GNU/Linux" 2 2 .SH NAME 3 3 mkpasswd \- Overfeatured front end to crypt(3) … … 17 17 Use the \fISTRING\fP as salt. It must not contain prefixes such as \fI$1$\fP. 18 18 .TP 19 .B -H, --hash=TYPE 20 Compute the password using the \fITYPE\fP algorithm. 21 If \fITYPE\fP is \fIhelp\fP available algorithms are printed. 19 .B -R, --rounds=NUMBER 20 Use \fINUMBER\fP rounds. This argument is ignored if the method choosen 21 does not support variable rounds. For the OpenBSD Blowfish method this is 22 the logarithm of the number of rounds. 23 .TP 24 .B -m, --method=TYPE 25 Compute the password using the \fITYPE\fP method. 26 If \fITYPE\fP is \fIhelp\fP then the available methods are printed. 22 27 .TP 23 28 .B -P, --password-fd=NUM … … 29 34 .B -s, --stdin 30 35 Like \fI--password-fd=0\fP. 36 .SH "ENVIRONMENT" 37 .IP "MKPASSWD_OPTIONS" 38 A list of options which will be evalued before the ones specified on the 39 command line. 31 40 .SH BUGS 32 41 If the \fI--stdin\fP option is used, passwords containing some control … … 41 50 .SH AUTHOR 42 51 .B mkpasswd 43 and this man page were written by Marco d'Itri <md@linux.it> 44 and are licensed under the terms of the GNU GPL. 52 and this man page were written by Marco d'Itri <\fImd@linux.it\fP> 53 and are licensed under the terms of the GNU General Public License, 54 version 2 or higher. 45 55 psad/trunk/whois/mkpasswd.c
r1555 r2167 1 1 /* 2 * Copyright (C) 2001-2002Marco d'Itri2 * Copyright (C) 2001-2008 Marco d'Itri 3 3 * 4 * This program is free software; you can redistribute it and/or modify5 * it under the terms of the GNU General Public License as published by6 * the Free Software Foundation; either version 2 of the License, or7 * (at your option) any later version.4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 8 * 9 * This program is distributed in the hope that it will be useful,10 * but WITHOUT ANY WARRANTY; without even the implied warranty of11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12 * GNU General Public License for more details.9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 13 * 14 * You should have received a copy of the GNU General Public License15 * along with this program; if not, write to the Free Software16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 */ 18 18 19 /* for crypt, snprintf and strcasecmp */ 19 20 #define _XOPEN_SOURCE 20 21 #define _BSD_SOURCE 22 23 /* System library */ 21 24 #include <stdio.h> 22 25 #include <stdlib.h> … … 29 32 #include <time.h> 30 33 #include <sys/types.h> 31 34 /*#define HAVE_XCRYPT 0*/ 35 #ifdef HAVE_XCRYPT 36 #include <xcrypt.h> 37 #include <sys/stat.h> 38 #include <fcntl.h> 39 #endif 40 41 /* Application-specific */ 42 #include "utils.h" 43 44 /* Global variables */ 32 45 #ifdef HAVE_GETOPT_LONG 33 static struct option longopts[] = { 46 static const struct option longopts[] = { 47 {"method", optional_argument, NULL, 'm'}, 48 /* for backward compatibility with versions < 4.7.25 (< 20080321): */ 34 49 {"hash", optional_argument, NULL, 'H'}, 35 50 {"help", no_argument, NULL, 'h'}, … … 37 52 {"stdin", no_argument, NULL, 's'}, 38 53 {"salt", required_argument, NULL, 'S'}, 54 {"rounds", required_argument, NULL, 'R'}, 39 55 {"version", no_argument, NULL, 'V'}, 40 56 {NULL, 0, NULL, 0 } … … 42 58 #endif 43 59 44 static c har valid_salts[] = "abcdefghijklmnopqrstuvwxyz"60 static const char valid_salts[] = "abcdefghijklmnopqrstuvwxyz" 45 61 "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./"; 46 62 47 struct salt_prefix { 48 const char *algo; /* short name used by the command line option */ 49 const char *prefix; /* salt prefix */ 50 unsigned int len; /* salt lenght */ 51 const char *desc; /* long description for the algorithms list */ 63 struct crypt_method { 64 const char *method; /* short name used by the command line option */ 65 const char *prefix; /* salt prefix */ 66 const unsigned int len; /* salt lenght */ 67 const unsigned int rounds; /* supports a variable number of rounds */ 68 const char *desc; /* long description for the methods list */ 52 69 }; 53 70 54 struct salt_prefix salt_prefixes[] = { 55 { "des", "", 2, N_("\tstandard 56 bit DES-based crypt(3)") }, 56 { "md5", "$1$", 8, "\tMD5" }, 57 /* untested! is the salt correctly generated? */ 58 #if defined OpenBSD || defined FreeBSD 59 { "blf", "$2$", 16, "\tBlowfish" }, 60 #endif 61 /* untested too, and does not even compile */ 71 static const struct crypt_method methods[] = { 72 /* method prefix len rounds description */ 73 { "des", "", 2, 0, 74 N_("standard 56 bit DES-based crypt(3)") }, 75 { "md5", "$1$", 8, 0, "MD5" }, 76 #if defined FreeBSD 77 { "bf", "$2$", 22, 0, "Blowfish (FreeBSD)" }, 78 #endif 79 #if defined OpenBSD || defined HAVE_XCRYPT 80 { "bf", "$2a$", 22, 1, "Blowfish" }, 81 #endif 82 #if defined FreeBSD 83 { "nt", "$3$", 0, 0, "NT-Hash" }, 84 #endif 85 #if defined HAVE_SHA_CRYPT 86 /* http://people.redhat.com/drepper/SHA-crypt.txt */ 87 { "sha-256", "$5$", 16, 1, "SHA-256" }, 88 { "sha-512", "$6$", 16, 1, "SHA-512" }, 89 #endif 90 /* http://www.crypticide.com/dropsafe/article/1389 */ 91 /* proper support is hard since solaris >= 9 supports pluggable methods 92 #if defined __SVR4 && defined __sun 93 { "sunmd5", "$md5$", ?, 1, "SunMD5" }, 94 */ 62 95 #if defined HAVE_XCRYPT 63 { "blf", "$2a$", 16, "\tBlowfish" }, 64 { "sha", "{SHA}", , "\tSHA-1" }, 65 #endif 66 { NULL, NULL, 0, NULL } 96 { "sha", "{SHA}", 0, 0, "SHA-1" }, 97 #endif 98 { NULL, NULL, 0, 0, NULL } 67 99 }; 68 100 69 void generate_salt(char *buf, const unsigned int len); 101 void generate_salt(char *const buf, const unsigned int len); 102 void *gather_entropy(const int len); 70 103 void display_help(void); 71 104 void display_version(void); 72 void display_ algorithms(void);105 void display_methods(void); 73 106 74 107 int main(int argc, char *argv[]) 75 108 { 76 int ch ;109 int ch, i; 77 110 int password_fd = -1; 78 unsigned int i, salt_len = 0; 111 unsigned int salt_len = 0; 112 unsigned int rounds_support = 0; 79 113 const char *salt_prefix = NULL; 114 const char *salt_arg = NULL; 115 unsigned int rounds = 0; 80 116 char *salt = NULL; 117 char rounds_str[30]; 81 118 char *password = NULL; 82 119 … … 87 124 #endif 88 125 89 while ((ch = GETOPT_LONGISH(argc, argv, "hH:P:sS:V", longopts, 0)) > 0) { 126 /* prepend options from environment */ 127 argv = merge_args(getenv("MKPASSWD_OPTIONS"), argv, &argc); 128 129 while ((ch = GETOPT_LONGISH(argc, argv, "hH:m:P:R:sSV", longopts, 0)) > 0) { 90 130 switch (ch) { 131 case 'm': 91 132 case 'H': 92 if (!optarg || strcase cmp("help", optarg) == 0) {93 display_ algorithms();133 if (!optarg || strcaseeq("help", optarg)) { 134 display_methods(); 94 135 exit(0); 95 136 } 96 for (i = 0; salt_prefixes[i].algo != NULL; i++) 97 if (strcasecmp(salt_prefixes[i].algo, optarg) == 0) { 98 salt_prefix = salt_prefixes[i].prefix; 99 salt_len = salt_prefixes[i].len; 137 for (i = 0; methods[i].method != NULL; i++) 138 if (strcaseeq(methods[i].method, optarg)) { 139 salt_prefix = methods[i].prefix; 140 salt_len = methods[i].len; 141 rounds_support = methods[i].rounds; 100 142 break; 101 143 } 102 144 if (!salt_prefix) { 103 fprintf(stderr, _("Invalid hash type'%s'.\n"), optarg);145 fprintf(stderr, _("Invalid method '%s'.\n"), optarg); 104 146 exit(1); 105 147 } … … 115 157 } 116 158 break; 159 case 'R': 160 { 161 char *p; 162 rounds = strtol(optarg, &p, 10); 163 if (p == NULL || *p != '\0' || rounds < 0) { 164 fprintf(stderr, _("Invalid number '%s'.\n"), optarg); 165 exit(1); 166 } 167 } 168 break; 117 169 case 's': 118 170 password_fd = 0; 119 171 break; 120 172 case 'S': 121 salt = optarg;173 salt_arg = optarg; 122 174 break; 123 175 case 'V': … … 136 188 argv += optind; 137 189 138 if (argc == 2 && !salt ) {190 if (argc == 2 && !salt_arg) { 139 191 password = argv[0]; 140 salt = argv[1];192 salt_arg = argv[1]; 141 193 } else if (argc == 1) { 142 194 password = argv[0]; … … 148 200 149 201 /* default: DES password */ 150 if (!salt_len) { 151 salt_len = salt_prefixes[0].len; 152 salt_prefix = salt_prefixes[0].prefix; 153 } 154 155 if (salt) { 156 unsigned int c = strlen(salt); 202 if (!salt_prefix) { 203 salt_len = methods[0].len; 204 salt_prefix = methods[0].prefix; 205 } 206 207 if (streq(salt_prefix, "$2a$")) { /* OpenBSD Blowfish */ 208 if (rounds <= 4) 209 rounds = 4; 210 /* actually for 2a it is the logarithm of the number of rounds */ 211 snprintf(rounds_str, sizeof(rounds_str), "%02u$", rounds); 212 } else if (rounds_support && rounds) 213 snprintf(rounds_str, sizeof(rounds_str), "rounds=%u$", rounds); 214 else 215 rounds_str[0] = '\0'; 216 217 if (salt_arg) { 218 unsigned int c = strlen(salt_arg); 219 /* XXX: should support methods which support variable-length salts */ 157 220 if (c != salt_len) { 158 221 fprintf(stderr, … … 161 224 exit(1); 162 225 } 163 while (c-- > 0) 164 if (strchr(valid_salts, salt[c]) == NULL) { 165 fprintf(stderr, _("Illegal salt character '%c'.\n"), salt[c]); 226 while (c-- > 0) { 227 if (strchr(valid_salts, salt_arg[c]) == NULL) { 228 fprintf(stderr, _("Illegal salt character '%c'.\n"), 229 salt_arg[c]); 166 230 exit(1); 167 231 } 232 } 233 234 salt = NOFAIL(malloc(strlen(salt_prefix) + strlen(rounds_str) 235 + strlen(salt_arg) + 1)); 236 *salt = '\0'; 237 strcat(salt, salt_prefix); 238 strcat(salt, rounds_str); 239 strcat(salt, salt_arg); 168 240 } else { 169 241 #ifdef HAVE_XCRYPT 170 char *entropy = gather_entropy(4096); 171 salt = crypt_gensalt(salt_prefix, 0, entropy, 4096); 242 void *entropy = gather_entropy(64); 243 244 salt = crypt_gensalt(salt_prefix, rounds, entropy, 64); 172 245 if (!salt) { 173 perror("crypt");246 fprintf(stderr, "crypt_gensalt failed.\n"); 174 247 exit(2); 175 248 } 176 249 free(entropy); 177 250 #else 178 salt = malloc(salt_len + 1); 179 generate_salt(salt, salt_len); 180 #endif 181 } 182 183 if (!password) { 184 if (password_fd != -1) { 185 FILE *fp; 186 unsigned char *p; 187 188 if (isatty(password_fd)) 189 fprintf(stderr, _("Password: ")); 190 password = malloc(128); 191 fp = fdopen(password_fd, "r"); 192 if (!fp) { 193 perror("fdopen"); 194 exit(2); 195 } 196 if (!fgets(password, 128, fp)) { 197 perror("fgets"); 198 exit(2); 199 } 200 201 p = (unsigned char *)password; 202 while (*p) { 203 if (*p == '\n') { 204 *p = '\0'; 205 break; 206 } 207 /* which characters are valid? */ 208 if (*p > 0x7f) { 209 fprintf(stderr, 210 _("Illegal password character '0x%hhx'.\n"), *p); 211 exit(1); 212 } 213 p++; 214 } 215 } else { 216 password = getpass(_("Password: ")); 217 if (!password) { 218 perror("getpass"); 219 exit(2); 220 } 251 salt = NOFAIL(malloc(strlen(salt_prefix) + strlen(rounds_str) 252 + salt_len + 1)); 253 *salt = '\0'; 254 strcat(salt, salt_prefix); 255 strcat(salt, rounds_str); 256 generate_salt(salt + strlen(salt), salt_len); 257 #endif 258 } 259 260 if (password) { 261 } else if (password_fd != -1) { 262 FILE *fp; 263 unsigned char *p; 264 265 if (isatty(password_fd)) 266 fprintf(stderr, _("Password: ")); 267 &nb
