diff --git a/meson.build b/meson.build index 36314f7157..d719160a1f 100644 --- a/meson.build +++ b/meson.build @@ -884,8 +884,9 @@ libcrypt = cc.find_library('crypt') crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include ''' : '''#include ''' foreach ident : [ - ['crypt_ra', crypt_header], - ['crypt_gensalt_ra', crypt_header]] + ['crypt_ra', crypt_header], + ['crypt_preferred_method', crypt_header], + ['crypt_gensalt_ra', crypt_header]] have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE', dependencies : libcrypt) diff --git a/src/shared/libcrypt-util.c b/src/shared/libcrypt-util.c index c5d98671bd..8a46ace205 100644 --- a/src/shared/libcrypt-util.c +++ b/src/shared/libcrypt-util.c @@ -40,7 +40,11 @@ int make_salt(char **ret) { e = secure_getenv("SYSTEMD_CRYPT_PREFIX"); if (!e) +#if HAVE_CRYPT_PREFERRED_METHOD e = crypt_preferred_method(); +#else + e = "$6$"; +#endif log_debug("Generating salt for hash prefix: %s", e);