diff --git a/README b/README index 0062563d5c..5fff47827f 100644 --- a/README +++ b/README @@ -212,6 +212,7 @@ REQUIREMENTS: newer though. TL;DR: turn audit off, still. glibc >= 2.31 + libxcrypt or glibc (<= 2.38 built with --enable-crypt) libcap libmount >= 2.30 (from util-linux) (util-linux *must* be built without --enable-libmount-support-mtab) diff --git a/meson.build b/meson.build index c5c08928f8..9f94162c60 100644 --- a/meson.build +++ b/meson.build @@ -685,15 +685,22 @@ conf.set('GPERF_LEN_TYPE', gperf_len_type, ##################################################################### -if not cc.has_header('sys/capability.h') - error('POSIX caps headers not found') -endif -foreach header : ['crypt.h', - 'sys/sdt.h', - 'threads.h', - 'valgrind/memcheck.h', - 'valgrind/valgrind.h', - ] +foreach header : [ + 'crypt.h', + 'sys/capability.h', +] + + if not cc.has_header(header) + error('Header file @0@ not found.'.format(header)) + endif +endforeach + +foreach header : [ + 'sys/sdt.h', + 'threads.h', + 'valgrind/memcheck.h', + 'valgrind/valgrind.h', +] conf.set10('HAVE_' + header.underscorify().to_upper(), cc.has_header(header)) @@ -989,11 +996,6 @@ threads = dependency('threads') librt = cc.find_library('rt') libm = cc.find_library('m') libdl = cc.find_library('dl') -libcrypt = dependency('libcrypt', 'libxcrypt', required : false) -if not libcrypt.found() - # fallback to use find_library() if libcrypt is provided by glibc, e.g. for LibreELEC. - libcrypt = cc.find_library('crypt') -endif libcap = dependency('libcap') # On some architectures, libatomic is required. But on some installations, @@ -1007,15 +1009,21 @@ else libatomic = [] endif -crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include ''' : '''#include ''' -foreach ident : [ - ['crypt_ra', crypt_header], - ['crypt_preferred_method', crypt_header], - ['crypt_gensalt_ra', crypt_header]] +libcrypt = dependency('libcrypt', 'libxcrypt', required : false) +if not libcrypt.found() + # fallback to use find_library() if libcrypt is provided by glibc, e.g. for LibreELEC. + libcrypt = cc.find_library('crypt') +endif - have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE', +foreach func : [ + 'crypt_ra', # since libxcrypt-4.0.0 + 'crypt_gensalt_ra', # since libxcrypt-4.0.0 + 'crypt_preferred_method', # since libxcrypt-4.4.0 +] + + have = cc.has_function(func, prefix : '''#include ''', args : '-D_GNU_SOURCE', dependencies : libcrypt) - conf.set10('HAVE_' + ident[0].to_upper(), have) + conf.set10('HAVE_' + func.to_upper(), have) endforeach bpf_framework = get_option('bpf-framework') diff --git a/src/shared/libcrypt-util.c b/src/shared/libcrypt-util.c index aa41cd4458..42c6feaabe 100644 --- a/src/shared/libcrypt-util.c +++ b/src/shared/libcrypt-util.c @@ -1,20 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#if HAVE_CRYPT_H -/* libxcrypt is a replacement for glibc's libcrypt, and libcrypt might be - * removed from glibc at some point. As part of the removal, defines for - * crypt(3) are dropped from unistd.h, and we must include crypt.h instead. - * - * Newer versions of glibc (v2.0+) already ship crypt.h with a definition - * of crypt(3) as well, so we simply include it if it is present. MariaDB, - * MySQL, PostgreSQL, Perl and some other wide-spread packages do it the - * same way since ages without any problems. - */ -# include -#else -# include -#endif - +#include #include #include "alloc-util.h" diff --git a/src/test/test-libcrypt-util.c b/src/test/test-libcrypt-util.c index f544a0003e..92eda2e1a7 100644 --- a/src/test/test-libcrypt-util.c +++ b/src/test/test-libcrypt-util.c @@ -1,10 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#if HAVE_CRYPT_H -# include -#else -# include -#endif +#include #include "libcrypt-util.h" #include "strv.h"