Skip to content
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,2 @@
Detect faulty ``lchmod`` implementation to fix ``shutil.copystat`` on alpine
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be useful to say "on Alpine linux and other distributions using musl libc", because the issue is actually related to the musl implementation, I believe. This affects me on Gentoo+musl.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, I did hit this on gentoo musl as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh shoot, I totally forgot about this patch -- I need to revive my other approach 😨

linux. Patch by Anthony Sottile.
56 changes: 55 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -11130,7 +11130,7 @@ for ac_func in alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
futimens futimes gai_strerror getentropy \
getgrouplist getgroups getlogin getloadavg getpeername getpgid getpid \
getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
initgroups kill killpg lchmod lchown linkat lstat lutimes mmap \
initgroups kill killpg lchown linkat lstat lutimes mmap \
memrchr mbrtowc mkdirat mkfifo \
mkfifoat mknod mknodat mktime mremap nice openat pathconf pause pipe2 plock poll \
posix_fallocate posix_fadvise pread \
Expand Down Expand Up @@ -11837,6 +11837,60 @@ $as_echo "#define HAVE_LCHFLAGS 1" >>confdefs.h

fi


# on alpine, lchmod raises errno EOPNOTSUPP on symlinks
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, technically not just Alpine, it's a musl libc thing.

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for broken lchmod" >&5
$as_echo_n "checking for broken lchmod... " >&6; }
if ${ac_cv_have_lchmod+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
ac_cv_have_lchmod=cross
else
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this else for the inner if-block? Should it be indented one level, along with an extra level for the cat command below it?

Actually, It looks like there's a ton of nested stuff below that isn't indented -- it makes it hard to read, but I don't know if that is a style thing I'm not used to since I haven't worked specifically in configure files much...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

configure is entirely machine generated, the actual code is in configure.am

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

#include <sys/stat.h>
#include <unistd.h>
int main(int argc, char*argv[])
{
if (symlink(argv[0], "test"))
return 1;
if (lchmod("test", 0777))
return 1;
return 0;
}

_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
ac_cv_have_lchmod=yes
else
ac_cv_have_lchmod=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi


fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_lchmod" >&5
$as_echo "$ac_cv_have_lchmod" >&6; }
if test "$ac_cv_have_lchmod" = cross ; then
ac_fn_c_check_func "$LINENO" "lchmod" "ac_cv_func_lchmod"
if test "x$ac_cv_func_lchmod" = xyes; then :
ac_cv_have_lchmod="yes"
else
ac_cv_have_lchmod="no"
fi

fi
if test "$ac_cv_have_lchmod" = yes ; then

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra newlines for a reason? Also, not indented?

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

fi
rm -f test

case $ac_sys_system/$ac_sys_release in
Darwin/*)
_CUR_CFLAGS="${CFLAGS}"
Expand Down
26 changes: 25 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3405,7 +3405,7 @@ AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
futimens futimes gai_strerror getentropy \
getgrouplist getgroups getlogin getloadavg getpeername getpgid getpid \
getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
initgroups kill killpg lchmod lchown linkat lstat lutimes mmap \
initgroups kill killpg lchown linkat lstat lutimes mmap \
memrchr mbrtowc mkdirat mkfifo \
mkfifoat mknod mknodat mktime mremap nice openat pathconf pause pipe2 plock poll \
posix_fallocate posix_fadvise pread \
Expand Down Expand Up @@ -3600,6 +3600,30 @@ if test "$ac_cv_have_lchflags" = yes ; then
AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
fi


# on alpine, lchmod raises errno EOPNOTSUPP on symlinks
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another mention of just Alpine, same suggestion as above.

AC_CACHE_CHECK([for broken lchmod], [ac_cv_have_lchmod], [dnl
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <sys/stat.h>
#include <unistd.h>
int main(int argc, char*argv[])
{
if (symlink(argv[0], "test"))
return 1;
if (lchmod("test", 0777))
return 1;
return 0;
}
]])],[ac_cv_have_lchmod=yes],[ac_cv_have_lchmod=no],[ac_cv_have_lchmod=cross])
])
if test "$ac_cv_have_lchmod" = cross ; then
AC_CHECK_FUNC([lchmod], [ac_cv_have_lchmod="yes"], [ac_cv_have_lchmod="no"])
fi
if test "$ac_cv_have_lchmod" = yes ; then
AC_DEFINE(HAVE_LCHMOD, 1, [Define to 1 if you have the `lchmod' function.])
fi
rm -f test

dnl Check if system zlib has *Copy() functions
dnl
dnl On MacOSX the linker will search for dylibs on the entire linker path
Expand Down