mirror of
https://github.com/systemd/systemd.git
synced 2024-11-02 10:51:20 +03:00
shared/libcrypt-util: do not refuse passwords if some other hash is unsupported
This commit is contained in:
parent
9de324c3c9
commit
35e22827a9
@ -182,8 +182,12 @@ int test_password_one(const char *hashed_password, const char *password) {
|
||||
|
||||
errno = 0;
|
||||
k = crypt_ra(password, hashed_password, &cd_data, &cd_size);
|
||||
if (!k)
|
||||
return errno_or_else(EINVAL);
|
||||
if (!k) {
|
||||
if (errno == ENOMEM)
|
||||
return -ENOMEM;
|
||||
/* Unknown or unavailable hashing method or string too short */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return streq(k, hashed_password);
|
||||
}
|
||||
|
@ -40,10 +40,18 @@ static void test_hash_password_full(void) {
|
||||
hashed,
|
||||
"$y$j9T$SAayASazWZIQeJd9AS02m/$"),
|
||||
i) == true);
|
||||
assert_se(test_password_many(STRV_MAKE("$W$j9T$dlCXwkX0GC5L6B8Gf.4PN/$VCyEH", /* no such method exists... */
|
||||
hashed,
|
||||
"$y$j9T$SAayASazWZIQeJd9AS02m/$"),
|
||||
i) == true);
|
||||
assert_se(test_password_many(STRV_MAKE("$y$j9T$dlCXwkX0GC5L6B8Gf.4PN/$VCyEH",
|
||||
hashed,
|
||||
"$y$j9T$SAayASazWZIQeJd9AS02m/$"),
|
||||
"") == false);
|
||||
assert_se(test_password_many(STRV_MAKE("$W$j9T$dlCXwkX0GC5L6B8Gf.4PN/$VCyEH", /* no such method exists... */
|
||||
hashed,
|
||||
"$y$j9T$SAayASazWZIQeJd9AS02m/$"),
|
||||
"") == false);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user