From: Dmitry V. Levin Date: Thu, 6 Jul 2023 08:00:00 +0000 (+0000) Subject: pwquality: add old password argument to quality_check_password X-Git-Tag: v254-rc1~7^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc0ef0e2c0a116731f8535802ca0d077212e3c1f;p=thirdparty%2Fsystemd.git pwquality: add old password argument to quality_check_password This would allow to use quality_check_password() in user_record_quality_check_password() which still uses sym_pwquality_check() directly. --- diff --git a/src/cryptenroll/cryptenroll-password.c b/src/cryptenroll/cryptenroll-password.c index de72278394a..44e6f0b227b 100644 --- a/src/cryptenroll/cryptenroll-password.c +++ b/src/cryptenroll/cryptenroll-password.c @@ -156,7 +156,7 @@ int enroll_password( } } - r = quality_check_password(new_password, NULL, &error); + r = quality_check_password(new_password, /* old */ NULL, /* user */ NULL, &error); if (r < 0) { if (ERRNO_IS_NOT_SUPPORTED(r)) log_warning("Password quality check is not supported, proceeding anyway."); diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index 019b7d70afa..501f074c94f 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -790,7 +790,7 @@ static int prompt_root_password(int rfd) { break; } - r = quality_check_password(*a, "root", &error); + r = quality_check_password(*a, /* old */ NULL, "root", &error); if (r < 0) { if (ERRNO_IS_NOT_SUPPORTED(r)) log_warning("Password quality check is not supported, proceeding anyway."); diff --git a/src/shared/pwquality-util.c b/src/shared/pwquality-util.c index 34d3e353305..450208319d8 100644 --- a/src/shared/pwquality-util.c +++ b/src/shared/pwquality-util.c @@ -132,7 +132,7 @@ int suggest_passwords(void) { return 1; } -int quality_check_password(const char *password, const char *username, char **ret_error) { +int quality_check_password(const char *password, const char *old, const char *username, char **ret_error) { _cleanup_(sym_pwquality_free_settingsp) pwquality_settings_t *pwq = NULL; char buf[PWQ_MAX_ERROR_MESSAGE_LEN]; void *auxerror; @@ -144,7 +144,7 @@ int quality_check_password(const char *password, const char *username, char **re if (r < 0) return log_debug_errno(r, "Failed to allocate libpwquality context: %m"); - r = sym_pwquality_check(pwq, password, NULL, username, &auxerror); + r = sym_pwquality_check(pwq, password, old, username, &auxerror); if (r < 0) { if (ret_error) { diff --git a/src/shared/pwquality-util.h b/src/shared/pwquality-util.h index 877f439d117..4e18f39f784 100644 --- a/src/shared/pwquality-util.h +++ b/src/shared/pwquality-util.h @@ -24,7 +24,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(pwquality_settings_t*, sym_pwquality_free_setti void pwq_maybe_disable_dictionary(pwquality_settings_t *pwq); int pwq_allocate_context(pwquality_settings_t **ret); int suggest_passwords(void); -int quality_check_password(const char *password, const char *username, char **ret_error); +int quality_check_password(const char *password, const char *old, const char *username, char **ret_error); #else @@ -32,7 +32,7 @@ static inline int suggest_passwords(void) { return 0; } -static inline int quality_check_password(const char *password, const char *username, char **ret_error) { +static inline int quality_check_password(const char *password, const char *old, const char *username, char **ret_error) { if (ret_error) *ret_error = NULL; return 1; /* all good */