diff --git a/backport-comm-fix-NUL-output-delimiter-with-total.patch b/backport-comm-fix-NUL-output-delimiter-with-total.patch new file mode 100644 index 0000000000000000000000000000000000000000..1721ebddc71d199acb791fab438d91b636660888 --- /dev/null +++ b/backport-comm-fix-NUL-output-delimiter-with-total.patch @@ -0,0 +1,86 @@ +From 708ae170c987dab83273cb885496e1a8a90233e8 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?P=C3=A1draig=20Brady?=
+Date: Sat, 27 Aug 2022 18:40:14 +0100 +Subject: [PATCH] comm: fix NUL --output-delimiter with --total + +* src/comm.c (compare_files): Handle the single character +--output-delimeter case separately so that NUL is appropriately +handled. +* doc/coreutils.texi (comm invocation): Fix the description +of --output-delimiter to say an empty delimeter is treated +as a NUL separator, rather than being disallowed. +* tests/misc/comm.pl: Add a test case. +Reported at https://bugs.debian.org/1014008 + +Reference:https://github.com/coreutils/coreutils/commit/708ae170c987dab83273cb885496e1a8a90233e8 +Conflict:Context adaptation + +--- + doc/coreutils.texi | 3 ++- + src/comm.c | 21 ++++++++++++++++----- + tests/misc/comm.pl | 3 +++ + 3 files changed, 21 insertions(+), 6 deletions(-) + +diff --git a/doc/coreutils.texi b/doc/coreutils.texi +index 9f31f6768..de819b6dc 100644 +--- a/doc/coreutils.texi ++++ b/doc/coreutils.texi +@@ -5427,7 +5427,8 @@ Other options are: + Print @var{str} between adjacent output columns, + rather than the default of a single TAB character. + +-The delimiter @var{str} may not be empty. ++The delimiter @var{str} may be empty, in which case ++the ASCII NUL character is used to delimit output columns. + + @item --total + Output a summary at the end. +diff --git a/src/comm.c b/src/comm.c +index 721139cb8..ed9d97d0a 100644 +--- a/src/comm.c ++++ b/src/comm.c +@@ -395,11 +395,22 @@ compare_files (char **infiles) + char buf1[INT_BUFSIZE_BOUND (uintmax_t)]; + char buf2[INT_BUFSIZE_BOUND (uintmax_t)]; + char buf3[INT_BUFSIZE_BOUND (uintmax_t)]; +- printf ("%s%s%s%s%s%s%s%c", +- umaxtostr (total[0], buf1), col_sep, +- umaxtostr (total[1], buf2), col_sep, +- umaxtostr (total[2], buf3), col_sep, +- _("total"), delim); ++ if (col_sep_len == 1) ++ { /* Separate to handle NUL char. */ ++ printf ("%s%c%s%c%s%c%s%c", ++ umaxtostr (total[0], buf1), *col_sep, ++ umaxtostr (total[1], buf2), *col_sep, ++ umaxtostr (total[2], buf3), *col_sep, ++ _("total"), delim); ++ } ++ else ++ { ++ printf ("%s%s%s%s%s%s%s%c", ++ umaxtostr (total[0], buf1), col_sep, ++ umaxtostr (total[1], buf2), col_sep, ++ umaxtostr (total[2], buf3), col_sep, ++ _("total"), delim); ++ } + } + } + +diff --git a/tests/misc/comm.pl b/tests/misc/comm.pl +index 73e8c3720..5d0c4f175 100755 +--- a/tests/misc/comm.pl ++++ b/tests/misc/comm.pl +@@ -157,6 +157,9 @@ my @Tests = + {OUT=>"1\n\0002\n\0002\n\000\0003\n\000\0003\n\000\0003\n"} ], + ['zdelim-empty', '-z', '-z --output-delimiter=', @zinputs, + {OUT=>"1\000\0002\000\0002\000\000\0003\000\000\0003\000\000\0003\000"} ], ++ ['total-delim-empty', '--total --output-delimiter=', @inputs, ++ {OUT=>"1\n\0002\n\0002\n\000\0003\n\000\0003\n\000\0003\n" ++ . "1\0002\0003\000total\n"} ], + + # invalid dual delimiter + ['delim-dual', '--output-delimiter=,', '--output-delimiter=+', @inputs, +-- +2.27.0 + diff --git a/backport-copy-copy_file_range-handle-ENOENT-for-CIFS.patch b/backport-copy-copy_file_range-handle-ENOENT-for-CIFS.patch new file mode 100644 index 0000000000000000000000000000000000000000..67d555f3e0c6090458d2a8ab630ca12b554beace --- /dev/null +++ b/backport-copy-copy_file_range-handle-ENOENT-for-CIFS.patch @@ -0,0 +1,54 @@ +From 7fc84d1c0f6b35231b0b4577b70aaa26bf548a7c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?P=C3=A1draig=20Brady?=
+Date: Sat, 7 Jan 2023 16:10:01 +0000
+Subject: [PATCH] copy: copy_file_range: handle ENOENT for CIFS
+
+* src/copy.c (sparse_copy): Fallback to standard copy upon ENOENT,
+which was seen intermittently across CIFS file systems.
+* NEWS: Mention the bug fix, though qualify it as an "issue"
+rather than a bug, as coreutils is likely only highlighting
+a CIFS bug in this case.
+Fixes https://bugs.gnu.org/60455
+
+Reference:https://github.com/coreutils/coreutils/commit/7fc84d1c0f6b35231b0b4577b70aaa26bf548a7c
+Conflict:NEWS context adapation
+
+---
+ NEWS | 4 ++++
+ src/copy.c | 5 +++++
+ 2 files changed, 9 insertions(+)
+
+diff --git a/NEWS b/NEWS
+index 9d3f253..b65bc85 100644
+--- a/NEWS
++++ b/NEWS
+@@ -3,6 +3,10 @@ GNU coreutils NEWS -*- outline -*-
+ * Noteworthy changes in release 9.0 (2021-09-24) [stable]
+
+ ** Bug fixes
++ cp, mv, and install now handle ENOENT failures across CIFS file systems,
++ falling back from copy_file_range to a better supported standard copy.
++ [issue introduced in coreutils-9.0]
++
+ stty now wraps output appropriately for the terminal width.
+ Previously it may have output 1 character too wide for certain widths.
+ [bug introduced in coreutils-5.3]
+diff --git a/src/copy.c b/src/copy.c
+index 519c43b00..98f2ba45a 100644
+--- a/src/copy.c
++++ b/src/copy.c
+@@ -290,6 +290,11 @@ sparse_copy (int src_fd, int dest_fd, char **abuf, size_t buf_size,
+ if (errno == EPERM && *total_n_read == 0)
+ break;
+
++ /* ENOENT was seen sometimes across CIFS shares, resulting in
++ no data being copied, but subsequent standard copies succeed. */
++ if (errno == ENOENT && *total_n_read == 0)
++ break;
++
+ if (errno == EINTR)
+ n_copied = 0;
+ else
+--
+2.27.0
+
diff --git a/backport-fts-fail-gracefully-when-out-of-memory.patch b/backport-fts-fail-gracefully-when-out-of-memory.patch
new file mode 100644
index 0000000000000000000000000000000000000000..a28f48e6eb0bb543dd38e38550565059347085ae
--- /dev/null
+++ b/backport-fts-fail-gracefully-when-out-of-memory.patch
@@ -0,0 +1,50 @@
+From f17d397771164c1b0f77fea8fb0abdc99cf4a3e1 Mon Sep 17 00:00:00 2001
+From: ChuanGang Jiang
+
+ version 9.0
+diff --git a/lib/fts.c b/lib/fts.c
+index 27354d39c8..74a08f7ec8 100644
+--- a/lib/fts.c
++++ b/lib/fts.c
+@@ -1316,19 +1316,35 @@ fts_build (register FTS *sp, int type)
+ /* Rather than calling fts_stat for each and every entry encountered
+ in the readdir loop (below), stat each directory only right after
+ opening it. */
+- if (cur->fts_info == FTS_NSOK)
+- cur->fts_info = fts_stat(sp, cur, false);
+- else if (sp->fts_options & FTS_TIGHT_CYCLE_CHECK)
+- {
+- /* Now read the stat info again after opening a directory to
++ bool stat_optimization = cur->fts_info == FTS_NSOK;
++
++ if (stat_optimization
++ /* Also read the stat info again after opening a directory to
+ reveal eventual changes caused by a submount triggered by
+ the traversal. But do it only for utilities which use
+ FTS_TIGHT_CYCLE_CHECK. Therefore, only find and du
+ benefit/suffer from this feature for now. */
+- LEAVE_DIR (sp, cur, "4");
+- fts_stat (sp, cur, false);
+- if (! enter_dir (sp, cur))
++ || ISSET (FTS_TIGHT_CYCLE_CHECK))
++ {
++ if (!stat_optimization)
++ LEAVE_DIR (sp, cur, "4");
++ if (fstat (dir_fd, cur->fts_statp) != 0)
++ {
++ int fstat_errno = errno;
++ closedir_and_clear (cur->fts_dirp);
++ if (type == BREAD)
++ {
++ cur->fts_errno = fstat_errno;
++ cur->fts_info = FTS_NS;
++ }
++ __set_errno (fstat_errno);
++ return NULL;
++ }
++ if (stat_optimization)
++ cur->fts_info = FTS_D;
++ else if (! enter_dir (sp, cur))
+ {
++ closedir_and_clear (cur->fts_dirp);
+ __set_errno (ENOMEM);
+ return NULL;
+ }
+--
+2.27.0
+
diff --git a/backport-stty-fix-off-by-one-column-wrapping-on-output.patch b/backport-stty-fix-off-by-one-column-wrapping-on-output.patch
new file mode 100644
index 0000000000000000000000000000000000000000..c7b9c257eac9c818a2b5e5cb5e658a6b0ec98b19
--- /dev/null
+++ b/backport-stty-fix-off-by-one-column-wrapping-on-output.patch
@@ -0,0 +1,66 @@
+From c9a21ec3173b93de4839e5ff9eddadb020431656 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?P=C3=A1draig=20Brady?=
+Date: Sat, 31 Dec 2022 17:03:39 +0000
+Subject: [PATCH] stty: fix off by one column wrapping on output
+
+* src/stty.c (wrapf): Adjust the comparison by 1,
+to account for the space we're adding.
+* tests/misc/stty.sh: Add a test case.
+* NEWS: Mention the fix.
+Reported in https://bugs.debian.org/1027442
+
+Refernece:https://github.com/coreutils/coreutils/commit/c9a21ec3173b93de4839e5ff9eddadb020431656
+Conflict:NEWS Context adapation
+
+---
+ NEWS | 4 ++++
+ src/stty.c | 2 +-
+ tests/misc/stty.sh | 6 ++++++
+ 3 files changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/NEWS b/NEWS
+index 805f012..9d3f253 100644
+--- a/NEWS
++++ b/NEWS
+@@ -3,6 +3,10 @@ GNU coreutils NEWS
+ * Noteworthy changes in release 9.0 (2021-09-24) [stable]
+
+ ** Bug fixes
++ stty now wraps output appropriately for the terminal width.
++ Previously it may have output 1 character too wide for certain widths.
++ [bug introduced in coreutils-5.3]
++
+ stty ispeed and ospeed options no longer accept and silently ignore
+ invalid speed arguments. Now they're validated against both the
+ general accepted set, and the system supported set of valid speeds.
+diff --git a/src/stty.c b/src/stty.c
+index b4c2cbecd..f3c7915e1 100644
+--- a/src/stty.c
++++ b/src/stty.c
+@@ -519,7 +519,7 @@ wrapf (char const *message,...)
+
+ if (0 < current_col)
+ {
+- if (max_col - current_col < buflen)
++ if (max_col - current_col <= buflen)
+ {
+ putchar ('\n');
+ current_col = 0;
+diff --git a/tests/misc/stty.sh b/tests/misc/stty.sh
+index bcdc80e87..7abcec5af 100755
+--- a/tests/misc/stty.sh
++++ b/tests/misc/stty.sh
+@@ -89,4 +89,10 @@ returns_ 1 strace -o log2 -e ioctl stty -blahblah || fail=1
+ n_ioctl2=$(wc -l < log2) || framework_failure_
+ test "$n_ioctl1" = "$n_ioctl2" || fail=1
+
++# Ensure we wrap output appropriately
++for W in $(seq 80 90); do
++ output_width=$(COLUMNS="$W" stty -a | wc -L)
++ test "$output_width" -le "$W" || fail=1
++done
++
+ Exit $fail
+--
+2.27.0
+
diff --git a/backport-stty-validate-ispeed-and-ospeed-arguments.patch b/backport-stty-validate-ispeed-and-ospeed-arguments.patch
new file mode 100644
index 0000000000000000000000000000000000000000..ed9f6691b999e72972e8d6cb1d23dc78ddfd6cad
--- /dev/null
+++ b/backport-stty-validate-ispeed-and-ospeed-arguments.patch
@@ -0,0 +1,110 @@
+From f87a78f334f25cbaac89507c8fda24d4f780b908 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?P=C3=A1draig=20Brady?=
+Date: Wed, 31 Aug 2022 00:17:21 +0100
+Subject: [PATCH] stty: validate ispeed and ospeed arguments
+
+* src/stty.c (apply_settings): Validate [io]speed arguments
+against the internal accepted set.
+(set_speed): Check the cfset[io]speed() return value so
+that we validate against the system supported set.
+* tests/misc/stty-invalid.sh: Add a test case.
+* NEWS: Mention the bug fix.
+Reported in https://bugs.debian.org/1018790
+
+Reference:https://github.com/coreutils/coreutils/commit/f87a78f334f25cbaac89507c8fda24d4f780b908
+Conflict:Context adapation
+
+---
+ NEWS | 5 +++++
+ src/stty.c | 29 +++++++++++++++++++++++++----
+ tests/misc/stty-invalid.sh | 3 +++
+ 3 files changed, 33 insertions(+), 4 deletions(-)
+
+diff --git a/NEWS b/NEWS
+index f2fbcbb..805f012 100644
+--- a/NEWS
++++ b/NEWS
+@@ -3,6 +3,10 @@ GNU coreutils NEWS
+ * Noteworthy changes in release 9.0 (2021-09-24) [stable]
+
+ ** Bug fixes
++ stty ispeed and ospeed options no longer accept and silently ignore
++ invalid speed arguments. Now they're validated against both the
++ general accepted set, and the system supported set of valid speeds.
++ [This bug was present in "the beginning".]
+
+ chmod -v no longer misreports modes of dangling symlinks.
+ [bug introduced in coreutils-5.3.0]
+diff --git a/src/stty.c b/src/stty.c
+index 3b6a592a9..3d515223e 100644
+--- a/src/stty.c
++++ b/src/stty.c
+@@ -1159,6 +1159,11 @@ apply_settings (bool checking, char const *device_name,
+ {
+ check_argument (arg);
+ ++k;
++ if (string_to_baud (settings[k]) == (speed_t) -1)
++ {
++ error (0, 0, _("invalid ispeed %s"), quote (settings[k]));
++ usage (EXIT_FAILURE);
++ }
+ if (checking)
+ continue;
+ set_speed (input_speed, settings[k], mode);
+@@ -1169,6 +1174,11 @@ apply_settings (bool checking, char const *device_name,
+ {
+ check_argument (arg);
+ ++k;
++ if (string_to_baud (settings[k]) == (speed_t) -1)
++ {
++ error (0, 0, _("invalid ospeed %s"), quote (settings[k]));
++ usage (EXIT_FAILURE);
++ }
+ if (checking)
+ continue;
+ set_speed (output_speed, settings[k], mode);
+@@ -1696,13 +1706,24 @@ set_control_char (struct control_info const *info, char const *arg,
+ static void
+ set_speed (enum speed_setting type, char const *arg, struct termios *mode)
+ {
+- speed_t baud;
++ /* Note cfset[io]speed(), do not check with the device,
++ and only check whether the system logic supports the specified speed.
++ Therefore we don't report the device name in any errors. */
++
++ speed_t baud = string_to_baud (arg);
++
++ assert (baud != (speed_t) -1);
+
+- baud = string_to_baud (arg);
+ if (type == input_speed || type == both_speeds)
+- cfsetispeed (mode, baud);
++ {
++ if (cfsetispeed (mode, baud))
++ die (EXIT_FAILURE, 0, "unsupported ispeed %s", quotef (arg));
++ }
+ if (type == output_speed || type == both_speeds)
+- cfsetospeed (mode, baud);
++ {
++ if (cfsetospeed (mode, baud))
++ die (EXIT_FAILURE, 0, "unsupported ospeed %s", quotef (arg));
++ }
+ }
+
+ #ifdef TIOCGWINSZ
+diff --git a/tests/misc/stty-invalid.sh b/tests/misc/stty-invalid.sh
+index 58e51311d..af49b8d89 100755
+--- a/tests/misc/stty-invalid.sh
++++ b/tests/misc/stty-invalid.sh
+@@ -50,6 +50,9 @@ if tty -s
+Date: Mon, 30 Jan 2023 21:44:10 +0000
+Subject: [PATCH] tail: fix support for -F with non seekable files
+
+This was seen to be an issue when following a
+symlink that was being updated to point to
+different underlying devices.
+
+* src/tail.c (recheck): Guard the lseek() call to only
+be performed for regular files.
+* NEWS: Mention the bug fix.
+
+Reference:https://github.com/coreutils/coreutils/commit/c0c63e9735908a9579f8735001957db6bd81afc3
+Conflict:NEWS Context adapation
+
+---
+ NEWS | 4 ++++
+ src/tail.c | 3 ++-
+ 2 files changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/NEWS b/NEWS
+index b65bc85..f65eb95 100644
+--- a/NEWS
++++ b/NEWS
+@@ -3,6 +3,10 @@ GNU coreutils NEWS -*- outline -*-
+ * Noteworthy changes in release 9.0 (2021-09-24) [stable]
+
+ ** Bug fixes
++ tail --follow=name works again with non seekable files. Previously it
++ exited with an "Illegal seek" error when such a file was replaced.
++ [bug introduced in fileutils-4.1.6]
++
+ cp, mv, and install now handle ENOENT failures across CIFS file systems,
+ falling back from copy_file_range to a better supported standard copy.
+ [issue introduced in coreutils-9.0]
+diff --git a/src/tail.c b/src/tail.c
+index 2244509dd..03061e8bf 100644
+--- a/src/tail.c
++++ b/src/tail.c
+@@ -1122,7 +1122,8 @@ recheck (struct File_spec *f, bool blocking)
+ {
+ /* Start at the beginning of the file. */
+ record_open_fd (f, fd, 0, &new_stats, (is_stdin ? -1 : blocking));
+- xlseek (fd, 0, SEEK_SET, pretty_name (f));
++ if (S_ISREG (new_stats.st_mode))
++ xlseek (fd, 0, SEEK_SET, pretty_name (f));
+ }
+ }
+
+--
+2.27.0
+
diff --git a/coreutils.spec b/coreutils.spec
index d903e98a001ab4cb97df606fb22c17b382e5f0ee..821a77facf1747ec72ab1a9001252936c7cf71ed 100644
--- a/coreutils.spec
+++ b/coreutils.spec
@@ -1,6 +1,6 @@
Name: coreutils
Version: 9.0
-Release: 7
+Release: 9
License: GPLv3+
Summary: A set of basic GNU tools commonly used in shell scripts
Url: https://www.gnu.org/software/coreutils/
@@ -24,6 +24,14 @@ Patch9: backport-config-color-alias-for-ls.patch
Patch10: backport-coreutils-i18n.patch
Patch11: backport-sort-fix-sort-g-infloop-again.patch
Patch12: backport-tests-sort-NaN-infloop-augment-testing-for-recent-fi.patch
+Patch13: backport-comm-fix-NUL-output-delimiter-with-total.patch
+Patch14: backport-stty-validate-ispeed-and-ospeed-arguments.patch
+Patch15: backport-fts-fix-race-mishandling-of-fstatat-failure.patch
+Patch16: backport-stty-fix-off-by-one-column-wrapping-on-output.patch
+Patch17: backport-copy-copy_file_range-handle-ENOENT-for-CIFS.patch
+Patch18: backport-tail-fix-support-for-F-with-non-seekable-files.patch
+Patch19: backport-fts-fail-gracefully-when-out-of-memory.patch
+
%ifarch sw_64
Patch13: coreutils-9.0-sw.patch
%endif
@@ -151,6 +159,18 @@ fi
%{_mandir}/man*/*
%changelog
+* Fri Mar 17 2023 jiangchuangang