df: fix bug with automounted arguments
Resolves: RHEL-180583
This commit is contained in:
parent
1b72513df3
commit
fbaa210cee
75
coreutils-8.32-df-fix-mishandled-automounts.patch
Normal file
75
coreutils-8.32-df-fix-mishandled-automounts.patch
Normal file
@ -0,0 +1,75 @@
|
||||
From 76c1da7ecf69bfe8a928f03304919f75e819e694 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Eggert <eggert@cs.ucla.edu>
|
||||
Date: Wed, 11 Aug 2021 11:16:05 -0700
|
||||
Subject: df: fix bug with automounted
|
||||
|
||||
If the command-line argument is automounted, df would use
|
||||
stat info that became wrong after the following open.
|
||||
* src/df.c (automount_stat_err): New function.
|
||||
This fixes the hang on fifos in a better way, by using O_NONBLOCK.
|
||||
(main): Use it.
|
||||
|
||||
(cherry picked from commit a3c04f8da14f0fe2a0561bf5562032b8ce5dafa9)
|
||||
---
|
||||
src/df.c | 34 +++++++++++++++++++++++++---------
|
||||
1 file changed, 25 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/src/df.c b/src/df.c
|
||||
index 99989399f..841b7715b 100644
|
||||
--- a/src/df.c
|
||||
+++ b/src/df.c
|
||||
@@ -276,6 +276,28 @@ static struct option const long_options[] =
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
+/* Stat FILE and put the results into *ST. Return 0 if successful, an
|
||||
+ error number otherwise. Try to open FILE before statting, to
|
||||
+ trigger automounts. */
|
||||
+
|
||||
+static int
|
||||
+automount_stat_err (char const *file, struct stat *st)
|
||||
+{
|
||||
+ int fd = open (file, O_RDONLY | O_NOCTTY | O_NONBLOCK);
|
||||
+ if (fd < 0)
|
||||
+ {
|
||||
+ if (errno == ENOENT || errno == ENOTDIR)
|
||||
+ return errno;
|
||||
+ return stat (file, st) == 0 ? 0 : errno;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ int err = fstat (fd, st) == 0 ? 0 : errno;
|
||||
+ close (fd);
|
||||
+ return err;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
/* Replace problematic chars with '?'.
|
||||
Since only control characters are currently considered,
|
||||
this should work in all encodings. */
|
||||
@@ -1772,19 +1794,13 @@ main (int argc, char **argv)
|
||||
stats = xnmalloc (argc - optind, sizeof *stats);
|
||||
for (int i = optind; i < argc; ++i)
|
||||
{
|
||||
- if (stat (argv[i], &stats[i - optind]))
|
||||
+ int err = automount_stat_err (argv[i], &stats[i - optind]);
|
||||
+ if (err != 0)
|
||||
{
|
||||
- error (0, errno, "%s", quotef (argv[i]));
|
||||
+ error (0, err, "%s", quotef (argv[i]));
|
||||
exit_status = EXIT_FAILURE;
|
||||
argv[i] = NULL;
|
||||
}
|
||||
- else if (! S_ISFIFO (stats[i - optind].st_mode))
|
||||
- {
|
||||
- /* open() is needed to automount in some cases. */
|
||||
- int fd = open (argv[i], O_RDONLY | O_NOCTTY);
|
||||
- if (0 <= fd)
|
||||
- close (fd);
|
||||
- }
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.54.0
|
||||
|
||||
@ -88,6 +88,10 @@ Patch24: coreutils-8.32-s390x-fdlimit.patch
|
||||
# upstream commit: https://cgit.git.savannah.gnu.org/cgit/coreutils.git/commit/?id=8c9602e3a145e9596dc1a63c6ed67865814b6633
|
||||
Patch25: coreutils-CVE-2025-5278.patch
|
||||
|
||||
# df: fix bug with automounted arguments (RHEL-180583)
|
||||
# upstream commit: https://cgit.git.savannah.gnu.org/cgit/coreutils.git/commit/?id=a3c04f8da14f0fe2a0561bf5562032b8ce5dafa9
|
||||
Patch26: coreutils-8.32-df-fix-mishandled-automounts.patch
|
||||
|
||||
# disable the test-lock gnulib test prone to deadlock
|
||||
Patch100: coreutils-8.26-test-lock.patch
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user