Skip to content
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

bpo-45847: Port _crypt to PY_STDLIB_MOD (GH-29725) #29725

Merged
merged 1 commit into from
Nov 23, 2021
Merged
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
2 changes: 2 additions & 0 deletions Modules/Setup.stdlib.in
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@
# Modules with some UNIX dependencies
#

# needs -lcrypt on some systems
@MODULE__CRYPT_TRUE@_crypt _cryptmodule.c
@MODULE_FCNTL_TRUE@fcntl fcntlmodule.c
@MODULE_GRP_TRUE@grp grpmodule.c
@MODULE_MMAP_TRUE@mmap mmapmodule.c
Expand Down
254 changes: 223 additions & 31 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,8 @@ MODULE_NIS_FALSE
MODULE_NIS_TRUE
MODULE__DECIMAL_FALSE
MODULE__DECIMAL_TRUE
MODULE__CRYPT_FALSE
MODULE__CRYPT_TRUE
MODULE__BLAKE2_FALSE
MODULE__BLAKE2_TRUE
MODULE__SHA3_FALSE
Expand Down Expand Up @@ -784,6 +786,8 @@ HAVE_GETHOSTBYNAME_R
HAVE_GETHOSTBYNAME_R_3_ARG
HAVE_GETHOSTBYNAME_R_5_ARG
HAVE_GETHOSTBYNAME_R_6_ARG
LIBCRYPT_LIBS
LIBCRYPT_CFLAGS
LIBOBJS
LIBLZMA_LIBS
LIBLZMA_CFLAGS
Expand Down Expand Up @@ -1041,7 +1045,9 @@ ZLIB_LIBS
BZIP2_CFLAGS
BZIP2_LIBS
LIBLZMA_CFLAGS
LIBLZMA_LIBS'
LIBLZMA_LIBS
LIBCRYPT_CFLAGS
LIBCRYPT_LIBS'


# Initialize some variables set by options.
Expand Down Expand Up @@ -1831,6 +1837,10 @@ Some influential environment variables:
C compiler flags for LIBLZMA, overriding pkg-config
LIBLZMA_LIBS
linker flags for LIBLZMA, overriding pkg-config
LIBCRYPT_CFLAGS
C compiler flags for LIBCRYPT, overriding pkg-config
LIBCRYPT_LIBS
linker flags for LIBCRYPT, overriding pkg-config

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Expand Down Expand Up @@ -15241,11 +15251,75 @@ fi
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.
LIBS_SAVE=$LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing crypt_r" >&5



pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBCRYPT" >&5
$as_echo_n "checking for LIBCRYPT... " >&6; }

if test -n "$LIBCRYPT_CFLAGS"; then
pkg_cv_LIBCRYPT_CFLAGS="$LIBCRYPT_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libxcrypt >= 3.1.1\""; } >&5
($PKG_CONFIG --exists --print-errors "libxcrypt >= 3.1.1") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_LIBCRYPT_CFLAGS=`$PKG_CONFIG --cflags "libxcrypt >= 3.1.1" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test -n "$LIBCRYPT_LIBS"; then
pkg_cv_LIBCRYPT_LIBS="$LIBCRYPT_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libxcrypt >= 3.1.1\""; } >&5
($PKG_CONFIG --exists --print-errors "libxcrypt >= 3.1.1") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_LIBCRYPT_LIBS=`$PKG_CONFIG --libs "libxcrypt >= 3.1.1" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi



if test $pkg_failed = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }

if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
LIBCRYPT_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libxcrypt >= 3.1.1" 2>&1`
else
LIBCRYPT_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libxcrypt >= 3.1.1" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$LIBCRYPT_PKG_ERRORS" >&5


save_CFLAGS=$CFLAGS
save_CPPFLAGS=$CPPFLAGS
save_LDFLAGS=$LDFLAGS
save_LIBS=$LIBS


{ $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 :
$as_echo_n "(cached) " >&6
Expand Down Expand Up @@ -15299,12 +15373,37 @@ 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_LIBS=
else
LIBCRYPT_LIBS="$ac_cv_search_crypt_r"
fi

fi

LIBS="$LIBS_SAVE"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing crypt" >&5
$as_echo_n "checking for library containing crypt... " >&6; }
if ${ac_cv_search_crypt+:} false; then :

CFLAGS=$save_CFLAGS
CPPFLAGS=$save_CPPFLAGS
LDFLAGS=$save_LDFLAGS
LIBS=$save_LIBS



elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }

save_CFLAGS=$CFLAGS
save_CPPFLAGS=$CPPFLAGS
save_LDFLAGS=$LDFLAGS
save_LIBS=$LIBS


