On 2025-09-21 11:45, Bruno Haible wrote:
The test-fchownat test got a bit further on OpenBSD 7.6, but it still
fails:

FAIL: test-fchownat
===================

../../gltests/test-lchown.h:185: assertion 'st1.st_gid == st2.st_gid' failed
../../gltests/test-lchown.h:192: assertion 'gids[1] == st2.st_gid' failed
../../gltests/test-lchown.h:185: assertion 'st1.st_gid == st2.st_gid' failed
../../gltests/test-lchown.h:192: assertion 'gids[1] == st2.st_gid' failed

Thanks for reporting that. I think I see the problem, which is fixed in the attached.

I expect I didn't observe the problem on the cfarm OpenBSD 7.7 hosts because I'm in just one group there and a one-group user cannot exercise the bug; whereas it looks like you're in multiple groups.
From 0b099a204c3cba47eec49a3c93d263ae7e4c2f8a Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sun, 21 Sep 2025 18:56:18 -0700
Subject: [PATCH] fchownat: fix recently introduced flag typo

Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2025-09/msg00282.html
* lib/fchownat.c (rpl_fchownat): Fix typo by passing
our flag to fstatat.
---
 ChangeLog      | 8 ++++++++
 lib/fchownat.c | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 27e3dea547..f61718951e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-09-21  Paul Eggert  <egg...@cs.ucla.edu>
+
+	fchownat: fix recently introduced flag typo
+	Problem reported by Bruno Haible in:
+	https://lists.gnu.org/r/bug-gnulib/2025-09/msg00282.html
+	* lib/fchownat.c (rpl_fchownat): Fix typo by passing
+	our flag to fstatat.
+
 2025-09-21  Bruno Haible  <br...@clisp.org>
 
 	pthread-once: Improve configuration.
diff --git a/lib/fchownat.c b/lib/fchownat.c
index cce3a7abd4..a5e8bb8f47 100644
--- a/lib/fchownat.c
+++ b/lib/fchownat.c
@@ -135,7 +135,7 @@ rpl_fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag)
       || (CHOWN_TRAILING_SLASH_BUG
           && file[0] && file[strlen (file) - 1] == '/'))
     {
-      int r = fstatat (fd, file, &st, 0);
+      int r = fstatat (fd, file, &st, flag);
 
       /* EOVERFLOW means the file exists, which is all that the
          trailing slash check needs.  */
-- 
2.48.1

Reply via email to