From: Bruno Haible Date: Sun, 21 Sep 2025 18:59:20 +0000 (+0200) Subject: chown, lchown: Fix regression on Cygwin 2.9.0 (regression today). X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb2c639c9c7d2604abdbf1514f51cf4f36069ebf;p=thirdparty%2Fgnulib.git chown, lchown: Fix regression on Cygwin 2.9.0 (regression today). * m4/chown.m4 (AC_FUNC_CHOWN): Restore the previous configure-time test on OpenBSD and Cygwin platforms. * doc/posix-functions/chown.texi: Update platforms list. --- diff --git a/ChangeLog b/ChangeLog index 2d904fafac..ce2c03e1d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2025-09-21 Bruno Haible + + chown, lchown: Fix regression on Cygwin 2.9.0 (regression today). + * m4/chown.m4 (AC_FUNC_CHOWN): Restore the previous configure-time test + on OpenBSD and Cygwin platforms. + * doc/posix-functions/chown.texi: Update platforms list. + 2025-09-21 Bruno Haible lchown: Fix compilation error on macOS (regression today). diff --git a/doc/posix-functions/chown.texi b/doc/posix-functions/chown.texi index fb100efa04..17e305de25 100644 --- a/doc/posix-functions/chown.texi +++ b/doc/posix-functions/chown.texi @@ -16,7 +16,7 @@ macOS 14, FreeBSD 7.2, AIX 7.3.1, Solaris 9. @item Some platforms fail to update the change time when at least one argument was not @minus{}1, but no ownership changes resulted: -OpenBSD 7.7. +OpenBSD 7.7, Cygwin 2.9.0. @item When passed an argument of @minus{}1, some implementations really set the owner user/group id of the file to this value, rather than leaving that id of the diff --git a/m4/chown.m4 b/m4/chown.m4 index 37993cfa78..f899f3b680 100644 --- a/m4/chown.m4 +++ b/m4/chown.m4 @@ -1,5 +1,5 @@ # chown.m4 -# serial 38 +# serial 39 dnl Copyright (C) 1997-2001, 2003-2005, 2007, 2009-2025 Free Software dnl Foundation, Inc. dnl This file is free software; the Free Software Foundation @@ -133,13 +133,36 @@ AC_DEFUN_ONCE([gl_FUNC_CHOWN], dnl OpenBSD fails to update ctime if ownership does not change. AC_CACHE_CHECK([whether chown updates ctime per POSIX], [gl_cv_func_chown_ctime_works], - [dnl Although this formerly used AC_RUN_IFELSE, that was tricky - dnl as it depended on timing and file timestamp resolution, - dnl and there were false positives when configuring with Linux fakeroot. - dnl Since the problem occurs only on OpenBSD, just test for that. + [dnl This test is tricky as it depends on timing and file timestamp + dnl resolution, and there were false positives when configuring with + dnl Linux fakeroot. Since the problem occurs only on OpenBSD and Cygwin, + dnl test only on these platforms. AS_CASE([$host_os], - [openbsd*], [gl_cv_func_chown_ctime_works=no], - [gl_cv_func_chown_ctime_works=yes])]) + [openbsd* | cygwin*], + [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +#include +#include +#include +]GL_MDA_DEFINES], + [[struct stat st1, st2; + if (close (creat ("conftest.file", 0600))) return 1; + if (stat ("conftest.file", &st1)) return 2; + sleep (1); + if (chown ("conftest.file", st1.st_uid, st1.st_gid)) return 3; + if (stat ("conftest.file", &st2)) return 4; + if (st2.st_ctime <= st1.st_ctime) return 5; + ]])], + [gl_cv_func_chown_ctime_works=yes], + [gl_cv_func_chown_ctime_works=no], + [# Obey --enable-cross-guesses. + gl_cv_func_chown_ctime_works="$gl_cross_guess_normal" + ]) + rm -f conftest.file + ], + [gl_cv_func_chown_ctime_works=yes]) + ]) case "$gl_cv_func_chown_ctime_works" in *yes) ;; *)