diff options
author | Hayden <me@diatr.us> | 2021-03-20 13:05:05 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-20 13:05:05 -0400 |
commit | f7c61b984eea1b31bedc1492b3c43722023ffb69 (patch) | |
tree | f10fc59b75b0e7eef592f234f1db68cf3f12a25e | |
parent | a477b5619a23ec06af401df48724cc6ec49d9f76 (diff) | |
download | pw-darwin-f7c61b984eea1b31bedc1492b3c43722023ffb69.tar.gz pw-darwin-f7c61b984eea1b31bedc1492b3c43722023ffb69.tar.zst pw-darwin-f7c61b984eea1b31bedc1492b3c43722023ffb69.zip |
Untested libxcrypt-enabled passwords
-rw-r--r-- | pw/pw_user.c | 14 |
1 files 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 <sys/types.h> #include <assert.h> +#include <crypt.h> #include <ctype.h> #include <dirent.h> #include <err.h> @@ -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)); |