From 8fef6f72f4bf01a37f886bb8db5aeb563ffca5d8 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 1 Feb 2012 12:12:53 -0500 Subject: [PATCH] Error out if user specified --with-pam but we can't find the headers or library. Also throw an error if the headers are present but the library is not and vice versa. --HG-- branch : 1.7 --- configure | 74 ++++++++++++++++++++++++++++++++++++---------------- configure.in | 50 +++++++++++++++++++++++------------ 2 files changed, 85 insertions(+), 39 deletions(-) diff --git a/configure b/configure index d2eb695c6..f178ba421 100755 --- a/configure +++ b/configure @@ -17454,50 +17454,58 @@ if test -z "${AUTH_EXCL}${AUTH_REG}" -a -n "$AUTH_EXCL_DEF"; then fi if test ${with_pam-"no"} != "no"; then - case "$LIBS" in - *-ldl*) SUDO_LIBS="${SUDO_LIBS} -lpam" - ;; - *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -ldl" >&5 -$as_echo_n "checking for main in -ldl... " >&6; } -if ${ac_cv_lib_dl_main+:} false; then : + # + # Check for pam_start() in libpam first, then for pam_appl.h. + # + found_pam_lib=no + as_ac_Lib=`$as_echo "ac_cv_lib_pam_pam_start$lt_cv_dlopen_libs" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pam_start in -lpam" >&5 +$as_echo_n "checking for pam_start in -lpam... " >&6; } +if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" +LIBS="-lpam $lt_cv_dlopen_libs $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pam_start (); int main () { -return main (); +return pam_start (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dl_main=yes + eval "$as_ac_Lib=yes" else - ac_cv_lib_dl_main=no + eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_main" >&5 -$as_echo "$ac_cv_lib_dl_main" >&6; } -if test "x$ac_cv_lib_dl_main" = xyes; then : - SUDO_LIBS="${SUDO_LIBS} -lpam -ldl" -else - SUDO_LIBS="${SUDO_LIBS} -lpam" +eval ac_res=\$$as_ac_Lib + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : + found_pam_lib=yes fi - ac_cv_lib_dl=ac_cv_lib_dl_main - ;; - esac - - for ac_header in security/pam_appl.h pam/pam_appl.h + # + # Some PAM implementations (MacOS X for example) put the PAM headers + # in /usr/include/pam instead of /usr/include/security... + # + found_pam_hdrs=no + for ac_header in security/pam_appl.h pam/pam_appl.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -17505,12 +17513,32 @@ if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF - with_pam=yes; break + found_pam_hdrs=yes; break fi done + if test "$found_pam_lib" = "yes" -a "$found_pam_hdrs" = "yes"; then + # Found both PAM libs and headers + with_pam=yes + elif test "$with_pam" = "yes"; then + if test "$found_pam_lib" = "no"; then + as_fn_error $? "\"--with-pam specified but unable to locate PAM development library.\"" "$LINENO" 5 + fi + if test "$found_pam_hdrs" = "no"; then + as_fn_error $? "\"--with-pam specified but unable to locate PAM development headers.\"" "$LINENO" 5 + fi + elif test "$found_pam_lib" != "$found_pam_hdrs"; then + if test "$found_pam_lib" = "no"; then + as_fn_error $? "\"found PAM headers but no PAM development library; specify --without-pam to build without PAM\"" "$LINENO" 5 + fi + if test "$found_pam_hdrs" = "no"; then + as_fn_error $? "\"found PAM library but no PAM development headers; specify --without-pam to build without PAM\"" "$LINENO" 5 + fi + fi + if test "$with_pam" = "yes"; then + SUDO_LIBS="${SUDO_LIBS} -lpam $lt_cv_dlopen_libs" $as_echo "#define HAVE_PAM 1" >>confdefs.h AUTH_OBJS="$AUTH_OBJS pam.o"; diff --git a/configure.in b/configure.in index d4e158821..7392baecf 100644 --- a/configure.in +++ b/configure.in @@ -2266,23 +2266,41 @@ dnl PAM support. Systems that use PAM by default set with_pam=default dnl and we do the actual tests here. dnl if test ${with_pam-"no"} != "no"; then - dnl - dnl Some platforms need libdl for dlopen - dnl - case "$LIBS" in - *-ldl*) SUDO_LIBS="${SUDO_LIBS} -lpam" - ;; - *) AC_CHECK_LIB([dl], [main], [SUDO_LIBS="${SUDO_LIBS} -lpam -ldl"], [SUDO_LIBS="${SUDO_LIBS} -lpam"]) - ac_cv_lib_dl=ac_cv_lib_dl_main - ;; - esac - - dnl - dnl Some PAM implementations (MacOS X for example) put the PAM headers - dnl in /usr/include/pam instead of /usr/include/security... - dnl - AC_CHECK_HEADERS([security/pam_appl.h] [pam/pam_appl.h], [with_pam=yes; break]) + # + # Check for pam_start() in libpam first, then for pam_appl.h. + # + found_pam_lib=no + AC_CHECK_LIB(pam, pam_start, [found_pam_lib=yes], [], [$lt_cv_dlopen_libs]) + # + # Some PAM implementations (MacOS X for example) put the PAM headers + # in /usr/include/pam instead of /usr/include/security... + # + found_pam_hdrs=no + AC_CHECK_HEADERS([security/pam_appl.h] [pam/pam_appl.h], [found_pam_hdrs=yes; break]) + if test "$found_pam_lib" = "yes" -a "$found_pam_hdrs" = "yes"; then + # Found both PAM libs and headers + with_pam=yes + elif test "$with_pam" = "yes"; then + if test "$found_pam_lib" = "no"; then + AC_MSG_ERROR(["--with-pam specified but unable to locate PAM development library."]) + fi + if test "$found_pam_hdrs" = "no"; then + AC_MSG_ERROR(["--with-pam specified but unable to locate PAM development headers."]) + fi + elif test "$found_pam_lib" != "$found_pam_hdrs"; then + if test "$found_pam_lib" = "no"; then + AC_MSG_ERROR(["found PAM headers but no PAM development library; specify --without-pam to build without PAM"]) + fi + if test "$found_pam_hdrs" = "no"; then + AC_MSG_ERROR(["found PAM library but no PAM development headers; specify --without-pam to build without PAM"]) + fi + fi + if test "$with_pam" = "yes"; then + dnl + dnl Some platforms need libdl for dlopen + dnl + SUDO_LIBS="${SUDO_LIBS} -lpam $lt_cv_dlopen_libs" AC_DEFINE(HAVE_PAM) AUTH_OBJS="$AUTH_OBJS pam.o"; AUTH_EXCL=PAM -- 2.40.0