pwquality: fix quality_check_password return value
quality_check_password() used to return the same value 0 in two different cases: when pwq_allocate_context() failed with a ERRNO_IS_NOT_SUPPORTED() code, and when pwquality_check() rejected the password. As result, users of quality_check_password() used to report password weakness also in case when the underlying library was not available. Fix this by changing quality_check_password() to forward the ERRNO_IS_NOT_SUPPORTED() code to its callers, and change the callers to handle this case gracefully.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "creds-util.h"
|
||||
#include "dissect-image.h"
|
||||
#include "env-file.h"
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fs-util.h"
|
||||
@@ -790,8 +791,12 @@ static int prompt_root_password(int rfd) {
|
||||
}
|
||||
|
||||
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) {
|
||||
if (ERRNO_IS_NOT_SUPPORTED(r))
|
||||
log_warning("Password quality check is not supported, proceeding anyway.");
|
||||
else
|
||||
return log_error_errno(r, "Failed to check password quality: %m");
|
||||
}
|
||||
if (r == 0)
|
||||
log_warning("Password is weak, accepting anyway: %s", error);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user