From f7c61b984eea1b31bedc1492b3c43722023ffb69 Mon Sep 17 00:00:00 2001 From: Hayden Date: Sat, 20 Mar 2021 13:05:05 -0400 Subject: Untested libxcrypt-enabled passwords --- pw/pw_user.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/pw/pw_user.c b/pw/pw_user.c index fa1ee36..85aa292 100644 --- a/pw/pw_user.c +++ b/pw/pw_user.c @@ -36,6 +36,7 @@ static const char rcsid[] = #include #include +#include #include #include #include @@ -636,27 +637,16 @@ pw_shellpolicy(struct userconf * cnf) return shell_path(cnf->shelldir, cnf->shells, cnf->shell_default); } -#define SALTSIZE 32 - static char const chars[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ./"; char * pw_pwcrypt(char *password) { - int i; - char salt[SALTSIZE + 1]; char *cryptpw; static char buf[256]; size_t pwlen; - /* - * Calculate a salt value - */ - for (i = 0; i < SALTSIZE; i++) - salt[i] = chars[arc4random_uniform(sizeof(chars) - 1)]; - salt[SALTSIZE] = '\0'; - - cryptpw = crypt(password, salt); + cryptpw = crypt(password, crypt_gensalt("$6$", 0, chars, strlen(chars))); if (cryptpw == NULL) errx(EX_CONFIG, "crypt(3) failure"); pwlen = strlcpy(buf, cryptpw, sizeof(buf)); -- cgit v1.2.3-56-ge451