From 22002f67be6bbb6720a277c62c099f841010d68e Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Tue, 11 Sep 2018 01:25:13 +0200 Subject: mkpasswd.1: clarify that --rounds without --method makes no sense On old systems it will be ignored because descrypt does not support changing the number of rounds, while on newer systems the default method may change depending on the local configuration. --- mkpasswd.1 | 1 + 1 file changed, 1 insertion(+) (limited to 'mkpasswd.1') diff --git a/mkpasswd.1 b/mkpasswd.1 index db7db47..86a949c 100644 --- a/mkpasswd.1 +++ b/mkpasswd.1 @@ -20,6 +20,7 @@ Use the \fISTRING\fP as salt. It must not contain prefixes such as \fI$1$\fP. Use \fINUMBER\fP rounds. This argument is ignored if the method chosen does not support variable rounds. For the OpenBSD Blowfish method this is the logarithm of the number of rounds. +The behavior is undefined if this option is used without \fI--method\fP. .TP .B -m, --method=TYPE Compute the password using the \fITYPE\fP method. -- cgit v1.2.3 From 4d24d493ff9e2e706a9d025b33956e8764a87c01 Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Sun, 14 Oct 2018 03:41:14 +0200 Subject: mkpasswd: implement a generic way to provide the hash type --- mkpasswd.1 | 4 ++++ mkpasswd.c | 11 +++++++++++ 2 files changed, 15 insertions(+) (limited to 'mkpasswd.1') diff --git a/mkpasswd.1 b/mkpasswd.1 index 86a949c..21555ad 100644 --- a/mkpasswd.1 +++ b/mkpasswd.1 @@ -25,6 +25,8 @@ The behavior is undefined if this option is used without \fI--method\fP. .B -m, --method=TYPE Compute the password using the \fITYPE\fP method. If \fITYPE\fP is \fIhelp\fP then the available methods are printed. +If \fITYPE\fP begins and end with \fI$\fP characters then the string +is passed to \fIcrypt_gensalt(3)\fP as-is. .TP .B -5 Like \fI--method=md5\fP. @@ -50,6 +52,8 @@ This programs suffers of a bad case of featuritis. .IR passwd(1), .IR passwd(5), .IR crypt(3), +.IR crypt(5), +.IR crypt_gensalt(3), .IR getpass(3) .SH AUTHOR .B mkpasswd diff --git a/mkpasswd.c b/mkpasswd.c index b2a4b95..00e839b 100644 --- a/mkpasswd.c +++ b/mkpasswd.c @@ -181,6 +181,17 @@ int main(int argc, char *argv[]) display_methods(); exit(0); } +#if defined HAVE_LINUX_CRYPT_GENSALT || defined HAVE_SOLARIS_CRYPT_GENSALT + if (optarg[0] == '$' + && strlen(optarg) > 2 + && *(optarg + strlen(optarg) - 1) == '$') { + salt_prefix = NOFAIL(strdup(optarg)); + salt_minlen = 0; + salt_maxlen = 0; + rounds_support = 0; + break; + } +#endif for (i = 0; methods[i].method != NULL; i++) if (strcaseeq(methods[i].method, optarg)) { salt_prefix = methods[i].prefix; -- cgit v1.2.3