]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
libcrypt-util: use build-time check for crypt_preferred_method
authorLuca Boccassi <luca.boccassi@microsoft.com>
Fri, 25 Sep 2020 10:19:56 +0000 (11:19 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 28 Sep 2020 08:23:48 +0000 (10:23 +0200)
After https://github.com/systemd/systemd/pull/16981 only the presence of crypt_gensalt_ra
is checked, but there are cases where that function is available but crypt_preferred_method
is not, and they are used in the same ifdef.
Add a check for the latter as well.

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

index 36314f7157b8a27822ffe0785bd3c2a8465a86c0..d719160a1f4cc4719f0efcedfdfc0ca57313b7bd 100644 (file)
@@ -884,8 +884,9 @@ libcrypt = cc.find_library('crypt')
 
 crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
 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)
index c5d98671bd6d672f49c1fd9398e245fae4c9f254..8a46ace205a921c279df611e92c03172581511ea 100644 (file)
@@ -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);