diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-08-18 10:37:44 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2020-08-19 10:03:56 +0200 |
commit | 7baf10a7be8bd1bad36d333f7013ed5c2b7b7d13 (patch) | |
tree | 9766eea45ee136569f13363fa383e57e0d1a1059 /src/firstboot/firstboot.c | |
parent | 679badd7ba5ddcff97ad8603fcf272454ab06663 (diff) | |
download | systemd-7baf10a7be8bd1bad36d333f7013ed5c2b7b7d13.tar.gz |
firstboot: hook up with libpwquality
Diffstat (limited to 'src/firstboot/firstboot.c')
-rw-r--r-- | src/firstboot/firstboot.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index e4c7a2d374..cf1ec28dd5 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -28,6 +28,7 @@ #include "path-util.h" #include "pretty-print.h" #include "proc-cmdline.h" +#include "pwquality-util.h" #include "random-util.h" #include "string-util.h" #include "strv.h" @@ -568,8 +569,11 @@ static int prompt_root_password(void) { msg1 = strjoina(special_glyph(SPECIAL_GLYPH_TRIANGULAR_BULLET), " Please enter a new root password (empty to skip):"); msg2 = strjoina(special_glyph(SPECIAL_GLYPH_TRIANGULAR_BULLET), " Please enter new root password again:"); + suggest_passwords(); + for (;;) { _cleanup_strv_free_erase_ char **a = NULL, **b = NULL; + _cleanup_free_ char *error = NULL; r = ask_password_tty(-1, msg1, NULL, 0, 0, NULL, &a); if (r < 0) @@ -583,6 +587,12 @@ static int prompt_root_password(void) { break; } + r = quality_check_password(*a, "root", &error); + if (r < 0) + return log_error_errno(r, "Failed to check quality of password: %m"); + if (r == 0) + log_warning("Password is weak, accepting anyway: %s", error); + r = ask_password_tty(-1, msg2, NULL, 0, 0, NULL, &b); if (r < 0) return log_error_errno(r, "Failed to query root password: %m"); |