2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 01:49:11 +00:00

Use SUDO_APPEND_LIBPATH when appending to LIBTLS and LIBMD.

The OpenSSL pkgconfig files only include -L paths, not -R paths.
Using SUDO_APPEND_LIBPATH ensures the rpath is set correctly so the
binaries will run (not just link).
This commit is contained in:
Todd C. Miller 2021-09-13 09:33:12 -06:00
parent 921bc1c697
commit 229dfe175d
2 changed files with 331 additions and 4 deletions

303
configure vendored
View File

@ -23396,14 +23396,238 @@ fi
LDFLAGS="$O_LDFLAGS"
# Use pkg-config to determine OpenSSL libs and cflags
LIBTLS=`$PKG_CONFIG $STATIC --libs $pkg_openssl`
for f in `$PKG_CONFIG $STATIC --libs $pkg_openssl`; do
case "$f" in
-L*)
f="${f#-L}"
if test ${LIBTLS+y}
then :
case " $LIBTLS " in #(
*" -L$f "*) :
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LIBTLS already contains -L\$f"; } >&5
(: LIBTLS already contains -L$f) 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } ;; #(
*) :
as_fn_append LIBTLS " -L$f"
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LIBTLS=\"\$LIBTLS\""; } >&5
(: LIBTLS="$LIBTLS") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
;;
esac
else $as_nop
LIBTLS=-L$f
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LIBTLS=\"\$LIBTLS\""; } >&5
(: LIBTLS="$LIBTLS") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
fi
if test X"$enable_rpath" = X"yes"; then
if test ${LIBTLS_R+y}
then :
case " $LIBTLS_R " in #(
*" -R$f "*) :
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LIBTLS_R already contains -R\$f"; } >&5
(: LIBTLS_R already contains -R$f) 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } ;; #(
*) :
as_fn_append LIBTLS_R " -R$f"
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LIBTLS_R=\"\$LIBTLS_R\""; } >&5
(: LIBTLS_R="$LIBTLS_R") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
;;
esac
else $as_nop
LIBTLS_R=-R$f
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LIBTLS_R=\"\$LIBTLS_R\""; } >&5
(: LIBTLS_R="$LIBTLS_R") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
fi
fi
;;
*)
if test ${LIBTLS+y}
then :
case " $LIBTLS " in #(
*" $f "*) :
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LIBTLS already contains \$f"; } >&5
(: LIBTLS already contains $f) 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } ;; #(
*) :
as_fn_append LIBTLS " $f"
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LIBTLS=\"\$LIBTLS\""; } >&5
(: LIBTLS="$LIBTLS") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
;;
esac
else $as_nop
LIBTLS=$f
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LIBTLS=\"\$LIBTLS\""; } >&5
(: LIBTLS="$LIBTLS") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
fi
;;
esac
done
if test "$DIGEST" = "digest_openssl.lo"; then
pkg_libcrypto=lib`printf $enable_openssl_pkgconfig_template "crypto"`
if $PKG_CONFIG --exists $pkg_libcrypto >/dev/null 2>&1; then
LIBMD=`$PKG_CONFIG $STATIC --libs $pkg_libcrypto`
for f in `$PKG_CONFIG $STATIC --libs $pkg_libcrypto`; do
case "$f" in
-L*)
f="${f#-L}"
if test ${LIBMD+y}
then :
case " $LIBMD " in #(
*" -L$f "*) :
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LIBMD already contains -L\$f"; } >&5
(: LIBMD already contains -L$f) 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } ;; #(
*) :
as_fn_append LIBMD " -L$f"
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LIBMD=\"\$LIBMD\""; } >&5
(: LIBMD="$LIBMD") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
;;
esac
else $as_nop
LIBMD=-L$f
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LIBMD=\"\$LIBMD\""; } >&5
(: LIBMD="$LIBMD") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
fi
if test X"$enable_rpath" = X"yes"; then
if test ${LIBMD_R+y}
then :
case " $LIBMD_R " in #(
*" -R$f "*) :
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LIBMD_R already contains -R\$f"; } >&5
(: LIBMD_R already contains -R$f) 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } ;; #(
*) :
as_fn_append LIBMD_R " -R$f"
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LIBMD_R=\"\$LIBMD_R\""; } >&5
(: LIBMD_R="$LIBMD_R") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
;;
esac
else $as_nop
LIBMD_R=-R$f
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LIBMD_R=\"\$LIBMD_R\""; } >&5
(: LIBMD_R="$LIBMD_R") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
fi
fi
;;
*)
if test ${LIBMD+y}
then :
case " $LIBMD " in #(
*" $f "*) :
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LIBMD already contains \$f"; } >&5
(: LIBMD already contains $f) 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } ;; #(
*) :
as_fn_append LIBMD " $f"
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LIBMD=\"\$LIBMD\""; } >&5
(: LIBMD="$LIBMD") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
;;
esac
else $as_nop
LIBMD=$f
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LIBMD=\"\$LIBMD\""; } >&5
(: LIBMD="$LIBMD") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
fi
;;
esac
done
else
# No separate pkg config for libcrypto
LIBMD="$LIBTLS"
LIBMD_R="$LIBTLS_R"
fi
fi
for f in `$PKG_CONFIG --cflags-only-I $pkg_openssl`; do
@ -23445,7 +23669,76 @@ fi
# No pkg-config file present, try to do it manually
O_LDFLAGS="$LDFLAGS"
if test "$enable_openssl" != "yes" -a "$enable_openssl" != "maybe"; then
LDFLAGS="$LDFLAGS -L${enable_openssl}/lib"
if test ${LDFLAGS+y}
then :
case " $LDFLAGS " in #(
*" -L${enable_openssl}/lib "*) :
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LDFLAGS already contains -L\${enable_openssl}/lib"; } >&5
(: LDFLAGS already contains -L${enable_openssl}/lib) 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } ;; #(
*) :
as_fn_append LDFLAGS " -L${enable_openssl}/lib"
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LDFLAGS=\"\$LDFLAGS\""; } >&5
(: LDFLAGS="$LDFLAGS") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
;;
esac
else $as_nop
LDFLAGS=-L${enable_openssl}/lib
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LDFLAGS=\"\$LDFLAGS\""; } >&5
(: LDFLAGS="$LDFLAGS") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
fi
if test X"$enable_rpath" = X"yes"; then
if test ${LDFLAGS_R+y}
then :
case " $LDFLAGS_R " in #(
*" -R${enable_openssl}/lib "*) :
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LDFLAGS_R already contains -R\${enable_openssl}/lib"; } >&5
(: LDFLAGS_R already contains -R${enable_openssl}/lib) 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } ;; #(
*) :
as_fn_append LDFLAGS_R " -R${enable_openssl}/lib"
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LDFLAGS_R=\"\$LDFLAGS_R\""; } >&5
(: LDFLAGS_R="$LDFLAGS_R") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
;;
esac
else $as_nop
LDFLAGS_R=-R${enable_openssl}/lib
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LDFLAGS_R=\"\$LDFLAGS_R\""; } >&5
(: LDFLAGS_R="$LDFLAGS_R") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
fi
fi
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SSL_new in -lssl" >&5
printf %s "checking for SSL_new in -lssl... " >&6; }
@ -30981,6 +31274,12 @@ fi
if test X"$ZLIB_R" != X""; then
ZLIB="$ZLIB_R $ZLIB"
fi
if test X"$LIBMD_R" != X""; then
LIBMD="$LIBMD_R $LIBMD"
fi
if test X"$LIBTLS_R" != X""; then
LIBTLS="$LIBTLS_R $LIBTLS"
fi
CFLAGS=${CFLAGS# }
CPPFLAGS=${CPPFLAGS# }

View File

@ -2961,14 +2961,36 @@ if test "${enable_openssl-no}" != no; then
LDFLAGS="$O_LDFLAGS"
# Use pkg-config to determine OpenSSL libs and cflags
LIBTLS=`$PKG_CONFIG $STATIC --libs $pkg_openssl`
for f in `$PKG_CONFIG $STATIC --libs $pkg_openssl`; do
case "$f" in
-L*)
f="${f#-L}"
SUDO_APPEND_LIBPATH([LIBTLS], [$f])
;;
*)
AX_APPEND_FLAG([$f], [LIBTLS])
;;
esac
done
if test "$DIGEST" = "digest_openssl.lo"; then
pkg_libcrypto=lib`printf $enable_openssl_pkgconfig_template "crypto"`
if $PKG_CONFIG --exists $pkg_libcrypto >/dev/null 2>&1; then
LIBMD=`$PKG_CONFIG $STATIC --libs $pkg_libcrypto`
for f in `$PKG_CONFIG $STATIC --libs $pkg_libcrypto`; do
case "$f" in
-L*)
f="${f#-L}"
SUDO_APPEND_LIBPATH([LIBMD], [$f])
;;
*)
AX_APPEND_FLAG([$f], [LIBMD])
;;
esac
done
else
# No separate pkg config for libcrypto
LIBMD="$LIBTLS"
LIBMD_R="$LIBTLS_R"
fi
fi
for f in `$PKG_CONFIG --cflags-only-I $pkg_openssl`; do
@ -2978,7 +3000,7 @@ if test "${enable_openssl-no}" != no; then
# No pkg-config file present, try to do it manually
O_LDFLAGS="$LDFLAGS"
if test "$enable_openssl" != "yes" -a "$enable_openssl" != "maybe"; then
LDFLAGS="$LDFLAGS -L${enable_openssl}/lib"
SUDO_APPEND_LIBPATH(LDFLAGS, [${enable_openssl}/lib])
fi
AC_CHECK_LIB(ssl, SSL_new, [
# Check OPENSSL_VERSION_NUMBER in headers
@ -4862,6 +4884,12 @@ fi
if test X"$ZLIB_R" != X""; then
ZLIB="$ZLIB_R $ZLIB"
fi
if test X"$LIBMD_R" != X""; then
LIBMD="$LIBMD_R $LIBMD"
fi
if test X"$LIBTLS_R" != X""; then
LIBTLS="$LIBTLS_R $LIBTLS"
fi
dnl
dnl Trim leading spaces