From 76ceb73044b594d9a547dfeb97f607cdd2a878f9 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Jul 09 2021 17:07:38 +0000 Subject: test-libcrypt-util: print out default for password settings, run make_salt() a few times Inspired by https://fedoraproject.org/wiki/Changes/yescrypt_as_default_hashing_method_for_shadow. (cherry picked from commit 7ff9d99e9e8b75930aa05b45eb21889eac8af014) --- diff --git a/src/test/meson.build b/src/test/meson.build index 283bf83..5d5cd38 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -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']], diff --git a/src/test/test-libcrypt-util.c b/src/test/test-libcrypt-util.c index cd296d6..360db28 100644 --- a/src/test/test-libcrypt-util.c +++ b/src/test/test-libcrypt-util.c @@ -10,6 +10,29 @@ #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");