]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
chown, lchown: Fix regression on Cygwin 2.9.0 (regression today).
authorBruno Haible <bruno@clisp.org>
Sun, 21 Sep 2025 18:59:20 +0000 (20:59 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 21 Sep 2025 18:59:20 +0000 (20:59 +0200)
* 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.

ChangeLog
doc/posix-functions/chown.texi
m4/chown.m4

index 2d904fafacecdc2884d8ebed4e46965b121ee535..ce2c03e1d0ab2d26de6c0ddcfd3ba5193d9c75fd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-09-21  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        lchown: Fix compilation error on macOS (regression today).
index fb100efa0429b3858d5d4840116c0ec1194badd5..17e305de2500d16c21b6cef62ba76b212ecff2fc 100644 (file)
@@ -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
index 37993cfa78bbfa0cc4763af307d17a823e8f40e3..f899f3b680d4626a61986ed152ca694ef2ebe747 100644 (file)
@@ -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 <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+]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) ;;
       *)