Skip to content

Commit bc0ef0e

Browse files
committed
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.
1 parent 0351d56 commit bc0ef0e

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/cryptenroll/cryptenroll-password.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ int enroll_password(
156156
}
157157
}
158158

159-
r = quality_check_password(new_password, NULL, &error);
159+
r = quality_check_password(new_password, /* old */ NULL, /* user */ NULL, &error);
160160
if (r < 0) {
161161
if (ERRNO_IS_NOT_SUPPORTED(r))
162162
log_warning("Password quality check is not supported, proceeding anyway.");

src/firstboot/firstboot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ static int prompt_root_password(int rfd) {
790790
break;
791791
}
792792

793-
r = quality_check_password(*a, "root", &error);
793+
r = quality_check_password(*a, /* old */ NULL, "root", &error);
794794
if (r < 0) {
795795
if (ERRNO_IS_NOT_SUPPORTED(r))
796796
log_warning("Password quality check is not supported, proceeding anyway.");

src/shared/pwquality-util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ int suggest_passwords(void) {
132132
return 1;
133133
}
134134

135-
int quality_check_password(const char *password, const char *username, char **ret_error) {
135+
int quality_check_password(const char *password, const char *old, const char *username, char **ret_error) {
136136
_cleanup_(sym_pwquality_free_settingsp) pwquality_settings_t *pwq = NULL;
137137
char buf[PWQ_MAX_ERROR_MESSAGE_LEN];
138138
void *auxerror;
@@ -144,7 +144,7 @@ int quality_check_password(const char *password, const char *username, char **re
144144
if (r < 0)
145145
return log_debug_errno(r, "Failed to allocate libpwquality context: %m");
146146

147-
r = sym_pwquality_check(pwq, password, NULL, username, &auxerror);
147+
r = sym_pwquality_check(pwq, password, old, username, &auxerror);
148148
if (r < 0) {
149149

150150
if (ret_error) {

src/shared/pwquality-util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(pwquality_settings_t*, sym_pwquality_free_setti
2424
void pwq_maybe_disable_dictionary(pwquality_settings_t *pwq);
2525
int pwq_allocate_context(pwquality_settings_t **ret);
2626
int suggest_passwords(void);
27-
int quality_check_password(const char *password, const char *username, char **ret_error);
27+
int quality_check_password(const char *password, const char *old, const char *username, char **ret_error);
2828

2929
#else
3030

3131
static inline int suggest_passwords(void) {
3232
return 0;
3333
}
3434

35-
static inline int quality_check_password(const char *password, const char *username, char **ret_error) {
35+
static inline int quality_check_password(const char *password, const char *old, const char *username, char **ret_error) {
3636
if (ret_error)
3737
*ret_error = NULL;
3838
return 1; /* all good */

0 commit comments

Comments
 (0)