+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).
@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
# 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
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) ;;
*)