1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-27 18:55:40 +03:00

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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-06-08 13:48:10 +02:00 committed by Lennart Poettering
parent a77f9dfbae
commit 7ff9d99e9e
2 changed files with 27 additions and 1 deletions

View 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']],

View File

@ -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");