diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README | 1 | ||||
-rw-r--r-- | config.h | 36 | ||||
-rw-r--r-- | debian/changelog | 16 | ||||
-rw-r--r-- | debian/control | 1 | ||||
-rw-r--r-- | ip_del_list | 2 | ||||
-rw-r--r-- | mkpasswd.1 | 26 | ||||
-rw-r--r-- | mkpasswd.c | 212 | ||||
-rw-r--r-- | po/el.po | 2 | ||||
-rw-r--r-- | po/it.po | 3 | ||||
-rw-r--r-- | po/no.po | 2 | ||||
-rw-r--r-- | po/pl.po | 2 | ||||
-rw-r--r-- | tld_serv_list | 6 | ||||
-rw-r--r-- | whois.c | 2 | ||||
-rw-r--r-- | whois.h | 33 |
15 files changed, 288 insertions, 58 deletions
@@ -13,7 +13,7 @@ all: whois #pos whois: whois.c whois.h config.h data.h as_del.h ip_del.h tld_serv.h $(CC) $(OPTS) whois.c -o whois $(LDFLAGS) -mkpasswd: +mkpasswd: mkpasswd.c $(CC) $(OPTS) mkpasswd.c -o mkpasswd -lcrypt as_del.h: as_del_list make_as_del.pl @@ -25,6 +25,7 @@ Other information sources: http://www.apnic.net/maps/tld-list.html - http://www.uninett.no/navn/domreg.html - http://www.iahc.org/dns-refs/registry.html +- http://www.iana.org/root-whois/xx.htm Marco d'Itri <md@linux.it> @@ -1,6 +1,6 @@ /* Program version */ /* not for the inetutils version */ -#define VERSION "4.5.6" +#define VERSION "4.5.7" /* Configurable features */ @@ -13,7 +13,7 @@ /* Default server */ #define DEFAULTSERVER "whois.internic.net" -/* not for the inetutils version */ +/* autoconf in cpp macros */ #ifdef linux # define ENABLE_NLS # define HAVE_GETOPT_LONG @@ -22,3 +22,35 @@ # endif #endif +/* system features */ +#ifdef ENABLE_NLS +# ifndef NLS_CAT_NAME +# define NLS_CAT_NAME "whois" +# endif +# ifndef LOCALEDIR +# define LOCALEDIR "/usr/share/locale" +# endif +#endif + +#ifdef HAVE_GETOPT_LONG +# define GETOPT_LONGISH(c, v, o, l, i) getopt_long(c, v, o, l, i) +#else +# define GETOPT_LONGISH(c, v, o, l, i) getopt(c, v, o) +#endif + + +/* NLS stuff */ +#ifdef ENABLE_NLS +# include <libintl.h> +# include <locale.h> +# define _(a) (gettext (a)) +# ifdef gettext_noop +# define N_(a) gettext_noop (a) +# else +# define N_(a) (a) +# endif +#else +# define _(a) (a) +# define N_(a) a +#endif + diff --git a/debian/changelog b/debian/changelog index 6ab8fd0..8797669 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,16 @@ -whois (4.5.6) unstable; urgency=low +whois (4.5.7) unstable; urgency=low + + * Added -nicat and -il NIC handles (Closes: #94465). + * Greatly bloated mkpasswd now can read the password from the console + (Closes: #94826). + + -- Marco d'Itri <md@linux.it> Tue, 5 Jun 2001 14:01:56 +0200 + +whois (4.5.6) unstable; urgency=medium * Fixed typo in the server name for .si. + * Added 80.0.0.0/7 allocation and -frnic NIC handles. + * Added Build-Depends (Closes: #90205). -- Marco d'Itri <md@linux.it> Wed, 4 Apr 2001 01:27:53 +0200 @@ -14,7 +24,7 @@ whois (4.5.5) unstable; urgency=low whois (4.5.4) unstable; urgency=low * Updated .at, .be, .cy, .cz, .ee, .gr, .il, .pl, .ro, .vi and .nz ccTLDs. - * Added -cz, -nicat, -norid and -rotld NIC handles. + * Added -cz, -nicat, and -rotld NIC handles. * Added telstra IP allocations. * Fixed fencepost error (Closes: #83661). @@ -185,7 +195,7 @@ whois (4.4.1) unstable; urgency=low whois (4.4.0) unstable; urgency=low * Now the program automatically select the right server for AS queries. - * Added RIPE delegations of netblocks in the B class space. + * Added RIPE allocations of netblocks in the B class space. * Extensive survey of all known whois servers and update of tld_serv_list. * Now the flag -VMd4.4 is sent to RIPE-like servers. * Written a test program for checking if all servers work. diff --git a/debian/control b/debian/control index a892887..1e53b8f 100644 --- a/debian/control +++ b/debian/control @@ -3,6 +3,7 @@ Section: net Priority: standard Maintainer: Marco d'Itri <md@linux.it> Standards-Version: 3.1.0.0 +Build-Depends: debhelper, gettext Package: whois Architecture: any diff --git a/ip_del_list b/ip_del_list index 1df866f..2206338 100644 --- a/ip_del_list +++ b/ip_del_list @@ -5,6 +5,7 @@ 62.0.0.0/8 ripe # broken? # 63.208.0.0/13 rr.level3.net +80.0.0.0/7 ripe 0.0.0.0/2 arin # all other A classes are managed by ARIN ## The B class space is a mess :-( - something could still be missing 139.20.0.0/14 ripe @@ -145,4 +146,3 @@ 214.0.0.0/7 arin # DoD 216.0.0.0/8 arin 217.0.0.0/8 ripe - @@ -1,6 +1,6 @@ -.TH MKPASSWD 1 "7 October 1999" "Marco d'Itri" "Debian GNU/Linux" +.TH MKPASSWD 1 "5 June 2001" "Marco d'Itri" "Debian GNU/Linux" .SH NAME -mkpasswd \- Very dumb front end to crypt(3) +mkpasswd \- Overfeatured front end to crypt(3) .SH SYNOPSIS .B mkpasswd .BR PASSWORD @@ -11,10 +11,28 @@ mkpasswd \- Very dumb front end to crypt(3) encrypts the given password with the .BR crypt(3) libc function using the given salt. +.SH OPTIONS +.TP +.B -S, --salt=STRING +Use the \fISTRING\fP as salt. +.TP +.B -H, --hash=TYPE +Compute the password using the \fITYPE\fP algorithm. +.TP +.B -s, --stdin +Read the password from stdin instead of using \fIgetpass(3)\fP. +.SH BUGS +If the \fI--stdin\fP option is used, passwords containing some control +characters may not be read correctly. +.TP +This programs suffers of a bad case of featuritis. .SH "SEE ALSO" -.IR crypt(3) +.IR passwd(1), +.IR passwd(5), +.IR crypt(3), +.IR getpass(3) .SH AUTHOR .B mkpasswd and this man page were written by Marco d'Itri <md@linux.it> -and put in the public domain. +and are licensed under the terms of the GNU GPL. @@ -1,21 +1,221 @@ -/* mkpasswd.c - written by Marco d'Itri <md@linux.it>, 1999/10/3. - * Silly little program for encrypting passwords - * It is so dumb that I will just place it in the public domain +/* + * Copyright (C) 2001 Marco d'Itri + * + * This program is free software; you can redistribute it and/or modify + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define _XOPEN_SOURCE +#define _BSD_SOURCE #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> +#include <string.h> +#include <time.h> +#include "config.h" +#ifdef HAVE_GETOPT_LONG +#include <getopt.h> +#endif + +#ifdef HAVE_GETOPT_LONG +static struct option longopts[] = { + {"stdin", no_argument, NULL, 's'}, + {"salt", required_argument, NULL, 'S'}, + {"hash", required_argument, NULL, 'H'}, + {"help", no_argument, NULL, 'h'}, + {"version", no_argument, NULL, 'V'}, + {NULL, 0, NULL, 0 } +}; +#endif + +static char valid_salts[] = "abcdefghijklmnopqrstuvwxyz" +"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./"; + +struct salt_prefix { + const char *algo; + const char *prefix; + unsigned int len; +}; + +struct salt_prefix salt_prefixes[] = { + { "des", "", 2 }, + { "md5", "$1$", 8 }, +}; + +void generate_salt(char *buf, const unsigned int len); +void display_help(void); +void display_version(void); +void display_algorithms(void); int main(int argc, char *argv[]) { - if (argc != 3) { - puts("Usage: mkpasswd PASSWORD SALT\n"); + int ch; + int use_stdin = 0; + unsigned int i, salt_len = 0; + const char *salt_prefix = NULL; + char *salt = NULL; + char *password = NULL; + unsigned char *p; + + while ((ch = GETOPT_LONGISH(argc, argv, "hH:sS:V", longopts, 0)) > 0) { + switch (ch) { + case 's': + use_stdin = 1; + break; + case 'S': + salt = optarg; + break; + case 'H': + if (*optarg == '\0') { + display_algorithms(); + exit(0); + } + for (i = 0; salt_prefixes[i].algo != NULL; i++) + if (strcasecmp(salt_prefixes[i].algo, optarg) == 0) { + salt_prefix = salt_prefixes[i].prefix; + salt_len = salt_prefixes[i].len; + break; + } + if (!salt_prefix) { + fprintf(stderr, "Invalid hash type `%s'.\n", optarg); + exit(1); + } + break; + case 'V': + display_version(); + exit(0); + case 'h': + display_help(); + exit(0); + default: + fprintf(stderr, "Try `%s --help' for more information.\n", argv[0]); + exit(1); + } + } + argc -= optind; + argv += optind; + + if (argc == 2 && !salt) { + password = argv[0]; + salt = argv[1]; + } else if (argc == 1) { + password = argv[0]; + } else if (argc == 0) { + } else { + display_help(); exit(1); } - printf("%s\n", crypt(argv[1], argv[2])); + + /* default: DES password */ + if (!salt_len) { + salt_len = salt_prefixes[0].len; + salt_prefix = salt_prefixes[0].prefix; + } + + if (salt) { + i = strlen(salt); + if (i != salt_len) { + fprintf(stderr, "Wrong salt length: %d byte(s) instead of %d.\n", + i, salt_len); + exit(1); + } + while (i-- > 0) + if (strchr(valid_salts, salt[i]) == NULL) { + fprintf(stderr, "Illegal salt character `%c'.\n", salt[i]); + exit(1); + } + } else { + salt = malloc(salt_len + 1); + generate_salt(salt, salt_len); + } + + if (!password) { + if (use_stdin) { + fprintf(stderr, "Password: "); + password = malloc(128); + if (!fgets(password, sizeof password, stdin)) { + perror("fgets:"); + exit(2); + } + p = password; + while (*p != '\0') { + if (*p == '\n') { + *p = '\0'; + break; + } + /* which characters are valid? */ + if (*p > 0x7f) { + fprintf(stderr, "Illegal password character `0x%hhx'.\n", + *p); + exit(1); + } + p++; + } + } else { + password = getpass("Password: "); + if (!password) { + perror("getpass:"); + exit(2); + } + } + } + + p = malloc(strlen(salt_prefix) + strlen(salt) + 1); + *p = '\0'; + strcat(p, salt_prefix); + strcat(p, salt); + printf("%s\n", crypt(password, p)); exit(0); } +void generate_salt(char *buf, const unsigned int len) +{ + unsigned int i; + + srand(time(NULL) + getpid()); + for (i = 0; i < len; i++) + buf[i] = valid_salts[rand() % (sizeof valid_salts - 1)]; + buf[i] = '\0'; +} + +void display_help(void) +{ + fprintf(stderr, "Usage: mkpasswd [OPTIONS]... [PASSWORD [SALT]]\n" + "Crypts the PASSWORD using crypt(3).\n\n"); + fprintf(stderr, +" -H, --hash=TYPE select hash TYPE\n" +" -S, --salt=SALT use the specified SALT\n" +" -s, --stdin read the password from stdin instead of /dev/tty\n" +" -h, --help display this help and exit\n" +" -v, --version output version information and exit\n" +"\n" +"If PASSWORD is missing then it is asked interactively.\n" +"If no SALT is specified, a random one is generated.\n" +"\n" +"Report bugs to %s.\n", "<md+whois@linux.it>"); +} + +void display_version(void) +{ + printf("GNU mkpasswd %s\n\n", VERSION); + puts("Copyright (C) 2001 Marco d'Itri\n" +"This is free software; see the source for copying conditions. There is NO\n" +"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."); +} + +void display_algorithms(void) +{ + printf("Available algorithms:\n"); +} @@ -150,7 +150,7 @@ msgid "" "-q [version|sources] query specified server info [RPSL only]\n" "-d return DNS reverse delegation objects too [RPSL " "only]\n" -"-K only primary keys are returned [RPSL only\n" +"-K only primary keys are returned [RPSL only]\n" "-V --verbose explain what is being done\n" " --help display this help and exit\n" " --version output version information and exit\n" @@ -147,7 +147,7 @@ msgid "" "-q [version|sources] query specified server info [RPSL only]\n" "-d return DNS reverse delegation objects too [RPSL " "only]\n" -"-K only primary keys are returned [RPSL only\n" +"-K only primary keys are returned [RPSL only]\n" "-V --verbose explain what is being done\n" " --help display this help and exit\n" " --version output version information and exit\n" @@ -183,4 +183,3 @@ msgstr "" "-V --verbose spiega cosa sta facendo\n" " --help mostra questo aiuto ed esce\n" " --version stampa le informazioni sulla versione ed esce\n" -"Versione %s. Segnala i bug a %s.\n" @@ -146,7 +146,7 @@ msgid "" "-q [version|sources] query specified server info [RPSL only]\n" "-d return DNS reverse delegation objects too [RPSL " "only]\n" -"-K only primary keys are returned [RPSL only\n" +"-K only primary keys are returned [RPSL only]\n" "-V --verbose explain what is being done\n" " --help display this help and exit\n" " --version output version information and exit\n" @@ -146,7 +146,7 @@ msgid "" "-q [version|sources] query specified server info [RPSL only]\n" "-d return DNS reverse delegation objects too [RPSL " "only]\n" -"-K only primary keys are returned [RPSL only\n" +"-K only primary keys are returned [RPSL only]\n" "-V --verbose explain what is being done\n" " --help display this help and exit\n" " --version output version information and exit\n" diff --git a/tld_serv_list b/tld_serv_list index 4afda95..a0af57f 100644 --- a/tld_serv_list +++ b/tld_serv_list @@ -3,7 +3,6 @@ # UPR means the TLD is managed by UPR, but I could not find any info # # centralnic domains are currently not supported -# http://www.iana.org/root-whois/xx.htm .br.com whois.centralnic.net .cn.com whois.centralnic.net .eu.com whois.centralnic.net @@ -262,6 +261,7 @@ .um whois.isi.edu # not checked .fed.us whois.nic.gov .us whois.isi.edu +.com.uy WEB http://dns.antel.net.uy/clientes/consultar.htm .uy WEB http://www.rau.edu.uy/rau/dom/reg.htm #.uz # www.noc.uz (broken) .va whois.ripe.net @@ -302,6 +302,8 @@ -cknic whois.nic.ck -cz whois.nic.cz -kg whois.domain.kg --norid whois.norid.no -rotld whois.rotld.ro -itnic whois.nic.it +-frnic whois.nic.fr +-nicat whois.nic.at +-il whois.isoc.org.il @@ -539,7 +539,7 @@ void usage(void) "-v TYPE request verbose template for object of TYPE\n" "-q [version|sources] query specified server info [RPSL only]\n" "-d return DNS reverse delegation objects too [RPSL only]\n" -"-K only primary keys are returned [RPSL only\n" +"-K only primary keys are returned [RPSL only]\n" "-V --verbose explain what is being done\n" " --help display this help and exit\n" " --version output version information and exit\n" @@ -5,39 +5,6 @@ /* Do *NOT* change it if you don't know what you are doing! */ #define IDSTRING "Md4.5" -/* system features */ -#ifdef ENABLE_NLS -# ifndef NLS_CAT_NAME -# define NLS_CAT_NAME "whois" -# endif -# ifndef LOCALEDIR -# define LOCALEDIR "/usr/share/locale" -# endif -#endif - -#ifdef HAVE_GETOPT_LONG -# define GETOPT_LONGISH(c, v, o, l, i) getopt_long(c, v, o, l, i) -#else -# define GETOPT_LONGISH(c, v, o, l, i) getopt(c, v, o) -#endif - - -/* NLS stuff */ -#ifdef ENABLE_NLS -# include <libintl.h> -# include <locale.h> -# define _(a) (gettext (a)) -# ifdef gettext_noop -# define N_(a) gettext_noop (a) -# else -# define N_(a) (a) -# endif -#else -# define _(a) (a) -# define N_(a) a -#endif - - /* prototypes */ const char *whichwhois(const char *); const char *whereas(int, struct as_del []); |