]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
chown: simplify CHOWN_CHANGE_TIME_BUG checking
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 21 Sep 2025 16:28:00 +0000 (09:28 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 21 Sep 2025 16:29:21 +0000 (09:29 -0700)
* m4/chown.m4 (AC_FUNC_CHOWN): Just use $host_os when checking for
CHOWN_CHANGE_TIME_BUG.  This should be good enough for currently
supported Gnulib targets.

ChangeLog
m4/chown.m4

index 8e2d1a6eb997c41db666502225417d18c2d867c6..0e5388483d495d16e211b220a2f25c470eae6db6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2025-09-21  Paul Eggert  <eggert@cs.ucla.edu>
 
+       chown: simplify CHOWN_CHANGE_TIME_BUG checking
+       * m4/chown.m4 (AC_FUNC_CHOWN): Just use $host_os when checking for
+       CHOWN_CHANGE_TIME_BUG.  This should be good enough for currently
+       supported Gnulib targets.
+
        fchownat: fix security races and other bugs
        This fixes some unlikely security races,
        where our “no-op” chmod undid some other process’s chmod.
index 8105cfd3ae2dc44854fe23bcd5e3ec1e358ba470..37993cfa78bbfa0cc4763af307d17a823e8f40e3 100644 (file)
@@ -1,5 +1,5 @@
 # chown.m4
-# serial 37
+# serial 38
 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
@@ -131,35 +131,15 @@ AC_DEFUN_ONCE([gl_FUNC_CHOWN],
     esac
 
     dnl OpenBSD fails to update ctime if ownership does not change.
-    AC_CACHE_CHECK([whether chown always updates ctime],
+    AC_CACHE_CHECK([whether chown updates ctime per POSIX],
       [gl_cv_func_chown_ctime_works],
-      [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],
-        [case "$host_os" in
-                    # Guess yes on glibc systems.
-           *-gnu*)  gl_cv_func_chown_ctime_works="guessing yes" ;;
-                    # Guess yes on musl systems.
-           *-musl*) gl_cv_func_chown_ctime_works="guessing yes" ;;
-                    # If we don't know, obey --enable-cross-guesses.
-           *)       gl_cv_func_chown_ctime_works="$gl_cross_guess_normal" ;;
-         esac
-        ])
-      rm -f conftest.file])
+      [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.
+       AS_CASE([$host_os],
+         [openbsd*], [gl_cv_func_chown_ctime_works=no],
+         [gl_cv_func_chown_ctime_works=yes])])
     case "$gl_cv_func_chown_ctime_works" in
       *yes) ;;
       *)