Changeset 2167

Show
Ignore:
Timestamp:
04/08/08 20:57:23 (8 months ago)
Author:
mbr
Message:

updated to version 4.7.26

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • psad/trunk/whois/Makefile

    r1555 r2167  
    1 prefix ?= /usr/local 
     1prefix = /usr/local 
    22 
    33OPTS := -O2 
     
    1515ifdef HAVE_LIBIDN 
    1616whois_LDADD += -lidn 
    17 whois_CFLAGS += -DHAVE_LIBIDN 
     17CFLAGS += -DHAVE_LIBIDN 
    1818endif 
    1919 
    2020ifdef HAVE_XCRYPT 
    2121mkpasswd_LDADD += -lxcrypt 
    22 mkpasswd_CFLAGS += -DHAVE_XCRYPT 
     22CFLAGS += -DHAVE_XCRYPT 
    2323else 
    2424mkpasswd_LDADD += -lcrypt 
     
    2727PERL := perl 
    2828 
    29 all: whois #pos 
     29all: Makefile.depend whois mkpasswd #pos 
    3030 
    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 $< 
    3434 
    35 mkpasswd: mkpasswd.c 
    36         $(CC) $(CFLAGS) $(mkpasswd_CFLAGS) $(OPTS) mkpasswd.c -o mkpasswd \ 
    37                 $(LDFLAGS) $(mkpasswd_LDADD) 
     35whois: whois.o utils.o 
     36        $(CC) $(LDFLAGS) $(whois_LDADD) -o $@ $^ 
    3837 
     38mkpasswd: mkpasswd.o utils.o 
     39        $(CC) $(LDFLAGS) $(mkpasswd_LDADD) -o $@ $^ 
     40 
     41############################################################################## 
    3942as_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 
     45as32_del.h: as32_del_list make_as32_del.pl 
     46        $(PERL) -w make_as32_del.pl < as32_del_list > $@ 
    4147 
    4248ip_del.h: ip_del_list make_ip_del.pl 
    43         $(PERL) -w make_ip_del.pl < ip_del_list > ip_del.h 
     49        $(PERL) -w make_ip_del.pl < ip_del_list > $@ 
    4450 
    4551ip6_del.h: ip6_del_list make_ip6_del.pl 
    46         $(PERL) -w make_ip6_del.pl < ip6_del_list > ip6_del.h 
     52        $(PERL) -w make_ip6_del.pl < ip6_del_list > $@ 
    4753 
    4854tld_serv.h: tld_serv_list make_tld_serv.pl 
    49         $(PERL) -w make_tld_serv.pl < tld_serv_list > tld_serv.h 
     55        $(PERL) -w make_tld_serv.pl < tld_serv_list > $@ 
    5056 
     57############################################################################## 
    5158install: whois 
     59        install -d $(BASEDIR)$(prefix)/bin/ 
     60        install -d $(BASEDIR)$(prefix)/share/man/man1/ 
    5261        install -m 0755 whois $(BASEDIR)$(prefix)/bin/ 
    5362        install -m 0644 whois.1 $(BASEDIR)$(prefix)/share/man/man1/ 
     
    5564 
    5665install-mkpasswd: mkpasswd 
     66        install -d $(BASEDIR)$(prefix)/bin/ 
     67        install -d $(BASEDIR)$(prefix)/share/man/man1/ 
    5768        install -m 0755 mkpasswd $(BASEDIR)$(prefix)/bin/ 
    5869        install -m 0644 mkpasswd.1 $(BASEDIR)$(prefix)/share/man/man1/ 
     
    6273 
    6374clean: 
    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 
    6577        rm -f po/*.mo 
    6678 
     
    7486        cd po && $(MAKE) 
    7587 
     88depend: Makefile.depend 
     89Makefile.depend: 
     90        $(CC) $(CFLAGS) -MM -MG *.c > $@ 
     91 
     92-include Makefile.depend 
  • psad/trunk/whois/README

    r631 r2167  
    2626- http://www.iahc.org/dns-refs/registry.html 
    2727- http://www.iana.org/root-whois/xx.htm 
    28 - http://www.afrinic.org 
    29 - http://www.aftld.org 
     28- http://www.afrinic.net/ 
     29- http://www.aftld.org/ 
    3030 
    3131Marco d'Itri 
  • psad/trunk/whois/VERSION

    r1555 r2167  
    1 4.7.13 
     14.7.26 
  • psad/trunk/whois/as_del_list

    r1555 r2167  
    44379     508     whois.nic.mil 
    551101    1200    ripe 
     61267    1275    ripe 
    671877    1901    ripe 
    782043    2043    ripe 
     
    28299943    9982    whois.nic.or.kr 
    29309990    10021   whois.nic.ad.jp 
    30 9261  10067   apnic 
     319216  10067   apnic 
    313210034   10073   whois.nic.or.kr 
    323310154   10198   whois.nic.or.kr 
     
    596037888   38911   apnic 
    606138912   39935   ripe 
     6240960   45055   ripe 
     6345056   46079   apnic 
    6164 
    6265# catch all: everything else comes from ARIN 
    63 1       39935 arin 
     661       40959 arin 
    6467 
  • psad/trunk/whois/config.h

    r1555 r2167  
    11/* Program version */ 
    22/* not for the inetutils version */ 
    3 #define VERSION "4.7.13
     3#define VERSION "4.7.26
    44 
    55/* Configurable features */ 
     
    4040#  define HAVE_GETADDRINFO 
    4141# endif 
     42# if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 7 
     43#  define HAVE_SHA_CRYPT 
     44# endif 
    4245#endif 
    4346 
     
    6265#endif 
    6366 
    64 #ifdef HAVE_GETOPT_LONG 
    65 # define GETOPT_LONGISH(c, v, o, l, i) getopt_long(c, v, o, l, i) 
    66 #else 
    67 # define GETOPT_LONGISH(c, v, o, l, i) getopt(c, v, o) 
    68 #endif 
    69  
    70  
    71 /* NLS stuff */ 
    72 #ifdef ENABLE_NLS 
    73 # include <libintl.h> 
    74 # include <locale.h> 
    75 # define _(a) (gettext (a)) 
    76 # ifdef gettext_noop 
    77 #  define N_(a) gettext_noop (a) 
    78 # else 
    79 #  define N_(a) (a) 
    80 # endif 
    81 #else 
    82 # define _(a) (a) 
    83 # define N_(a) a 
    84 #endif 
    85  
  • psad/trunk/whois/data.h

    r1555 r2167  
    1111    "whois.apnic.net", 
    1212    "whois.afrinic.net", 
    13     "whois.denic.de", 
    1413    "rr.arin.net",              /* does not accept the old syntax */ 
    1514    "whois.6bone.net",          /* 3.0.0b1 */ 
    1615    "whois.connect.com.au",     /* 3.0.0b1 */ 
    1716    "whois.nic.fr", 
    18     "whois.nic.it", 
    1917    "whois.telstra.net", 
    2018    "whois.restena.lu", 
     
    2624    "whois.nic.ck", 
    2725    "whois.ra.net", 
    28     "whois.radb.net", 
    2926    NULL 
    3027}; 
     
    3431    "TERMS OF USE: You are not", "",                            /* crsnic */ 
    3532    "NOTICE: Access to .ORG WHOIS", "", 
    36     "NOTICE: Access to .INFO WHOIS", "", 
    3733    "NOTICE: Access to the .aero", "", 
    3834    "This Registry database contains ONLY .EDU", "type: help",  /* edu */ 
     
    6157    "%% BookMyName Whois", "%% this policy", 
    6258    "The .coop registry WHOIS", "VERIFICATION, NOR DO", 
    63     "Tralliance, Inc., the Registry", "",                       /* travel */ 
     59    "Tralliance, Inc., the Registry", "",                       /* .travel */ 
    6460    "NOTICE: Access to the domains information", "",            /* CORE */ 
    6561    "%% 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 */ 
    6667    NULL, NULL 
    6768}; 
     
    121122}; 
    122123 
     124struct as32_del { 
     125    const unsigned long first; 
     126    const unsigned long last; 
     127    const char         *serv; 
     128}; 
     129 
     130const struct as32_del as32_assign[] = { 
     131#include "as32_del.h" 
     132    { 0, 0, NULL } 
     133}; 
     134 
    123135const char *tld_serv[] = { 
    124136#include "tld_serv.h" 
  • psad/trunk/whois/debian/changelog

    r1555 r2167  
     1whois (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 
     9whois (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 
     27whois (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 
     35whois (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 
     43whois (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 
     55whois (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 
     66whois (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 
     74whois (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 
     80whois (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 
     90whois (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 
     96whois (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 
     104whois (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 
     113whois (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 
    1126whois (4.7.13) unstable; urgency=medium 
    2127 
  • psad/trunk/whois/debian/control

    r1555 r2167  
    33Priority: standard 
    44Maintainer: Marco d'Itri <md@linux.it> 
    5 Standards-Version: 3.6.2.1 
     5Standards-Version: 3.7.3 
    66Build-Depends: debhelper (>= 4), gettext, libidn11-dev 
    77 
  • psad/trunk/whois/debian/copyright

    r631 r2167  
    22Sun Oct  3 19:46:30 CEST 1999. 
    33 
    4 It was written by Marco d'Itri
     4Copyright 1999-2008 by Marco d'Itri <md@linux.it>
    55 
    6 Copyright: GPL (please see /usr/share/common-licenses/GPL-2). 
     6License: GPL (please see /usr/share/common-licenses/GPL-2). 
    77 
  • psad/trunk/whois/debian/rules

    r1555 r2167  
    66D := $(shell pwd)/debian/whois 
    77 
    8 VERSION := $(shell dpkg-parsechangelog | sed -n '/^Version/s/.* //p') 
     8VERSION := $(shell dpkg-parsechangelog | sed -n 's/\+.*$$//; /^Version/s/.* //p') 
    99 
    1010build: 
    1111        dh_testdir 
    12         make whois mkpasswd
     12        $(MAKE)
    1313                OPTS="-O2 -g -DCONFIG_FILE=\\\"/etc/whois.conf\\\"" \ 
    1414                HAVE_LIBIDN=1 
     15        cd po && $(MAKE) whois.pot 
    1516        touch $@ 
    1617 
     
    1819        dh_testdir 
    1920        -rm -f build 
    20         -make distclean 
     21        $(MAKE) distclean 
    2122        dh_clean 
    2223 
     
    3031        dh_installdirs usr/bin 
    3132        install whois mkpasswd $D/usr/bin/ 
    32         cd po && make install BASEDIR=$D 
     33        cd po && $(MAKE) install BASEDIR=$D 
    3334        dh_installman whois.1 mkpasswd.1 
    3435        dh_installdocs README 
     
    4445binary: binary-arch 
    4546 
     47binary-indep: 
     48 
    4649checkroot: 
    4750        test root = "`whoami`" 
  • psad/trunk/whois/ip6_del_list

    r1560 r2167  
    33# addresses. It does not deal with networks == 0 or > 24 bit. 
    44 
     52001:0000::/32  teredo 
    562001:0200::/23  apnic 
    672001:0400::/23  arin 
     
    17182001:2000::/19  ripe 
    18192001:4000::/23  ripe 
    19 2001:4200::/23  arin 
     202001:4200::/23  afrinic 
    20212001:4400::/23  apnic 
    21222001:4600::/23  ripe 
     
    34352003:0000::/18  ripe 
    3536 
    36 2400:0000::/18  apnic 
    37 2404:0000::/23  apnic 
    38  
     372400:0000::/20  whois.nic.or.kr 
     382400:0000::/12  apnic 
    39392600:0000::/12  arin 
    40 #2600:0000::/22 arin 
    41 #2604:0000::/22 arin 
    42 #2608:0000::/22 arin 
    43 #260C:0000::/22 arin 
    44402610:0000::/23  arin 
    45  
    46 2800:0000::/23  lacnic 
    47  
    48 2A00:0000::/21  ripe 
    49 2A01:0000::/16  ripe 
     412620:0000::/23  arin 
     422800:0000::/12  lacnic 
     432A00:0000::/12  ripe 
     442C00:0000::/12  afrinic 
    5045 
    51463FFE:0000::/16  6bone 
  • psad/trunk/whois/ip_del_list

    r1555 r2167  
    101041.0.0.0/8      afrinic 
    111143.0.0.0/8      v6nic 
     12# whois -r -K -h whois.apnic.net -i admin-c IM76-AP 
     1359.0.0.0/11     whois.nic.or.kr 
    121458.0.0.0/7      apnic 
    131561.72.0.0/13    whois.nic.or.kr 
     
    192160.0.0.0/7      apnic 
    202262.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 
     2377.0.0.0/8      ripe 
     2478.0.0.0/7      ripe 
     2580.0.0.0/4      ripe                    # => 95.255.255.255 
     2696.0.0.0/6      arin 
     27114.0.0.0/7     apnic 
     28116.0.0.0/6     apnic 
     29121.128.0.0/10  whois.nic.or.kr 
     30125.128.0.0/11  whois.nic.or.kr 
     31120.0.0.0/6     apnic 
    2532124.0.0.0/7     apnic 
    2633126.0.0.0/8     apnic 
    273496.0.0.0/3      UNALLOCATED             # => 127.215.255.255 
    28 0.0.0.0/1       arin    # all other A classes are managed by ARIN 
     350.0.0.0/1       arin    # all other A class addresses are managed by ARIN 
    2936133.0.0.0/8     whois.nic.ad.jp 
    3037139.20.0.0/14   ripe 
     
    7784171.16.0.0/12   ripe 
    7885171.32.0.0/15   ripe 
    79 # 173 -> 187 reserved 
     86# 173 -> 185 reserved 
     87186.0.0.0/7     lacnic 
    8088188.0.0.0/8     ripe # transferred from ARIN to to RIPE 
    8189189.0.0.0/8     lacnic 
     
    132140203.224.0.0/11  whois.nic.or.kr # => 203.255.255.255 
    133141202.0.0.0/7     apnic 
    134 204.0.0.0/14    verio         # rwhois too 
     142204.0.0.0/14    rwhois.gin.ntt.net    # rwhois too 
    135143204.0.0.0/6     arin 
    136144208.0.0.0/7     arin 
     
    183191218.40.0.0/13   whois.nic.ad.jp 
    184192218.48.0.0/13   whois.nic.or.kr 
     193219.96.0.0/11   whois.nic.ad.jp 
    185194218.144.0.0/12  whois.nic.or.kr 
    186195218.160.0.0/12  twnic 
  • psad/trunk/whois/make_ip6_del.pl

    r1560 r2167  
    2727        } elsif ($s eq '6to4') { 
    2828                print "\\x0A"; 
     29        } elsif ($s eq 'teredo') { 
     30                print "\\x0B"; 
    2931        } elsif ($s eq 'UNALLOCATED') { 
    3032                print "\\006"; 
  • psad/trunk/whois/make_tld_serv.pl

    r767 r2167  
    1515        $b = "\\x04" if $b eq 'CRSNIC'; 
    1616        $b = "\\x07" if $b eq 'PIR'; 
     17        $b = "\\x08" if $b eq 'AFILIAS'; 
    1718        $b = "\\x09" if $b eq 'NICCC'; 
    1819        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" 
    22.SH NAME 
    33mkpasswd \- Overfeatured front end to crypt(3) 
     
    1717Use the \fISTRING\fP as salt. It must not contain prefixes such as \fI$1$\fP. 
    1818.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 
     20Use \fINUMBER\fP rounds. This argument is ignored if the method choosen 
     21does not support variable rounds. For the OpenBSD Blowfish method this is 
     22the logarithm of the number of rounds. 
     23.TP 
     24.B -m, --method=TYPE 
     25Compute the password using the \fITYPE\fP method. 
     26If \fITYPE\fP is \fIhelp\fP then the available methods are printed. 
    2227.TP 
    2328.B -P, --password-fd=NUM 
     
    2934.B -s, --stdin 
    3035Like \fI--password-fd=0\fP. 
     36.SH "ENVIRONMENT" 
     37.IP "MKPASSWD_OPTIONS" 
     38A list of options which will be evalued before the ones specified on the 
     39command line. 
    3140.SH BUGS 
    3241If the \fI--stdin\fP option is used, passwords containing some control 
     
    4150.SH AUTHOR 
    4251.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. 
     52and this man page were written by Marco d'Itri <\fImd@linux.it\fP> 
     53and are licensed under the terms of the GNU General Public License, 
     54version 2 or higher. 
    4555 
  • psad/trunk/whois/mkpasswd.c

    r1555 r2167  
    11/* 
    2  *    Copyright (C) 2001-2002  Marco d'Itri 
     2 * Copyright (C) 2001-2008  Marco d'Itri 
    33 * 
    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. 
     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. 
    88 * 
    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. 
     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. 
    1313 * 
    14  *    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 
     14 * 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 
    1717 */ 
    1818 
     19/* for crypt, snprintf and strcasecmp */ 
    1920#define _XOPEN_SOURCE 
    2021#define _BSD_SOURCE 
     22 
     23/* System library */ 
    2124#include <stdio.h> 
    2225#include <stdlib.h> 
     
    2932#include <time.h> 
    3033#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 */ 
    3245#ifdef HAVE_GETOPT_LONG 
    33 static struct option longopts[] = { 
     46static const struct option longopts[] = { 
     47    {"method",          optional_argument,      NULL, 'm'}, 
     48    /* for backward compatibility with versions < 4.7.25 (< 20080321): */ 
    3449    {"hash",            optional_argument,      NULL, 'H'}, 
    3550    {"help",            no_argument,            NULL, 'h'}, 
     
    3752    {"stdin",           no_argument,            NULL, 's'}, 
    3853    {"salt",            required_argument,      NULL, 'S'}, 
     54    {"rounds",          required_argument,      NULL, 'R'}, 
    3955    {"version",         no_argument,            NULL, 'V'}, 
    4056    {NULL,              0,                      NULL, 0  } 
     
    4258#endif 
    4359 
    44 static char valid_salts[] = "abcdefghijklmnopqrstuvwxyz" 
     60static const char valid_salts[] = "abcdefghijklmnopqrstuvwxyz" 
    4561"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./"; 
    4662 
    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 */ 
     63struct 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 */ 
    5269}; 
    5370 
    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 */ 
     71static 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*/ 
    6295#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 } 
    6799}; 
    68100 
    69 void generate_salt(char *buf, const unsigned int len); 
     101void generate_salt(char *const buf, const unsigned int len); 
     102void *gather_entropy(const int len); 
    70103void display_help(void); 
    71104void display_version(void); 
    72 void display_algorithms(void); 
     105void display_methods(void); 
    73106 
    74107int main(int argc, char *argv[]) 
    75108{ 
    76     int ch
     109    int ch, i
    77110    int password_fd = -1; 
    78     unsigned int i, salt_len = 0; 
     111    unsigned int salt_len = 0; 
     112    unsigned int rounds_support = 0; 
    79113    const char *salt_prefix = NULL; 
     114    const char *salt_arg = NULL; 
     115    unsigned int rounds = 0; 
    80116    char *salt = NULL; 
     117    char rounds_str[30]; 
    81118    char *password = NULL; 
    82119 
     
    87124#endif 
    88125 
    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) { 
    90130        switch (ch) { 
     131        case 'm': 
    91132        case 'H': 
    92             if (!optarg || strcasecmp("help", optarg) == 0) { 
    93                 display_algorithms(); 
     133            if (!optarg || strcaseeq("help", optarg)) { 
     134                display_methods(); 
    94135                exit(0); 
    95136            } 
    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; 
    100142                    break; 
    101143                } 
    102144            if (!salt_prefix) { 
    103                 fprintf(stderr, _("Invalid hash type '%s'.\n"), optarg); 
     145                fprintf(stderr, _("Invalid method '%s'.\n"), optarg); 
    104146                exit(1); 
    105147            } 
     
    115157            } 
    116158            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; 
    117169        case 's': 
    118170            password_fd = 0; 
    119171            break; 
    120172        case 'S': 
    121             salt = optarg; 
     173            salt_arg = optarg; 
    122174            break; 
    123175        case 'V': 
     
    136188    argv += optind; 
    137189 
    138     if (argc == 2 && !salt) { 
     190    if (argc == 2 && !salt_arg) { 
    139191        password = argv[0]; 
    140         salt = argv[1]; 
     192        salt_arg = argv[1]; 
    141193    } else if (argc == 1) { 
    142194        password = argv[0]; 
     
    148200 
    149201    /* 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 */ 
    157220        if (c != salt_len) { 
    158221            fprintf(stderr, 
     
    161224            exit(1); 
    162225        } 
    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]); 
    166230                exit(1); 
    167231            } 
     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); 
    168240    } else { 
    169241#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); 
    172245        if (!salt) { 
    173                 perror("crypt"); 
     246                fprintf(stderr, "crypt_gensalt failed.\n"); 
    174247                exit(2); 
    175248        } 
    176249        free(entropy); 
    177250#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