closes bpo-34652: Always disable lchmod on Linux. (GH-9234)

(cherry picked from commit 40caa05fa4d1810a1a6bfc34e0ec930c351089b7)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
diff --git a/configure.ac b/configure.ac
index 2b8aa4d..d7e0de3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3519,6 +3519,13 @@
  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
+  AC_CHECK_FUNC(lchmod)
+fi
+
 AC_CHECK_DECL(dirfd,
     AC_DEFINE(HAVE_DIRFD, 1,
               Define if you have the 'dirfd' function or macro.), ,