From b780e1e31ac7373e22821fa60075307b958d7b3f Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Wed, 12 Sep 2018 14:44:44 -0700 Subject: [PATCH 1/2] bpo-34652: Always disable lchmod on Linux. Symbolic link modes cannot be changed on Linux, so there's no point ever trying to use this function. --- .../next/Library/2018-09-12-14-46-51.bpo-34652.Rt1m1b.rst | 1 + configure | 7 +++++++ configure.ac | 7 +++++++ 3 files changed, 15 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2018-09-12-14-46-51.bpo-34652.Rt1m1b.rst diff --git a/Misc/NEWS.d/next/Library/2018-09-12-14-46-51.bpo-34652.Rt1m1b.rst b/Misc/NEWS.d/next/Library/2018-09-12-14-46-51.bpo-34652.Rt1m1b.rst new file mode 100644 index 00000000000000..cbdd7e0ec6ce09 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-09-12-14-46-51.bpo-34652.Rt1m1b.rst @@ -0,0 +1 @@ +Ensure :func:`os.lchmod` is never defined on Linux. diff --git a/configure b/configure index fe642c439a4c3b..6907e677f2723f 100755 --- a/configure +++ b/configure @@ -11285,6 +11285,13 @@ fi done +# Force lchmod off for Linux. Linux disallows changing the mode of symbolic +# links. Some libc implementations have a stub lchmod implementation that always +# returns ENOSYS. +if test "$MACHDEP" = linux; then + undef HAVE_LCHMOD +fi + ac_fn_c_check_decl "$LINENO" "dirfd" "ac_cv_have_decl_dirfd" "#include #include " diff --git a/configure.ac b/configure.ac index a985ec2b000b65..9a4df37028114d 100644 --- a/configure.ac +++ b/configure.ac @@ -3454,6 +3454,13 @@ AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \ truncate uname unlinkat unsetenv utimensat utimes waitid waitpid wait3 wait4 \ wcscoll wcsftime wcsxfrm wmemcmp writev _getpty) +# Force lchmod off for Linux. Linux disallows changing the mode of symbolic +# links. Some libc implementations have a stub lchmod implementation that always +# returns an error. +if test "$MACHDEP" = linux; then + undef HAVE_LCHMOD +fi + AC_CHECK_DECL(dirfd, AC_DEFINE(HAVE_DIRFD, 1, Define if you have the 'dirfd' function or macro.), , From 2f95a7d7d0a456e8823b8dd39b4a11ca39a37464 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Wed, 12 Sep 2018 15:15:35 -0700 Subject: [PATCH 2/2] better plan --- configure | 10 +++++++--- configure.ac | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 6907e677f2723f..d341453443fc4c 100755 --- a/configure +++ b/configure @@ -11287,9 +11287,13 @@ done # Force lchmod off for Linux. Linux disallows changing the mode of symbolic # links. Some libc implementations have a stub lchmod implementation that always -# returns ENOSYS. -if test "$MACHDEP" = linux; then - undef HAVE_LCHMOD +# returns an error. +if test "$MACHDEP" != linux; then + ac_fn_c_check_func "$LINENO" "lchmod" "ac_cv_func_lchmod" +if test "x$ac_cv_func_lchmod" = xyes; then : + +fi + fi ac_fn_c_check_decl "$LINENO" "dirfd" "ac_cv_have_decl_dirfd" "#include diff --git a/configure.ac b/configure.ac index 9a4df37028114d..cf7328c4032a95 100644 --- a/configure.ac +++ b/configure.ac @@ -3457,8 +3457,8 @@ AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \ # Force lchmod off for Linux. Linux disallows changing the mode of symbolic # links. Some libc implementations have a stub lchmod implementation that always # returns an error. -if test "$MACHDEP" = linux; then - undef HAVE_LCHMOD +if test "$MACHDEP" != linux; then + AC_CHECK_FUNC(lchmod) fi AC_CHECK_DECL(dirfd,