diff --git a/backport-cat-fix-plain-cat-bug.patch b/backport-cat-fix-plain-cat-bug.patch new file mode 100644 index 0000000000000000000000000000000000000000..a5808e8aea5beec4fdd1e013f8ee7adfb51d7712 --- /dev/null +++ b/backport-cat-fix-plain-cat-bug.patch @@ -0,0 +1,81 @@ +From 7386c291be8e2de115f2e161886e872429edadd7 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Fri, 14 Feb 2025 13:10:02 -0800 +Subject: =?UTF-8?q?cat:=20fix=20plain=20=E2=80=98cat=E2=80=99=20bug?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +* src/cat.c (main): Do not fail with plain ‘cat’ where input and +output are both /dev/tty, if the output happens to have O_APPEND set. +Problem reported by lilydjwg . +Also, don’t report an error if the seek position is at or after EOF, +even if O_APPEND is set. +--- + src/cat.c | 26 +++++++++++++------------- + 1 file changed, 13 insertions(+), 13 deletions(-) + +(limited to 'src/cat.c') + +diff --git a/src/cat.c b/src/cat.c +index 274f844..c022103 100644 +--- a/src/cat.c ++++ b/src/cat.c +@@ -646,9 +646,15 @@ + idx_t outsize = io_blksize (&stat_buf); + + /* Device, I-node number and lazily-acquired flags of the output. */ +- dev_t out_dev = stat_buf.st_dev; +- ino_t out_ino = stat_buf.st_ino; ++ dev_t out_dev; ++ ino_t out_ino; + int out_flags = -2; ++ bool have_out_dev = ! (S_TYPEISSHM (&stat_buf) || S_TYPEISTMO (&stat_buf)); ++ if (have_out_dev) ++ { ++ out_dev = stat_buf.st_dev; ++ out_ino = stat_buf.st_ino; ++ } + + /* True if the output is a regular file. */ + bool out_isreg = S_ISREG (stat_buf.st_mode) != 0; +@@ -706,22 +712,25 @@ + output device. It's better to catch this error earlier + rather than later. */ + +- if (stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino) ++ if (! (S_ISFIFO (stat_buf.st_mode) || S_ISSOCK (stat_buf.st_mode) ++ || S_TYPEISSHM (&stat_buf) || S_TYPEISTMO (&stat_buf)) ++ && have_out_dev ++ && stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino) + { +- if (out_flags < -1) +- out_flags = fcntl (STDOUT_FILENO, F_GETFL); +- bool exhausting = 0 <= out_flags && out_flags & O_APPEND; +- if (!exhausting) +- { +- off_t in_pos = lseek (input_desc, 0, SEEK_CUR); +- if (0 <= in_pos) +- exhausting = in_pos < lseek (STDOUT_FILENO, 0, SEEK_CUR); +- } +- if (exhausting) ++ off_t in_pos = lseek (input_desc, 0, SEEK_CUR); ++ if (0 <= in_pos) + { +- error (0, 0, _("%s: input file is output file"), quotef (infile)); +- ok = false; +- goto contin; ++ if (out_flags < -1) ++ out_flags = fcntl (STDOUT_FILENO, F_GETFL); ++ int whence = (0 <= out_flags && out_flags & O_APPEND ++ ? SEEK_END : SEEK_CUR); ++ if (in_pos < lseek (STDOUT_FILENO, 0, whence)) ++ { ++ error (0, 0, _("%s: input file is output file"), ++ quotef (infile)); ++ ok = false; ++ goto contin; ++ } + } + } + diff --git a/backport-who-m-systemd.patch b/backport-who-m-systemd.patch new file mode 100644 index 0000000000000000000000000000000000000000..5d43364478fc84d7b5be0d8502119f3fd075bdf1 --- /dev/null +++ b/backport-who-m-systemd.patch @@ -0,0 +1,25 @@ +From 24450e5eecf012bc1ea8cab8d677a45fa42c1778 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= +Date: Mon, 24 Feb 2025 10:36:35 +0100 +Subject: who: fix -m with guessed tty names + +* who.c (scan_entries): Account for guessed tty names (e.g. +'sshd pts/1') from the readutmp module when using the systemd backend. +Addresses https://bugzilla.redhat.com/2343998 +--- + src/who.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/who.c b/src/who.c +index b56a1ac..17c1e34 100644 +--- a/src/who.c ++++ b/src/who.c +@@ -583,7 +583,7 @@ scan_entries (idx_t n, struct gl_utmp const *utmp_buf) + while (n--) + { + if (!my_line_only +- || STREQ (ttyname_b, utmp_buf->ut_line)) ++ || str_endswith (utmp_buf->ut_line, ttyname_b)) + { + if (need_users && IS_USER_PROCESS (utmp_buf)) + print_user (utmp_buf, boottime); diff --git a/coreutils.spec b/coreutils.spec index 1bd5a52ce8d887020f8f63dafccd94c9c741a066..75d4acd84de92716588ff9e1c3fe3cb54b5cf829 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,6 +1,6 @@ Name: coreutils Version: 9.6 -Release: 1 +Release: 2 License: GPL-3.0-or-later Summary: A set of basic GNU tools commonly used in shell scripts Url: https://www.gnu.org/software/coreutils/ @@ -22,6 +22,8 @@ Patch8: test-skip-overlay-filesystem-because-of-no-inotify_add_watch.patch # Upstream patches Patch6001: backport-ls-fix-crash-with-context.patch +Patch6002: backport-who-m-systemd.patch +Patch6003: backport-cat-fix-plain-cat-bug.patch Patch9001: coreutils-9.6-sw.patch @@ -152,6 +154,10 @@ popd %{_mandir}/man*/* %changelog +* Sat Mar 08 2025 Funda Wang - 9.6-2 +- fix 'who -m' with guessed tty names +- fix cat bug appearing in conjunction with gawk + * Sat Jan 18 2025 Funda Wang - 9.6-1 - update to 9.6 diff --git a/coreutils.yaml b/coreutils.yaml index 1fb4e241291bfbbfd9789eca494c8cd8044a3f83..f48e817d5610a8d30f898787d08fa29df3b8a0dd 100644 --- a/coreutils.yaml +++ b/coreutils.yaml @@ -1,4 +1,4 @@ -version_control: github -src_repo: coreutils/coreutils -tag_prefix: "^v" -seperator: "." +version_control: git +src_repo: https://git.savannah.gnu.org/git/coreutils.git +tag_prefix: "^v" +separator: "."