mirror of
https://https.git.savannah.gnu.org/git/coreutils.git
synced 2026-01-26 15:29:07 +00:00
build: fix libcrypto version linked by sort at runtime
One should link the versioned lib at runtime, and the unversioned lib at build time, as the unversioned lib may not be installed, and better couples the binary with the required version. * configure.ac: Define LIBCRYPTO_SONAME, determined from the test binary linked with -lcrypto. Also document why we use SHA512() in the check, rather than MD5(). * src/sort.c (link_libcrypto): Use the versioned lib in dlopen().
This commit is contained in:
parent
10be42f033
commit
3bbdb39388
13
configure.ac
13
configure.ac
@ -365,12 +365,16 @@ AS_CASE([$LIB_CRYPTO],
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <dlfcn.h>
|
||||
#include <openssl/sha.h>
|
||||
/* Use SHA512 rather than MD5 here to avoid deprecation warnings.
|
||||
So need to check HAVE_OPENSSL_MD5.. with DLOPEN_LIBCRYPTO. */
|
||||
]],
|
||||
[[return !(dlopen ("libcrypto.so", RTLD_LAZY | RTLD_GLOBAL)
|
||||
&& SHA512 (0, 0, 0));]])],
|
||||
[# readelf works with cross-builds; ldd works on more platforms.
|
||||
AS_CASE([`(readelf -d conftest$EXEEXT || ldd conftest$EXEEXT
|
||||
) 2>/dev/null`],
|
||||
LIBCRYPTO_SONAME="`(readelf -d conftest$EXEEXT || ldd conftest$EXEEXT
|
||||
) 2>/dev/null |
|
||||
sed -n 's/.*\(libcrypto.so.[[.0-9]]*\).*/\1/p'`"
|
||||
AS_CASE([$LIBCRYPTO_SONAME],
|
||||
[*libcrypto*],
|
||||
[utils_cv_dlopen_libcrypto=yes])])
|
||||
LIBS=$saved_LIBS])
|
||||
@ -378,7 +382,10 @@ AS_CASE([$LIB_CRYPTO],
|
||||
[yes],
|
||||
[AC_DEFINE([DLOPEN_LIBCRYPTO], [1],
|
||||
[Define to 1 if dlopen exists and libcrypto is
|
||||
linked dynamically.])])])
|
||||
linked dynamically.])
|
||||
AC_DEFINE_UNQUOTED([LIBCRYPTO_SONAME], ["$LIBCRYPTO_SONAME"],
|
||||
[versioned libcrypto])
|
||||
])])
|
||||
|
||||
# macOS >= 10.12
|
||||
AC_CHECK_FUNCS([fclonefileat])
|
||||
|
||||
@ -2125,7 +2125,7 @@ static void
|
||||
link_libcrypto (void)
|
||||
{
|
||||
#if DLOPEN_LIBCRYPTO && HAVE_OPENSSL_MD5
|
||||
void *handle = dlopen ("libcrypto.so", RTLD_LAZY | RTLD_GLOBAL);
|
||||
void *handle = dlopen (LIBCRYPTO_SONAME, RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (!handle)
|
||||
link_failure ();
|
||||
ptr_MD5_Init = symbol_address (handle, "MD5_Init");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user