summaryrefslogtreecommitdiff
path: root/src/home/home-util.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-09-08 15:21:21 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-09-15 11:52:30 +0200
commit2ae297fe0d8b0736ee16b3be47ef62e17b4afe4e (patch)
treea274d294137dd41b31c24aff1ab16a4029628069 /src/home/home-util.c
parenta937ce2d8545568c1de3ba0370fd621ffcbdd8ff (diff)
downloadsystemd-2ae297fe0d8b0736ee16b3be47ef62e17b4afe4e.tar.gz
Move test_password_{one,many} to libcrypt-util.c
They are only used under src/home/, but I want to add tests in test-libcrypt-util.c. And the functions are almost trivial, so I think it is OK to move them to shared.
Diffstat (limited to 'src/home/home-util.c')
-rw-r--r--src/home/home-util.c33
1 files changed, 0 insertions, 33 deletions
diff --git a/src/home/home-util.c b/src/home/home-util.c
index 3fd57639f8..8e28e3ab76 100644
--- a/src/home/home-util.c
+++ b/src/home/home-util.c
@@ -1,7 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#include "dns-domain.h"
-#include "errno-util.h"
#include "home-util.h"
#include "libcrypt-util.h"
#include "memory-util.h"
@@ -134,35 +133,3 @@ int bus_message_append_secret(sd_bus_message *m, UserRecord *secret) {
return sd_bus_message_append(m, "s", formatted);
}
-
-int test_password_one(const char *hashed_password, const char *password) {
- struct crypt_data cc = {};
- const char *k;
- bool b;
-
- errno = 0;
- k = crypt_r(password, hashed_password, &cc);
- if (!k) {
- explicit_bzero_safe(&cc, sizeof(cc));
- return errno_or_else(EINVAL);
- }
-
- b = streq(k, hashed_password);
- explicit_bzero_safe(&cc, sizeof(cc));
- return b;
-}
-
-int test_password_many(char **hashed_password, const char *password) {
- char **hpw;
- int r;
-
- STRV_FOREACH(hpw, hashed_password) {
- r = test_password_one(*hpw, password);
- if (r < 0)
- return r;
- if (r > 0)
- return true;
- }
-
- return false;
-}