mirror of
https://github.com/rfc1036/whois.git
synced 2026-08-31 07:30:22 +00:00
mkpasswd: support letting crypt_gensalt decide the prefix
If crypt_gensalt (as implemented by Solaris and modern versions of libxcrypt) is passed a NULL prefix then it will decide by itself which algorithm should be used by default.
This commit is contained in:
parent
61f4e5d64c
commit
3197cb7db4
1
config.h
1
config.h
@ -56,6 +56,7 @@
|
||||
#if defined __SVR4 && defined __sun
|
||||
# define HAVE_SHA_CRYPT
|
||||
# define HAVE_SOLARIS_CRYPT_GENSALT
|
||||
# define CRYPT_GENSALT_IMPLEMENTS_DEFAULT_PREFIX
|
||||
#endif
|
||||
|
||||
/* FIXME: which systems lack this? */
|
||||
|
||||
13
mkpasswd.c
13
mkpasswd.c
@ -83,6 +83,9 @@ struct crypt_method {
|
||||
|
||||
static const struct crypt_method methods[] = {
|
||||
/* method prefix minlen, maxlen rounds description */
|
||||
#ifdef CRYPT_GENSALT_IMPLEMENTS_DEFAULT_PREFIX
|
||||
{ "auto", NULL, 0, 0, 0, NULL },
|
||||
#endif
|
||||
{ "des", "", 2, 2, 0,
|
||||
N_("standard 56 bit DES-based crypt(3)") },
|
||||
{ "md5", "$1$", 8, 8, 0, "MD5" },
|
||||
@ -229,14 +232,17 @@ int main(int argc, char *argv[])
|
||||
display_help(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* default: DES password */
|
||||
/* default: DES password, or else whatever crypt_gensalt chooses */
|
||||
if (!salt_prefix) {
|
||||
salt_minlen = methods[0].minlen;
|
||||
salt_maxlen = methods[0].maxlen;
|
||||
salt_prefix = methods[0].prefix;
|
||||
rounds_support = methods[0].rounds;
|
||||
}
|
||||
|
||||
if (streq(salt_prefix, "$2a$") || streq(salt_prefix, "$2y$")) {
|
||||
if (!salt_prefix) {
|
||||
/* NULL means that crypt_gensalt will choose one later */
|
||||
} else if (streq(salt_prefix, "$2a$") || streq(salt_prefix, "$2b$")) {
|
||||
/* OpenBSD Blowfish and derivatives */
|
||||
if (rounds <= 5)
|
||||
rounds = 5;
|
||||
@ -492,7 +498,8 @@ void display_methods(void)
|
||||
|
||||
printf(_("Available methods:\n"));
|
||||
for (i = 0; methods[i].method != NULL; i++)
|
||||
printf("%s\t%s\n", methods[i].method, methods[i].desc);
|
||||
if (methods[i].desc)
|
||||
printf("%s\t%s\n", methods[i].method, methods[i].desc);
|
||||
}
|
||||
|
||||
char *read_line(FILE *fp) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user