* src/chown-core.c (change_file_owner): Ensure ENOTSUP is
only suppressed for symlinks.
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-FIO8FRNZ.
---
NEWS | 6 ++++++
src/chown-core.c | 20 +++++++++++++++-----
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/NEWS b/NEWS
index aed61f9cd..af956c2ad 100644
--- a/NEWS
+++ b/NEWS
@@ -52,6 +52,12 @@ GNU coreutils NEWS -*-
outline -*-
when operating on dangling symbolic links.
[bug introduced in coreutils-5.3.0]
+ 'chown' and 'chgrp', with -h or with -R (without -H or -L), no longer
+ silently ignore ENOTSUP errors for files other than symbolic links.
+ Previously on file systems that do not support changing ownership,
+ nothing was changed or diagnosed and the exit status indicated success.
+ [bug introduced in coreutils-5.3.0]
+
'cksum' now detects GNU and BSD reversed formats for each checksum file.
Previously mixing these formats across files could reject valid checksums
or incorrectly interpret a space as part of a file name.
diff --git a/src/chown-core.c b/src/chown-core.c
index 70022cab6..c9ba675f2 100644
--- a/src/chown-core.c
+++ b/src/chown-core.c
@@ -28,6 +28,7 @@
#include "fcntl--.h"
#include "fts-missing.h"
#include "ignore-value.h"
+#include "issymlinkat.h"
#include "root-dev-ino.h"
#include "xfts.h"
@@ -423,13 +424,22 @@ change_file_owner (FTS *fts, FTSENT *ent,
{
ok = (lchownat (fts->fts_cwd_fd, file, uid, gid) == 0);
- /* Ignore any error due to lack of support; POSIX requires
- this behavior for top-level symbolic links with -h, and
- implies that it's required for all symbolic links. */
+ /* Ignore unsupported ownership changes only for symlinks, as POSIX
+ requires for command-line symlinks with -h. Check the name here
+ since FTS may have followed the link (e.g., with -RhL). */
if (!ok && is_ENOTSUP (errno))
{
- ok = true;
- symlink_changed = false;
+ int chown_errno = errno;
+ int is_symlink = issymlinkat (fts->fts_cwd_fd, file);
+ if (is_symlink < 0 && ignore_missing
+ && ignorable_traversal_errno (errno))
+ return true;
+ if (is_symlink == 1)
+ {
+ ok = true;
+ symlink_changed = false;
+ }
+ errno = chown_errno;
}
}
else
--
2.56.0