From: Zbigniew Jędrzejewski-Szmek Date: Tue, 8 Jun 2021 11:48:10 +0000 (+0200) Subject: test-libcrypt-util: print out default for password settings, run make_salt() a few... X-Git-Tag: v249-rc1~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ff9d99e9e8b75930aa05b45eb21889eac8af014;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/test/meson.build b/src/test/meson.build index c7b2bbfedc3..29f488f4d86 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 cd296d698e1..360db2816d4 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");