mkpasswd: support raw $salt$ prefixes

If the salt provided to the program starts with '$' then it will be
passed straight to crypt(3) without any checks.
This commit is contained in:
Marco d'Itri 2019-12-31 02:36:51 +01:00
parent 38cab73d18
commit aea6650cfc
2 changed files with 8 additions and 3 deletions

View File

@ -16,8 +16,11 @@ libc function, using the given salt.
.BI \-\-salt= STRING
Use the
.I STRING
as salt. It must not contain prefixes such as
.IR $1$ .
as salt. If it begins with
.I $
then it will be passed straight to
.BR crypt (3)
without any checks.
.TP
.BR \-R ", "\c
.BI \-\-rounds= NUMBER

View File

@ -282,7 +282,9 @@ int main(int argc, char *argv[])
else
rounds_str[0] = '\0';
if (salt_arg && salt_arg[0] != '\0') {
if (salt_arg && salt_arg[0] == '$')
salt = NOFAIL(strdup(salt_arg));
else if (salt_arg && salt_arg[0] != '\0') {
unsigned int c = strlen(salt_arg);
if (c < salt_minlen || c > salt_maxlen) {
if (salt_minlen == salt_maxlen)