]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-libcrypt-util: print out default for password settings, run make_salt() a few...
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 8 Jun 2021 11:48:10 +0000 (13:48 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 8 Jun 2021 19:41:17 +0000 (21:41 +0200)
Inspired by
https://fedoraproject.org/wiki/Changes/yescrypt_as_default_hashing_method_for_shadow.

src/test/meson.build
src/test/test-libcrypt-util.c

index c7b2bbfedc36cea550c6b2d025aa9362cc393c36..29f488f4d86cf386a938b26a6da78d111819d813 100644 (file)
@@ -224,7 +224,7 @@ tests += [
         [['src/test/test-os-util.c']],
 
         [['src/test/test-libcrypt-util.c'],
-         [], [], [], '', 'timeout=120'],
+         [], [libcrypt], [], '', 'timeout=120'],
 
         [['src/test/test-escape.c']],
 
index cd296d698e1c5b2b9b5a16c5754335ffbd5455d5..360db2816d442f8e880bc3b8c2c861eac343ead8 100644 (file)
 #include "tests.h"
 #include "libcrypt-util.h"
 
+static void test_crypt_preferred_method(void) {
+        log_info("/* %s */", __func__);
+
+        log_info("crypt_preferred_method: %s",
+#if HAVE_CRYPT_PREFERRED_METHOD
+                 crypt_preferred_method()
+#else
+                 "(not available)"
+#endif
+        );
+}
+
+static void test_make_salt(void) {
+        log_info("/* %s */", __func__);
+
+        for (int i = 0; i < 10; i++) {
+                _cleanup_free_ char *t;
+
+                assert_se(make_salt(&t) == 0);
+                log_info("%s", t);
+        }
+}
+
 static int test_hash_password(void) {
         log_info("/* %s */", __func__);
 
@@ -93,6 +116,9 @@ int main(int argc, char *argv[]) {
         return log_tests_skipped("crypt_r() causes a buffer overflow on ppc64el, see https://github.com/systemd/systemd/pull/16981#issuecomment-691203787");
 #endif
 
+        test_crypt_preferred_method();
+        test_make_salt();
+
         if (!test_hash_password())
                 return log_tests_skipped("crypt doesn't support yescrypt or sha512crypt");