passwd: Do not allow empty passwords

The user should use the delete flag when wanting to issue an empty
password. passwd should return an error after receiving empty input.
This commit is contained in:
brapru 2021-05-24 16:41:36 -04:00 committed by Andreas Kling
parent 1a9d0dee2c
commit c62804df46

View file

@ -110,6 +110,12 @@ int main(int argc, char** argv)
return 1;
}
if (new_password.value().is_empty() && new_password_retype.value().is_empty()) {
warnln("No password supplied.");
warnln("Password for user {} unchanged.", target_account.username());
return 1;
}
if (new_password.value() != new_password_retype.value()) {
warnln("Sorry, passwords don't match.");
warnln("Password for user {} unchanged.", target_account.username());