Skip to content

bpo-45808: Fix check for crypt_r on platforms without crypt.h #29563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Correct check for ``crypt_r`` on platforms without ``crypt.h``.
45 changes: 17 additions & 28 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -14052,9 +14052,9 @@ done


# We search for both crypt and crypt_r as one or the other may be defined
# This gets us our -lcrypt in LIBS when required on the target platform.
# Save/restore LIBS to avoid linking libpython with libcrypt.
# Some platforms have crypt.h, others like FreeBSD have crypt*() in unistd.h
LIBS_SAVE=$LIBS
LIBCRYPT=
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing crypt_r" >&5
$as_echo_n "checking for library containing crypt_r... " >&6; }
if ${ac_cv_search_crypt_r+:} false; then :
Expand Down Expand Up @@ -14109,6 +14109,13 @@ ac_res=$ac_cv_search_crypt_r
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"


$as_echo "#define HAVE_CRYPT_R 1" >>confdefs.h

if test "$ac_cv_search_crypt_r" != "none required"; then
LIBCRYPT="$ac_cv_search_crypt_r"
fi

fi

LIBS="$LIBS_SAVE"
Expand Down Expand Up @@ -14166,35 +14173,17 @@ ac_res=$ac_cv_search_crypt
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"

fi


ac_fn_c_check_func "$LINENO" "crypt_r" "ac_cv_func_crypt_r"
if test "x$ac_cv_func_crypt_r" = xyes; then :
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

#include <crypt.h>

int
main ()
{

struct crypt_data d;
char *r = crypt_r("", "", &d);

;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :

$as_echo "#define HAVE_CRYPT_R 1" >>confdefs.h
if test "$ac_cv_search_crypt" != "none required"; then
LIBCRYPT="$ac_cv_search_crypt"
fi

fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for crypt(_r) linker argument" >&5
$as_echo_n "checking for crypt(_r) linker argument... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBCRYPT" >&5
$as_echo "$LIBCRYPT" >&6; }

LIBS=$LIBS_SAVE

Expand Down
30 changes: 16 additions & 14 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4072,23 +4072,25 @@ AC_CHECK_FUNCS(setpgrp,
)

# We search for both crypt and crypt_r as one or the other may be defined
# This gets us our -lcrypt in LIBS when required on the target platform.
# Save/restore LIBS to avoid linking libpython with libcrypt.
# Some platforms have crypt.h, others like FreeBSD have crypt*() in unistd.h
LIBS_SAVE=$LIBS
AC_SEARCH_LIBS(crypt_r, crypt)
LIBCRYPT=
AC_SEARCH_LIBS([crypt_r], [crypt], [
AC_DEFINE(HAVE_CRYPT_R, 1, [Define if you have the crypt_r() function.])
if test "$ac_cv_search_crypt_r" != "none required"; then
LIBCRYPT="$ac_cv_search_crypt_r"
fi
])
LIBS="$LIBS_SAVE"
AC_SEARCH_LIBS(crypt, crypt)
AC_SEARCH_LIBS([crypt], [crypt], [
if test "$ac_cv_search_crypt" != "none required"; then
LIBCRYPT="$ac_cv_search_crypt"
fi
])

AC_MSG_CHECKING([for crypt(_r) linker argument])
AC_MSG_RESULT([$LIBCRYPT])

AC_CHECK_FUNC(crypt_r,
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <crypt.h>
]], [[
struct crypt_data d;
char *r = crypt_r("", "", &d);
]])],
[AC_DEFINE(HAVE_CRYPT_R, 1, [Define if you have the crypt_r() function.])],
[])
)
LIBS=$LIBS_SAVE

AC_CHECK_FUNCS(clock_gettime, [], [
Expand Down