]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
ls: avoid triggering automounts
authorRohan Sable <rsable@redhat.com>
Mon, 7 Mar 2022 14:14:13 +0000 (14:14 +0000)
committerPádraig Brady <P@draigBrady.com>
Mon, 7 Mar 2022 23:26:42 +0000 (23:26 +0000)
statx() has different defaults wrt automounting
compared to stat() or lstat(), so explicitly
set the AT_NO_AUTOMOUNT flag to suppress that behavior,
and avoid unintended operations or potential errors.

* src/ls.c (do_statx): Pass AT_NO_AUTOMOUNT to avoid this behavior.
* NEWS: Mention the change in behavior.
Fixes https://bugs.gnu.org/54286

Signed-off-by: Rohan Sable <rsable@redhat.com>
NEWS
src/ls.c

diff --git a/NEWS b/NEWS
index af6596b062a3053b981c04d178f110b7bca32560..a3442c5dd794cdee95141f7eb1228768da2af953 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -75,6 +75,9 @@ GNU coreutils NEWS                                    -*- outline -*-
   seek_bytes are therefore obsolescent and are no longer documented,
   though they still work.
 
+  ls no longer tries to automount files, reverting to the behavior
+  before the statx() call was introduced in coreutils-8.32.
+
   timeout --foreground --kill-after=... will now exit with status 137
   if the kill signal was sent, which is consistent with the behavior
   when the --foreground option is not specified.  This allows users to
index 1930e4abbc4fd927e050e091a773b7f24a7a433b..255789061b20fdf667d7b8a7fa93a4a76fad9766 100644 (file)
--- a/src/ls.c
+++ b/src/ls.c
@@ -1177,7 +1177,7 @@ do_statx (int fd, char const *name, struct stat *st, int flags,
 {
   struct statx stx;
   bool want_btime = mask & STATX_BTIME;
-  int ret = statx (fd, name, flags, mask, &stx);
+  int ret = statx (fd, name, flags | AT_NO_AUTOMOUNT, mask, &stx);
   if (ret >= 0)
     {
       statx_to_stat (&stx, st);