{ $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 :
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
Expand All @@ -15317,11 +15416,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
#ifdef __cplusplus
extern "C"
#endif
char crypt ();
char crypt_r ();
int
main ()
{
return crypt ();
return crypt_r ();
;
return 0;
}
Expand All @@ -15334,59 +15433,112 @@ for ac_lib in '' crypt; do
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_search_crypt=$ac_res
ac_cv_search_crypt_r=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext
if ${ac_cv_search_crypt+:} false; then :
if ${ac_cv_search_crypt_r+:} false; then :
break
fi
done
if ${ac_cv_search_crypt+:} false; then :
if ${ac_cv_search_crypt_r+:} false; then :

else
ac_cv_search_crypt=no
ac_cv_search_crypt_r=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_crypt" >&5
$as_echo "$ac_cv_search_crypt" >&6; }
ac_res=$ac_cv_search_crypt
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_crypt_r" >&5
$as_echo "$ac_cv_search_crypt_r" >&6; }
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_LIBS=
else
LIBCRYPT_LIBS="$ac_cv_search_crypt_r"
fi

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
CFLAGS=$save_CFLAGS
CPPFLAGS=$save_CPPFLAGS
LDFLAGS=$save_LDFLAGS
LIBS=$save_LIBS



else
LIBCRYPT_CFLAGS=$pkg_cv_LIBCRYPT_CFLAGS
LIBCRYPT_LIBS=$pkg_cv_LIBCRYPT_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }

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


fi

save_CFLAGS=$CFLAGS
save_CPPFLAGS=$CPPFLAGS
save_LDFLAGS=$LDFLAGS
save_LIBS=$LIBS


CPPFLAGS="$LIBCRYPT_CFLAGS $CFLAGS"
LDFLAGS="$LIBCRYPT_LIBS $LDFLAGS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for crypt or crypt_r" >&5
$as_echo_n "checking for crypt or crypt_r... " >&6; }
if ${ac_cv_crypt_crypt+:} false; then :
$as_echo_n "(cached) " >&6
else

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

#include <crypt.h>
#ifdef HAVE_CRYPT_H
#include <crypt.h>
#endif
#include <unistd.h>

int
main ()
{

struct crypt_data d;
char *r = crypt_r("", "", &d);
#ifdef HAVE_CRYPT_R
void *x = crypt_r;
#else
void *x = crypt;
#endif

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

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

_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_crypt_crypt=yes
else
ac_cv_crypt_crypt=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_crypt_crypt" >&5
$as_echo "$ac_cv_crypt_crypt" >&6; }

CFLAGS=$save_CFLAGS
CPPFLAGS=$save_CPPFLAGS
LDFLAGS=$save_LDFLAGS
LIBS=$save_LIBS


LIBS=$LIBS_SAVE

for ac_func in clock_gettime
do :
Expand Down Expand Up @@ -21370,6 +21522,42 @@ $as_echo "$py_cv_module__blake2" >&6; }



{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _crypt" >&5
$as_echo_n "checking for stdlib extension module _crypt... " >&6; }
case $py_stdlib_not_available in #(
*_crypt*) :
py_cv_module__crypt=n/a ;; #(
*) :
if true; then :
if test "$ac_cv_crypt_crypt" = yes; then :
py_cv_module__crypt=yes
else
py_cv_module__crypt=missing
fi
else
py_cv_module__crypt=disabled
fi
;;
esac
as_fn_append MODULE_BLOCK "MODULE__CRYPT=$py_cv_module__crypt$as_nl"
if test "x$py_cv_module__crypt" = xyes; then :

as_fn_append MODULE_BLOCK "MODULE__CRYPT_CFLAGS=$LIBCRYPT_CFLAGS$as_nl"
as_fn_append MODULE_BLOCK "MODULE__CRYPT_LDFLAGS=$LIBCRYPT_LIBS$as_nl"

fi
if test "$py_cv_module__crypt" = yes; then
MODULE__CRYPT_TRUE=
MODULE__CRYPT_FALSE='#'
else
MODULE__CRYPT_TRUE='#'
MODULE__CRYPT_FALSE=
fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $py_cv_module__crypt" >&5
$as_echo "$py_cv_module__crypt" >&6; }


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _decimal" >&5
$as_echo_n "checking for stdlib extension module _decimal... " >&6; }
case $py_stdlib_not_available in #(
Expand Down Expand Up @@ -22250,6 +22438,10 @@ if test -z "${MODULE__BLAKE2_TRUE}" && test -z "${MODULE__BLAKE2_FALSE}"; then
as_fn_error $? "conditional \"MODULE__BLAKE2\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${MODULE__CRYPT_TRUE}" && test -z "${MODULE__CRYPT_FALSE}"; then
as_fn_error $? "conditional \"MODULE__CRYPT\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${MODULE__DECIMAL_TRUE}" && test -z "${MODULE__DECIMAL_FALSE}"; then
as_fn_error $? "conditional \"MODULE__DECIMAL\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
Expand Down
Loading