From fdfe50c891adab069561406a15b3a7917e679c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= Date: Thu, 10 Apr 2025 10:40:14 +0200 Subject: [PATCH 01/15] rebase to latest upstream release Resolves: rhbz#2358624 --- coreutils-8.32-DIR_COLORS.patch | 14 +- coreutils-9.6-ls-selinux-crash.patch | 77 ---------- coreutils-9.6-who-m-systemd.patch | 25 ---- coreutils-df-direct.patch | 18 +-- coreutils-i18n.patch | 204 +++++++++++++++------------ coreutils.spec | 15 +- 6 files changed, 132 insertions(+), 221 deletions(-) delete mode 100644 coreutils-9.6-ls-selinux-crash.patch delete mode 100644 coreutils-9.6-who-m-systemd.patch diff --git a/coreutils-8.32-DIR_COLORS.patch b/coreutils-8.32-DIR_COLORS.patch index 021d2a5..37ce3e6 100644 --- a/coreutils-8.32-DIR_COLORS.patch +++ b/coreutils-8.32-DIR_COLORS.patch @@ -1,4 +1,4 @@ -From c7b13f5e1a7ad012c510a8bdd5a8943ab4b55833 Mon Sep 17 00:00:00 2001 +From bca11e30e8a6281a8cbddc9fb196dd86ab09c955 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Fri, 17 Jun 2016 16:58:18 +0200 Subject: [PATCH] downstream changes to default DIR_COLORS @@ -9,7 +9,7 @@ Subject: [PATCH] downstream changes to default DIR_COLORS 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/DIR_COLORS b/DIR_COLORS -index b465771..ad42b09 100644 +index 540f6cd..b4785b6 100644 --- a/DIR_COLORS +++ b/DIR_COLORS @@ -1,3 +1,7 @@ @@ -30,7 +30,7 @@ index b465771..ad42b09 100644 # =================================================================== # Terminal filters # =================================================================== -@@ -69,7 +76,7 @@ DOOR 01;35 # door +@@ -70,7 +77,7 @@ DOOR 01;35 # door BLK 40;33;01 # block device driver CHR 40;33;01 # character device driver ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file ... @@ -40,7 +40,7 @@ index b465771..ad42b09 100644 SETGID 30;43 # regular file that is setgid (g+s) CAPABILITY 00 # regular file with capability (very expensive to lookup) diff --git a/DIR_COLORS.lightbgcolor b/DIR_COLORS.lightbgcolor -index eab6258..1627b63 100644 +index e3b0ec3..39a0a4c 100644 --- a/DIR_COLORS.lightbgcolor +++ b/DIR_COLORS.lightbgcolor @@ -1,3 +1,9 @@ @@ -63,7 +63,7 @@ index eab6258..1627b63 100644 # =================================================================== # Terminal filters # =================================================================== -@@ -59,17 +68,17 @@ TERM xterm* +@@ -60,17 +69,17 @@ TERM xterm* #NORMAL 00 # no color code at all #FILE 00 # regular file: use no color at all RESET 0 # reset to "normal" color @@ -86,7 +86,7 @@ index eab6258..1627b63 100644 SETUID 37;41 # regular file that is setuid (u+s) SETGID 30;43 # regular file that is setgid (g+s) CAPABILITY 00 # regular file with capability (very expensive to lookup) -@@ -78,7 +87,7 @@ OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky +@@ -79,7 +88,7 @@ OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable # This is for regular files with execute permission: @@ -96,5 +96,5 @@ index eab6258..1627b63 100644 # =================================================================== # File extension attributes -- -2.34.1 +2.49.0 diff --git a/coreutils-9.6-ls-selinux-crash.patch b/coreutils-9.6-ls-selinux-crash.patch deleted file mode 100644 index 70837cc..0000000 --- a/coreutils-9.6-ls-selinux-crash.patch +++ /dev/null @@ -1,77 +0,0 @@ -From 915004f403cb25fadb207ddfdbe6a2f43bd44fac Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?P=C3=A1draig=20Brady?= -Date: Fri, 17 Jan 2025 17:29:34 +0000 -Subject: [PATCH] ls: fix crash with --context - -* src/ls.c (main): Flag that we need to stat() -if we're going to get security context (call file_has_aclinfo_cache). -(file_has_aclinfo_cache): Be defensive and only lookup the device -for the file if the stat has been performed. -(has_capability_cache): Likewise. -* tests/ls/selinux-segfault.sh: Add a test case. -Reported by Bruno Haible. ---- - src/ls.c | 10 +++++----- - tests/ls/selinux-segfault.sh | 3 +++ - 2 files changed, 8 insertions(+), 5 deletions(-) - -diff --git a/src/ls.c b/src/ls.c -index 3215360216..f67167f160 100644 ---- a/src/ls.c -+++ b/src/ls.c -@@ -1768,7 +1768,7 @@ main (int argc, char **argv) - - format_needs_stat = ((sort_type == sort_time) | (sort_type == sort_size) - | (format == long_format) -- | print_block_size | print_hyperlink); -+ | print_block_size | print_hyperlink | print_scontext); - format_needs_type = ((! format_needs_stat) - & (recursive | print_with_color | print_scontext - | directories_first -@@ -3309,7 +3309,7 @@ file_has_aclinfo_cache (char const *file, struct fileinfo *f, - static int unsupported_scontext_err; - static dev_t unsupported_device; - -- if (f->stat.st_dev == unsupported_device) -+ if (f->stat_ok && f->stat.st_dev == unsupported_device) - { - ai->buf = ai->u.__gl_acl_ch; - ai->size = 0; -@@ -3322,7 +3322,7 @@ file_has_aclinfo_cache (char const *file, struct fileinfo *f, - errno = 0; - int n = file_has_aclinfo (file, ai, flags); - int err = errno; -- if (n <= 0 && !acl_errno_valid (err)) -+ if (f->stat_ok && n <= 0 && !acl_errno_valid (err)) - { - unsupported_return = n; - unsupported_scontext = ai->scontext; -@@ -3342,14 +3342,14 @@ has_capability_cache (char const *file, struct fileinfo *f) - found that has_capability fails indicating lack of support. */ - static dev_t unsupported_device; - -- if (f->stat.st_dev == unsupported_device) -+ if (f->stat_ok && f->stat.st_dev == unsupported_device) - { - errno = ENOTSUP; - return 0; - } - - bool b = has_capability (file); -- if ( !b && !acl_errno_valid (errno)) -+ if (f->stat_ok && !b && !acl_errno_valid (errno)) - unsupported_device = f->stat.st_dev; - return b; - } -diff --git a/tests/ls/selinux-segfault.sh b/tests/ls/selinux-segfault.sh -index 11623acb3f..1cac2b5fc0 100755 ---- a/tests/ls/selinux-segfault.sh -+++ b/tests/ls/selinux-segfault.sh -@@ -30,4 +30,7 @@ mkdir sedir || framework_failure_ - ln -sf missing sedir/broken || framework_failure_ - returns_ 1 ls -L -R -Z -m sedir > out || fail=1 - -+# ls 9.6 would segfault with the following -+ls -Z . > out || fail=1 -+ - Exit $fail diff --git a/coreutils-9.6-who-m-systemd.patch b/coreutils-9.6-who-m-systemd.patch deleted file mode 100644 index 5d43364..0000000 --- a/coreutils-9.6-who-m-systemd.patch +++ /dev/null @@ -1,25 +0,0 @@ -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-df-direct.patch b/coreutils-df-direct.patch index d19ec29..f5e3d73 100644 --- a/coreutils-df-direct.patch +++ b/coreutils-df-direct.patch @@ -1,4 +1,4 @@ -From d179da4730f414069dd2c0ac995a32398718916c Mon Sep 17 00:00:00 2001 +From d3117ae1bb422f771f1c19af54f81d5151f55065 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Mon, 29 Mar 2010 17:20:34 +0000 Subject: [PATCH] coreutils-df-direct.patch @@ -11,7 +11,7 @@ Subject: [PATCH] coreutils-df-direct.patch create mode 100755 tests/df/direct.sh diff --git a/doc/coreutils.texi b/doc/coreutils.texi -index ec58f6c..17cda80 100644 +index d1c282f..6d1ee11 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -12467,6 +12467,13 @@ some systems (notably Solaris), doing this yields more up to date results, @@ -29,7 +29,7 @@ index ec58f6c..17cda80 100644 @opindex --total @cindex grand total of file system size, usage and available space diff --git a/src/df.c b/src/df.c -index 5c7efd8..52ece19 100644 +index a969c5c..c465a3f 100644 --- a/src/df.c +++ b/src/df.c @@ -122,6 +122,9 @@ static bool print_type; @@ -59,7 +59,7 @@ index 5c7efd8..52ece19 100644 {"inodes", no_argument, nullptr, 'i'}, {"human-readable", no_argument, nullptr, 'h'}, {"si", no_argument, nullptr, 'H'}, -@@ -571,7 +576,10 @@ get_header (void) +@@ -572,7 +577,10 @@ get_header (void) for (idx_t col = 0; col < ncolumns; col++) { char *cell; @@ -71,7 +71,7 @@ index 5c7efd8..52ece19 100644 if (columns[col]->field == SIZE_FIELD && (header_mode == DEFAULT_MODE -@@ -1452,6 +1460,17 @@ get_point (char const *point, const struct stat *statp) +@@ -1454,6 +1462,17 @@ get_point (char const *point, const struct stat *statp) static void get_entry (char const *name, struct stat const *statp) { @@ -89,7 +89,7 @@ index 5c7efd8..52ece19 100644 if ((S_ISBLK (statp->st_mode) || S_ISCHR (statp->st_mode)) && get_device (name)) return; -@@ -1522,6 +1541,7 @@ or all file systems by default.\n\ +@@ -1524,6 +1543,7 @@ or all file systems by default.\n\ -B, --block-size=SIZE scale sizes by SIZE before printing them; e.g.,\n\ '-BM' prints sizes in units of 1,048,576 bytes;\n\ see SIZE format below\n\ @@ -97,7 +97,7 @@ index 5c7efd8..52ece19 100644 -h, --human-readable print sizes in powers of 1024 (e.g., 1023M)\n\ -H, --si print sizes in powers of 1000 (e.g., 1.1G)\n\ "), stdout); -@@ -1616,6 +1636,9 @@ main (int argc, char **argv) +@@ -1618,6 +1638,9 @@ main (int argc, char **argv) xstrtol_fatal (e, oi, c, long_options, optarg); } break; @@ -107,7 +107,7 @@ index 5c7efd8..52ece19 100644 case 'i': if (header_mode == OUTPUT_MODE) { -@@ -1712,6 +1735,13 @@ main (int argc, char **argv) +@@ -1714,6 +1737,13 @@ main (int argc, char **argv) } } @@ -183,5 +183,5 @@ index 0000000..8e4cfb8 + +Exit $fail -- -2.48.1 +2.49.0 diff --git a/coreutils-i18n.patch b/coreutils-i18n.patch index e7699c1..38b871c 100644 --- a/coreutils-i18n.patch +++ b/coreutils-i18n.patch @@ -1,4 +1,4 @@ -From a153c65067f6c09cf2cf38dc7c149aa1521c615a Mon Sep 17 00:00:00 2001 +From 3d25791ec9cc357a34620516d1c024ef17a4dd75 Mon Sep 17 00:00:00 2001 From: rpm-build Date: Wed, 30 Aug 2023 17:19:58 +0200 Subject: [PATCH] coreutils-i18n.patch @@ -8,11 +8,11 @@ Subject: [PATCH] coreutils-i18n.patch configure.ac | 6 + lib/linebuffer.h | 8 + lib/mbchar.c | 23 ++ - lib/mbchar.h | 373 +++++++++++++++++ + lib/mbchar.h | 383 +++++++++++++++++ lib/mbfile.c | 20 + - lib/mbfile.h | 267 ++++++++++++ - m4/mbchar.m4 | 13 + - m4/mbfile.m4 | 14 + + lib/mbfile.h | 283 +++++++++++++ + m4/mbchar.m4 | 15 + + m4/mbfile.m4 | 16 + src/cut.c | 508 +++++++++++++++++++++-- src/expand-common.c | 114 ++++++ src/expand-common.h | 12 + @@ -20,21 +20,21 @@ Subject: [PATCH] coreutils-i18n.patch src/fold.c | 311 ++++++++++++-- src/local.mk | 4 +- src/pr.c | 443 ++++++++++++++++++-- - src/sort.c | 792 +++++++++++++++++++++++++++++++++--- + src/sort.c | 790 +++++++++++++++++++++++++++++++++--- src/unexpand.c | 101 ++++- tests/Coreutils.pm | 3 + tests/expand/mb.sh | 183 +++++++++ tests/i18n/sort.sh | 29 ++ tests/local.mk | 4 + tests/misc/expand.pl | 42 ++ - tests/misc/fold.pl | 51 ++- + tests/misc/fold.pl | 50 ++- tests/misc/sort-mb-tests.sh | 45 ++ tests/misc/unexpand.pl | 39 ++ tests/pr/pr-tests.pl | 49 +++ tests/sort/sort-merge.pl | 42 ++ tests/sort/sort.pl | 40 +- tests/unexpand/mb.sh | 172 ++++++++ - 30 files changed, 3603 insertions(+), 197 deletions(-) + 30 files changed, 3632 insertions(+), 195 deletions(-) create mode 100644 lib/mbchar.c create mode 100644 lib/mbchar.h create mode 100644 lib/mbfile.c @@ -47,10 +47,10 @@ Subject: [PATCH] coreutils-i18n.patch create mode 100644 tests/unexpand/mb.sh diff --git a/bootstrap.conf b/bootstrap.conf -index 380fa11..ca80e6f 100644 +index 94c164e..cecbf26 100644 --- a/bootstrap.conf +++ b/bootstrap.conf -@@ -165,6 +165,8 @@ gnulib_modules=" +@@ -166,6 +166,8 @@ gnulib_modules=" maintainer-makefile malloc-gnu manywarnings @@ -60,10 +60,10 @@ index 380fa11..ca80e6f 100644 mbrtoc32 mbrtowc diff --git a/configure.ac b/configure.ac -index bf6da2a..321016d 100644 +index 775c4cc..e6b5c9c 100644 --- a/configure.ac +++ b/configure.ac -@@ -505,6 +505,12 @@ fi +@@ -504,6 +504,12 @@ fi # I'm leaving it here for now. This whole thing needs to be modernized... gl_WINSIZE_IN_PTEM @@ -104,11 +104,11 @@ index ca56f80..509b7e6 100644 /* Initialize linebuffer LINEBUFFER for use. */ diff --git a/lib/mbchar.c b/lib/mbchar.c new file mode 100644 -index 0000000..d94b7c3 +index 0000000..713c2f7 --- /dev/null +++ b/lib/mbchar.c @@ -0,0 +1,23 @@ -+/* Copyright (C) 2001, 2006, 2009-2024 Free Software Foundation, Inc. ++/* Copyright (C) 2001, 2006, 2009-2025 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as @@ -133,12 +133,12 @@ index 0000000..d94b7c3 +#include "mbchar.h" diff --git a/lib/mbchar.h b/lib/mbchar.h new file mode 100644 -index 0000000..c06ef11 +index 0000000..d77168e --- /dev/null +++ b/lib/mbchar.h -@@ -0,0 +1,373 @@ +@@ -0,0 +1,383 @@ +/* Multibyte character data type. -+ Copyright (C) 2001, 2005-2007, 2009-2024 Free Software Foundation, Inc. ++ Copyright (C) 2001, 2005-2007, 2009-2025 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as @@ -296,6 +296,11 @@ index 0000000..c06ef11 +# define MBCHAR_INLINE _GL_INLINE +#endif + ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++ +/* The longest multibyte characters, nowadays, are 4 bytes long. + Regardless of the values of MB_CUR_MAX and MB_LEN_MAX. */ +#define MBCHAR_BUF_SIZE 4 @@ -507,17 +512,22 @@ index 0000000..c06ef11 + +#endif + ++ ++#ifdef __cplusplus ++} ++#endif ++ +_GL_INLINE_HEADER_END + +#endif /* _MBCHAR_H */ diff --git a/lib/mbfile.c b/lib/mbfile.c new file mode 100644 -index 0000000..8d2957b +index 0000000..f4e3e77 --- /dev/null +++ b/lib/mbfile.c @@ -0,0 +1,20 @@ +/* Multibyte character I/O: macros for multi-byte encodings. -+ Copyright (C) 2012-2023 Free Software Foundation, Inc. ++ Copyright (C) 2012-2025 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as @@ -538,12 +548,12 @@ index 0000000..8d2957b +#include "mbfile.h" diff --git a/lib/mbfile.h b/lib/mbfile.h new file mode 100644 -index 0000000..ad61c19 +index 0000000..c852f31 --- /dev/null +++ b/lib/mbfile.h -@@ -0,0 +1,267 @@ +@@ -0,0 +1,283 @@ +/* Multibyte character I/O: macros for multi-byte encodings. -+ Copyright (C) 2001, 2005, 2009-2023 Free Software Foundation, Inc. ++ Copyright (C) 2001, 2005, 2009-2025 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as @@ -598,6 +608,7 @@ index 0000000..ad61c19 + +#include +#include ++#include +#include +#include + @@ -608,14 +619,22 @@ index 0000000..ad61c19 +# define MBFILE_INLINE _GL_INLINE +#endif + ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++ ++/* Guarantee two characters of pushback. */ ++#define MBFILE_MAX_PUSHBACK 2 ++ +struct mbfile_multi { + FILE *fp; + bool eof_seen; -+ bool have_pushback; ++ unsigned int pushback_count; /* <= MBFILE_MAX_PUSHBACK */ + mbstate_t state; + unsigned int bufcount; + char buf[MBCHAR_BUF_SIZE]; -+ struct mbchar pushback; ++ struct mbchar pushback[MBFILE_MAX_PUSHBACK]; +}; + +MBFILE_INLINE void @@ -624,19 +643,19 @@ index 0000000..ad61c19 + unsigned int new_bufcount; + size_t bytes; + ++ /* Return character pushed back, if there is one. */ ++ if (mbf->pushback_count > 0) ++ { ++ mb_copy (mbc, &mbf->pushback[mbf->pushback_count - 1]); ++ mbf->pushback_count--; ++ return; ++ } ++ + /* If EOF has already been seen, don't use getc. This matters if + mbf->fp is connected to an interactive tty. */ + if (mbf->eof_seen) + goto eof; + -+ /* Return character pushed back, if there is one. */ -+ if (mbf->have_pushback) -+ { -+ mb_copy (mbc, &mbf->pushback); -+ mbf->have_pushback = false; -+ return; -+ } -+ + new_bufcount = mbf->bufcount; + + /* If mbf->state is not in an initial state, some more 32-bit wide character @@ -785,8 +804,10 @@ index 0000000..ad61c19 +MBFILE_INLINE void +mbfile_multi_ungetc (const struct mbchar *mbc, struct mbfile_multi *mbf) +{ -+ mb_copy (&mbf->pushback, mbc); -+ mbf->have_pushback = true; ++ if (mbf->pushback_count == MBFILE_MAX_PUSHBACK) ++ abort (); ++ mb_copy (&mbf->pushback[mbf->pushback_count], mbc); ++ mbf->pushback_count++; +} + +typedef struct mbfile_multi mb_file_t; @@ -796,7 +817,7 @@ index 0000000..ad61c19 +#define mbf_init(mbf, stream) \ + ((mbf).fp = (stream), \ + (mbf).eof_seen = false, \ -+ (mbf).have_pushback = false, \ ++ (mbf).pushback_count = 0, \ + mbszero (&(mbf).state), \ + (mbf).bufcount = 0) + @@ -806,20 +827,27 @@ index 0000000..ad61c19 + +#define mb_iseof(mbc) ((mbc).bytes == 0) + ++ ++#ifdef __cplusplus ++} ++#endif ++ +_GL_INLINE_HEADER_END + +#endif /* _MBFILE_H */ diff --git a/m4/mbchar.m4 b/m4/mbchar.m4 new file mode 100644 -index 0000000..471e8c4 +index 0000000..b76f1d7 --- /dev/null +++ b/m4/mbchar.m4 -@@ -0,0 +1,13 @@ -+# mbchar.m4 serial 9 -+dnl Copyright (C) 2005-2007, 2009-2024 Free Software Foundation, Inc. +@@ -0,0 +1,15 @@ ++# mbchar.m4 ++# serial 9 ++dnl Copyright (C) 2005-2007, 2009-2025 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. ++dnl This file is offered as-is, without any warranty. + +dnl autoconf tests required for use of mbchar.m4 +dnl From Bruno Haible. @@ -830,15 +858,17 @@ index 0000000..471e8c4 +]) diff --git a/m4/mbfile.m4 b/m4/mbfile.m4 new file mode 100644 -index 0000000..83068a9 +index 0000000..1d126e0 --- /dev/null +++ b/m4/mbfile.m4 -@@ -0,0 +1,14 @@ -+# mbfile.m4 serial 7 -+dnl Copyright (C) 2005, 2008-2023 Free Software Foundation, Inc. +@@ -0,0 +1,16 @@ ++# mbfile.m4 ++# serial 7 ++dnl Copyright (C) 2005, 2008-2025 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. ++dnl This file is offered as-is, without any warranty. + +dnl autoconf tests required for use of mbfile.h +dnl From Bruno Haible. @@ -1509,7 +1539,7 @@ index b424997..c9f181c 100644 if (have_read_stdin && fclose (stdin) == EOF) diff --git a/src/expand-common.c b/src/expand-common.c -index 2dbbbe4..91a90a3 100644 +index 732123f..fdbef3f 100644 --- a/src/expand-common.c +++ b/src/expand-common.c @@ -19,6 +19,7 @@ @@ -3008,7 +3038,7 @@ index e7081a0..19e0268 100644 looking for more options and printing the next batch of files. diff --git a/src/sort.c b/src/sort.c -index 0928fd5..8c43fd4 100644 +index b10183b..fbf325b 100644 --- a/src/sort.c +++ b/src/sort.c @@ -29,6 +29,14 @@ @@ -3084,7 +3114,7 @@ index 0928fd5..8c43fd4 100644 /* Flag to remove consecutive duplicate lines from the output. Only the last of a sequence of equal lines will be output. */ -@@ -807,6 +838,46 @@ reap_all (void) +@@ -806,6 +837,46 @@ reap_all (void) reap (-1); } @@ -3131,7 +3161,7 @@ index 0928fd5..8c43fd4 100644 /* Clean up any remaining temporary files. */ static void -@@ -1274,7 +1345,7 @@ zaptemp (char const *name) +@@ -1273,7 +1344,7 @@ zaptemp (char const *name) free (node); } @@ -3140,7 +3170,7 @@ index 0928fd5..8c43fd4 100644 static int struct_month_cmp (void const *m1, void const *m2) -@@ -1289,7 +1360,7 @@ struct_month_cmp (void const *m1, void const *m2) +@@ -1288,7 +1359,7 @@ struct_month_cmp (void const *m1, void const *m2) /* Initialize the character class tables. */ static void @@ -3149,7 +3179,7 @@ index 0928fd5..8c43fd4 100644 { size_t i; -@@ -1301,7 +1372,7 @@ inittables (void) +@@ -1300,7 +1371,7 @@ inittables (void) fold_toupper[i] = toupper (i); } @@ -3158,7 +3188,7 @@ index 0928fd5..8c43fd4 100644 /* If we're not in the "C" locale, read different names for months. */ if (hard_LC_TIME) { -@@ -1381,6 +1452,84 @@ specify_nmerge (int oi, char c, char const *s) +@@ -1380,6 +1451,84 @@ specify_nmerge (int oi, char c, char const *s) xstrtol_fatal (e, oi, c, long_options, s); } @@ -3243,7 +3273,7 @@ index 0928fd5..8c43fd4 100644 /* Specify the amount of main memory to use when sorting. */ static void specify_sort_size (int oi, char c, char const *s) -@@ -1612,7 +1761,7 @@ buffer_linelim (struct buffer const *buf) +@@ -1611,7 +1760,7 @@ buffer_linelim (struct buffer const *buf) by KEY in LINE. */ static char * @@ -3252,7 +3282,7 @@ index 0928fd5..8c43fd4 100644 { char *ptr = line->text, *lim = ptr + line->length - 1; size_t sword = key->sword; -@@ -1621,10 +1770,10 @@ begfield (struct line const *line, struct keyfield const *key) +@@ -1620,10 +1769,10 @@ begfield (struct line const *line, struct keyfield const *key) /* The leading field separator itself is included in a field when -t is absent. */ @@ -3265,7 +3295,7 @@ index 0928fd5..8c43fd4 100644 ++ptr; if (ptr < lim) ++ptr; -@@ -1650,12 +1799,71 @@ begfield (struct line const *line, struct keyfield const *key) +@@ -1649,12 +1798,71 @@ begfield (struct line const *line, struct keyfield const *key) return ptr; } @@ -3338,7 +3368,7 @@ index 0928fd5..8c43fd4 100644 { char *ptr = line->text, *lim = ptr + line->length - 1; size_t eword = key->eword, echar = key->echar; -@@ -1670,10 +1878,10 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1669,10 +1877,10 @@ limfield (struct line const *line, struct keyfield const *key) 'beginning' is the first character following the delimiting TAB. Otherwise, leave PTR pointing at the first 'blank' character after the preceding field. */ @@ -3351,7 +3381,7 @@ index 0928fd5..8c43fd4 100644 ++ptr; if (ptr < lim && (eword || echar)) ++ptr; -@@ -1719,10 +1927,10 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1718,10 +1926,10 @@ limfield (struct line const *line, struct keyfield const *key) */ /* Make LIM point to the end of (one byte past) the current field. */ @@ -3364,7 +3394,7 @@ index 0928fd5..8c43fd4 100644 if (newlim) lim = newlim; } -@@ -1753,6 +1961,130 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1752,6 +1960,130 @@ limfield (struct line const *line, struct keyfield const *key) return ptr; } @@ -3495,7 +3525,7 @@ index 0928fd5..8c43fd4 100644 /* Fill BUF reading from FP, moving buf->left bytes from the end of buf->buf to the beginning first. If EOF is reached and the file wasn't terminated by a newline, supply one. Set up BUF's line -@@ -1839,8 +2171,22 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file) +@@ -1838,8 +2170,22 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file) else { if (key->skipsblanks) @@ -3520,7 +3550,7 @@ index 0928fd5..8c43fd4 100644 line->keybeg = line_start; } } -@@ -1978,12 +2324,10 @@ find_unit_order (char const *number) +@@ -1977,12 +2323,10 @@ find_unit_order (char const *number) ATTRIBUTE_PURE static int @@ -3536,7 +3566,7 @@ index 0928fd5..8c43fd4 100644 int diff = find_unit_order (a) - find_unit_order (b); return (diff ? diff : strnumcmp (a, b, decimal_point, thousands_sep)); -@@ -1995,7 +2339,7 @@ human_numcompare (char const *a, char const *b) +@@ -1994,7 +2338,7 @@ human_numcompare (char const *a, char const *b) ATTRIBUTE_PURE static int @@ -3545,7 +3575,7 @@ index 0928fd5..8c43fd4 100644 { while (blanks[to_uchar (*a)]) a++; -@@ -2005,6 +2349,25 @@ numcompare (char const *a, char const *b) +@@ -2004,6 +2348,25 @@ numcompare (char const *a, char const *b) return strnumcmp (a, b, decimal_point, thousands_sep); } @@ -3571,7 +3601,7 @@ index 0928fd5..8c43fd4 100644 static int nan_compare (long double a, long double b) { -@@ -2046,7 +2409,7 @@ general_numcompare (char const *sa, char const *sb) +@@ -2045,7 +2408,7 @@ general_numcompare (char const *sa, char const *sb) Return 0 if the name in S is not recognized. */ static int @@ -3580,7 +3610,7 @@ index 0928fd5..8c43fd4 100644 { size_t lo = 0; size_t hi = MONTHS_PER_YEAR; -@@ -2385,15 +2748,14 @@ debug_key (struct line const *line, struct keyfield const *key) +@@ -2384,15 +2747,14 @@ debug_key (struct line const *line, struct keyfield const *key) char saved = *lim; *lim = '\0'; @@ -3598,7 +3628,7 @@ index 0928fd5..8c43fd4 100644 else if (key->general_numeric) ignore_value (strtold (beg, &tighter_lim)); else if (key->numeric || key->human_numeric) -@@ -2539,7 +2901,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2538,7 +2900,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) /* Warn about significant leading blanks. */ bool implicit_skip = key_numeric (key) || key->month; bool line_offset = key->eword == 0 && key->echar != 0; /* -k1.x,1.y */ @@ -3607,7 +3637,7 @@ index 0928fd5..8c43fd4 100644 && ((!key->skipsblanks && !implicit_skip) || (!key->skipsblanks && key->schar) || (!key->skipeblanks && key->echar))) -@@ -2587,9 +2949,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2586,9 +2948,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) bool number_locale_warned = false; if (basic_numeric_field_span) { @@ -3620,7 +3650,7 @@ index 0928fd5..8c43fd4 100644 { error (0, 0, _("field separator %s is treated as a " -@@ -2600,9 +2962,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2599,9 +2961,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) } if (basic_numeric_field_span || general_numeric_field_span) { @@ -3633,7 +3663,7 @@ index 0928fd5..8c43fd4 100644 { error (0, 0, _("field separator %s is treated as a " -@@ -2610,19 +2972,19 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2609,19 +2971,19 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) quote (((char []) {decimal_point, 0}))); number_locale_warned = true; } @@ -3657,16 +3687,7 @@ index 0928fd5..8c43fd4 100644 } } -@@ -2633,7 +2995,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) - { - error (0, 0, - _("%snumbers use %s as a decimal point in this locale"), -- tab == decimal_point ? "" : _("note "), -+ (tab_length && tab[0] == decimal_point) ? "" : _("note "), - quote (((char []) {decimal_point, 0}))); - - } -@@ -2675,11 +3037,87 @@ diff_reversed (int diff, bool reversed) +@@ -2673,11 +3035,87 @@ diff_reversed (int diff, bool reversed) return reversed ? (diff < 0) - (diff > 0) : diff; } @@ -3755,7 +3776,7 @@ index 0928fd5..8c43fd4 100644 { struct keyfield *key = keylist; -@@ -2760,7 +3198,7 @@ keycompare (struct line const *a, struct line const *b) +@@ -2758,7 +3196,7 @@ keycompare (struct line const *a, struct line const *b) else if (key->human_numeric) diff = human_numcompare (ta, tb); else if (key->month) @@ -3764,7 +3785,7 @@ index 0928fd5..8c43fd4 100644 else if (key->random) diff = compare_random (ta, tlena, tb, tlenb); else if (key->version) -@@ -2870,6 +3308,211 @@ keycompare (struct line const *a, struct line const *b) +@@ -2868,6 +3306,211 @@ keycompare (struct line const *a, struct line const *b) return diff_reversed (diff, key->reverse); } @@ -3976,7 +3997,7 @@ index 0928fd5..8c43fd4 100644 /* Compare two lines A and B, returning negative, zero, or positive depending on whether A compares less than, equal to, or greater than B. */ -@@ -2897,7 +3540,7 @@ compare (struct line const *a, struct line const *b) +@@ -2895,7 +3538,7 @@ compare (struct line const *a, struct line const *b) diff = - NONZERO (blen); else if (blen == 0) diff = 1; @@ -3985,7 +4006,7 @@ index 0928fd5..8c43fd4 100644 { /* xmemcoll0 is a performance enhancement as it will not unconditionally write '\0' after the -@@ -4285,6 +4928,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype) +@@ -4283,6 +4926,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype) break; case 'f': key->translate = fold_toupper; @@ -3993,7 +4014,7 @@ index 0928fd5..8c43fd4 100644 break; case 'g': key->general_numeric = true; -@@ -4364,7 +5008,7 @@ main (int argc, char **argv) +@@ -4362,7 +5006,7 @@ main (int argc, char **argv) initialize_exit_failure (SORT_FAILURE); hard_LC_COLLATE = hard_locale (LC_COLLATE); @@ -4002,7 +4023,7 @@ index 0928fd5..8c43fd4 100644 hard_LC_TIME = hard_locale (LC_TIME); #endif -@@ -4387,6 +5031,29 @@ main (int argc, char **argv) +@@ -4385,6 +5029,29 @@ main (int argc, char **argv) thousands_sep = NON_CHAR; } @@ -4032,7 +4053,7 @@ index 0928fd5..8c43fd4 100644 have_read_stdin = false; inittables (); -@@ -4657,13 +5324,34 @@ main (int argc, char **argv) +@@ -4655,13 +5322,34 @@ main (int argc, char **argv) case 't': { @@ -4071,7 +4092,7 @@ index 0928fd5..8c43fd4 100644 else { /* Provoke with 'sort -txx'. Complain about -@@ -4674,9 +5362,11 @@ main (int argc, char **argv) +@@ -4672,9 +5360,11 @@ main (int argc, char **argv) quote (optarg)); } } @@ -4528,7 +4549,7 @@ index 0000000..26c95de + +Exit $fail diff --git a/tests/local.mk b/tests/local.mk -index 12e30b4..1529db6 100644 +index 4da6756..fcbeef8 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -390,6 +390,8 @@ all_tests = \ @@ -4540,7 +4561,7 @@ index 12e30b4..1529db6 100644 tests/sort/sort-h-thousands-sep.sh \ tests/sort/sort-merge.pl \ tests/sort/sort-merge-fdlimit.sh \ -@@ -593,6 +595,7 @@ all_tests = \ +@@ -594,6 +596,7 @@ all_tests = \ tests/du/threshold.sh \ tests/du/trailing-slash.sh \ tests/du/two-args.sh \ @@ -4548,7 +4569,7 @@ index 12e30b4..1529db6 100644 tests/id/gnu-zero-uids.sh \ tests/id/no-context.sh \ tests/id/context.sh \ -@@ -749,6 +752,7 @@ all_tests = \ +@@ -750,6 +753,7 @@ all_tests = \ tests/touch/read-only.sh \ tests/touch/relative.sh \ tests/touch/trailing-slash.sh \ @@ -4624,7 +4645,7 @@ index 4b07210..68b9ea1 100755 my $verbose = $ENV{VERBOSE}; diff --git a/tests/misc/fold.pl b/tests/misc/fold.pl -index 0981ec9..ba889c8 100755 +index 877322e..ba889c8 100755 --- a/tests/misc/fold.pl +++ b/tests/misc/fold.pl @@ -20,9 +20,17 @@ use strict; @@ -4646,7 +4667,7 @@ index 0981ec9..ba889c8 100755 my @Tests = ( -@@ -44,9 +52,48 @@ my @Tests = +@@ -44,6 +52,46 @@ my @Tests = {OUT=>"123456\n7890\nabcdef\nghij\n123456\n7890"}], ); @@ -4693,9 +4714,6 @@ index 0981ec9..ba889c8 100755 my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE}; --my $prog = 'fold'; - my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); - exit $fail; diff --git a/tests/misc/sort-mb-tests.sh b/tests/misc/sort-mb-tests.sh new file mode 100644 index 0000000..11836ba @@ -5180,5 +5198,5 @@ index 0000000..8a82d74 +LC_ALL=C unexpand in in > out || fail=1 +compare exp out > /dev/null 2>&1 || fail=1 -- -2.48.1 +2.49.0 diff --git a/coreutils.spec b/coreutils.spec index 23eb924..727da1b 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils -Version: 9.6 -Release: 2%{?dist} +Version: 9.7 +Release: 1%{?dist} # some used parts of gnulib are under various variants of LGPL License: GPL-3.0-or-later AND GFDL-1.3-no-invariants-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later Url: https://www.gnu.org/software/coreutils/ @@ -32,14 +32,6 @@ Patch103: coreutils-python3.patch # df --direct Patch104: coreutils-df-direct.patch -# ls: fix crash with --context -# https://git.savannah.gnu.org/cgit/coreutils.git/patch/?id=915004f403cb25fadb207ddfdbe6a2f43bd44fac -Patch105: coreutils-9.6-ls-selinux-crash.patch - -# who: fix -m with guessed tty names (rhbz#2343998) -# https://git.savannah.gnu.org/cgit/coreutils.git/patch/?id=24450e5eecf012bc1ea8cab8d677a45fa42c1778 -Patch106: coreutils-9.6-who-m-systemd.patch - # (sb) lin18nux/lsb compliance - multibyte functionality patch Patch800: coreutils-i18n.patch @@ -286,6 +278,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Wed Apr 09 2025 Lukáš Zaoral - 9.7-1 +- rebase to latest upstream release (rhbz#2358624) + * Tue Feb 25 2025 Lukáš Zaoral - 9.6-2 - fix 'who -m' with guessed tty names (rhbz#2343998) From 386bf34c2e19247b3b4b506588adf7cff5552d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= Date: Fri, 11 Apr 2025 09:17:07 +0200 Subject: [PATCH 02/15] sources: update for coreutils 9.7 ... which I forgot to commit with the rest of the changes... --- sources | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources b/sources index 498bfd9..0e9a66d 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (coreutils-9.6.tar.xz) = 398391d7f9d77e6117b750abb8711eebdd9cd2549e7846cab26884fb2dd522b6bcfb8bf7fef35a12683e213ada7f89b817bf615628628d42aee3fa3102647b28 -SHA512 (coreutils-9.6.tar.xz.sig) = a8e578b5e1d053b49e3e2c5dc94431d17c6a14662f459b2174cea23865ccca32e5ae5c13fedb0a8345d25269a9b98cb7f463a897c9663f9f9bcaf61e5c781378 +SHA512 (coreutils-9.7.tar.xz) = fe81e6ba4fb492095153d5baac1eca8f07ece0957849de746a2a858cf007893cc2ded595a31a5e5d43d13216cc44b9d74a3245d9f23221ecc8cd00f428f27414 +SHA512 (coreutils-9.7.tar.xz.sig) = 48d86a19cee3c153f01f7478847f4621685c02e59942540bb20b30e314df05230817b87d0e73acd953e79fab35718e5bea57f25fe511a2c275a85ced4b317bae From 4fbe411873d44109669215ee59f79369a1ea8b0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= Date: Mon, 19 May 2025 09:12:27 +0200 Subject: [PATCH 03/15] cp/mv: do not fail when copying of trivial NFSv4 ACLs fails Resolves: rhbz#2363149 --- ...ils-9.6-cp-improve-nfsv4-acl-support.patch | 573 ++++++++++++++++++ coreutils.spec | 11 +- 2 files changed, 583 insertions(+), 1 deletion(-) create mode 100644 coreutils-9.6-cp-improve-nfsv4-acl-support.patch diff --git a/coreutils-9.6-cp-improve-nfsv4-acl-support.patch b/coreutils-9.6-cp-improve-nfsv4-acl-support.patch new file mode 100644 index 0000000..f2a3840 --- /dev/null +++ b/coreutils-9.6-cp-improve-nfsv4-acl-support.patch @@ -0,0 +1,573 @@ +From 1cddf45cbba44b2afa34291b1b605d39c8cb061c Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Mon, 7 Apr 2025 01:45:17 -0700 +Subject: [PATCH 1/3] file-has-acl: port symlink code to Cygwin + +Problem reported by Corinna Vinschen in: +https://lists.gnu.org/r/bug-gnulib/2025-03/msg00112.html +* lib/file-has-acl.c (acl_get_link_np): New static function, +defined only if needed; include if needed for this. +(HAVE_ACL_GET_LINK_NP): Define this if defining acl_get_link_np. + +(cherry picked from commit 41e7b7e0d159d8ac0eb385964119f350ac9dfc3f) +--- + lib/file-has-acl.c | 25 ++++++++++++++++++++++++- + 1 file changed, 24 insertions(+), 1 deletion(-) + +diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c +index c02cfee..59ad9b9 100644 +--- a/lib/file-has-acl.c ++++ b/lib/file-has-acl.c +@@ -363,6 +363,29 @@ acl_nfs4_nontrivial (uint32_t *xattr, ssize_t nbytes) + } + #endif + ++#if (!USE_LINUX_XATTR && USE_ACL && HAVE_ACL_GET_FD \ ++ && !HAVE_ACL_EXTENDED_FILE && !HAVE_ACL_TYPE_EXTENDED \ ++ && !HAVE_ACL_GET_LINK_NP) ++# include ++# ifdef O_PATH ++ ++/* Like acl_get_file, but do not follow symbolic links. */ ++static acl_t ++acl_get_link_np (char const *name, acl_type_t type) ++{ ++ int fd = open (name, O_PATH | O_NOFOLLOW); ++ if (fd < 0) ++ return NULL; ++ acl_t r = acl_get_fd (fd); ++ int err = errno; ++ close (fd); ++ errno = err; ++ return r; ++} ++# define HAVE_ACL_GET_LINK_NP 1 ++# endif ++#endif ++ + /* Return 1 if NAME has a nontrivial access control list, + 0 if ACLs are not supported, or if NAME has no or only a base ACL, + and -1 (setting errno) on error. Note callers can determine +@@ -468,7 +491,7 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + ret = -1; + # else /* FreeBSD, NetBSD >= 10, IRIX, Tru64, Cygwin >= 2.5 */ + acl_t (*acl_get_file_or_link) (char const *, acl_type_t) = acl_get_file; +-# if HAVE_ACL_GET_LINK_NP /* FreeBSD, NetBSD >= 10 */ ++# if HAVE_ACL_GET_LINK_NP /* FreeBSD, NetBSD >= 10, Cygwin >= 2.5 */ + if (! (flags & ACL_SYMLINK_FOLLOW)) + acl_get_file_or_link = acl_get_link_np; + # endif +-- +2.49.0 + +From a0e61926b04ff6ec0449607ba306c1b5770660d3 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Fri, 9 May 2025 18:02:29 -0700 +Subject: [PATCH 2/3] qcopy-acl: port better to NFSv4 on GNU/Linux + +Problem reported by Ian Dall in +and by Thomas Clark in . +* lib/file-has-acl.c (smack_new_label_from_file) [!HAVE_SMACK]: +New dummy function. +(has_xattr, get_aclinfo): New arg FD. All callers changed. +Remove some unnecessary MAYBE_UNUSEDs. +(acl_get_fd_np): Fall back on acl_get_fd if this function is +needed but not available. +(acl_get_fdfile): New function, if needed. +(file_has_aclinfo): Reimplement in terms of ... +(fdfile_has_aclinfo): ... this new function, +which also has an FD argument. +* lib/qcopy-acl.c [USE_XATTR]: Include dirent.h, for DT_DIR etc. +(qcopy_acl): If attr_copy_file or attr_copy_fd fail with EOPNOTSUPP, +don’t fail if the source has a trivial ACL (this is the part +that fixes the bug; the rest is optimization). + +(cherry picked from commit 8a356b77717a2e4f735ec06e326880ca1f61aadb) +--- + lib/acl.h | 2 + + lib/copy-acl.c | 1 + + lib/file-has-acl.c | 172 ++++++++++++++++++++++++++++++++------------- + lib/qcopy-acl.c | 29 ++++++-- + 4 files changed, 152 insertions(+), 52 deletions(-) + +diff --git a/lib/acl.h b/lib/acl.h +index 90fd24e..e3c134f 100644 +--- a/lib/acl.h ++++ b/lib/acl.h +@@ -79,6 +79,8 @@ struct aclinfo + bool acl_errno_valid (int) _GL_ATTRIBUTE_CONST; + int file_has_acl (char const *, struct stat const *); + int file_has_aclinfo (char const *restrict, struct aclinfo *restrict, int); ++int fdfile_has_aclinfo (int, char const *restrict, ++ struct aclinfo *restrict, int); + + #if HAVE_LINUX_XATTR_H && HAVE_LISTXATTR + bool aclinfo_has_xattr (struct aclinfo const *, char const *) +diff --git a/lib/copy-acl.c b/lib/copy-acl.c +index c36f64e..2fce6c7 100644 +--- a/lib/copy-acl.c ++++ b/lib/copy-acl.c +@@ -33,6 +33,7 @@ + a valid file descriptor, use file descriptor operations, else use + filename based operations on SRC_NAME. Likewise for DEST_DESC and + DST_NAME. ++ MODE should be the source file's st_mode. + If access control lists are not available, fchmod the target file to + MODE. Also sets the non-permission bits of the destination file + (S_ISUID, S_ISGID, S_ISVTX) to those from MODE if any are set. +diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c +index 59ad9b9..afd951a 100644 +--- a/lib/file-has-acl.c ++++ b/lib/file-has-acl.c +@@ -86,6 +86,13 @@ smack_new_label_from_path (MAYBE_UNUSED const char *path, + { + return -1; + } ++static ssize_t ++smack_new_label_from_file (MAYBE_UNUSED int fd, ++ MAYBE_UNUSED const char *xattr, ++ MAYBE_UNUSED char **label) ++{ ++ return -1; ++} + # endif + static bool + is_smack_enabled (void) +@@ -116,14 +123,16 @@ aclinfo_may_indicate_xattr (struct aclinfo const *ai) + + static bool + has_xattr (char const *xattr, struct aclinfo const *ai, +- MAYBE_UNUSED char const *restrict name, MAYBE_UNUSED int flags) ++ int fd, char const *restrict name, int flags) + { + if (ai && aclinfo_has_xattr (ai, xattr)) + return true; + else if (!ai || aclinfo_may_indicate_xattr (ai)) + { +- int ret = ((flags & ACL_SYMLINK_FOLLOW ? getxattr : lgetxattr) +- (name, xattr, NULL, 0)); ++ int ret = (fd < 0 ++ ? ((flags & ACL_SYMLINK_FOLLOW ? getxattr : lgetxattr) ++ (name, xattr, NULL, 0)) ++ : fgetxattr (fd, xattr, NULL, 0)); + if (0 <= ret || (errno == ERANGE || errno == E2BIG)) + return true; + } +@@ -146,11 +155,12 @@ aclinfo_has_xattr (struct aclinfo const *ai, char const *xattr) + return false; + } + +-/* Get attributes of the file NAME into AI, if USE_ACL. ++/* Get attributes of the file FD aka NAME into AI, if USE_ACL. ++ Ignore FD if it is negative. + If FLAGS & ACL_GET_SCONTEXT, also get security context. + If FLAGS & ACL_SYMLINK_FOLLOW, follow symbolic links. */ + static void +-get_aclinfo (char const *name, struct aclinfo *ai, int flags) ++get_aclinfo (int fd, char const *name, struct aclinfo *ai, int flags) + { + int scontext_err = ENOTSUP; + ai->buf = ai->u.__gl_acl_ch; +@@ -164,7 +174,9 @@ get_aclinfo (char const *name, struct aclinfo *ai, int flags) + = (flags & ACL_SYMLINK_FOLLOW ? listxattr : llistxattr); + while (true) + { +- ai->size = lsxattr (name, ai->buf, acl_alloc); ++ ai->size = (fd < 0 ++ ? lsxattr (name, ai->buf, acl_alloc) ++ : flistxattr (fd, ai->buf, acl_alloc)); + if (0 < ai->size) + break; + ai->u.err = ai->size < 0 ? errno : 0; +@@ -172,7 +184,9 @@ get_aclinfo (char const *name, struct aclinfo *ai, int flags) + break; + + /* The buffer was too small. Find how large it should have been. */ +- ssize_t size = lsxattr (name, NULL, 0); ++ ssize_t size = (fd < 0 ++ ? lsxattr (name, NULL, 0) ++ : flistxattr (fd, NULL, 0)); + if (size <= 0) + { + ai->size = size; +@@ -215,9 +229,13 @@ get_aclinfo (char const *name, struct aclinfo *ai, int flags) + { + if (ai->size < 0 || aclinfo_has_xattr (ai, XATTR_NAME_SMACK)) + { +- ssize_t r = smack_new_label_from_path (name, "security.SMACK64", +- flags & ACL_SYMLINK_FOLLOW, +- &ai->scontext); ++ static char const SMACK64[] = "security.SMACK64"; ++ ssize_t r = ++ (fd < 0 ++ ? smack_new_label_from_path (name, SMACK64, ++ flags & ACL_SYMLINK_FOLLOW, ++ &ai->scontext) ++ : smack_new_label_from_file (fd, SMACK64, &ai->scontext)); + scontext_err = r < 0 ? errno : 0; + } + } +@@ -227,8 +245,10 @@ get_aclinfo (char const *name, struct aclinfo *ai, int flags) + if (ai->size < 0 || aclinfo_has_xattr (ai, XATTR_NAME_SELINUX)) + { + ssize_t r = +- ((flags & ACL_SYMLINK_FOLLOW ? getfilecon : lgetfilecon) +- (name, &ai->scontext)); ++ (fd < 0 ++ ? ((flags & ACL_SYMLINK_FOLLOW ? getfilecon : lgetfilecon) ++ (name, &ai->scontext)) ++ : fgetfilecon (fd, &ai->scontext)); + scontext_err = r < 0 ? errno : 0; + # ifndef SE_SELINUX_INLINE + /* Gnulib's selinux-h module is not in use, so getfilecon and +@@ -363,11 +383,13 @@ acl_nfs4_nontrivial (uint32_t *xattr, ssize_t nbytes) + } + #endif + +-#if (!USE_LINUX_XATTR && USE_ACL && HAVE_ACL_GET_FD \ +- && !HAVE_ACL_EXTENDED_FILE && !HAVE_ACL_TYPE_EXTENDED \ +- && !HAVE_ACL_GET_LINK_NP) +-# include +-# ifdef O_PATH ++#if (!USE_LINUX_XATTR && USE_ACL && !HAVE_ACL_EXTENDED_FILE \ ++ && !HAVE_ACL_TYPE_EXTENDED) ++ ++# if HAVE_ACL_GET_FD && !HAVE_ACL_GET_LINK_NP ++# include ++# ifdef O_PATH ++# define acl_get_fd_np(fd, type) acl_get_fd (fd) + + /* Like acl_get_file, but do not follow symbolic links. */ + static acl_t +@@ -382,8 +404,24 @@ acl_get_link_np (char const *name, acl_type_t type) + errno = err; + return r; + } +-# define HAVE_ACL_GET_LINK_NP 1 ++# define HAVE_ACL_GET_LINK_NP 1 ++# endif + # endif ++ ++static acl_t ++acl_get_fdfile (int fd, char const *name, acl_type_t type, int flags) ++{ ++ acl_t (*get) (char const *, acl_type_t) = acl_get_file; ++# if HAVE_ACL_GET_LINK_NP /* FreeBSD, NetBSD >= 10, Cygwin >= 2.5 */ ++ if (0 <= fd) ++ return acl_get_fd_np (fd, type); ++ if (! (flags & ACL_SYMLINK_FOLLOW)) ++ get = acl_get_link_np; ++# else ++ /* Ignore FD and FLAGS, unfortunately. */ ++# endif ++ return get (name, type); ++} + #endif + + /* Return 1 if NAME has a nontrivial access control list, +@@ -399,14 +437,35 @@ acl_get_link_np (char const *name, acl_type_t type) + If the d_type value is not known, use DT_UNKNOWN though this may be less + efficient. */ + int +-file_has_aclinfo (MAYBE_UNUSED char const *restrict name, ++file_has_aclinfo (char const *restrict name, + struct aclinfo *restrict ai, int flags) ++{ ++ return fdfile_has_aclinfo (-1, name, ai, flags); ++} ++ ++/* Return 1 if FD aka NAME has a nontrivial access control list, ++ 0 if ACLs are not supported, or if NAME has no or only a base ACL, ++ and -1 (setting errno) on error. Note callers can determine ++ if ACLs are not supported as errno is set in that case also. ++ Ignore FD if it is negative. ++ Set *AI to ACL info regardless of return value. ++ FLAGS should be a d_type value, optionally ORed with ++ - _GL_DT_NOTDIR if it is known that NAME is not a directory, ++ - ACL_GET_SCONTEXT to retrieve security context and return 1 if present, ++ - ACL_SYMLINK_FOLLOW to follow the link if NAME is a symbolic link; ++ otherwise do not follow them if possible. ++ If the d_type value is not known, use DT_UNKNOWN though this may be less ++ efficient. */ ++int ++fdfile_has_aclinfo (MAYBE_UNUSED int fd, ++ MAYBE_UNUSED char const *restrict name, ++ struct aclinfo *restrict ai, int flags) + { + MAYBE_UNUSED unsigned char d_type = flags & UCHAR_MAX; + + #if USE_LINUX_XATTR + int initial_errno = errno; +- get_aclinfo (name, ai, flags); ++ get_aclinfo (fd, name, ai, flags); + + if (!aclinfo_may_indicate_xattr (ai) && ai->size <= 0) + { +@@ -419,11 +478,11 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + In earlier Fedora the two types of ACLs were mutually exclusive. + Attempt to work correctly on both kinds of systems. */ + +- if (!has_xattr (XATTR_NAME_NFSV4_ACL, ai, name, flags)) ++ if (!has_xattr (XATTR_NAME_NFSV4_ACL, ai, fd, name, flags)) + return +- (has_xattr (XATTR_NAME_POSIX_ACL_ACCESS, ai, name, flags) ++ (has_xattr (XATTR_NAME_POSIX_ACL_ACCESS, ai, fd, name, flags) + || ((d_type == DT_DIR || d_type == DT_UNKNOWN) +- && has_xattr (XATTR_NAME_POSIX_ACL_DEFAULT, ai, name, flags))); ++ && has_xattr (XATTR_NAME_POSIX_ACL_DEFAULT, ai, fd, name, flags))); + + /* A buffer large enough to hold any trivial NFSv4 ACL. + The max length of a trivial NFSv4 ACL is 6 words for owner, +@@ -433,8 +492,10 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + everyone is another word to hold "EVERYONE@". */ + uint32_t buf[2 * (6 + 6 + 7)]; + +- int ret = ((flags & ACL_SYMLINK_FOLLOW ? getxattr : lgetxattr) +- (name, XATTR_NAME_NFSV4_ACL, buf, sizeof buf)); ++ int ret = (fd < 0 ++ ? ((flags & ACL_SYMLINK_FOLLOW ? getxattr : lgetxattr) ++ (name, XATTR_NAME_NFSV4_ACL, buf, sizeof buf)) ++ : fgetxattr (fd, XATTR_NAME_NFSV4_ACL, buf, sizeof buf)); + if (ret < 0) + switch (errno) + { +@@ -468,20 +529,23 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + /* On Linux, acl_extended_file is an optimized function: It only + makes two calls to getxattr(), one for ACL_TYPE_ACCESS, one for + ACL_TYPE_DEFAULT. */ +- ret = ((flags & ACL_SYMLINK_FOLLOW +- ? acl_extended_file +- : acl_extended_file_nofollow) +- (name)); ++ ret = (fd < 0 ++ ? ((flags & ACL_SYMLINK_FOLLOW ++ ? acl_extended_file ++ : acl_extended_file_nofollow) ++ (name)) ++ : acl_extended_fd (fd)); + # elif HAVE_ACL_TYPE_EXTENDED /* Mac OS X */ + /* On Mac OS X, acl_get_file (name, ACL_TYPE_ACCESS) + and acl_get_file (name, ACL_TYPE_DEFAULT) + always return NULL / EINVAL. There is no point in making + these two useless calls. The real ACL is retrieved through +- acl_get_file (name, ACL_TYPE_EXTENDED). */ +- acl_t acl = ((flags & ACL_SYMLINK_FOLLOW +- ? acl_get_file +- : acl_get_link_np) +- (name, ACL_TYPE_EXTENDED)); ++ ACL_TYPE_EXTENDED. */ ++ acl_t acl = ++ (fd < 0 ++ ? ((flags & ACL_SYMLINK_FOLLOW ? acl_get_file : acl_get_link_np) ++ (name, ACL_TYPE_EXTENDED)) ++ : acl_get_fd_np (fd, ACL_TYPE_EXTENDED)); + if (acl) + { + ret = acl_extended_nontrivial (acl); +@@ -490,13 +554,8 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + else + ret = -1; + # else /* FreeBSD, NetBSD >= 10, IRIX, Tru64, Cygwin >= 2.5 */ +- acl_t (*acl_get_file_or_link) (char const *, acl_type_t) = acl_get_file; +-# if HAVE_ACL_GET_LINK_NP /* FreeBSD, NetBSD >= 10, Cygwin >= 2.5 */ +- if (! (flags & ACL_SYMLINK_FOLLOW)) +- acl_get_file_or_link = acl_get_link_np; +-# endif + +- acl_t acl = acl_get_file_or_link (name, ACL_TYPE_ACCESS); ++ acl_t acl = acl_get_fdfile (fd, name, ACL_TYPE_ACCESS, flags); + if (acl) + { + ret = acl_access_nontrivial (acl); +@@ -518,7 +577,7 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + && (d_type == DT_DIR + || (d_type == DT_UNKNOWN && !(flags & _GL_DT_NOTDIR)))) + { +- acl = acl_get_file_or_link (name, ACL_TYPE_DEFAULT); ++ acl = acl_get_fdfile (fd, name, ACL_TYPE_DEFAULT, flags); + if (acl) + { + # ifdef __CYGWIN__ /* Cygwin >= 2.5 */ +@@ -563,7 +622,10 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + + /* Solaris 10 (newer version), which has additional API declared in + (acl_t) and implemented in libsec (acl_set, acl_trivial, +- acl_fromtext, ...). */ ++ acl_fromtext, ...). ++ ++ Ignore FD, unfortunately. That is better than mishandling ++ ZFS-style ACLs, as the general case code does. */ + return acl_trivial (name); + + # else /* Solaris, Cygwin, general case */ +@@ -587,7 +649,9 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + + for (;;) + { +- count = acl (name, GETACL, alloc, entries); ++ count = (fd < 0 ++ ? acl (name, GETACL, alloc, entries) ++ : facl (fd, GETACL, alloc, entries)); + if (count < 0 && errno == ENOSPC) + { + /* Increase the size of the buffer. */ +@@ -658,7 +722,9 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + + for (;;) + { +- count = acl (name, ACE_GETACL, alloc, entries); ++ count = (fd < 0 ++ ? acl (name, ACE_GETACL, alloc, entries) ++ : facl (fd, ACE_GETACL, alloc, entries)); + if (count < 0 && errno == ENOSPC) + { + /* Increase the size of the buffer. */ +@@ -723,7 +789,9 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + struct acl_entry entries[NACLENTRIES]; + int count; + +- count = getacl (name, NACLENTRIES, entries); ++ count = (fd < 0 ++ ? getacl (name, NACLENTRIES, entries) ++ : fgetacl (fd, NACLENTRIES, entries)); + + if (count < 0) + { +@@ -752,7 +820,8 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + { + struct stat statbuf; + +- if (stat (name, &statbuf) == -1 && errno != EOVERFLOW) ++ if ((fd < 0 ? stat (name, &statbuf) : fstat (fd, &statbuf)) < 0 ++ && errno != EOVERFLOW) + return -1; + + return acl_nontrivial (count, entries); +@@ -766,6 +835,7 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + struct acl entries[NACLVENTRIES]; + int count; + ++ /* Ignore FD, unfortunately. */ + count = acl ((char *) name, ACL_GET, NACLVENTRIES, entries); + + if (count < 0) +@@ -810,7 +880,9 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + /* The docs say that type being 0 is equivalent to ACL_ANY, but it + is not true, in AIX 5.3. */ + type.u64 = ACL_ANY; +- if (aclx_get (name, 0, &type, aclbuf, &aclsize, &mode) >= 0) ++ if (0 <= (fd < 0 ++ ? aclx_get (name, 0, &type, aclbuf, &aclsize, &mode) ++ : aclx_fget (fd, 0, &type, aclbuf, &aclsize, &mode))) + break; + if (errno == ENOSYS) + return 0; +@@ -856,7 +928,10 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + + union { struct acl a; char room[4096]; } u; + +- if (statacl ((char *) name, STX_NORMAL, &u.a, sizeof (u)) < 0) ++ if ((fd < 0 ++ ? statacl ((char *) name, STX_NORMAL, &u.a, sizeof u) ++ : fstatacl (fd, STX_NORMAL, &u.a, sizeof u)) ++ < 0) + return -1; + + return acl_nontrivial (&u.a); +@@ -867,6 +942,7 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + struct acl entries[NACLENTRIES]; + int count; + ++ /* Ignore FD, unfortunately. */ + count = acl ((char *) name, ACL_GET, NACLENTRIES, entries); + + if (count < 0) +diff --git a/lib/qcopy-acl.c b/lib/qcopy-acl.c +index ad79661..282f4b2 100644 +--- a/lib/qcopy-acl.c ++++ b/lib/qcopy-acl.c +@@ -26,6 +26,7 @@ + #if USE_XATTR + + # include ++# include + # include + + # if HAVE_LINUX_XATTR_H +@@ -61,6 +62,7 @@ is_attr_permissions (const char *name, struct error_context *ctx) + a valid file descriptor, use file descriptor operations, else use + filename based operations on SRC_NAME. Likewise for DEST_DESC and + DST_NAME. ++ MODE should be the source file's st_mode. + If access control lists are not available, fchmod the target file to + MODE. Also sets the non-permission bits of the destination file + (S_ISUID, S_ISGID, S_ISVTX) to those from MODE if any are set. +@@ -86,10 +88,29 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, + Functions attr_copy_* return 0 in case we copied something OR nothing + to copy */ + if (ret == 0) +- ret = source_desc <= 0 || dest_desc <= 0 +- ? attr_copy_file (src_name, dst_name, is_attr_permissions, NULL) +- : attr_copy_fd (src_name, source_desc, dst_name, dest_desc, +- is_attr_permissions, NULL); ++ { ++ ret = source_desc <= 0 || dest_desc <= 0 ++ ? attr_copy_file (src_name, dst_name, is_attr_permissions, NULL) ++ : attr_copy_fd (src_name, source_desc, dst_name, dest_desc, ++ is_attr_permissions, NULL); ++ ++ /* Copying can fail with EOPNOTSUPP even when the source ++ permissions are trivial (Bug#78328). Don't report an error ++ in this case, as the chmod_or_fchmod suffices. */ ++ if (ret < 0 && errno == EOPNOTSUPP) ++ { ++ /* fdfile_has_aclinfo cares only about DT_DIR, _GL_DT_NOTDIR, ++ and DT_LNK (but DT_LNK is not possible here), ++ so use _GL_DT_NOTDIR | DT_UNKNOWN for other file types. */ ++ int flags = S_ISDIR (mode) ? DT_DIR : _GL_DT_NOTDIR | DT_UNKNOWN; ++ ++ struct aclinfo ai; ++ if (!fdfile_has_aclinfo (source_desc, src_name, &ai, flags)) ++ ret = 0; ++ aclinfo_free (&ai); ++ errno = EOPNOTSUPP; ++ } ++ } + #else + /* no XATTR, so we proceed the old dusty way */ + struct permission_context ctx; +-- +2.49.0 + +From 6595a08347c03321e1061ae747f02e4fe67e2073 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Fri, 9 May 2025 18:48:03 -0700 +Subject: [PATCH 3/3] acl-tests: link with $(FILE_HAS_ACL_LIB) + +* modules/acl-tests (test_copy_acl_LDADD): Add +$(FILE_HAS_ACL_LIB), since qcopy-acl depends on file-has-acl. +Although this suggests that QCOPY_ACL_LIB should contain +FILE_HAS_ACL_LIB, I’m not sure whether that’s the right course of +action and anyway this is good enough for coreutils. + +(cherry picked from commit 955360a66c99bdd9ac3688519a8b521b06958fd3) +--- + gnulib-tests/gnulib.mk | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gnulib-tests/gnulib.mk b/gnulib-tests/gnulib.mk +index eab1c6b..a5fd178 100644 +--- a/gnulib-tests/gnulib.mk ++++ b/gnulib-tests/gnulib.mk +@@ -99,7 +99,7 @@ TESTS += \ + TESTS_ENVIRONMENT += USE_ACL=$(USE_ACL) + check_PROGRAMS += test-set-mode-acl test-copy-acl test-sameacls + test_set_mode_acl_LDADD = $(LDADD) $(LIB_ACL) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV) +-test_copy_acl_LDADD = $(LDADD) $(LIB_ACL) $(QCOPY_ACL_LIB) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV) ++test_copy_acl_LDADD = $(LDADD) $(LIB_ACL) $(QCOPY_ACL_LIB) $(FILE_HAS_ACL_LIB) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV) + test_sameacls_LDADD = $(LDADD) $(LIB_ACL) @LIBINTL@ $(MBRTOWC_LIB) + EXTRA_DIST += test-set-mode-acl.sh test-set-mode-acl-1.sh test-set-mode-acl-2.sh test-copy-acl.sh test-copy-acl-1.sh test-copy-acl-2.sh test-set-mode-acl.c test-copy-acl.c test-sameacls.c macros.h + +-- +2.49.0 + diff --git a/coreutils.spec b/coreutils.spec index 23eb924..b0b2230 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 9.6 -Release: 2%{?dist} +Release: 3%{?dist} # some used parts of gnulib are under various variants of LGPL License: GPL-3.0-or-later AND GFDL-1.3-no-invariants-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later Url: https://www.gnu.org/software/coreutils/ @@ -40,6 +40,12 @@ Patch105: coreutils-9.6-ls-selinux-crash.patch # https://git.savannah.gnu.org/cgit/coreutils.git/patch/?id=24450e5eecf012bc1ea8cab8d677a45fa42c1778 Patch106: coreutils-9.6-who-m-systemd.patch +# cp/mv: do not fail when copying of trivial NFSv4 ACLs fails (rhbz#2363149) +# https://git.savannah.gnu.org/cgit/gnulib.git/patch?id=41e7b7e0d159d8ac0eb385964119f350ac9dfc3f +# https://git.savannah.gnu.org/cgit/gnulib.git/patch?id=8a356b77717a2e4f735ec06e326880ca1f61aadb +# https://git.savannah.gnu.org/cgit/gnulib.git/patch?id=955360a66c99bdd9ac3688519a8b521b06958fd3 +Patch107: coreutils-9.6-cp-improve-nfsv4-acl-support.patch + # (sb) lin18nux/lsb compliance - multibyte functionality patch Patch800: coreutils-i18n.patch @@ -286,6 +292,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Mon May 19 2025 Lukáš Zaoral - 9.6-3 +- cp/mv: do not fail when copying of trivial NFSv4 ACLs fails (rhbz#2363149) + * Tue Feb 25 2025 Lukáš Zaoral - 9.6-2 - fix 'who -m' with guessed tty names (rhbz#2343998) From a0b27bcd5fc64c0a9720e0b8ecc767258bac71de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= Date: Mon, 19 May 2025 09:47:42 +0200 Subject: [PATCH 04/15] cp/mv: do not fail when copying of trivial NFSv4 ACLs fails Resolves: rhbz#2363149 --- ...ils-9.6-cp-improve-nfsv4-acl-support.patch | 512 ++++++++++++++++++ coreutils.spec | 10 +- 2 files changed, 521 insertions(+), 1 deletion(-) create mode 100644 coreutils-9.6-cp-improve-nfsv4-acl-support.patch diff --git a/coreutils-9.6-cp-improve-nfsv4-acl-support.patch b/coreutils-9.6-cp-improve-nfsv4-acl-support.patch new file mode 100644 index 0000000..1b36b1e --- /dev/null +++ b/coreutils-9.6-cp-improve-nfsv4-acl-support.patch @@ -0,0 +1,512 @@ +From 6ad28e2b6627caf7b83bf893027c087b8cea1a97 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Fri, 9 May 2025 18:02:29 -0700 +Subject: [PATCH 1/2] qcopy-acl: port better to NFSv4 on GNU/Linux + +Problem reported by Ian Dall in +and by Thomas Clark in . +* lib/file-has-acl.c (smack_new_label_from_file) [!HAVE_SMACK]: +New dummy function. +(has_xattr, get_aclinfo): New arg FD. All callers changed. +Remove some unnecessary MAYBE_UNUSEDs. +(acl_get_fd_np): Fall back on acl_get_fd if this function is +needed but not available. +(acl_get_fdfile): New function, if needed. +(file_has_aclinfo): Reimplement in terms of ... +(fdfile_has_aclinfo): ... this new function, +which also has an FD argument. +* lib/qcopy-acl.c [USE_XATTR]: Include dirent.h, for DT_DIR etc. +(qcopy_acl): If attr_copy_file or attr_copy_fd fail with EOPNOTSUPP, +don’t fail if the source has a trivial ACL (this is the part +that fixes the bug; the rest is optimization). + +(cherry picked from commit 8a356b77717a2e4f735ec06e326880ca1f61aadb) +--- + lib/acl.h | 2 + + lib/copy-acl.c | 1 + + lib/file-has-acl.c | 172 ++++++++++++++++++++++++++++++++------------- + lib/qcopy-acl.c | 29 ++++++-- + 4 files changed, 152 insertions(+), 52 deletions(-) + +diff --git a/lib/acl.h b/lib/acl.h +index 90fd24e..e3c134f 100644 +--- a/lib/acl.h ++++ b/lib/acl.h +@@ -79,6 +79,8 @@ struct aclinfo + bool acl_errno_valid (int) _GL_ATTRIBUTE_CONST; + int file_has_acl (char const *, struct stat const *); + int file_has_aclinfo (char const *restrict, struct aclinfo *restrict, int); ++int fdfile_has_aclinfo (int, char const *restrict, ++ struct aclinfo *restrict, int); + + #if HAVE_LINUX_XATTR_H && HAVE_LISTXATTR + bool aclinfo_has_xattr (struct aclinfo const *, char const *) +diff --git a/lib/copy-acl.c b/lib/copy-acl.c +index c36f64e..2fce6c7 100644 +--- a/lib/copy-acl.c ++++ b/lib/copy-acl.c +@@ -33,6 +33,7 @@ + a valid file descriptor, use file descriptor operations, else use + filename based operations on SRC_NAME. Likewise for DEST_DESC and + DST_NAME. ++ MODE should be the source file's st_mode. + If access control lists are not available, fchmod the target file to + MODE. Also sets the non-permission bits of the destination file + (S_ISUID, S_ISGID, S_ISVTX) to those from MODE if any are set. +diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c +index 66b920c..a356ee0 100644 +--- a/lib/file-has-acl.c ++++ b/lib/file-has-acl.c +@@ -85,6 +85,13 @@ smack_new_label_from_path (MAYBE_UNUSED const char *path, + { + return -1; + } ++static ssize_t ++smack_new_label_from_file (MAYBE_UNUSED int fd, ++ MAYBE_UNUSED const char *xattr, ++ MAYBE_UNUSED char **label) ++{ ++ return -1; ++} + # endif + static bool + is_smack_enabled (void) +@@ -115,14 +122,16 @@ aclinfo_may_indicate_xattr (struct aclinfo const *ai) + + static bool + has_xattr (char const *xattr, struct aclinfo const *ai, +- MAYBE_UNUSED char const *restrict name, MAYBE_UNUSED int flags) ++ int fd, char const *restrict name, int flags) + { + if (ai && aclinfo_has_xattr (ai, xattr)) + return true; + else if (!ai || aclinfo_may_indicate_xattr (ai)) + { +- int ret = ((flags & ACL_SYMLINK_FOLLOW ? getxattr : lgetxattr) +- (name, xattr, NULL, 0)); ++ int ret = (fd < 0 ++ ? ((flags & ACL_SYMLINK_FOLLOW ? getxattr : lgetxattr) ++ (name, xattr, NULL, 0)) ++ : fgetxattr (fd, xattr, NULL, 0)); + if (0 <= ret || (errno == ERANGE || errno == E2BIG)) + return true; + } +@@ -145,11 +154,12 @@ aclinfo_has_xattr (struct aclinfo const *ai, char const *xattr) + return false; + } + +-/* Get attributes of the file NAME into AI, if USE_ACL. ++/* Get attributes of the file FD aka NAME into AI, if USE_ACL. ++ Ignore FD if it is negative. + If FLAGS & ACL_GET_SCONTEXT, also get security context. + If FLAGS & ACL_SYMLINK_FOLLOW, follow symbolic links. */ + static void +-get_aclinfo (char const *name, struct aclinfo *ai, int flags) ++get_aclinfo (int fd, char const *name, struct aclinfo *ai, int flags) + { + int scontext_err = ENOTSUP; + ai->buf = ai->u.__gl_acl_ch; +@@ -163,7 +173,9 @@ get_aclinfo (char const *name, struct aclinfo *ai, int flags) + = (flags & ACL_SYMLINK_FOLLOW ? listxattr : llistxattr); + while (true) + { +- ai->size = lsxattr (name, ai->buf, acl_alloc); ++ ai->size = (fd < 0 ++ ? lsxattr (name, ai->buf, acl_alloc) ++ : flistxattr (fd, ai->buf, acl_alloc)); + if (0 < ai->size) + break; + ai->u.err = ai->size < 0 ? errno : 0; +@@ -171,7 +183,9 @@ get_aclinfo (char const *name, struct aclinfo *ai, int flags) + break; + + /* The buffer was too small. Find how large it should have been. */ +- ssize_t size = lsxattr (name, NULL, 0); ++ ssize_t size = (fd < 0 ++ ? lsxattr (name, NULL, 0) ++ : flistxattr (fd, NULL, 0)); + if (size <= 0) + { + ai->size = size; +@@ -214,9 +228,13 @@ get_aclinfo (char const *name, struct aclinfo *ai, int flags) + { + if (ai->size < 0 || aclinfo_has_xattr (ai, XATTR_NAME_SMACK)) + { +- ssize_t r = smack_new_label_from_path (name, "security.SMACK64", +- flags & ACL_SYMLINK_FOLLOW, +- &ai->scontext); ++ static char const SMACK64[] = "security.SMACK64"; ++ ssize_t r = ++ (fd < 0 ++ ? smack_new_label_from_path (name, SMACK64, ++ flags & ACL_SYMLINK_FOLLOW, ++ &ai->scontext) ++ : smack_new_label_from_file (fd, SMACK64, &ai->scontext)); + scontext_err = r < 0 ? errno : 0; + } + } +@@ -226,8 +244,10 @@ get_aclinfo (char const *name, struct aclinfo *ai, int flags) + if (ai->size < 0 || aclinfo_has_xattr (ai, XATTR_NAME_SELINUX)) + { + ssize_t r = +- ((flags & ACL_SYMLINK_FOLLOW ? getfilecon : lgetfilecon) +- (name, &ai->scontext)); ++ (fd < 0 ++ ? ((flags & ACL_SYMLINK_FOLLOW ? getfilecon : lgetfilecon) ++ (name, &ai->scontext)) ++ : fgetfilecon (fd, &ai->scontext)); + scontext_err = r < 0 ? errno : 0; + # ifndef SE_SELINUX_INLINE + /* Gnulib's selinux-h module is not in use, so getfilecon and +@@ -362,11 +382,13 @@ acl_nfs4_nontrivial (uint32_t *xattr, ssize_t nbytes) + } + #endif + +-#if (!USE_LINUX_XATTR && USE_ACL && HAVE_ACL_GET_FD \ +- && !HAVE_ACL_EXTENDED_FILE && !HAVE_ACL_TYPE_EXTENDED \ +- && !HAVE_ACL_GET_LINK_NP) +-# include +-# ifdef O_PATH ++#if (!USE_LINUX_XATTR && USE_ACL && !HAVE_ACL_EXTENDED_FILE \ ++ && !HAVE_ACL_TYPE_EXTENDED) ++ ++# if HAVE_ACL_GET_FD && !HAVE_ACL_GET_LINK_NP ++# include ++# ifdef O_PATH ++# define acl_get_fd_np(fd, type) acl_get_fd (fd) + + /* Like acl_get_file, but do not follow symbolic links. */ + static acl_t +@@ -381,8 +403,24 @@ acl_get_link_np (char const *name, acl_type_t type) + errno = err; + return r; + } +-# define HAVE_ACL_GET_LINK_NP 1 ++# define HAVE_ACL_GET_LINK_NP 1 ++# endif + # endif ++ ++static acl_t ++acl_get_fdfile (int fd, char const *name, acl_type_t type, int flags) ++{ ++ acl_t (*get) (char const *, acl_type_t) = acl_get_file; ++# if HAVE_ACL_GET_LINK_NP /* FreeBSD, NetBSD >= 10, Cygwin >= 2.5 */ ++ if (0 <= fd) ++ return acl_get_fd_np (fd, type); ++ if (! (flags & ACL_SYMLINK_FOLLOW)) ++ get = acl_get_link_np; ++# else ++ /* Ignore FD and FLAGS, unfortunately. */ ++# endif ++ return get (name, type); ++} + #endif + + /* Return 1 if NAME has a nontrivial access control list, +@@ -398,14 +436,35 @@ acl_get_link_np (char const *name, acl_type_t type) + If the d_type value is not known, use DT_UNKNOWN though this may be less + efficient. */ + int +-file_has_aclinfo (MAYBE_UNUSED char const *restrict name, ++file_has_aclinfo (char const *restrict name, + struct aclinfo *restrict ai, int flags) ++{ ++ return fdfile_has_aclinfo (-1, name, ai, flags); ++} ++ ++/* Return 1 if FD aka NAME has a nontrivial access control list, ++ 0 if ACLs are not supported, or if NAME has no or only a base ACL, ++ and -1 (setting errno) on error. Note callers can determine ++ if ACLs are not supported as errno is set in that case also. ++ Ignore FD if it is negative. ++ Set *AI to ACL info regardless of return value. ++ FLAGS should be a d_type value, optionally ORed with ++ - _GL_DT_NOTDIR if it is known that NAME is not a directory, ++ - ACL_GET_SCONTEXT to retrieve security context and return 1 if present, ++ - ACL_SYMLINK_FOLLOW to follow the link if NAME is a symbolic link; ++ otherwise do not follow them if possible. ++ If the d_type value is not known, use DT_UNKNOWN though this may be less ++ efficient. */ ++int ++fdfile_has_aclinfo (MAYBE_UNUSED int fd, ++ MAYBE_UNUSED char const *restrict name, ++ struct aclinfo *restrict ai, int flags) + { + MAYBE_UNUSED unsigned char d_type = flags & UCHAR_MAX; + + #if USE_LINUX_XATTR + int initial_errno = errno; +- get_aclinfo (name, ai, flags); ++ get_aclinfo (fd, name, ai, flags); + + if (!aclinfo_may_indicate_xattr (ai) && ai->size <= 0) + { +@@ -418,11 +477,11 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + In earlier Fedora the two types of ACLs were mutually exclusive. + Attempt to work correctly on both kinds of systems. */ + +- if (!has_xattr (XATTR_NAME_NFSV4_ACL, ai, name, flags)) ++ if (!has_xattr (XATTR_NAME_NFSV4_ACL, ai, fd, name, flags)) + return +- (has_xattr (XATTR_NAME_POSIX_ACL_ACCESS, ai, name, flags) ++ (has_xattr (XATTR_NAME_POSIX_ACL_ACCESS, ai, fd, name, flags) + || ((d_type == DT_DIR || d_type == DT_UNKNOWN) +- && has_xattr (XATTR_NAME_POSIX_ACL_DEFAULT, ai, name, flags))); ++ && has_xattr (XATTR_NAME_POSIX_ACL_DEFAULT, ai, fd, name, flags))); + + /* A buffer large enough to hold any trivial NFSv4 ACL. + The max length of a trivial NFSv4 ACL is 6 words for owner, +@@ -432,8 +491,10 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + everyone is another word to hold "EVERYONE@". */ + uint32_t buf[2 * (6 + 6 + 7)]; + +- int ret = ((flags & ACL_SYMLINK_FOLLOW ? getxattr : lgetxattr) +- (name, XATTR_NAME_NFSV4_ACL, buf, sizeof buf)); ++ int ret = (fd < 0 ++ ? ((flags & ACL_SYMLINK_FOLLOW ? getxattr : lgetxattr) ++ (name, XATTR_NAME_NFSV4_ACL, buf, sizeof buf)) ++ : fgetxattr (fd, XATTR_NAME_NFSV4_ACL, buf, sizeof buf)); + if (ret < 0) + switch (errno) + { +@@ -467,20 +528,23 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + /* On Linux, acl_extended_file is an optimized function: It only + makes two calls to getxattr(), one for ACL_TYPE_ACCESS, one for + ACL_TYPE_DEFAULT. */ +- ret = ((flags & ACL_SYMLINK_FOLLOW +- ? acl_extended_file +- : acl_extended_file_nofollow) +- (name)); ++ ret = (fd < 0 ++ ? ((flags & ACL_SYMLINK_FOLLOW ++ ? acl_extended_file ++ : acl_extended_file_nofollow) ++ (name)) ++ : acl_extended_fd (fd)); + # elif HAVE_ACL_TYPE_EXTENDED /* Mac OS X */ + /* On Mac OS X, acl_get_file (name, ACL_TYPE_ACCESS) + and acl_get_file (name, ACL_TYPE_DEFAULT) + always return NULL / EINVAL. There is no point in making + these two useless calls. The real ACL is retrieved through +- acl_get_file (name, ACL_TYPE_EXTENDED). */ +- acl_t acl = ((flags & ACL_SYMLINK_FOLLOW +- ? acl_get_file +- : acl_get_link_np) +- (name, ACL_TYPE_EXTENDED)); ++ ACL_TYPE_EXTENDED. */ ++ acl_t acl = ++ (fd < 0 ++ ? ((flags & ACL_SYMLINK_FOLLOW ? acl_get_file : acl_get_link_np) ++ (name, ACL_TYPE_EXTENDED)) ++ : acl_get_fd_np (fd, ACL_TYPE_EXTENDED)); + if (acl) + { + ret = acl_extended_nontrivial (acl); +@@ -489,13 +553,8 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + else + ret = -1; + # else /* FreeBSD, NetBSD >= 10, IRIX, Tru64, Cygwin >= 2.5 */ +- acl_t (*acl_get_file_or_link) (char const *, acl_type_t) = acl_get_file; +-# if HAVE_ACL_GET_LINK_NP /* FreeBSD, NetBSD >= 10, Cygwin >= 2.5 */ +- if (! (flags & ACL_SYMLINK_FOLLOW)) +- acl_get_file_or_link = acl_get_link_np; +-# endif + +- acl_t acl = acl_get_file_or_link (name, ACL_TYPE_ACCESS); ++ acl_t acl = acl_get_fdfile (fd, name, ACL_TYPE_ACCESS, flags); + if (acl) + { + ret = acl_access_nontrivial (acl); +@@ -517,7 +576,7 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + && (d_type == DT_DIR + || (d_type == DT_UNKNOWN && !(flags & _GL_DT_NOTDIR)))) + { +- acl = acl_get_file_or_link (name, ACL_TYPE_DEFAULT); ++ acl = acl_get_fdfile (fd, name, ACL_TYPE_DEFAULT, flags); + if (acl) + { + # ifdef __CYGWIN__ /* Cygwin >= 2.5 */ +@@ -562,7 +621,10 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + + /* Solaris 10 (newer version), which has additional API declared in + (acl_t) and implemented in libsec (acl_set, acl_trivial, +- acl_fromtext, ...). */ ++ acl_fromtext, ...). ++ ++ Ignore FD, unfortunately. That is better than mishandling ++ ZFS-style ACLs, as the general case code does. */ + return acl_trivial (name); + + # else /* Solaris, Cygwin, general case */ +@@ -586,7 +648,9 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + + for (;;) + { +- count = acl (name, GETACL, alloc, entries); ++ count = (fd < 0 ++ ? acl (name, GETACL, alloc, entries) ++ : facl (fd, GETACL, alloc, entries)); + if (count < 0 && errno == ENOSPC) + { + /* Increase the size of the buffer. */ +@@ -657,7 +721,9 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + + for (;;) + { +- count = acl (name, ACE_GETACL, alloc, entries); ++ count = (fd < 0 ++ ? acl (name, ACE_GETACL, alloc, entries) ++ : facl (fd, ACE_GETACL, alloc, entries)); + if (count < 0 && errno == ENOSPC) + { + /* Increase the size of the buffer. */ +@@ -722,7 +788,9 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + struct acl_entry entries[NACLENTRIES]; + int count; + +- count = getacl (name, NACLENTRIES, entries); ++ count = (fd < 0 ++ ? getacl (name, NACLENTRIES, entries) ++ : fgetacl (fd, NACLENTRIES, entries)); + + if (count < 0) + { +@@ -751,7 +819,8 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + { + struct stat statbuf; + +- if (stat (name, &statbuf) == -1 && errno != EOVERFLOW) ++ if ((fd < 0 ? stat (name, &statbuf) : fstat (fd, &statbuf)) < 0 ++ && errno != EOVERFLOW) + return -1; + + return acl_nontrivial (count, entries); +@@ -765,6 +834,7 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + struct acl entries[NACLVENTRIES]; + int count; + ++ /* Ignore FD, unfortunately. */ + count = acl ((char *) name, ACL_GET, NACLVENTRIES, entries); + + if (count < 0) +@@ -809,7 +879,9 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + /* The docs say that type being 0 is equivalent to ACL_ANY, but it + is not true, in AIX 5.3. */ + type.u64 = ACL_ANY; +- if (aclx_get (name, 0, &type, aclbuf, &aclsize, &mode) >= 0) ++ if (0 <= (fd < 0 ++ ? aclx_get (name, 0, &type, aclbuf, &aclsize, &mode) ++ : aclx_fget (fd, 0, &type, aclbuf, &aclsize, &mode))) + break; + if (errno == ENOSYS) + return 0; +@@ -855,7 +927,10 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + + union { struct acl a; char room[4096]; } u; + +- if (statacl ((char *) name, STX_NORMAL, &u.a, sizeof (u)) < 0) ++ if ((fd < 0 ++ ? statacl ((char *) name, STX_NORMAL, &u.a, sizeof u) ++ : fstatacl (fd, STX_NORMAL, &u.a, sizeof u)) ++ < 0) + return -1; + + return acl_nontrivial (&u.a); +@@ -866,6 +941,7 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + struct acl entries[NACLENTRIES]; + int count; + ++ /* Ignore FD, unfortunately. */ + count = acl ((char *) name, ACL_GET, NACLENTRIES, entries); + + if (count < 0) +diff --git a/lib/qcopy-acl.c b/lib/qcopy-acl.c +index ad79661..282f4b2 100644 +--- a/lib/qcopy-acl.c ++++ b/lib/qcopy-acl.c +@@ -26,6 +26,7 @@ + #if USE_XATTR + + # include ++# include + # include + + # if HAVE_LINUX_XATTR_H +@@ -61,6 +62,7 @@ is_attr_permissions (const char *name, struct error_context *ctx) + a valid file descriptor, use file descriptor operations, else use + filename based operations on SRC_NAME. Likewise for DEST_DESC and + DST_NAME. ++ MODE should be the source file's st_mode. + If access control lists are not available, fchmod the target file to + MODE. Also sets the non-permission bits of the destination file + (S_ISUID, S_ISGID, S_ISVTX) to those from MODE if any are set. +@@ -86,10 +88,29 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, + Functions attr_copy_* return 0 in case we copied something OR nothing + to copy */ + if (ret == 0) +- ret = source_desc <= 0 || dest_desc <= 0 +- ? attr_copy_file (src_name, dst_name, is_attr_permissions, NULL) +- : attr_copy_fd (src_name, source_desc, dst_name, dest_desc, +- is_attr_permissions, NULL); ++ { ++ ret = source_desc <= 0 || dest_desc <= 0 ++ ? attr_copy_file (src_name, dst_name, is_attr_permissions, NULL) ++ : attr_copy_fd (src_name, source_desc, dst_name, dest_desc, ++ is_attr_permissions, NULL); ++ ++ /* Copying can fail with EOPNOTSUPP even when the source ++ permissions are trivial (Bug#78328). Don't report an error ++ in this case, as the chmod_or_fchmod suffices. */ ++ if (ret < 0 && errno == EOPNOTSUPP) ++ { ++ /* fdfile_has_aclinfo cares only about DT_DIR, _GL_DT_NOTDIR, ++ and DT_LNK (but DT_LNK is not possible here), ++ so use _GL_DT_NOTDIR | DT_UNKNOWN for other file types. */ ++ int flags = S_ISDIR (mode) ? DT_DIR : _GL_DT_NOTDIR | DT_UNKNOWN; ++ ++ struct aclinfo ai; ++ if (!fdfile_has_aclinfo (source_desc, src_name, &ai, flags)) ++ ret = 0; ++ aclinfo_free (&ai); ++ errno = EOPNOTSUPP; ++ } ++ } + #else + /* no XATTR, so we proceed the old dusty way */ + struct permission_context ctx; +-- +2.49.0 + + +From ed2bda5888829f4ebacd6dc9c86b7494dbf2a3b7 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Fri, 9 May 2025 18:48:03 -0700 +Subject: [PATCH 2/2] acl-tests: link with $(FILE_HAS_ACL_LIB) + +* modules/acl-tests (test_copy_acl_LDADD): Add +$(FILE_HAS_ACL_LIB), since qcopy-acl depends on file-has-acl. +Although this suggests that QCOPY_ACL_LIB should contain +FILE_HAS_ACL_LIB, I’m not sure whether that’s the right course of +action and anyway this is good enough for coreutils. + +(cherry picked from commit 955360a66c99bdd9ac3688519a8b521b06958fd3) +--- + gnulib-tests/gnulib.mk | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gnulib-tests/gnulib.mk b/gnulib-tests/gnulib.mk +index e222c63..4b78de4 100644 +--- a/gnulib-tests/gnulib.mk ++++ b/gnulib-tests/gnulib.mk +@@ -99,7 +99,7 @@ TESTS += \ + TESTS_ENVIRONMENT += USE_ACL=$(USE_ACL) + check_PROGRAMS += test-set-mode-acl test-copy-acl test-sameacls + test_set_mode_acl_LDADD = $(LDADD) $(LIB_ACL) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV) +-test_copy_acl_LDADD = $(LDADD) $(LIB_ACL) $(QCOPY_ACL_LIB) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV) ++test_copy_acl_LDADD = $(LDADD) $(LIB_ACL) $(QCOPY_ACL_LIB) $(FILE_HAS_ACL_LIB) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV) + test_sameacls_LDADD = $(LDADD) $(LIB_ACL) @LIBINTL@ $(MBRTOWC_LIB) + EXTRA_DIST += test-set-mode-acl.sh test-set-mode-acl-1.sh test-set-mode-acl-2.sh test-copy-acl.sh test-copy-acl-1.sh test-copy-acl-2.sh test-set-mode-acl.c test-copy-acl.c test-sameacls.c macros.h + +-- +2.49.0 + diff --git a/coreutils.spec b/coreutils.spec index 727da1b..a9bbd58 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 9.7 -Release: 1%{?dist} +Release: 2%{?dist} # some used parts of gnulib are under various variants of LGPL License: GPL-3.0-or-later AND GFDL-1.3-no-invariants-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later Url: https://www.gnu.org/software/coreutils/ @@ -32,6 +32,11 @@ Patch103: coreutils-python3.patch # df --direct Patch104: coreutils-df-direct.patch +# cp/mv: do not fail when copying of trivial NFSv4 ACLs fails (rhbz#2363149) +# https://git.savannah.gnu.org/cgit/gnulib.git/patch?id=8a356b77717a2e4f735ec06e326880ca1f61aadb +# https://git.savannah.gnu.org/cgit/gnulib.git/patch?id=955360a66c99bdd9ac3688519a8b521b06958fd3 +Patch105: coreutils-9.6-cp-improve-nfsv4-acl-support.patch + # (sb) lin18nux/lsb compliance - multibyte functionality patch Patch800: coreutils-i18n.patch @@ -278,6 +283,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Mon May 19 2025 Lukáš Zaoral - 9.7-2 +- cp/mv: do not fail when copying of trivial NFSv4 ACLs fails (rhbz#2363149) + * Wed Apr 09 2025 Lukáš Zaoral - 9.7-1 - rebase to latest upstream release (rhbz#2358624) From e454479c5cd5c28ccbbc0e3dc5668c33ffd7a683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= Date: Wed, 28 May 2025 09:40:47 +0200 Subject: [PATCH 05/15] sort: fix buffer under-read Resolves: CVE-2025-5278 --- coreutils-CVE-2025-5278.patch | 107 ++++++++++++++++++++++++++++++++++ coreutils-i18n.patch | 60 +++++++++---------- coreutils.spec | 9 ++- 3 files changed, 145 insertions(+), 31 deletions(-) create mode 100644 coreutils-CVE-2025-5278.patch diff --git a/coreutils-CVE-2025-5278.patch b/coreutils-CVE-2025-5278.patch new file mode 100644 index 0000000..af81286 --- /dev/null +++ b/coreutils-CVE-2025-5278.patch @@ -0,0 +1,107 @@ +From 701a9bdbf78f869e0fb778ed5aede00e42517add Mon Sep 17 00:00:00 2001 +From: Pádraig Brady +Date: Tue, 20 May 2025 16:03:44 +0100 +Subject: [PATCH] sort: fix buffer under-read (CWE-127) + +* src/sort.c (begfield): Check pointer adjustment +to avoid Out-of-range pointer offset (CWE-823). +(limfield): Likewise. +* tests/sort/sort-field-limit.sh: Add a new test, +which triggers with ASAN or Valgrind. +* tests/local.mk: Reference the new test. +Fixes https://bugs.gnu.org/78507 + +(cherry picked from commit 8c9602e3a145e9596dc1a63c6ed67865814b6633) +--- + src/sort.c | 12 ++++++++++-- + tests/local.mk | 1 + + tests/sort/sort-field-limit.sh | 35 ++++++++++++++++++++++++++++++++++ + 3 files changed, 46 insertions(+), 2 deletions(-) + create mode 100755 tests/sort/sort-field-limit.sh + +diff --git a/src/sort.c b/src/sort.c +index b10183b..7af1a25 100644 +--- a/src/sort.c ++++ b/src/sort.c +@@ -1644,7 +1644,11 @@ begfield (struct line const *line, struct keyfield const *key) + ++ptr; + + /* Advance PTR by SCHAR (if possible), but no further than LIM. */ +- ptr = MIN (lim, ptr + schar); ++ size_t remaining_bytes = lim - ptr; ++ if (schar < remaining_bytes) ++ ptr += schar; ++ else ++ ptr = lim; + + return ptr; + } +@@ -1746,7 +1750,11 @@ limfield (struct line const *line, struct keyfield const *key) + ++ptr; + + /* Advance PTR by ECHAR (if possible), but no further than LIM. */ +- ptr = MIN (lim, ptr + echar); ++ size_t remaining_bytes = lim - ptr; ++ if (echar < remaining_bytes) ++ ptr += echar; ++ else ++ ptr = lim; + } + + return ptr; +diff --git a/tests/local.mk b/tests/local.mk +index 4da6756..642d225 100644 +--- a/tests/local.mk ++++ b/tests/local.mk +@@ -388,6 +388,7 @@ all_tests = \ + tests/sort/sort-debug-keys.sh \ + tests/sort/sort-debug-warn.sh \ + tests/sort/sort-discrim.sh \ ++ tests/sort/sort-field-limit.sh \ + tests/sort/sort-files0-from.pl \ + tests/sort/sort-float.sh \ + tests/sort/sort-h-thousands-sep.sh \ +diff --git a/tests/sort/sort-field-limit.sh b/tests/sort/sort-field-limit.sh +new file mode 100755 +index 0000000..52d8e1d +--- /dev/null ++++ b/tests/sort/sort-field-limit.sh +@@ -0,0 +1,35 @@ ++#!/bin/sh ++# From 7.2-9.7, this would trigger an out of bounds mem read ++ ++# Copyright (C) 2025 Free Software Foundation, Inc. ++ ++# This program is free software: you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation, either version 3 of the License, or ++# (at your option) any later version. ++ ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++ ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src ++print_ver_ sort ++getlimits_ ++ ++# This issue triggers with valgrind or ASAN ++valgrind --error-exitcode=1 sort --version 2>/dev/null && ++ VALGRIND='valgrind --error-exitcode=1' ++ ++{ printf '%s\n' aa bb; } > in || framework_failure_ ++ ++_POSIX2_VERSION=200809 $VALGRIND sort +0.${SIZE_MAX}R in > out || fail=1 ++compare in out || fail=1 ++ ++_POSIX2_VERSION=200809 $VALGRIND sort +1 -1.${SIZE_MAX}R in > out || fail=1 ++compare in out || fail=1 ++ ++Exit $fail +-- +2.49.0 + diff --git a/coreutils-i18n.patch b/coreutils-i18n.patch index 38b871c..755f216 100644 --- a/coreutils-i18n.patch +++ b/coreutils-i18n.patch @@ -1,4 +1,4 @@ -From 3d25791ec9cc357a34620516d1c024ef17a4dd75 Mon Sep 17 00:00:00 2001 +From c657452b2d716807830c473bf36ef8d97c93cadf Mon Sep 17 00:00:00 2001 From: rpm-build Date: Wed, 30 Aug 2023 17:19:58 +0200 Subject: [PATCH] coreutils-i18n.patch @@ -3038,7 +3038,7 @@ index e7081a0..19e0268 100644 looking for more options and printing the next batch of files. diff --git a/src/sort.c b/src/sort.c -index b10183b..fbf325b 100644 +index 7af1a25..d3dc684 100644 --- a/src/sort.c +++ b/src/sort.c @@ -29,6 +29,14 @@ @@ -3295,7 +3295,7 @@ index b10183b..fbf325b 100644 ++ptr; if (ptr < lim) ++ptr; -@@ -1649,12 +1798,71 @@ begfield (struct line const *line, struct keyfield const *key) +@@ -1653,12 +1802,71 @@ begfield (struct line const *line, struct keyfield const *key) return ptr; } @@ -3368,7 +3368,7 @@ index b10183b..fbf325b 100644 { char *ptr = line->text, *lim = ptr + line->length - 1; size_t eword = key->eword, echar = key->echar; -@@ -1669,10 +1877,10 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1673,10 +1881,10 @@ limfield (struct line const *line, struct keyfield const *key) 'beginning' is the first character following the delimiting TAB. Otherwise, leave PTR pointing at the first 'blank' character after the preceding field. */ @@ -3381,7 +3381,7 @@ index b10183b..fbf325b 100644 ++ptr; if (ptr < lim && (eword || echar)) ++ptr; -@@ -1718,10 +1926,10 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1722,10 +1930,10 @@ limfield (struct line const *line, struct keyfield const *key) */ /* Make LIM point to the end of (one byte past) the current field. */ @@ -3394,7 +3394,7 @@ index b10183b..fbf325b 100644 if (newlim) lim = newlim; } -@@ -1752,6 +1960,130 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1760,6 +1968,130 @@ limfield (struct line const *line, struct keyfield const *key) return ptr; } @@ -3525,7 +3525,7 @@ index b10183b..fbf325b 100644 /* Fill BUF reading from FP, moving buf->left bytes from the end of buf->buf to the beginning first. If EOF is reached and the file wasn't terminated by a newline, supply one. Set up BUF's line -@@ -1838,8 +2170,22 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file) +@@ -1846,8 +2178,22 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file) else { if (key->skipsblanks) @@ -3550,7 +3550,7 @@ index b10183b..fbf325b 100644 line->keybeg = line_start; } } -@@ -1977,12 +2323,10 @@ find_unit_order (char const *number) +@@ -1985,12 +2331,10 @@ find_unit_order (char const *number) ATTRIBUTE_PURE static int @@ -3566,7 +3566,7 @@ index b10183b..fbf325b 100644 int diff = find_unit_order (a) - find_unit_order (b); return (diff ? diff : strnumcmp (a, b, decimal_point, thousands_sep)); -@@ -1994,7 +2338,7 @@ human_numcompare (char const *a, char const *b) +@@ -2002,7 +2346,7 @@ human_numcompare (char const *a, char const *b) ATTRIBUTE_PURE static int @@ -3575,7 +3575,7 @@ index b10183b..fbf325b 100644 { while (blanks[to_uchar (*a)]) a++; -@@ -2004,6 +2348,25 @@ numcompare (char const *a, char const *b) +@@ -2012,6 +2356,25 @@ numcompare (char const *a, char const *b) return strnumcmp (a, b, decimal_point, thousands_sep); } @@ -3601,7 +3601,7 @@ index b10183b..fbf325b 100644 static int nan_compare (long double a, long double b) { -@@ -2045,7 +2408,7 @@ general_numcompare (char const *sa, char const *sb) +@@ -2053,7 +2416,7 @@ general_numcompare (char const *sa, char const *sb) Return 0 if the name in S is not recognized. */ static int @@ -3610,7 +3610,7 @@ index b10183b..fbf325b 100644 { size_t lo = 0; size_t hi = MONTHS_PER_YEAR; -@@ -2384,15 +2747,14 @@ debug_key (struct line const *line, struct keyfield const *key) +@@ -2392,15 +2755,14 @@ debug_key (struct line const *line, struct keyfield const *key) char saved = *lim; *lim = '\0'; @@ -3628,7 +3628,7 @@ index b10183b..fbf325b 100644 else if (key->general_numeric) ignore_value (strtold (beg, &tighter_lim)); else if (key->numeric || key->human_numeric) -@@ -2538,7 +2900,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2546,7 +2908,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) /* Warn about significant leading blanks. */ bool implicit_skip = key_numeric (key) || key->month; bool line_offset = key->eword == 0 && key->echar != 0; /* -k1.x,1.y */ @@ -3637,7 +3637,7 @@ index b10183b..fbf325b 100644 && ((!key->skipsblanks && !implicit_skip) || (!key->skipsblanks && key->schar) || (!key->skipeblanks && key->echar))) -@@ -2586,9 +2948,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2594,9 +2956,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) bool number_locale_warned = false; if (basic_numeric_field_span) { @@ -3650,7 +3650,7 @@ index b10183b..fbf325b 100644 { error (0, 0, _("field separator %s is treated as a " -@@ -2599,9 +2961,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2607,9 +2969,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) } if (basic_numeric_field_span || general_numeric_field_span) { @@ -3663,7 +3663,7 @@ index b10183b..fbf325b 100644 { error (0, 0, _("field separator %s is treated as a " -@@ -2609,19 +2971,19 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2617,19 +2979,19 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) quote (((char []) {decimal_point, 0}))); number_locale_warned = true; } @@ -3687,7 +3687,7 @@ index b10183b..fbf325b 100644 } } -@@ -2673,11 +3035,87 @@ diff_reversed (int diff, bool reversed) +@@ -2681,11 +3043,87 @@ diff_reversed (int diff, bool reversed) return reversed ? (diff < 0) - (diff > 0) : diff; } @@ -3776,7 +3776,7 @@ index b10183b..fbf325b 100644 { struct keyfield *key = keylist; -@@ -2758,7 +3196,7 @@ keycompare (struct line const *a, struct line const *b) +@@ -2766,7 +3204,7 @@ keycompare (struct line const *a, struct line const *b) else if (key->human_numeric) diff = human_numcompare (ta, tb); else if (key->month) @@ -3785,7 +3785,7 @@ index b10183b..fbf325b 100644 else if (key->random) diff = compare_random (ta, tlena, tb, tlenb); else if (key->version) -@@ -2868,6 +3306,211 @@ keycompare (struct line const *a, struct line const *b) +@@ -2876,6 +3314,211 @@ keycompare (struct line const *a, struct line const *b) return diff_reversed (diff, key->reverse); } @@ -3997,7 +3997,7 @@ index b10183b..fbf325b 100644 /* Compare two lines A and B, returning negative, zero, or positive depending on whether A compares less than, equal to, or greater than B. */ -@@ -2895,7 +3538,7 @@ compare (struct line const *a, struct line const *b) +@@ -2903,7 +3546,7 @@ compare (struct line const *a, struct line const *b) diff = - NONZERO (blen); else if (blen == 0) diff = 1; @@ -4006,7 +4006,7 @@ index b10183b..fbf325b 100644 { /* xmemcoll0 is a performance enhancement as it will not unconditionally write '\0' after the -@@ -4283,6 +4926,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype) +@@ -4291,6 +4934,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype) break; case 'f': key->translate = fold_toupper; @@ -4014,7 +4014,7 @@ index b10183b..fbf325b 100644 break; case 'g': key->general_numeric = true; -@@ -4362,7 +5006,7 @@ main (int argc, char **argv) +@@ -4370,7 +5014,7 @@ main (int argc, char **argv) initialize_exit_failure (SORT_FAILURE); hard_LC_COLLATE = hard_locale (LC_COLLATE); @@ -4023,7 +4023,7 @@ index b10183b..fbf325b 100644 hard_LC_TIME = hard_locale (LC_TIME); #endif -@@ -4385,6 +5029,29 @@ main (int argc, char **argv) +@@ -4393,6 +5037,29 @@ main (int argc, char **argv) thousands_sep = NON_CHAR; } @@ -4053,7 +4053,7 @@ index b10183b..fbf325b 100644 have_read_stdin = false; inittables (); -@@ -4655,13 +5322,34 @@ main (int argc, char **argv) +@@ -4663,13 +5330,34 @@ main (int argc, char **argv) case 't': { @@ -4092,7 +4092,7 @@ index b10183b..fbf325b 100644 else { /* Provoke with 'sort -txx'. Complain about -@@ -4672,9 +5360,11 @@ main (int argc, char **argv) +@@ -4680,9 +5368,11 @@ main (int argc, char **argv) quote (optarg)); } } @@ -4549,11 +4549,11 @@ index 0000000..26c95de + +Exit $fail diff --git a/tests/local.mk b/tests/local.mk -index 4da6756..fcbeef8 100644 +index 642d225..8e89530 100644 --- a/tests/local.mk +++ b/tests/local.mk -@@ -390,6 +390,8 @@ all_tests = \ - tests/sort/sort-discrim.sh \ +@@ -391,6 +391,8 @@ all_tests = \ + tests/sort/sort-field-limit.sh \ tests/sort/sort-files0-from.pl \ tests/sort/sort-float.sh \ + tests/misc/sort-mb-tests.sh \ @@ -4561,7 +4561,7 @@ index 4da6756..fcbeef8 100644 tests/sort/sort-h-thousands-sep.sh \ tests/sort/sort-merge.pl \ tests/sort/sort-merge-fdlimit.sh \ -@@ -594,6 +596,7 @@ all_tests = \ +@@ -595,6 +597,7 @@ all_tests = \ tests/du/threshold.sh \ tests/du/trailing-slash.sh \ tests/du/two-args.sh \ @@ -4569,7 +4569,7 @@ index 4da6756..fcbeef8 100644 tests/id/gnu-zero-uids.sh \ tests/id/no-context.sh \ tests/id/context.sh \ -@@ -750,6 +753,7 @@ all_tests = \ +@@ -751,6 +754,7 @@ all_tests = \ tests/touch/read-only.sh \ tests/touch/relative.sh \ tests/touch/trailing-slash.sh \ diff --git a/coreutils.spec b/coreutils.spec index a9bbd58..af3a17a 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 9.7 -Release: 2%{?dist} +Release: 3%{?dist} # some used parts of gnulib are under various variants of LGPL License: GPL-3.0-or-later AND GFDL-1.3-no-invariants-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later Url: https://www.gnu.org/software/coreutils/ @@ -37,6 +37,10 @@ Patch104: coreutils-df-direct.patch # https://git.savannah.gnu.org/cgit/gnulib.git/patch?id=955360a66c99bdd9ac3688519a8b521b06958fd3 Patch105: coreutils-9.6-cp-improve-nfsv4-acl-support.patch +# sort: fix buffer under-read (CVE-2025-5278) +# https://cgit.git.savannah.gnu.org/cgit/coreutils.git/patch/?id=8c9602e3a145e9596dc1a63c6ed67865814b6633 +Patch106: coreutils-CVE-2025-5278.patch + # (sb) lin18nux/lsb compliance - multibyte functionality patch Patch800: coreutils-i18n.patch @@ -283,6 +287,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Wed May 28 2025 Lukáš Zaoral - 9.7-3 +- sort: fix buffer under-read (CVE-2025-5278) + * Mon May 19 2025 Lukáš Zaoral - 9.7-2 - cp/mv: do not fail when copying of trivial NFSv4 ACLs fails (rhbz#2363149) From 808a3165673f80423f6576b734c91ea50a8ca8c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= Date: Wed, 28 May 2025 10:19:41 +0200 Subject: [PATCH 06/15] sort: fix buffer under-read Resolves: CVE-2025-5278 Resolves: rhbz#2368767 --- coreutils-CVE-2025-5278.patch | 107 ++++++++++++++++++++++++++++++++++ coreutils-i18n.patch | 64 ++++++++++---------- coreutils.spec | 9 ++- 3 files changed, 147 insertions(+), 33 deletions(-) create mode 100644 coreutils-CVE-2025-5278.patch diff --git a/coreutils-CVE-2025-5278.patch b/coreutils-CVE-2025-5278.patch new file mode 100644 index 0000000..af81286 --- /dev/null +++ b/coreutils-CVE-2025-5278.patch @@ -0,0 +1,107 @@ +From 701a9bdbf78f869e0fb778ed5aede00e42517add Mon Sep 17 00:00:00 2001 +From: Pádraig Brady +Date: Tue, 20 May 2025 16:03:44 +0100 +Subject: [PATCH] sort: fix buffer under-read (CWE-127) + +* src/sort.c (begfield): Check pointer adjustment +to avoid Out-of-range pointer offset (CWE-823). +(limfield): Likewise. +* tests/sort/sort-field-limit.sh: Add a new test, +which triggers with ASAN or Valgrind. +* tests/local.mk: Reference the new test. +Fixes https://bugs.gnu.org/78507 + +(cherry picked from commit 8c9602e3a145e9596dc1a63c6ed67865814b6633) +--- + src/sort.c | 12 ++++++++++-- + tests/local.mk | 1 + + tests/sort/sort-field-limit.sh | 35 ++++++++++++++++++++++++++++++++++ + 3 files changed, 46 insertions(+), 2 deletions(-) + create mode 100755 tests/sort/sort-field-limit.sh + +diff --git a/src/sort.c b/src/sort.c +index b10183b..7af1a25 100644 +--- a/src/sort.c ++++ b/src/sort.c +@@ -1644,7 +1644,11 @@ begfield (struct line const *line, struct keyfield const *key) + ++ptr; + + /* Advance PTR by SCHAR (if possible), but no further than LIM. */ +- ptr = MIN (lim, ptr + schar); ++ size_t remaining_bytes = lim - ptr; ++ if (schar < remaining_bytes) ++ ptr += schar; ++ else ++ ptr = lim; + + return ptr; + } +@@ -1746,7 +1750,11 @@ limfield (struct line const *line, struct keyfield const *key) + ++ptr; + + /* Advance PTR by ECHAR (if possible), but no further than LIM. */ +- ptr = MIN (lim, ptr + echar); ++ size_t remaining_bytes = lim - ptr; ++ if (echar < remaining_bytes) ++ ptr += echar; ++ else ++ ptr = lim; + } + + return ptr; +diff --git a/tests/local.mk b/tests/local.mk +index 4da6756..642d225 100644 +--- a/tests/local.mk ++++ b/tests/local.mk +@@ -388,6 +388,7 @@ all_tests = \ + tests/sort/sort-debug-keys.sh \ + tests/sort/sort-debug-warn.sh \ + tests/sort/sort-discrim.sh \ ++ tests/sort/sort-field-limit.sh \ + tests/sort/sort-files0-from.pl \ + tests/sort/sort-float.sh \ + tests/sort/sort-h-thousands-sep.sh \ +diff --git a/tests/sort/sort-field-limit.sh b/tests/sort/sort-field-limit.sh +new file mode 100755 +index 0000000..52d8e1d +--- /dev/null ++++ b/tests/sort/sort-field-limit.sh +@@ -0,0 +1,35 @@ ++#!/bin/sh ++# From 7.2-9.7, this would trigger an out of bounds mem read ++ ++# Copyright (C) 2025 Free Software Foundation, Inc. ++ ++# This program is free software: you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation, either version 3 of the License, or ++# (at your option) any later version. ++ ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++ ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src ++print_ver_ sort ++getlimits_ ++ ++# This issue triggers with valgrind or ASAN ++valgrind --error-exitcode=1 sort --version 2>/dev/null && ++ VALGRIND='valgrind --error-exitcode=1' ++ ++{ printf '%s\n' aa bb; } > in || framework_failure_ ++ ++_POSIX2_VERSION=200809 $VALGRIND sort +0.${SIZE_MAX}R in > out || fail=1 ++compare in out || fail=1 ++ ++_POSIX2_VERSION=200809 $VALGRIND sort +1 -1.${SIZE_MAX}R in > out || fail=1 ++compare in out || fail=1 ++ ++Exit $fail +-- +2.49.0 + diff --git a/coreutils-i18n.patch b/coreutils-i18n.patch index e7699c1..13e36d7 100644 --- a/coreutils-i18n.patch +++ b/coreutils-i18n.patch @@ -1,4 +1,4 @@ -From a153c65067f6c09cf2cf38dc7c149aa1521c615a Mon Sep 17 00:00:00 2001 +From 26b941130b4bba79d1b3e5cf0c352a0887c97d80 Mon Sep 17 00:00:00 2001 From: rpm-build Date: Wed, 30 Aug 2023 17:19:58 +0200 Subject: [PATCH] coreutils-i18n.patch @@ -3008,7 +3008,7 @@ index e7081a0..19e0268 100644 looking for more options and printing the next batch of files. diff --git a/src/sort.c b/src/sort.c -index 0928fd5..8c43fd4 100644 +index d059826..132f9bc 100644 --- a/src/sort.c +++ b/src/sort.c @@ -29,6 +29,14 @@ @@ -3265,7 +3265,7 @@ index 0928fd5..8c43fd4 100644 ++ptr; if (ptr < lim) ++ptr; -@@ -1650,12 +1799,71 @@ begfield (struct line const *line, struct keyfield const *key) +@@ -1654,12 +1803,71 @@ begfield (struct line const *line, struct keyfield const *key) return ptr; } @@ -3338,7 +3338,7 @@ index 0928fd5..8c43fd4 100644 { char *ptr = line->text, *lim = ptr + line->length - 1; size_t eword = key->eword, echar = key->echar; -@@ -1670,10 +1878,10 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1674,10 +1882,10 @@ limfield (struct line const *line, struct keyfield const *key) 'beginning' is the first character following the delimiting TAB. Otherwise, leave PTR pointing at the first 'blank' character after the preceding field. */ @@ -3351,7 +3351,7 @@ index 0928fd5..8c43fd4 100644 ++ptr; if (ptr < lim && (eword || echar)) ++ptr; -@@ -1719,10 +1927,10 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1723,10 +1931,10 @@ limfield (struct line const *line, struct keyfield const *key) */ /* Make LIM point to the end of (one byte past) the current field. */ @@ -3364,7 +3364,7 @@ index 0928fd5..8c43fd4 100644 if (newlim) lim = newlim; } -@@ -1753,6 +1961,130 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1761,6 +1969,130 @@ limfield (struct line const *line, struct keyfield const *key) return ptr; } @@ -3495,7 +3495,7 @@ index 0928fd5..8c43fd4 100644 /* Fill BUF reading from FP, moving buf->left bytes from the end of buf->buf to the beginning first. If EOF is reached and the file wasn't terminated by a newline, supply one. Set up BUF's line -@@ -1839,8 +2171,22 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file) +@@ -1847,8 +2179,22 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file) else { if (key->skipsblanks) @@ -3520,7 +3520,7 @@ index 0928fd5..8c43fd4 100644 line->keybeg = line_start; } } -@@ -1978,12 +2324,10 @@ find_unit_order (char const *number) +@@ -1986,12 +2332,10 @@ find_unit_order (char const *number) ATTRIBUTE_PURE static int @@ -3536,7 +3536,7 @@ index 0928fd5..8c43fd4 100644 int diff = find_unit_order (a) - find_unit_order (b); return (diff ? diff : strnumcmp (a, b, decimal_point, thousands_sep)); -@@ -1995,7 +2339,7 @@ human_numcompare (char const *a, char const *b) +@@ -2003,7 +2347,7 @@ human_numcompare (char const *a, char const *b) ATTRIBUTE_PURE static int @@ -3545,7 +3545,7 @@ index 0928fd5..8c43fd4 100644 { while (blanks[to_uchar (*a)]) a++; -@@ -2005,6 +2349,25 @@ numcompare (char const *a, char const *b) +@@ -2013,6 +2357,25 @@ numcompare (char const *a, char const *b) return strnumcmp (a, b, decimal_point, thousands_sep); } @@ -3571,7 +3571,7 @@ index 0928fd5..8c43fd4 100644 static int nan_compare (long double a, long double b) { -@@ -2046,7 +2409,7 @@ general_numcompare (char const *sa, char const *sb) +@@ -2054,7 +2417,7 @@ general_numcompare (char const *sa, char const *sb) Return 0 if the name in S is not recognized. */ static int @@ -3580,7 +3580,7 @@ index 0928fd5..8c43fd4 100644 { size_t lo = 0; size_t hi = MONTHS_PER_YEAR; -@@ -2385,15 +2748,14 @@ debug_key (struct line const *line, struct keyfield const *key) +@@ -2393,15 +2756,14 @@ debug_key (struct line const *line, struct keyfield const *key) char saved = *lim; *lim = '\0'; @@ -3598,7 +3598,7 @@ index 0928fd5..8c43fd4 100644 else if (key->general_numeric) ignore_value (strtold (beg, &tighter_lim)); else if (key->numeric || key->human_numeric) -@@ -2539,7 +2901,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2547,7 +2909,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) /* Warn about significant leading blanks. */ bool implicit_skip = key_numeric (key) || key->month; bool line_offset = key->eword == 0 && key->echar != 0; /* -k1.x,1.y */ @@ -3607,7 +3607,7 @@ index 0928fd5..8c43fd4 100644 && ((!key->skipsblanks && !implicit_skip) || (!key->skipsblanks && key->schar) || (!key->skipeblanks && key->echar))) -@@ -2587,9 +2949,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2595,9 +2957,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) bool number_locale_warned = false; if (basic_numeric_field_span) { @@ -3620,7 +3620,7 @@ index 0928fd5..8c43fd4 100644 { error (0, 0, _("field separator %s is treated as a " -@@ -2600,9 +2962,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2608,9 +2970,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) } if (basic_numeric_field_span || general_numeric_field_span) { @@ -3633,7 +3633,7 @@ index 0928fd5..8c43fd4 100644 { error (0, 0, _("field separator %s is treated as a " -@@ -2610,19 +2972,19 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2618,19 +2980,19 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) quote (((char []) {decimal_point, 0}))); number_locale_warned = true; } @@ -3657,7 +3657,7 @@ index 0928fd5..8c43fd4 100644 } } -@@ -2633,7 +2995,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2641,7 +3003,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) { error (0, 0, _("%snumbers use %s as a decimal point in this locale"), @@ -3666,7 +3666,7 @@ index 0928fd5..8c43fd4 100644 quote (((char []) {decimal_point, 0}))); } -@@ -2675,11 +3037,87 @@ diff_reversed (int diff, bool reversed) +@@ -2683,11 +3045,87 @@ diff_reversed (int diff, bool reversed) return reversed ? (diff < 0) - (diff > 0) : diff; } @@ -3755,7 +3755,7 @@ index 0928fd5..8c43fd4 100644 { struct keyfield *key = keylist; -@@ -2760,7 +3198,7 @@ keycompare (struct line const *a, struct line const *b) +@@ -2768,7 +3206,7 @@ keycompare (struct line const *a, struct line const *b) else if (key->human_numeric) diff = human_numcompare (ta, tb); else if (key->month) @@ -3764,7 +3764,7 @@ index 0928fd5..8c43fd4 100644 else if (key->random) diff = compare_random (ta, tlena, tb, tlenb); else if (key->version) -@@ -2870,6 +3308,211 @@ keycompare (struct line const *a, struct line const *b) +@@ -2878,6 +3316,211 @@ keycompare (struct line const *a, struct line const *b) return diff_reversed (diff, key->reverse); } @@ -3976,7 +3976,7 @@ index 0928fd5..8c43fd4 100644 /* Compare two lines A and B, returning negative, zero, or positive depending on whether A compares less than, equal to, or greater than B. */ -@@ -2897,7 +3540,7 @@ compare (struct line const *a, struct line const *b) +@@ -2905,7 +3548,7 @@ compare (struct line const *a, struct line const *b) diff = - NONZERO (blen); else if (blen == 0) diff = 1; @@ -3985,7 +3985,7 @@ index 0928fd5..8c43fd4 100644 { /* xmemcoll0 is a performance enhancement as it will not unconditionally write '\0' after the -@@ -4285,6 +4928,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype) +@@ -4293,6 +4936,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype) break; case 'f': key->translate = fold_toupper; @@ -3993,7 +3993,7 @@ index 0928fd5..8c43fd4 100644 break; case 'g': key->general_numeric = true; -@@ -4364,7 +5008,7 @@ main (int argc, char **argv) +@@ -4372,7 +5016,7 @@ main (int argc, char **argv) initialize_exit_failure (SORT_FAILURE); hard_LC_COLLATE = hard_locale (LC_COLLATE); @@ -4002,7 +4002,7 @@ index 0928fd5..8c43fd4 100644 hard_LC_TIME = hard_locale (LC_TIME); #endif -@@ -4387,6 +5031,29 @@ main (int argc, char **argv) +@@ -4395,6 +5039,29 @@ main (int argc, char **argv) thousands_sep = NON_CHAR; } @@ -4032,7 +4032,7 @@ index 0928fd5..8c43fd4 100644 have_read_stdin = false; inittables (); -@@ -4657,13 +5324,34 @@ main (int argc, char **argv) +@@ -4665,13 +5332,34 @@ main (int argc, char **argv) case 't': { @@ -4071,7 +4071,7 @@ index 0928fd5..8c43fd4 100644 else { /* Provoke with 'sort -txx'. Complain about -@@ -4674,9 +5362,11 @@ main (int argc, char **argv) +@@ -4682,9 +5370,11 @@ main (int argc, char **argv) quote (optarg)); } } @@ -4528,11 +4528,11 @@ index 0000000..26c95de + +Exit $fail diff --git a/tests/local.mk b/tests/local.mk -index 12e30b4..1529db6 100644 +index 864cd16..eb898ab 100644 --- a/tests/local.mk +++ b/tests/local.mk -@@ -390,6 +390,8 @@ all_tests = \ - tests/sort/sort-discrim.sh \ +@@ -391,6 +391,8 @@ all_tests = \ + tests/sort/sort-field-limit.sh \ tests/sort/sort-files0-from.pl \ tests/sort/sort-float.sh \ + tests/misc/sort-mb-tests.sh \ @@ -4540,7 +4540,7 @@ index 12e30b4..1529db6 100644 tests/sort/sort-h-thousands-sep.sh \ tests/sort/sort-merge.pl \ tests/sort/sort-merge-fdlimit.sh \ -@@ -593,6 +595,7 @@ all_tests = \ +@@ -594,6 +596,7 @@ all_tests = \ tests/du/threshold.sh \ tests/du/trailing-slash.sh \ tests/du/two-args.sh \ @@ -4548,7 +4548,7 @@ index 12e30b4..1529db6 100644 tests/id/gnu-zero-uids.sh \ tests/id/no-context.sh \ tests/id/context.sh \ -@@ -749,6 +752,7 @@ all_tests = \ +@@ -750,6 +753,7 @@ all_tests = \ tests/touch/read-only.sh \ tests/touch/relative.sh \ tests/touch/trailing-slash.sh \ @@ -5180,5 +5180,5 @@ index 0000000..8a82d74 +LC_ALL=C unexpand in in > out || fail=1 +compare exp out > /dev/null 2>&1 || fail=1 -- -2.48.1 +2.49.0 diff --git a/coreutils.spec b/coreutils.spec index b0b2230..2340126 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 9.6 -Release: 3%{?dist} +Release: 4%{?dist} # some used parts of gnulib are under various variants of LGPL License: GPL-3.0-or-later AND GFDL-1.3-no-invariants-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later Url: https://www.gnu.org/software/coreutils/ @@ -46,6 +46,10 @@ Patch106: coreutils-9.6-who-m-systemd.patch # https://git.savannah.gnu.org/cgit/gnulib.git/patch?id=955360a66c99bdd9ac3688519a8b521b06958fd3 Patch107: coreutils-9.6-cp-improve-nfsv4-acl-support.patch +# sort: fix buffer under-read (CVE-2025-5278) +# https://cgit.git.savannah.gnu.org/cgit/coreutils.git/patch/?id=8c9602e3a145e9596dc1a63c6ed67865814b6633 +Patch108: coreutils-CVE-2025-5278.patch + # (sb) lin18nux/lsb compliance - multibyte functionality patch Patch800: coreutils-i18n.patch @@ -292,6 +296,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Wed May 28 2025 Lukáš Zaoral - 9.6-4 +- sort: fix buffer under-read (CVE-2025-5278) + * Mon May 19 2025 Lukáš Zaoral - 9.6-3 - cp/mv: do not fail when copying of trivial NFSv4 ACLs fails (rhbz#2363149) From c3c18147bda34d67a55115f5d5e2ff9b386380a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= Date: Mon, 30 Jun 2025 12:36:00 +0200 Subject: [PATCH 07/15] stty: add support for arbitrary baud rates Resolves: rhbz#2375439 --- coreutils-9.7-stty-arbitrary-baud-rates.patch | 669 ++++++++++++++++++ coreutils-i18n.patch | 14 +- coreutils.spec | 13 +- 3 files changed, 688 insertions(+), 8 deletions(-) create mode 100644 coreutils-9.7-stty-arbitrary-baud-rates.patch diff --git a/coreutils-9.7-stty-arbitrary-baud-rates.patch b/coreutils-9.7-stty-arbitrary-baud-rates.patch new file mode 100644 index 0000000..20d078b --- /dev/null +++ b/coreutils-9.7-stty-arbitrary-baud-rates.patch @@ -0,0 +1,669 @@ +From 8e5ee22042931bdac6488d61c5d59bcd1b0dba5f Mon Sep 17 00:00:00 2001 +From: "H. Peter Anvin" +Date: Mon, 16 Jun 2025 14:58:01 -0700 +Subject: [PATCH 1/5] stty: arbitrary or non-a priori known speed_t support + +Support the case where speed_t is simply a number, and in that case +assume that arbitrary values can be passed. This is assumed to be the +case when all known speed_t macros equal their own value. + +Try to probe for a variety of speed_t constants by trying to coax +$(CC) into emitting macro definitions (-E -dM). If this is not +supported, use a fairly extensive list of constants as a +fallback. This both improves the test for arbitrary speed support, as +well as allowing proper operation in the case where the constants are +not plain numbers and allows for handing enumerated speed constants +that were not known a priori when the source code was written. + +A simple shell script (mostly using sed) is used to turn the list of +constants (probed and predefined) into a pair of conversion functions, +baud_to_value() and value_to_baud(); string_to_baud() is then +reimplemented as a wrapper around the latter. + +* src/local.mk: Generate speedlist.h. +* src/speedgen: Portable shell script to generate speedlist.h. +* src/stty.c: Adjust string_to_baud to +convert from arbitrary numeric values. +* src/termios.c: A helper used when generating speedlist.h + +@lzaoral: This patch was amended to fix build failure in the +"single-binary" mode. + +(cherry picked from commit 357fda90d15fd3f7dba61e1ab322b183a48d0081) +--- + src/local.mk | 15 +++++- + src/speedgen | 85 ++++++++++++++++++++++++++++++ + src/stty.c | 143 +++++++++++++++++++------------------------------- + src/termios.c | 34 ++++++++++++ + 4 files changed, 188 insertions(+), 89 deletions(-) + create mode 100755 src/speedgen + create mode 100644 src/termios.c + +diff --git a/src/local.mk b/src/local.mk +index fd9dc81..3b8a34e 100644 +--- a/src/local.mk ++++ b/src/local.mk +@@ -71,7 +71,8 @@ EXTRA_DIST += \ + src/dircolors.hin \ + src/primes.h \ + src/tac-pipe.c \ +- src/extract-magic ++ src/extract-magic \ ++ src/speedgen + + CLEANFILES += $(SCRIPTS) + +@@ -672,6 +673,18 @@ src/version.h: Makefile + $(AM_V_at)chmod a-w $@t + $(AM_V_at)mv $@t $@ + ++# Target-specific termios baud rate file. This is opportunistic; ++# if cc -E doesn't support -dM, the speedgen script still includes ++# an extensive fallback list of common constants. ++BUILT_SOURCES += src/speedlist.h ++src/speedlist.h: src/termios.c lib/config.h src/speedgen ++ $(AM_V_GEN)rm -f $@ ++ $(AM_V_at)${MKDIR_P} src ++ $(AM_V_at)$(COMPILE) -E -dM $< 2>/dev/null | \ ++ $(SHELL) $(srcdir)/src/speedgen $@t ++ $(AM_V_at)chmod a-w $@t ++ $(AM_V_at)mv $@t $@ ++ + # Generates a list of macro invocations like: + # SINGLE_BINARY_PROGRAM(program_name_str, main_name) + # once for each program list on $(single_binary_progs). Note that +diff --git a/src/speedgen b/src/speedgen +new file mode 100755 +index 0000000..f1647d9 +--- /dev/null ++++ b/src/speedgen +@@ -0,0 +1,85 @@ ++#!/bin/sh -e ++ ++out="$1" ++tmp="$out.tmp" ++ ++if [ -z "$out" ]; then ++ echo "Usage: $0 outfile" 2>&1 ++ exit 1 ++fi ++ ++s='[[:space:]]' # For brevity's sake ++ ++trap "rm -f '$tmp'" EXIT ++trap "rm -f '$tmp' '$out'" ERR HUP INT QUIT TERM ++ ++# Fallback list of speeds that are always tested for ++defspeeds="0 50 75 110 134 150 200 300 600 1200 1800 2400 4800 7200 9600 \ ++14400 19200 28800 33600 38400 57600 76800 115200 153600 230400 307200 \ ++460800 500000 576000 614400 921600 1000000 1152000 1500000 \ ++2000000 2500000 3000000 3500000 4000000 5000000 10000000" ++( ++ sed -n -e "s/^$s*\#$s*define$s$s*B\\([1-9][0-9]*\\)$s.*\$/\\1/p" ++ for s in $defspeeds; do echo "$s"; done ++) | sort -n | uniq > "$tmp" ++ ++cat > "$out" <<'EOF' ++#ifndef SPEEDLIST_H ++# define SPEEDLIST_H 1 ++ ++# if 1 \ ++EOF ++ ++sed -e 's/^.*$/ \&\& (!defined(B&) || B& == &) \\/' < "$tmp" >> "$out" ++ ++cat >> "$out" <<'EOF' ++ ++# define TERMIOS_SPEED_T_SANE 1 ++ ++# endif ++ ++ATTRIBUTE_CONST ++static unsigned long int ++baud_to_value (speed_t speed) ++{ ++# ifdef TERMIOS_SPEED_T_SANE ++ return speed; ++# else ++ switch (speed) ++ { ++EOF ++ ++sed -e 's/^.*$/# ifdef B&\n case B&: return &;\n# endif/' \ ++ < "$tmp" >> "$out" ++ ++cat >> "$out" <<'EOF' ++ default: return -1; ++ } ++# endif ++} ++ ++ATTRIBUTE_CONST ++static speed_t ++value_to_baud (unsigned long int value) ++{ ++# ifdef TERMIOS_SPEED_T_SANE ++ speed_t speed = value; ++ if (speed != value) ++ speed = (speed_t) -1; /* Unrepresentable (overflow?) */ ++ return speed; ++# else ++ switch (value) ++ { ++EOF ++ ++sed -e 's/^.*$/# ifdef B&\n case &: return B&;\n# endif/' \ ++ < "$tmp" >> "$out" ++ ++cat >> "$out" <<'EOF' ++ default: return (speed_t) -1; ++ } ++# endif ++} ++ ++#endif ++EOF +diff --git a/src/stty.c b/src/stty.c +index 133b33c..561de1c 100644 +--- a/src/stty.c ++++ b/src/stty.c +@@ -55,6 +55,7 @@ + + #include "system.h" + #include "assure.h" ++#include "c-ctype.h" + #include "fd-reopen.h" + #include "quote.h" + #include "xdectoint.h" +@@ -2172,100 +2173,66 @@ recover_mode (char const *arg, struct termios *mode) + return true; + } + +-struct speed_map +-{ +- char const *string; /* ASCII representation. */ +- speed_t speed; /* Internal form. */ +- unsigned long int value; /* Numeric value. */ +-}; +- +-static struct speed_map const speeds[] = +-{ +- {"0", B0, 0}, +- {"50", B50, 50}, +- {"75", B75, 75}, +- {"110", B110, 110}, +- {"134", B134, 134}, +- {"134.5", B134, 134}, +- {"150", B150, 150}, +- {"200", B200, 200}, +- {"300", B300, 300}, +- {"600", B600, 600}, +- {"1200", B1200, 1200}, +- {"1800", B1800, 1800}, +- {"2400", B2400, 2400}, +- {"4800", B4800, 4800}, +- {"9600", B9600, 9600}, +- {"19200", B19200, 19200}, +- {"38400", B38400, 38400}, +- {"exta", B19200, 19200}, +- {"extb", B38400, 38400}, +-#ifdef B57600 +- {"57600", B57600, 57600}, +-#endif +-#ifdef B115200 +- {"115200", B115200, 115200}, +-#endif +-#ifdef B230400 +- {"230400", B230400, 230400}, +-#endif +-#ifdef B460800 +- {"460800", B460800, 460800}, +-#endif +-#ifdef B500000 +- {"500000", B500000, 500000}, +-#endif +-#ifdef B576000 +- {"576000", B576000, 576000}, +-#endif +-#ifdef B921600 +- {"921600", B921600, 921600}, +-#endif +-#ifdef B1000000 +- {"1000000", B1000000, 1000000}, +-#endif +-#ifdef B1152000 +- {"1152000", B1152000, 1152000}, +-#endif +-#ifdef B1500000 +- {"1500000", B1500000, 1500000}, +-#endif +-#ifdef B2000000 +- {"2000000", B2000000, 2000000}, +-#endif +-#ifdef B2500000 +- {"2500000", B2500000, 2500000}, +-#endif +-#ifdef B3000000 +- {"3000000", B3000000, 3000000}, +-#endif +-#ifdef B3500000 +- {"3500000", B3500000, 3500000}, +-#endif +-#ifdef B4000000 +- {"4000000", B4000000, 4000000}, +-#endif +- {nullptr, 0, 0} +-}; ++/* Autogenerated conversion functions to/from speed_t */ ++#include "speedlist.h" + + ATTRIBUTE_PURE + static speed_t + string_to_baud (char const *arg) + { +- for (int i = 0; speeds[i].string != nullptr; ++i) +- if (STREQ (arg, speeds[i].string)) +- return speeds[i].speed; +- return (speed_t) -1; +-} ++ char *ep; ++ unsigned long value; ++ unsigned char c; + +-ATTRIBUTE_PURE +-static unsigned long int +-baud_to_value (speed_t speed) +-{ +- for (int i = 0; speeds[i].string != nullptr; ++i) +- if (speed == speeds[i].speed) +- return speeds[i].value; +- return 0; ++ /* Explicitly disallow negative numbers. */ ++ while (c_isspace (*arg)) ++ arg++; ++ if (*arg == '-') ++ return (speed_t) -1; ++ ++ value = strtoul (arg, &ep, 10); ++ ++ c = *ep++; ++ if (c == '.') ++ { ++ /* Number includes a fraction. Round it to nearest-even. ++ Note in particular that 134.5 must round to 134! */ ++ c = *ep++; ++ if (c) ++ { ++ c -= '0'; ++ if (c > 9) ++ { ++ return (speed_t) -1; /* Garbage after otherwise valid number */ ++ } ++ else if (c > 5) ++ { ++ value++; ++ } ++ else if (c == 5) ++ { ++ while ((c = *ep++) == '0') ++ ; /* Skip zeroes after .5 */ ++ ++ if (c >= '1' && c <= '9') ++ value++; /* Nonzero digit, round up */ ++ else ++ value += (value & 1); /* Exactly in the middle, round even */ ++ } ++ } ++ } ++ else if (c) ++ { ++ /* Not a valid number; check for legacy aliases "exta" and "extb" */ ++ if (STREQ (arg, "exta")) ++ return B19200; ++ else if (STREQ (arg, "extb")) ++ return B38400; ++ else ++ return (speed_t) -1; ++ } ++ ++ return value_to_baud (value); + } + + static void +diff --git a/src/termios.c b/src/termios.c +new file mode 100644 +index 0000000..f17e12e +--- /dev/null ++++ b/src/termios.c +@@ -0,0 +1,34 @@ ++/* termios.c -- coax out Bxxx macros from termios.h ++ ++ Copyright (C) 2025 Free Software Foundation, Inc. ++ ++ This program is free software: you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation, either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++/* This simply #includes headers which may or may not provide Bxxx ++ constant macros. This is run through the C preprocessor and defined ++ macros are extracted. ++ ++ In the case where the C preprocessor isn't capable of doing so, ++ the script this is fed through contains a pre-defined set of common ++ constants. */ ++ ++#include ++ ++#ifdef TERMIOS_NEEDS_XOPEN_SOURCE ++# define _XOPEN_SOURCE ++#endif ++ ++#include ++#include ++#include +-- +2.50.0 + + +From 60c9206391e2fac32639d3a143435d1dd9ec6421 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?P=C3=A1draig=20Brady?= +Date: Tue, 17 Jun 2025 23:32:05 +0100 +Subject: [PATCH 2/5] tests: stty: adjust tests for arbitary speeds + +* tests/stty/stty-invalid.sh: Adjust to what is now invalid. +* tests/stty/stty.sh: Add checks for valid speed variants. +* tests/stty/bad-speed.sh: New test to ensure unsupported speeds +are diagnosed. + +(cherry picked from commit efaec8078142996d958b6720b85a13b12497c3d0) +--- + tests/local.mk | 1 + + tests/stty/bad-speed.sh | 50 ++++++++++++++++++++++++++++++++++++++ + tests/stty/stty-invalid.sh | 10 ++++++-- + tests/stty/stty.sh | 10 ++++++++ + 4 files changed, 69 insertions(+), 2 deletions(-) + create mode 100755 tests/stty/bad-speed.sh + +diff --git a/tests/local.mk b/tests/local.mk +index 642d225..b68df41 100644 +--- a/tests/local.mk ++++ b/tests/local.mk +@@ -425,6 +425,7 @@ all_tests = \ + tests/stat/stat-printf.pl \ + tests/stat/stat-slash.sh \ + tests/misc/stdbuf.sh \ ++ tests/stty/bad-speed.sh \ + tests/stty/stty.sh \ + tests/stty/stty-invalid.sh \ + tests/stty/stty-pairs.sh \ +diff --git a/tests/stty/bad-speed.sh b/tests/stty/bad-speed.sh +new file mode 100755 +index 0000000..d80d2e7 +--- /dev/null ++++ b/tests/stty/bad-speed.sh +@@ -0,0 +1,50 @@ ++#!/bin/sh ++# Ensure we handle cfsetispeed failing ++# which we did not before coreutils v9.1 ++ ++# Copyright (C) 2025 Free Software Foundation, Inc. ++ ++# This program is free software: you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation, either version 3 of the License, or ++# (at your option) any later version. ++ ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++ ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src ++print_ver_ stty ++require_gcc_shared_ ++ ++# Replace each cfsetispeed call with a call to these stubs. ++cat > k.c <<'EOF' || framework_failure_ ++#include ++#include ++#include ++#include ++ ++int cfsetispeed(struct termios *termios_p, speed_t speed) ++{ ++ /* Leave a marker so we can identify if the function was intercepted. */ ++ fclose(fopen("preloaded", "w")); ++ ++ errno=EINVAL; ++ return -1; ++} ++EOF ++ ++# Then compile/link it: ++gcc_shared_ k.c k.so \ ++ || skip_ 'failed to build shared library' ++ ++( export LD_PRELOAD=$LD_PRELOAD:./k.so ++ returns_ 1 stty ispeed 9600 ) || fail=1 ++ ++test -e preloaded || skip_ 'LD_PRELOAD interception failed' ++ ++Exit $fail +diff --git a/tests/stty/stty-invalid.sh b/tests/stty/stty-invalid.sh +index 4b87e2a..a1442a8 100755 +--- a/tests/stty/stty-invalid.sh ++++ b/tests/stty/stty-invalid.sh +@@ -20,6 +20,7 @@ + print_ver_ stty + require_controlling_input_terminal_ + require_trap_signame_ ++getlimits_ + + trap '' TTOU # Ignore SIGTTOU + +@@ -50,8 +51,13 @@ if tty -s = 9.8 supports arbitrary speeds on some systems ++# so restrict tests here to invalid numbers ++# We simulate unsupported numbers in a separate "LD_PRELOAD" test. ++WRAP_9600="$(expr $ULONG_OFLOW - 9600)" ++for speed in 9600.. ++9600 -$WRAP_9600 --$WRAP_9600 0x2580 96E2; do ++ returns_ 1 stty ispeed "$speed" || fail=1 ++done + + # Just in case either of the above mistakenly succeeds (and changes + # the state of our tty), try to restore the initial state. +diff --git a/tests/stty/stty.sh b/tests/stty/stty.sh +index dab4cd0..c0f7494 100755 +--- a/tests/stty/stty.sh ++++ b/tests/stty/stty.sh +@@ -95,4 +95,14 @@ for W in $(seq 80 90); do + test "$output_width" -le "$W" || fail=1 + done + ++# Ensure we support varied numeric forms ++# with appropriate rounding ++if stty ispeed '9600'; then ++ stty ispeed ' +9600' || fail=1 ++ stty ispeed '9600.49' || fail=1 ++ stty ispeed '9600.50' || fail=1 ++ stty ispeed '9599.51' || fail=1 ++ stty ispeed ' 9600.' || fail=1 ++fi ++ + Exit $fail +-- +2.50.0 + + +From a47c15eea3ffe08662415ae13873b40c7ffcdb43 Mon Sep 17 00:00:00 2001 +From: Collin Funk +Date: Sat, 21 Jun 2025 22:05:19 -0700 +Subject: [PATCH 3/5] build: add src/termios.c to the tarball + +* src/local.mk (EXTRA_DIST): Add src/termios.c. + +(cherry picked from commit b7db7757831e93ca44ae59e1921bc4ebbc87974f) +--- + src/local.mk | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/local.mk b/src/local.mk +index 3b8a34e..188dda1 100644 +--- a/src/local.mk ++++ b/src/local.mk +@@ -72,7 +72,8 @@ EXTRA_DIST += \ + src/primes.h \ + src/tac-pipe.c \ + src/extract-magic \ +- src/speedgen ++ src/speedgen \ ++ src/termios.c + + CLEANFILES += $(SCRIPTS) + +-- +2.50.0 + + +From caa439bf750193bcbed215a6676053f0b3c96e21 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?P=C3=A1draig=20Brady?= +Date: Sun, 22 Jun 2025 15:01:21 +0100 +Subject: [PATCH 4/5] doc: stty: adjust description of supported speeds + +* doc/coreutils.texi (stty invocation): Remove now imprecise +list of speeds given we may now support higher or arbitrary speeds. +Mention that we may support higher or arbitrary speeds. + +(cherry picked from commit 8b05eca972f70858749a946ac24f08d0718c1be6) +--- + doc/coreutils.texi | 21 ++------------------- + 1 file changed, 2 insertions(+), 19 deletions(-) + +diff --git a/doc/coreutils.texi b/doc/coreutils.texi +index 6d1ee11..c04af2b 100644 +--- a/doc/coreutils.texi ++++ b/doc/coreutils.texi +@@ -15932,25 +15932,8 @@ Print the terminal speed. + Set the input and output speeds to @var{n}. @var{n} can be one of: 0 + 50 75 110 134 134.5 150 200 300 600 1200 1800 2400 4800 9600 19200 + 38400 @code{exta} @code{extb}. @code{exta} is the same as 19200; +-@code{extb} is the same as 38400. Many systems, including GNU/Linux, +-support higher speeds. The @command{stty} command includes support +-for speeds of +-57600, +-115200, +-230400, +-460800, +-500000, +-576000, +-921600, +-1000000, +-1152000, +-1500000, +-2000000, +-2500000, +-3000000, +-3500000, +-or +-4000000 where the system supports these. ++@code{extb} is the same as 38400. Many systems, support arbitrary ++or higher speeds. + 0 hangs up the line if @option{-clocal} is set. + @end table + +-- +2.50.0 + + +From 8e48d56c2aa10f9875ffe1ec051a17f0eab6d2f9 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?P=C3=A1draig=20Brady?= +Date: Sun, 22 Jun 2025 16:40:04 +0100 +Subject: [PATCH 5/5] stty: stricter floating point parsing + +* src/stty.c (string_to_baud): Disallow extraneous characters +after floating point numbers. +* tests/stty/stty-invalid.sh: Add test cases. + +(cherry picked from commit 3d35b3c0e56bd556c90dc98c3e5e2e7289b0eb0d) +--- + src/stty.c | 27 +++++++++++++-------------- + tests/stty/stty-invalid.sh | 3 ++- + 2 files changed, 15 insertions(+), 15 deletions(-) + +diff --git a/src/stty.c b/src/stty.c +index 561de1c..0163ea4 100644 +--- a/src/stty.c ++++ b/src/stty.c +@@ -2200,25 +2200,24 @@ string_to_baud (char const *arg) + c = *ep++; + if (c) + { +- c -= '0'; +- if (c > 9) ++ unsigned char d = c - '0'; ++ if (d > 5) ++ value++; ++ else if (d == 5) + { +- return (speed_t) -1; /* Garbage after otherwise valid number */ +- } +- else if (c > 5) +- { +- value++; +- } +- else if (c == 5) +- { +- while ((c = *ep++) == '0') +- ; /* Skip zeroes after .5 */ ++ while ((c = *ep++) == '0'); /* Skip zeroes after .5 */ + +- if (c >= '1' && c <= '9') +- value++; /* Nonzero digit, round up */ ++ if (c) ++ value++; /* Nonzero, round up */ + else + value += (value & 1); /* Exactly in the middle, round even */ + } ++ ++ while (c_isdigit (c)) /* Skip remaining digits. */ ++ c = *ep++; ++ ++ if (c) ++ return (speed_t) -1; /* Garbage after otherwise valid number */ + } + } + else if (c) +diff --git a/tests/stty/stty-invalid.sh b/tests/stty/stty-invalid.sh +index a1442a8..868ed1d 100755 +--- a/tests/stty/stty-invalid.sh ++++ b/tests/stty/stty-invalid.sh +@@ -55,7 +55,8 @@ fi + # so restrict tests here to invalid numbers + # We simulate unsupported numbers in a separate "LD_PRELOAD" test. + WRAP_9600="$(expr $ULONG_OFLOW - 9600)" +-for speed in 9600.. ++9600 -$WRAP_9600 --$WRAP_9600 0x2580 96E2; do ++for speed in 9599.. 9600.. 9600.5. 9600.50. 9600.0. ++9600 \ ++ -$WRAP_9600 --$WRAP_9600 0x2580 96E2 9600,0 '9600.0 '; do + returns_ 1 stty ispeed "$speed" || fail=1 + done + +-- +2.50.0 + diff --git a/coreutils-i18n.patch b/coreutils-i18n.patch index 755f216..2917075 100644 --- a/coreutils-i18n.patch +++ b/coreutils-i18n.patch @@ -1,4 +1,4 @@ -From c657452b2d716807830c473bf36ef8d97c93cadf Mon Sep 17 00:00:00 2001 +From c0db8de625ca1ae0e0f4784c4eb2c779eae0047f Mon Sep 17 00:00:00 2001 From: rpm-build Date: Wed, 30 Aug 2023 17:19:58 +0200 Subject: [PATCH] coreutils-i18n.patch @@ -2252,10 +2252,10 @@ index b64aad4..a156337 100644 case 's': /* Break at word boundaries. */ diff --git a/src/local.mk b/src/local.mk -index fd9dc81..5133cc0 100644 +index 188dda1..7db5753 100644 --- a/src/local.mk +++ b/src/local.mk -@@ -476,8 +476,8 @@ src_base32_CPPFLAGS = -DBASE_TYPE=32 $(AM_CPPFLAGS) +@@ -478,8 +478,8 @@ src_base32_CPPFLAGS = -DBASE_TYPE=32 $(AM_CPPFLAGS) src_basenc_SOURCES = src/basenc.c src_basenc_CPPFLAGS = -DBASE_TYPE=42 $(AM_CPPFLAGS) @@ -4549,7 +4549,7 @@ index 0000000..26c95de + +Exit $fail diff --git a/tests/local.mk b/tests/local.mk -index 642d225..8e89530 100644 +index b68df41..0fe8193 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -391,6 +391,8 @@ all_tests = \ @@ -4561,7 +4561,7 @@ index 642d225..8e89530 100644 tests/sort/sort-h-thousands-sep.sh \ tests/sort/sort-merge.pl \ tests/sort/sort-merge-fdlimit.sh \ -@@ -595,6 +597,7 @@ all_tests = \ +@@ -596,6 +598,7 @@ all_tests = \ tests/du/threshold.sh \ tests/du/trailing-slash.sh \ tests/du/two-args.sh \ @@ -4569,7 +4569,7 @@ index 642d225..8e89530 100644 tests/id/gnu-zero-uids.sh \ tests/id/no-context.sh \ tests/id/context.sh \ -@@ -751,6 +754,7 @@ all_tests = \ +@@ -752,6 +755,7 @@ all_tests = \ tests/touch/read-only.sh \ tests/touch/relative.sh \ tests/touch/trailing-slash.sh \ @@ -5198,5 +5198,5 @@ index 0000000..8a82d74 +LC_ALL=C unexpand in in > out || fail=1 +compare exp out > /dev/null 2>&1 || fail=1 -- -2.49.0 +2.50.0 diff --git a/coreutils.spec b/coreutils.spec index af3a17a..dfe70d7 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 9.7 -Release: 3%{?dist} +Release: 4%{?dist} # some used parts of gnulib are under various variants of LGPL License: GPL-3.0-or-later AND GFDL-1.3-no-invariants-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later Url: https://www.gnu.org/software/coreutils/ @@ -41,6 +41,14 @@ Patch105: coreutils-9.6-cp-improve-nfsv4-acl-support.patch # https://cgit.git.savannah.gnu.org/cgit/coreutils.git/patch/?id=8c9602e3a145e9596dc1a63c6ed67865814b6633 Patch106: coreutils-CVE-2025-5278.patch +# stty: add support for arbitrary baud rates (rhbz#2375439) +# https://cgit.git.savannah.gnu.org/cgit/coreutils.git/patch/?id=357fda90d15fd3f7dba61e1ab322b183a48d0081 +# https://cgit.git.savannah.gnu.org/cgit/coreutils.git/patch/?id=efaec8078142996d958b6720b85a13b12497c3d0 +# https://cgit.git.savannah.gnu.org/cgit/coreutils.git/patch/?id=b7db7757831e93ca44ae59e1921bc4ebbc87974f +# https://cgit.git.savannah.gnu.org/cgit/coreutils.git/patch/?id=8b05eca972f70858749a946ac24f08d0718c1be6 +# https://cgit.git.savannah.gnu.org/cgit/coreutils.git/patch/?id=3d35b3c0e56bd556c90dc98c3e5e2e7289b0eb0d +Patch107: coreutils-9.7-stty-arbitrary-baud-rates.patch + # (sb) lin18nux/lsb compliance - multibyte functionality patch Patch800: coreutils-i18n.patch @@ -287,6 +295,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Mon Jun 30 2025 Lukáš Zaoral - 9.7-4 +- stty: add support for arbitrary baud rates (rhbz#2375439) + * Wed May 28 2025 Lukáš Zaoral - 9.7-3 - sort: fix buffer under-read (CVE-2025-5278) From dfeff61db9c78840ec66990989c5f8ab5f5f012f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= Date: Tue, 8 Jul 2025 13:14:50 +0200 Subject: [PATCH 08/15] ls: fix crash on systems with SELinux but without xattr support Resolves: rhbz#2376721 --- coreutils-9.6-ls-selinux-crash-2.patch | 37 ++++++++++++++++++++++++++ coreutils.spec | 9 ++++++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 coreutils-9.6-ls-selinux-crash-2.patch diff --git a/coreutils-9.6-ls-selinux-crash-2.patch b/coreutils-9.6-ls-selinux-crash-2.patch new file mode 100644 index 0000000..8c6de3c --- /dev/null +++ b/coreutils-9.6-ls-selinux-crash-2.patch @@ -0,0 +1,37 @@ +From b54c3d30b0447b69d9bb405d2adb830ae1172dce Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?P=C3=A1draig=20Brady?= +Date: Thu, 20 Mar 2025 18:40:01 +0000 +Subject: [PATCH] ls: fix crash on systems with SELinux but without xattr + support + +This was seen on termux on Android with ./configure --disable-xattr +where listxattr() and getxattr() returned ENOTSUP. +Then the valid security context obtained by file_has_aclinfo() +was discounted, and problematically then freed multiple times. +Reported at https://github.com/termux/termux-packages/issues/23752 + +* src/ls.c (file_has_aclinfo_cache): Only discount the returned +acl info when all components are defaulted due to being unsupported. + +(cherry picked from commit cb2abbac7f9e40e0f0d6183bf9b11e80b0cad8ef) +--- + src/ls.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/ls.c b/src/ls.c +index f67167f..97cf46a 100644 +--- a/src/ls.c ++++ b/src/ls.c +@@ -3322,7 +3322,8 @@ file_has_aclinfo_cache (char const *file, struct fileinfo *f, + errno = 0; + int n = file_has_aclinfo (file, ai, flags); + int err = errno; +- if (f->stat_ok && n <= 0 && !acl_errno_valid (err)) ++ if (f->stat_ok && n <= 0 && !acl_errno_valid (err) ++ && (!(flags & ACL_GET_SCONTEXT) || !acl_errno_valid (ai->scontext_err))) + { + unsupported_return = n; + unsupported_scontext = ai->scontext; +-- +2.50.0 + diff --git a/coreutils.spec b/coreutils.spec index 2340126..47c546e 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 9.6 -Release: 4%{?dist} +Release: 5%{?dist} # some used parts of gnulib are under various variants of LGPL License: GPL-3.0-or-later AND GFDL-1.3-no-invariants-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later Url: https://www.gnu.org/software/coreutils/ @@ -50,6 +50,10 @@ Patch107: coreutils-9.6-cp-improve-nfsv4-acl-support.patch # https://cgit.git.savannah.gnu.org/cgit/coreutils.git/patch/?id=8c9602e3a145e9596dc1a63c6ed67865814b6633 Patch108: coreutils-CVE-2025-5278.patch +# ls: fix crash on systems with SELinux but without xattr support (rhbz#2376721) +# https://cgit.git.savannah.gnu.org/cgit/coreutils.git/patch/?id=cb2abbac7f9e40e0f0d6183bf9b11e80b0cad8ef +Patch109: coreutils-9.6-ls-selinux-crash-2.patch + # (sb) lin18nux/lsb compliance - multibyte functionality patch Patch800: coreutils-i18n.patch @@ -296,6 +300,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Tue Jul 08 2025 Lukáš Zaoral - 9.6-5 +- ls: fix crash on systems with SELinux but without xattr support (rhbz#2376721) + * Wed May 28 2025 Lukáš Zaoral - 9.6-4 - sort: fix buffer under-read (CVE-2025-5278) From c493f607abc435122d1cb12a358a672bee09ee93 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 23 Jul 2025 18:40:40 +0000 Subject: [PATCH 09/15] Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild --- coreutils.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/coreutils.spec b/coreutils.spec index dfe70d7..17e98b3 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 9.7 -Release: 4%{?dist} +Release: 5%{?dist} # some used parts of gnulib are under various variants of LGPL License: GPL-3.0-or-later AND GFDL-1.3-no-invariants-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later Url: https://www.gnu.org/software/coreutils/ @@ -295,6 +295,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Wed Jul 23 2025 Fedora Release Engineering - 9.7-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild + * Mon Jun 30 2025 Lukáš Zaoral - 9.7-4 - stty: add support for arbitrary baud rates (rhbz#2375439) From 20976b8be8f329b2ffc60ed31fba89ed8ad2106a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= Date: Wed, 24 Sep 2025 10:00:43 +0200 Subject: [PATCH 10/15] rebase to latest upstream release - remove downstream patch for selinux options deprecated since 2009 Resolves: rhbz#2397467 --- ...ils-9.6-cp-improve-nfsv4-acl-support.patch | 512 --------- coreutils-9.7-stty-arbitrary-baud-rates.patch | 669 ------------ coreutils-CVE-2025-5278.patch | 107 -- coreutils-df-direct.patch | 24 +- coreutils-i18n.patch | 976 +----------------- coreutils-python3.patch | 10 +- coreutils-selinux.patch | 87 -- coreutils.spec | 28 +- sources | 4 +- 9 files changed, 53 insertions(+), 2364 deletions(-) delete mode 100644 coreutils-9.6-cp-improve-nfsv4-acl-support.patch delete mode 100644 coreutils-9.7-stty-arbitrary-baud-rates.patch delete mode 100644 coreutils-CVE-2025-5278.patch delete mode 100644 coreutils-selinux.patch diff --git a/coreutils-9.6-cp-improve-nfsv4-acl-support.patch b/coreutils-9.6-cp-improve-nfsv4-acl-support.patch deleted file mode 100644 index 1b36b1e..0000000 --- a/coreutils-9.6-cp-improve-nfsv4-acl-support.patch +++ /dev/null @@ -1,512 +0,0 @@ -From 6ad28e2b6627caf7b83bf893027c087b8cea1a97 Mon Sep 17 00:00:00 2001 -From: Paul Eggert -Date: Fri, 9 May 2025 18:02:29 -0700 -Subject: [PATCH 1/2] qcopy-acl: port better to NFSv4 on GNU/Linux - -Problem reported by Ian Dall in -and by Thomas Clark in . -* lib/file-has-acl.c (smack_new_label_from_file) [!HAVE_SMACK]: -New dummy function. -(has_xattr, get_aclinfo): New arg FD. All callers changed. -Remove some unnecessary MAYBE_UNUSEDs. -(acl_get_fd_np): Fall back on acl_get_fd if this function is -needed but not available. -(acl_get_fdfile): New function, if needed. -(file_has_aclinfo): Reimplement in terms of ... -(fdfile_has_aclinfo): ... this new function, -which also has an FD argument. -* lib/qcopy-acl.c [USE_XATTR]: Include dirent.h, for DT_DIR etc. -(qcopy_acl): If attr_copy_file or attr_copy_fd fail with EOPNOTSUPP, -don’t fail if the source has a trivial ACL (this is the part -that fixes the bug; the rest is optimization). - -(cherry picked from commit 8a356b77717a2e4f735ec06e326880ca1f61aadb) ---- - lib/acl.h | 2 + - lib/copy-acl.c | 1 + - lib/file-has-acl.c | 172 ++++++++++++++++++++++++++++++++------------- - lib/qcopy-acl.c | 29 ++++++-- - 4 files changed, 152 insertions(+), 52 deletions(-) - -diff --git a/lib/acl.h b/lib/acl.h -index 90fd24e..e3c134f 100644 ---- a/lib/acl.h -+++ b/lib/acl.h -@@ -79,6 +79,8 @@ struct aclinfo - bool acl_errno_valid (int) _GL_ATTRIBUTE_CONST; - int file_has_acl (char const *, struct stat const *); - int file_has_aclinfo (char const *restrict, struct aclinfo *restrict, int); -+int fdfile_has_aclinfo (int, char const *restrict, -+ struct aclinfo *restrict, int); - - #if HAVE_LINUX_XATTR_H && HAVE_LISTXATTR - bool aclinfo_has_xattr (struct aclinfo const *, char const *) -diff --git a/lib/copy-acl.c b/lib/copy-acl.c -index c36f64e..2fce6c7 100644 ---- a/lib/copy-acl.c -+++ b/lib/copy-acl.c -@@ -33,6 +33,7 @@ - a valid file descriptor, use file descriptor operations, else use - filename based operations on SRC_NAME. Likewise for DEST_DESC and - DST_NAME. -+ MODE should be the source file's st_mode. - If access control lists are not available, fchmod the target file to - MODE. Also sets the non-permission bits of the destination file - (S_ISUID, S_ISGID, S_ISVTX) to those from MODE if any are set. -diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c -index 66b920c..a356ee0 100644 ---- a/lib/file-has-acl.c -+++ b/lib/file-has-acl.c -@@ -85,6 +85,13 @@ smack_new_label_from_path (MAYBE_UNUSED const char *path, - { - return -1; - } -+static ssize_t -+smack_new_label_from_file (MAYBE_UNUSED int fd, -+ MAYBE_UNUSED const char *xattr, -+ MAYBE_UNUSED char **label) -+{ -+ return -1; -+} - # endif - static bool - is_smack_enabled (void) -@@ -115,14 +122,16 @@ aclinfo_may_indicate_xattr (struct aclinfo const *ai) - - static bool - has_xattr (char const *xattr, struct aclinfo const *ai, -- MAYBE_UNUSED char const *restrict name, MAYBE_UNUSED int flags) -+ int fd, char const *restrict name, int flags) - { - if (ai && aclinfo_has_xattr (ai, xattr)) - return true; - else if (!ai || aclinfo_may_indicate_xattr (ai)) - { -- int ret = ((flags & ACL_SYMLINK_FOLLOW ? getxattr : lgetxattr) -- (name, xattr, NULL, 0)); -+ int ret = (fd < 0 -+ ? ((flags & ACL_SYMLINK_FOLLOW ? getxattr : lgetxattr) -+ (name, xattr, NULL, 0)) -+ : fgetxattr (fd, xattr, NULL, 0)); - if (0 <= ret || (errno == ERANGE || errno == E2BIG)) - return true; - } -@@ -145,11 +154,12 @@ aclinfo_has_xattr (struct aclinfo const *ai, char const *xattr) - return false; - } - --/* Get attributes of the file NAME into AI, if USE_ACL. -+/* Get attributes of the file FD aka NAME into AI, if USE_ACL. -+ Ignore FD if it is negative. - If FLAGS & ACL_GET_SCONTEXT, also get security context. - If FLAGS & ACL_SYMLINK_FOLLOW, follow symbolic links. */ - static void --get_aclinfo (char const *name, struct aclinfo *ai, int flags) -+get_aclinfo (int fd, char const *name, struct aclinfo *ai, int flags) - { - int scontext_err = ENOTSUP; - ai->buf = ai->u.__gl_acl_ch; -@@ -163,7 +173,9 @@ get_aclinfo (char const *name, struct aclinfo *ai, int flags) - = (flags & ACL_SYMLINK_FOLLOW ? listxattr : llistxattr); - while (true) - { -- ai->size = lsxattr (name, ai->buf, acl_alloc); -+ ai->size = (fd < 0 -+ ? lsxattr (name, ai->buf, acl_alloc) -+ : flistxattr (fd, ai->buf, acl_alloc)); - if (0 < ai->size) - break; - ai->u.err = ai->size < 0 ? errno : 0; -@@ -171,7 +183,9 @@ get_aclinfo (char const *name, struct aclinfo *ai, int flags) - break; - - /* The buffer was too small. Find how large it should have been. */ -- ssize_t size = lsxattr (name, NULL, 0); -+ ssize_t size = (fd < 0 -+ ? lsxattr (name, NULL, 0) -+ : flistxattr (fd, NULL, 0)); - if (size <= 0) - { - ai->size = size; -@@ -214,9 +228,13 @@ get_aclinfo (char const *name, struct aclinfo *ai, int flags) - { - if (ai->size < 0 || aclinfo_has_xattr (ai, XATTR_NAME_SMACK)) - { -- ssize_t r = smack_new_label_from_path (name, "security.SMACK64", -- flags & ACL_SYMLINK_FOLLOW, -- &ai->scontext); -+ static char const SMACK64[] = "security.SMACK64"; -+ ssize_t r = -+ (fd < 0 -+ ? smack_new_label_from_path (name, SMACK64, -+ flags & ACL_SYMLINK_FOLLOW, -+ &ai->scontext) -+ : smack_new_label_from_file (fd, SMACK64, &ai->scontext)); - scontext_err = r < 0 ? errno : 0; - } - } -@@ -226,8 +244,10 @@ get_aclinfo (char const *name, struct aclinfo *ai, int flags) - if (ai->size < 0 || aclinfo_has_xattr (ai, XATTR_NAME_SELINUX)) - { - ssize_t r = -- ((flags & ACL_SYMLINK_FOLLOW ? getfilecon : lgetfilecon) -- (name, &ai->scontext)); -+ (fd < 0 -+ ? ((flags & ACL_SYMLINK_FOLLOW ? getfilecon : lgetfilecon) -+ (name, &ai->scontext)) -+ : fgetfilecon (fd, &ai->scontext)); - scontext_err = r < 0 ? errno : 0; - # ifndef SE_SELINUX_INLINE - /* Gnulib's selinux-h module is not in use, so getfilecon and -@@ -362,11 +382,13 @@ acl_nfs4_nontrivial (uint32_t *xattr, ssize_t nbytes) - } - #endif - --#if (!USE_LINUX_XATTR && USE_ACL && HAVE_ACL_GET_FD \ -- && !HAVE_ACL_EXTENDED_FILE && !HAVE_ACL_TYPE_EXTENDED \ -- && !HAVE_ACL_GET_LINK_NP) --# include --# ifdef O_PATH -+#if (!USE_LINUX_XATTR && USE_ACL && !HAVE_ACL_EXTENDED_FILE \ -+ && !HAVE_ACL_TYPE_EXTENDED) -+ -+# if HAVE_ACL_GET_FD && !HAVE_ACL_GET_LINK_NP -+# include -+# ifdef O_PATH -+# define acl_get_fd_np(fd, type) acl_get_fd (fd) - - /* Like acl_get_file, but do not follow symbolic links. */ - static acl_t -@@ -381,8 +403,24 @@ acl_get_link_np (char const *name, acl_type_t type) - errno = err; - return r; - } --# define HAVE_ACL_GET_LINK_NP 1 -+# define HAVE_ACL_GET_LINK_NP 1 -+# endif - # endif -+ -+static acl_t -+acl_get_fdfile (int fd, char const *name, acl_type_t type, int flags) -+{ -+ acl_t (*get) (char const *, acl_type_t) = acl_get_file; -+# if HAVE_ACL_GET_LINK_NP /* FreeBSD, NetBSD >= 10, Cygwin >= 2.5 */ -+ if (0 <= fd) -+ return acl_get_fd_np (fd, type); -+ if (! (flags & ACL_SYMLINK_FOLLOW)) -+ get = acl_get_link_np; -+# else -+ /* Ignore FD and FLAGS, unfortunately. */ -+# endif -+ return get (name, type); -+} - #endif - - /* Return 1 if NAME has a nontrivial access control list, -@@ -398,14 +436,35 @@ acl_get_link_np (char const *name, acl_type_t type) - If the d_type value is not known, use DT_UNKNOWN though this may be less - efficient. */ - int --file_has_aclinfo (MAYBE_UNUSED char const *restrict name, -+file_has_aclinfo (char const *restrict name, - struct aclinfo *restrict ai, int flags) -+{ -+ return fdfile_has_aclinfo (-1, name, ai, flags); -+} -+ -+/* Return 1 if FD aka NAME has a nontrivial access control list, -+ 0 if ACLs are not supported, or if NAME has no or only a base ACL, -+ and -1 (setting errno) on error. Note callers can determine -+ if ACLs are not supported as errno is set in that case also. -+ Ignore FD if it is negative. -+ Set *AI to ACL info regardless of return value. -+ FLAGS should be a d_type value, optionally ORed with -+ - _GL_DT_NOTDIR if it is known that NAME is not a directory, -+ - ACL_GET_SCONTEXT to retrieve security context and return 1 if present, -+ - ACL_SYMLINK_FOLLOW to follow the link if NAME is a symbolic link; -+ otherwise do not follow them if possible. -+ If the d_type value is not known, use DT_UNKNOWN though this may be less -+ efficient. */ -+int -+fdfile_has_aclinfo (MAYBE_UNUSED int fd, -+ MAYBE_UNUSED char const *restrict name, -+ struct aclinfo *restrict ai, int flags) - { - MAYBE_UNUSED unsigned char d_type = flags & UCHAR_MAX; - - #if USE_LINUX_XATTR - int initial_errno = errno; -- get_aclinfo (name, ai, flags); -+ get_aclinfo (fd, name, ai, flags); - - if (!aclinfo_may_indicate_xattr (ai) && ai->size <= 0) - { -@@ -418,11 +477,11 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, - In earlier Fedora the two types of ACLs were mutually exclusive. - Attempt to work correctly on both kinds of systems. */ - -- if (!has_xattr (XATTR_NAME_NFSV4_ACL, ai, name, flags)) -+ if (!has_xattr (XATTR_NAME_NFSV4_ACL, ai, fd, name, flags)) - return -- (has_xattr (XATTR_NAME_POSIX_ACL_ACCESS, ai, name, flags) -+ (has_xattr (XATTR_NAME_POSIX_ACL_ACCESS, ai, fd, name, flags) - || ((d_type == DT_DIR || d_type == DT_UNKNOWN) -- && has_xattr (XATTR_NAME_POSIX_ACL_DEFAULT, ai, name, flags))); -+ && has_xattr (XATTR_NAME_POSIX_ACL_DEFAULT, ai, fd, name, flags))); - - /* A buffer large enough to hold any trivial NFSv4 ACL. - The max length of a trivial NFSv4 ACL is 6 words for owner, -@@ -432,8 +491,10 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, - everyone is another word to hold "EVERYONE@". */ - uint32_t buf[2 * (6 + 6 + 7)]; - -- int ret = ((flags & ACL_SYMLINK_FOLLOW ? getxattr : lgetxattr) -- (name, XATTR_NAME_NFSV4_ACL, buf, sizeof buf)); -+ int ret = (fd < 0 -+ ? ((flags & ACL_SYMLINK_FOLLOW ? getxattr : lgetxattr) -+ (name, XATTR_NAME_NFSV4_ACL, buf, sizeof buf)) -+ : fgetxattr (fd, XATTR_NAME_NFSV4_ACL, buf, sizeof buf)); - if (ret < 0) - switch (errno) - { -@@ -467,20 +528,23 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, - /* On Linux, acl_extended_file is an optimized function: It only - makes two calls to getxattr(), one for ACL_TYPE_ACCESS, one for - ACL_TYPE_DEFAULT. */ -- ret = ((flags & ACL_SYMLINK_FOLLOW -- ? acl_extended_file -- : acl_extended_file_nofollow) -- (name)); -+ ret = (fd < 0 -+ ? ((flags & ACL_SYMLINK_FOLLOW -+ ? acl_extended_file -+ : acl_extended_file_nofollow) -+ (name)) -+ : acl_extended_fd (fd)); - # elif HAVE_ACL_TYPE_EXTENDED /* Mac OS X */ - /* On Mac OS X, acl_get_file (name, ACL_TYPE_ACCESS) - and acl_get_file (name, ACL_TYPE_DEFAULT) - always return NULL / EINVAL. There is no point in making - these two useless calls. The real ACL is retrieved through -- acl_get_file (name, ACL_TYPE_EXTENDED). */ -- acl_t acl = ((flags & ACL_SYMLINK_FOLLOW -- ? acl_get_file -- : acl_get_link_np) -- (name, ACL_TYPE_EXTENDED)); -+ ACL_TYPE_EXTENDED. */ -+ acl_t acl = -+ (fd < 0 -+ ? ((flags & ACL_SYMLINK_FOLLOW ? acl_get_file : acl_get_link_np) -+ (name, ACL_TYPE_EXTENDED)) -+ : acl_get_fd_np (fd, ACL_TYPE_EXTENDED)); - if (acl) - { - ret = acl_extended_nontrivial (acl); -@@ -489,13 +553,8 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, - else - ret = -1; - # else /* FreeBSD, NetBSD >= 10, IRIX, Tru64, Cygwin >= 2.5 */ -- acl_t (*acl_get_file_or_link) (char const *, acl_type_t) = acl_get_file; --# if HAVE_ACL_GET_LINK_NP /* FreeBSD, NetBSD >= 10, Cygwin >= 2.5 */ -- if (! (flags & ACL_SYMLINK_FOLLOW)) -- acl_get_file_or_link = acl_get_link_np; --# endif - -- acl_t acl = acl_get_file_or_link (name, ACL_TYPE_ACCESS); -+ acl_t acl = acl_get_fdfile (fd, name, ACL_TYPE_ACCESS, flags); - if (acl) - { - ret = acl_access_nontrivial (acl); -@@ -517,7 +576,7 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, - && (d_type == DT_DIR - || (d_type == DT_UNKNOWN && !(flags & _GL_DT_NOTDIR)))) - { -- acl = acl_get_file_or_link (name, ACL_TYPE_DEFAULT); -+ acl = acl_get_fdfile (fd, name, ACL_TYPE_DEFAULT, flags); - if (acl) - { - # ifdef __CYGWIN__ /* Cygwin >= 2.5 */ -@@ -562,7 +621,10 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, - - /* Solaris 10 (newer version), which has additional API declared in - (acl_t) and implemented in libsec (acl_set, acl_trivial, -- acl_fromtext, ...). */ -+ acl_fromtext, ...). -+ -+ Ignore FD, unfortunately. That is better than mishandling -+ ZFS-style ACLs, as the general case code does. */ - return acl_trivial (name); - - # else /* Solaris, Cygwin, general case */ -@@ -586,7 +648,9 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, - - for (;;) - { -- count = acl (name, GETACL, alloc, entries); -+ count = (fd < 0 -+ ? acl (name, GETACL, alloc, entries) -+ : facl (fd, GETACL, alloc, entries)); - if (count < 0 && errno == ENOSPC) - { - /* Increase the size of the buffer. */ -@@ -657,7 +721,9 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, - - for (;;) - { -- count = acl (name, ACE_GETACL, alloc, entries); -+ count = (fd < 0 -+ ? acl (name, ACE_GETACL, alloc, entries) -+ : facl (fd, ACE_GETACL, alloc, entries)); - if (count < 0 && errno == ENOSPC) - { - /* Increase the size of the buffer. */ -@@ -722,7 +788,9 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, - struct acl_entry entries[NACLENTRIES]; - int count; - -- count = getacl (name, NACLENTRIES, entries); -+ count = (fd < 0 -+ ? getacl (name, NACLENTRIES, entries) -+ : fgetacl (fd, NACLENTRIES, entries)); - - if (count < 0) - { -@@ -751,7 +819,8 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, - { - struct stat statbuf; - -- if (stat (name, &statbuf) == -1 && errno != EOVERFLOW) -+ if ((fd < 0 ? stat (name, &statbuf) : fstat (fd, &statbuf)) < 0 -+ && errno != EOVERFLOW) - return -1; - - return acl_nontrivial (count, entries); -@@ -765,6 +834,7 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, - struct acl entries[NACLVENTRIES]; - int count; - -+ /* Ignore FD, unfortunately. */ - count = acl ((char *) name, ACL_GET, NACLVENTRIES, entries); - - if (count < 0) -@@ -809,7 +879,9 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, - /* The docs say that type being 0 is equivalent to ACL_ANY, but it - is not true, in AIX 5.3. */ - type.u64 = ACL_ANY; -- if (aclx_get (name, 0, &type, aclbuf, &aclsize, &mode) >= 0) -+ if (0 <= (fd < 0 -+ ? aclx_get (name, 0, &type, aclbuf, &aclsize, &mode) -+ : aclx_fget (fd, 0, &type, aclbuf, &aclsize, &mode))) - break; - if (errno == ENOSYS) - return 0; -@@ -855,7 +927,10 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, - - union { struct acl a; char room[4096]; } u; - -- if (statacl ((char *) name, STX_NORMAL, &u.a, sizeof (u)) < 0) -+ if ((fd < 0 -+ ? statacl ((char *) name, STX_NORMAL, &u.a, sizeof u) -+ : fstatacl (fd, STX_NORMAL, &u.a, sizeof u)) -+ < 0) - return -1; - - return acl_nontrivial (&u.a); -@@ -866,6 +941,7 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, - struct acl entries[NACLENTRIES]; - int count; - -+ /* Ignore FD, unfortunately. */ - count = acl ((char *) name, ACL_GET, NACLENTRIES, entries); - - if (count < 0) -diff --git a/lib/qcopy-acl.c b/lib/qcopy-acl.c -index ad79661..282f4b2 100644 ---- a/lib/qcopy-acl.c -+++ b/lib/qcopy-acl.c -@@ -26,6 +26,7 @@ - #if USE_XATTR - - # include -+# include - # include - - # if HAVE_LINUX_XATTR_H -@@ -61,6 +62,7 @@ is_attr_permissions (const char *name, struct error_context *ctx) - a valid file descriptor, use file descriptor operations, else use - filename based operations on SRC_NAME. Likewise for DEST_DESC and - DST_NAME. -+ MODE should be the source file's st_mode. - If access control lists are not available, fchmod the target file to - MODE. Also sets the non-permission bits of the destination file - (S_ISUID, S_ISGID, S_ISVTX) to those from MODE if any are set. -@@ -86,10 +88,29 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, - Functions attr_copy_* return 0 in case we copied something OR nothing - to copy */ - if (ret == 0) -- ret = source_desc <= 0 || dest_desc <= 0 -- ? attr_copy_file (src_name, dst_name, is_attr_permissions, NULL) -- : attr_copy_fd (src_name, source_desc, dst_name, dest_desc, -- is_attr_permissions, NULL); -+ { -+ ret = source_desc <= 0 || dest_desc <= 0 -+ ? attr_copy_file (src_name, dst_name, is_attr_permissions, NULL) -+ : attr_copy_fd (src_name, source_desc, dst_name, dest_desc, -+ is_attr_permissions, NULL); -+ -+ /* Copying can fail with EOPNOTSUPP even when the source -+ permissions are trivial (Bug#78328). Don't report an error -+ in this case, as the chmod_or_fchmod suffices. */ -+ if (ret < 0 && errno == EOPNOTSUPP) -+ { -+ /* fdfile_has_aclinfo cares only about DT_DIR, _GL_DT_NOTDIR, -+ and DT_LNK (but DT_LNK is not possible here), -+ so use _GL_DT_NOTDIR | DT_UNKNOWN for other file types. */ -+ int flags = S_ISDIR (mode) ? DT_DIR : _GL_DT_NOTDIR | DT_UNKNOWN; -+ -+ struct aclinfo ai; -+ if (!fdfile_has_aclinfo (source_desc, src_name, &ai, flags)) -+ ret = 0; -+ aclinfo_free (&ai); -+ errno = EOPNOTSUPP; -+ } -+ } - #else - /* no XATTR, so we proceed the old dusty way */ - struct permission_context ctx; --- -2.49.0 - - -From ed2bda5888829f4ebacd6dc9c86b7494dbf2a3b7 Mon Sep 17 00:00:00 2001 -From: Paul Eggert -Date: Fri, 9 May 2025 18:48:03 -0700 -Subject: [PATCH 2/2] acl-tests: link with $(FILE_HAS_ACL_LIB) - -* modules/acl-tests (test_copy_acl_LDADD): Add -$(FILE_HAS_ACL_LIB), since qcopy-acl depends on file-has-acl. -Although this suggests that QCOPY_ACL_LIB should contain -FILE_HAS_ACL_LIB, I’m not sure whether that’s the right course of -action and anyway this is good enough for coreutils. - -(cherry picked from commit 955360a66c99bdd9ac3688519a8b521b06958fd3) ---- - gnulib-tests/gnulib.mk | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/gnulib-tests/gnulib.mk b/gnulib-tests/gnulib.mk -index e222c63..4b78de4 100644 ---- a/gnulib-tests/gnulib.mk -+++ b/gnulib-tests/gnulib.mk -@@ -99,7 +99,7 @@ TESTS += \ - TESTS_ENVIRONMENT += USE_ACL=$(USE_ACL) - check_PROGRAMS += test-set-mode-acl test-copy-acl test-sameacls - test_set_mode_acl_LDADD = $(LDADD) $(LIB_ACL) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV) --test_copy_acl_LDADD = $(LDADD) $(LIB_ACL) $(QCOPY_ACL_LIB) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV) -+test_copy_acl_LDADD = $(LDADD) $(LIB_ACL) $(QCOPY_ACL_LIB) $(FILE_HAS_ACL_LIB) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV) - test_sameacls_LDADD = $(LDADD) $(LIB_ACL) @LIBINTL@ $(MBRTOWC_LIB) - EXTRA_DIST += test-set-mode-acl.sh test-set-mode-acl-1.sh test-set-mode-acl-2.sh test-copy-acl.sh test-copy-acl-1.sh test-copy-acl-2.sh test-set-mode-acl.c test-copy-acl.c test-sameacls.c macros.h - --- -2.49.0 - diff --git a/coreutils-9.7-stty-arbitrary-baud-rates.patch b/coreutils-9.7-stty-arbitrary-baud-rates.patch deleted file mode 100644 index 20d078b..0000000 --- a/coreutils-9.7-stty-arbitrary-baud-rates.patch +++ /dev/null @@ -1,669 +0,0 @@ -From 8e5ee22042931bdac6488d61c5d59bcd1b0dba5f Mon Sep 17 00:00:00 2001 -From: "H. Peter Anvin" -Date: Mon, 16 Jun 2025 14:58:01 -0700 -Subject: [PATCH 1/5] stty: arbitrary or non-a priori known speed_t support - -Support the case where speed_t is simply a number, and in that case -assume that arbitrary values can be passed. This is assumed to be the -case when all known speed_t macros equal their own value. - -Try to probe for a variety of speed_t constants by trying to coax -$(CC) into emitting macro definitions (-E -dM). If this is not -supported, use a fairly extensive list of constants as a -fallback. This both improves the test for arbitrary speed support, as -well as allowing proper operation in the case where the constants are -not plain numbers and allows for handing enumerated speed constants -that were not known a priori when the source code was written. - -A simple shell script (mostly using sed) is used to turn the list of -constants (probed and predefined) into a pair of conversion functions, -baud_to_value() and value_to_baud(); string_to_baud() is then -reimplemented as a wrapper around the latter. - -* src/local.mk: Generate speedlist.h. -* src/speedgen: Portable shell script to generate speedlist.h. -* src/stty.c: Adjust string_to_baud to -convert from arbitrary numeric values. -* src/termios.c: A helper used when generating speedlist.h - -@lzaoral: This patch was amended to fix build failure in the -"single-binary" mode. - -(cherry picked from commit 357fda90d15fd3f7dba61e1ab322b183a48d0081) ---- - src/local.mk | 15 +++++- - src/speedgen | 85 ++++++++++++++++++++++++++++++ - src/stty.c | 143 +++++++++++++++++++------------------------------- - src/termios.c | 34 ++++++++++++ - 4 files changed, 188 insertions(+), 89 deletions(-) - create mode 100755 src/speedgen - create mode 100644 src/termios.c - -diff --git a/src/local.mk b/src/local.mk -index fd9dc81..3b8a34e 100644 ---- a/src/local.mk -+++ b/src/local.mk -@@ -71,7 +71,8 @@ EXTRA_DIST += \ - src/dircolors.hin \ - src/primes.h \ - src/tac-pipe.c \ -- src/extract-magic -+ src/extract-magic \ -+ src/speedgen - - CLEANFILES += $(SCRIPTS) - -@@ -672,6 +673,18 @@ src/version.h: Makefile - $(AM_V_at)chmod a-w $@t - $(AM_V_at)mv $@t $@ - -+# Target-specific termios baud rate file. This is opportunistic; -+# if cc -E doesn't support -dM, the speedgen script still includes -+# an extensive fallback list of common constants. -+BUILT_SOURCES += src/speedlist.h -+src/speedlist.h: src/termios.c lib/config.h src/speedgen -+ $(AM_V_GEN)rm -f $@ -+ $(AM_V_at)${MKDIR_P} src -+ $(AM_V_at)$(COMPILE) -E -dM $< 2>/dev/null | \ -+ $(SHELL) $(srcdir)/src/speedgen $@t -+ $(AM_V_at)chmod a-w $@t -+ $(AM_V_at)mv $@t $@ -+ - # Generates a list of macro invocations like: - # SINGLE_BINARY_PROGRAM(program_name_str, main_name) - # once for each program list on $(single_binary_progs). Note that -diff --git a/src/speedgen b/src/speedgen -new file mode 100755 -index 0000000..f1647d9 ---- /dev/null -+++ b/src/speedgen -@@ -0,0 +1,85 @@ -+#!/bin/sh -e -+ -+out="$1" -+tmp="$out.tmp" -+ -+if [ -z "$out" ]; then -+ echo "Usage: $0 outfile" 2>&1 -+ exit 1 -+fi -+ -+s='[[:space:]]' # For brevity's sake -+ -+trap "rm -f '$tmp'" EXIT -+trap "rm -f '$tmp' '$out'" ERR HUP INT QUIT TERM -+ -+# Fallback list of speeds that are always tested for -+defspeeds="0 50 75 110 134 150 200 300 600 1200 1800 2400 4800 7200 9600 \ -+14400 19200 28800 33600 38400 57600 76800 115200 153600 230400 307200 \ -+460800 500000 576000 614400 921600 1000000 1152000 1500000 \ -+2000000 2500000 3000000 3500000 4000000 5000000 10000000" -+( -+ sed -n -e "s/^$s*\#$s*define$s$s*B\\([1-9][0-9]*\\)$s.*\$/\\1/p" -+ for s in $defspeeds; do echo "$s"; done -+) | sort -n | uniq > "$tmp" -+ -+cat > "$out" <<'EOF' -+#ifndef SPEEDLIST_H -+# define SPEEDLIST_H 1 -+ -+# if 1 \ -+EOF -+ -+sed -e 's/^.*$/ \&\& (!defined(B&) || B& == &) \\/' < "$tmp" >> "$out" -+ -+cat >> "$out" <<'EOF' -+ -+# define TERMIOS_SPEED_T_SANE 1 -+ -+# endif -+ -+ATTRIBUTE_CONST -+static unsigned long int -+baud_to_value (speed_t speed) -+{ -+# ifdef TERMIOS_SPEED_T_SANE -+ return speed; -+# else -+ switch (speed) -+ { -+EOF -+ -+sed -e 's/^.*$/# ifdef B&\n case B&: return &;\n# endif/' \ -+ < "$tmp" >> "$out" -+ -+cat >> "$out" <<'EOF' -+ default: return -1; -+ } -+# endif -+} -+ -+ATTRIBUTE_CONST -+static speed_t -+value_to_baud (unsigned long int value) -+{ -+# ifdef TERMIOS_SPEED_T_SANE -+ speed_t speed = value; -+ if (speed != value) -+ speed = (speed_t) -1; /* Unrepresentable (overflow?) */ -+ return speed; -+# else -+ switch (value) -+ { -+EOF -+ -+sed -e 's/^.*$/# ifdef B&\n case &: return B&;\n# endif/' \ -+ < "$tmp" >> "$out" -+ -+cat >> "$out" <<'EOF' -+ default: return (speed_t) -1; -+ } -+# endif -+} -+ -+#endif -+EOF -diff --git a/src/stty.c b/src/stty.c -index 133b33c..561de1c 100644 ---- a/src/stty.c -+++ b/src/stty.c -@@ -55,6 +55,7 @@ - - #include "system.h" - #include "assure.h" -+#include "c-ctype.h" - #include "fd-reopen.h" - #include "quote.h" - #include "xdectoint.h" -@@ -2172,100 +2173,66 @@ recover_mode (char const *arg, struct termios *mode) - return true; - } - --struct speed_map --{ -- char const *string; /* ASCII representation. */ -- speed_t speed; /* Internal form. */ -- unsigned long int value; /* Numeric value. */ --}; -- --static struct speed_map const speeds[] = --{ -- {"0", B0, 0}, -- {"50", B50, 50}, -- {"75", B75, 75}, -- {"110", B110, 110}, -- {"134", B134, 134}, -- {"134.5", B134, 134}, -- {"150", B150, 150}, -- {"200", B200, 200}, -- {"300", B300, 300}, -- {"600", B600, 600}, -- {"1200", B1200, 1200}, -- {"1800", B1800, 1800}, -- {"2400", B2400, 2400}, -- {"4800", B4800, 4800}, -- {"9600", B9600, 9600}, -- {"19200", B19200, 19200}, -- {"38400", B38400, 38400}, -- {"exta", B19200, 19200}, -- {"extb", B38400, 38400}, --#ifdef B57600 -- {"57600", B57600, 57600}, --#endif --#ifdef B115200 -- {"115200", B115200, 115200}, --#endif --#ifdef B230400 -- {"230400", B230400, 230400}, --#endif --#ifdef B460800 -- {"460800", B460800, 460800}, --#endif --#ifdef B500000 -- {"500000", B500000, 500000}, --#endif --#ifdef B576000 -- {"576000", B576000, 576000}, --#endif --#ifdef B921600 -- {"921600", B921600, 921600}, --#endif --#ifdef B1000000 -- {"1000000", B1000000, 1000000}, --#endif --#ifdef B1152000 -- {"1152000", B1152000, 1152000}, --#endif --#ifdef B1500000 -- {"1500000", B1500000, 1500000}, --#endif --#ifdef B2000000 -- {"2000000", B2000000, 2000000}, --#endif --#ifdef B2500000 -- {"2500000", B2500000, 2500000}, --#endif --#ifdef B3000000 -- {"3000000", B3000000, 3000000}, --#endif --#ifdef B3500000 -- {"3500000", B3500000, 3500000}, --#endif --#ifdef B4000000 -- {"4000000", B4000000, 4000000}, --#endif -- {nullptr, 0, 0} --}; -+/* Autogenerated conversion functions to/from speed_t */ -+#include "speedlist.h" - - ATTRIBUTE_PURE - static speed_t - string_to_baud (char const *arg) - { -- for (int i = 0; speeds[i].string != nullptr; ++i) -- if (STREQ (arg, speeds[i].string)) -- return speeds[i].speed; -- return (speed_t) -1; --} -+ char *ep; -+ unsigned long value; -+ unsigned char c; - --ATTRIBUTE_PURE --static unsigned long int --baud_to_value (speed_t speed) --{ -- for (int i = 0; speeds[i].string != nullptr; ++i) -- if (speed == speeds[i].speed) -- return speeds[i].value; -- return 0; -+ /* Explicitly disallow negative numbers. */ -+ while (c_isspace (*arg)) -+ arg++; -+ if (*arg == '-') -+ return (speed_t) -1; -+ -+ value = strtoul (arg, &ep, 10); -+ -+ c = *ep++; -+ if (c == '.') -+ { -+ /* Number includes a fraction. Round it to nearest-even. -+ Note in particular that 134.5 must round to 134! */ -+ c = *ep++; -+ if (c) -+ { -+ c -= '0'; -+ if (c > 9) -+ { -+ return (speed_t) -1; /* Garbage after otherwise valid number */ -+ } -+ else if (c > 5) -+ { -+ value++; -+ } -+ else if (c == 5) -+ { -+ while ((c = *ep++) == '0') -+ ; /* Skip zeroes after .5 */ -+ -+ if (c >= '1' && c <= '9') -+ value++; /* Nonzero digit, round up */ -+ else -+ value += (value & 1); /* Exactly in the middle, round even */ -+ } -+ } -+ } -+ else if (c) -+ { -+ /* Not a valid number; check for legacy aliases "exta" and "extb" */ -+ if (STREQ (arg, "exta")) -+ return B19200; -+ else if (STREQ (arg, "extb")) -+ return B38400; -+ else -+ return (speed_t) -1; -+ } -+ -+ return value_to_baud (value); - } - - static void -diff --git a/src/termios.c b/src/termios.c -new file mode 100644 -index 0000000..f17e12e ---- /dev/null -+++ b/src/termios.c -@@ -0,0 +1,34 @@ -+/* termios.c -- coax out Bxxx macros from termios.h -+ -+ Copyright (C) 2025 Free Software Foundation, Inc. -+ -+ This program is free software: you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation, either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+/* This simply #includes headers which may or may not provide Bxxx -+ constant macros. This is run through the C preprocessor and defined -+ macros are extracted. -+ -+ In the case where the C preprocessor isn't capable of doing so, -+ the script this is fed through contains a pre-defined set of common -+ constants. */ -+ -+#include -+ -+#ifdef TERMIOS_NEEDS_XOPEN_SOURCE -+# define _XOPEN_SOURCE -+#endif -+ -+#include -+#include -+#include --- -2.50.0 - - -From 60c9206391e2fac32639d3a143435d1dd9ec6421 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?P=C3=A1draig=20Brady?= -Date: Tue, 17 Jun 2025 23:32:05 +0100 -Subject: [PATCH 2/5] tests: stty: adjust tests for arbitary speeds - -* tests/stty/stty-invalid.sh: Adjust to what is now invalid. -* tests/stty/stty.sh: Add checks for valid speed variants. -* tests/stty/bad-speed.sh: New test to ensure unsupported speeds -are diagnosed. - -(cherry picked from commit efaec8078142996d958b6720b85a13b12497c3d0) ---- - tests/local.mk | 1 + - tests/stty/bad-speed.sh | 50 ++++++++++++++++++++++++++++++++++++++ - tests/stty/stty-invalid.sh | 10 ++++++-- - tests/stty/stty.sh | 10 ++++++++ - 4 files changed, 69 insertions(+), 2 deletions(-) - create mode 100755 tests/stty/bad-speed.sh - -diff --git a/tests/local.mk b/tests/local.mk -index 642d225..b68df41 100644 ---- a/tests/local.mk -+++ b/tests/local.mk -@@ -425,6 +425,7 @@ all_tests = \ - tests/stat/stat-printf.pl \ - tests/stat/stat-slash.sh \ - tests/misc/stdbuf.sh \ -+ tests/stty/bad-speed.sh \ - tests/stty/stty.sh \ - tests/stty/stty-invalid.sh \ - tests/stty/stty-pairs.sh \ -diff --git a/tests/stty/bad-speed.sh b/tests/stty/bad-speed.sh -new file mode 100755 -index 0000000..d80d2e7 ---- /dev/null -+++ b/tests/stty/bad-speed.sh -@@ -0,0 +1,50 @@ -+#!/bin/sh -+# Ensure we handle cfsetispeed failing -+# which we did not before coreutils v9.1 -+ -+# Copyright (C) 2025 Free Software Foundation, Inc. -+ -+# This program is free software: you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation, either version 3 of the License, or -+# (at your option) any later version. -+ -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+ -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src -+print_ver_ stty -+require_gcc_shared_ -+ -+# Replace each cfsetispeed call with a call to these stubs. -+cat > k.c <<'EOF' || framework_failure_ -+#include -+#include -+#include -+#include -+ -+int cfsetispeed(struct termios *termios_p, speed_t speed) -+{ -+ /* Leave a marker so we can identify if the function was intercepted. */ -+ fclose(fopen("preloaded", "w")); -+ -+ errno=EINVAL; -+ return -1; -+} -+EOF -+ -+# Then compile/link it: -+gcc_shared_ k.c k.so \ -+ || skip_ 'failed to build shared library' -+ -+( export LD_PRELOAD=$LD_PRELOAD:./k.so -+ returns_ 1 stty ispeed 9600 ) || fail=1 -+ -+test -e preloaded || skip_ 'LD_PRELOAD interception failed' -+ -+Exit $fail -diff --git a/tests/stty/stty-invalid.sh b/tests/stty/stty-invalid.sh -index 4b87e2a..a1442a8 100755 ---- a/tests/stty/stty-invalid.sh -+++ b/tests/stty/stty-invalid.sh -@@ -20,6 +20,7 @@ - print_ver_ stty - require_controlling_input_terminal_ - require_trap_signame_ -+getlimits_ - - trap '' TTOU # Ignore SIGTTOU - -@@ -50,8 +51,13 @@ if tty -s = 9.8 supports arbitrary speeds on some systems -+# so restrict tests here to invalid numbers -+# We simulate unsupported numbers in a separate "LD_PRELOAD" test. -+WRAP_9600="$(expr $ULONG_OFLOW - 9600)" -+for speed in 9600.. ++9600 -$WRAP_9600 --$WRAP_9600 0x2580 96E2; do -+ returns_ 1 stty ispeed "$speed" || fail=1 -+done - - # Just in case either of the above mistakenly succeeds (and changes - # the state of our tty), try to restore the initial state. -diff --git a/tests/stty/stty.sh b/tests/stty/stty.sh -index dab4cd0..c0f7494 100755 ---- a/tests/stty/stty.sh -+++ b/tests/stty/stty.sh -@@ -95,4 +95,14 @@ for W in $(seq 80 90); do - test "$output_width" -le "$W" || fail=1 - done - -+# Ensure we support varied numeric forms -+# with appropriate rounding -+if stty ispeed '9600'; then -+ stty ispeed ' +9600' || fail=1 -+ stty ispeed '9600.49' || fail=1 -+ stty ispeed '9600.50' || fail=1 -+ stty ispeed '9599.51' || fail=1 -+ stty ispeed ' 9600.' || fail=1 -+fi -+ - Exit $fail --- -2.50.0 - - -From a47c15eea3ffe08662415ae13873b40c7ffcdb43 Mon Sep 17 00:00:00 2001 -From: Collin Funk -Date: Sat, 21 Jun 2025 22:05:19 -0700 -Subject: [PATCH 3/5] build: add src/termios.c to the tarball - -* src/local.mk (EXTRA_DIST): Add src/termios.c. - -(cherry picked from commit b7db7757831e93ca44ae59e1921bc4ebbc87974f) ---- - src/local.mk | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/src/local.mk b/src/local.mk -index 3b8a34e..188dda1 100644 ---- a/src/local.mk -+++ b/src/local.mk -@@ -72,7 +72,8 @@ EXTRA_DIST += \ - src/primes.h \ - src/tac-pipe.c \ - src/extract-magic \ -- src/speedgen -+ src/speedgen \ -+ src/termios.c - - CLEANFILES += $(SCRIPTS) - --- -2.50.0 - - -From caa439bf750193bcbed215a6676053f0b3c96e21 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?P=C3=A1draig=20Brady?= -Date: Sun, 22 Jun 2025 15:01:21 +0100 -Subject: [PATCH 4/5] doc: stty: adjust description of supported speeds - -* doc/coreutils.texi (stty invocation): Remove now imprecise -list of speeds given we may now support higher or arbitrary speeds. -Mention that we may support higher or arbitrary speeds. - -(cherry picked from commit 8b05eca972f70858749a946ac24f08d0718c1be6) ---- - doc/coreutils.texi | 21 ++------------------- - 1 file changed, 2 insertions(+), 19 deletions(-) - -diff --git a/doc/coreutils.texi b/doc/coreutils.texi -index 6d1ee11..c04af2b 100644 ---- a/doc/coreutils.texi -+++ b/doc/coreutils.texi -@@ -15932,25 +15932,8 @@ Print the terminal speed. - Set the input and output speeds to @var{n}. @var{n} can be one of: 0 - 50 75 110 134 134.5 150 200 300 600 1200 1800 2400 4800 9600 19200 - 38400 @code{exta} @code{extb}. @code{exta} is the same as 19200; --@code{extb} is the same as 38400. Many systems, including GNU/Linux, --support higher speeds. The @command{stty} command includes support --for speeds of --57600, --115200, --230400, --460800, --500000, --576000, --921600, --1000000, --1152000, --1500000, --2000000, --2500000, --3000000, --3500000, --or --4000000 where the system supports these. -+@code{extb} is the same as 38400. Many systems, support arbitrary -+or higher speeds. - 0 hangs up the line if @option{-clocal} is set. - @end table - --- -2.50.0 - - -From 8e48d56c2aa10f9875ffe1ec051a17f0eab6d2f9 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?P=C3=A1draig=20Brady?= -Date: Sun, 22 Jun 2025 16:40:04 +0100 -Subject: [PATCH 5/5] stty: stricter floating point parsing - -* src/stty.c (string_to_baud): Disallow extraneous characters -after floating point numbers. -* tests/stty/stty-invalid.sh: Add test cases. - -(cherry picked from commit 3d35b3c0e56bd556c90dc98c3e5e2e7289b0eb0d) ---- - src/stty.c | 27 +++++++++++++-------------- - tests/stty/stty-invalid.sh | 3 ++- - 2 files changed, 15 insertions(+), 15 deletions(-) - -diff --git a/src/stty.c b/src/stty.c -index 561de1c..0163ea4 100644 ---- a/src/stty.c -+++ b/src/stty.c -@@ -2200,25 +2200,24 @@ string_to_baud (char const *arg) - c = *ep++; - if (c) - { -- c -= '0'; -- if (c > 9) -+ unsigned char d = c - '0'; -+ if (d > 5) -+ value++; -+ else if (d == 5) - { -- return (speed_t) -1; /* Garbage after otherwise valid number */ -- } -- else if (c > 5) -- { -- value++; -- } -- else if (c == 5) -- { -- while ((c = *ep++) == '0') -- ; /* Skip zeroes after .5 */ -+ while ((c = *ep++) == '0'); /* Skip zeroes after .5 */ - -- if (c >= '1' && c <= '9') -- value++; /* Nonzero digit, round up */ -+ if (c) -+ value++; /* Nonzero, round up */ - else - value += (value & 1); /* Exactly in the middle, round even */ - } -+ -+ while (c_isdigit (c)) /* Skip remaining digits. */ -+ c = *ep++; -+ -+ if (c) -+ return (speed_t) -1; /* Garbage after otherwise valid number */ - } - } - else if (c) -diff --git a/tests/stty/stty-invalid.sh b/tests/stty/stty-invalid.sh -index a1442a8..868ed1d 100755 ---- a/tests/stty/stty-invalid.sh -+++ b/tests/stty/stty-invalid.sh -@@ -55,7 +55,8 @@ fi - # so restrict tests here to invalid numbers - # We simulate unsupported numbers in a separate "LD_PRELOAD" test. - WRAP_9600="$(expr $ULONG_OFLOW - 9600)" --for speed in 9600.. ++9600 -$WRAP_9600 --$WRAP_9600 0x2580 96E2; do -+for speed in 9599.. 9600.. 9600.5. 9600.50. 9600.0. ++9600 \ -+ -$WRAP_9600 --$WRAP_9600 0x2580 96E2 9600,0 '9600.0 '; do - returns_ 1 stty ispeed "$speed" || fail=1 - done - --- -2.50.0 - diff --git a/coreutils-CVE-2025-5278.patch b/coreutils-CVE-2025-5278.patch deleted file mode 100644 index af81286..0000000 --- a/coreutils-CVE-2025-5278.patch +++ /dev/null @@ -1,107 +0,0 @@ -From 701a9bdbf78f869e0fb778ed5aede00e42517add Mon Sep 17 00:00:00 2001 -From: Pádraig Brady -Date: Tue, 20 May 2025 16:03:44 +0100 -Subject: [PATCH] sort: fix buffer under-read (CWE-127) - -* src/sort.c (begfield): Check pointer adjustment -to avoid Out-of-range pointer offset (CWE-823). -(limfield): Likewise. -* tests/sort/sort-field-limit.sh: Add a new test, -which triggers with ASAN or Valgrind. -* tests/local.mk: Reference the new test. -Fixes https://bugs.gnu.org/78507 - -(cherry picked from commit 8c9602e3a145e9596dc1a63c6ed67865814b6633) ---- - src/sort.c | 12 ++++++++++-- - tests/local.mk | 1 + - tests/sort/sort-field-limit.sh | 35 ++++++++++++++++++++++++++++++++++ - 3 files changed, 46 insertions(+), 2 deletions(-) - create mode 100755 tests/sort/sort-field-limit.sh - -diff --git a/src/sort.c b/src/sort.c -index b10183b..7af1a25 100644 ---- a/src/sort.c -+++ b/src/sort.c -@@ -1644,7 +1644,11 @@ begfield (struct line const *line, struct keyfield const *key) - ++ptr; - - /* Advance PTR by SCHAR (if possible), but no further than LIM. */ -- ptr = MIN (lim, ptr + schar); -+ size_t remaining_bytes = lim - ptr; -+ if (schar < remaining_bytes) -+ ptr += schar; -+ else -+ ptr = lim; - - return ptr; - } -@@ -1746,7 +1750,11 @@ limfield (struct line const *line, struct keyfield const *key) - ++ptr; - - /* Advance PTR by ECHAR (if possible), but no further than LIM. */ -- ptr = MIN (lim, ptr + echar); -+ size_t remaining_bytes = lim - ptr; -+ if (echar < remaining_bytes) -+ ptr += echar; -+ else -+ ptr = lim; - } - - return ptr; -diff --git a/tests/local.mk b/tests/local.mk -index 4da6756..642d225 100644 ---- a/tests/local.mk -+++ b/tests/local.mk -@@ -388,6 +388,7 @@ all_tests = \ - tests/sort/sort-debug-keys.sh \ - tests/sort/sort-debug-warn.sh \ - tests/sort/sort-discrim.sh \ -+ tests/sort/sort-field-limit.sh \ - tests/sort/sort-files0-from.pl \ - tests/sort/sort-float.sh \ - tests/sort/sort-h-thousands-sep.sh \ -diff --git a/tests/sort/sort-field-limit.sh b/tests/sort/sort-field-limit.sh -new file mode 100755 -index 0000000..52d8e1d ---- /dev/null -+++ b/tests/sort/sort-field-limit.sh -@@ -0,0 +1,35 @@ -+#!/bin/sh -+# From 7.2-9.7, this would trigger an out of bounds mem read -+ -+# Copyright (C) 2025 Free Software Foundation, Inc. -+ -+# This program is free software: you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation, either version 3 of the License, or -+# (at your option) any later version. -+ -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+ -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src -+print_ver_ sort -+getlimits_ -+ -+# This issue triggers with valgrind or ASAN -+valgrind --error-exitcode=1 sort --version 2>/dev/null && -+ VALGRIND='valgrind --error-exitcode=1' -+ -+{ printf '%s\n' aa bb; } > in || framework_failure_ -+ -+_POSIX2_VERSION=200809 $VALGRIND sort +0.${SIZE_MAX}R in > out || fail=1 -+compare in out || fail=1 -+ -+_POSIX2_VERSION=200809 $VALGRIND sort +1 -1.${SIZE_MAX}R in > out || fail=1 -+compare in out || fail=1 -+ -+Exit $fail --- -2.49.0 - diff --git a/coreutils-df-direct.patch b/coreutils-df-direct.patch index f5e3d73..2deacf7 100644 --- a/coreutils-df-direct.patch +++ b/coreutils-df-direct.patch @@ -1,4 +1,4 @@ -From d3117ae1bb422f771f1c19af54f81d5151f55065 Mon Sep 17 00:00:00 2001 +From ae768935e696a23e336601c5a239e147628ecf05 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Mon, 29 Mar 2010 17:20:34 +0000 Subject: [PATCH] coreutils-df-direct.patch @@ -11,10 +11,10 @@ Subject: [PATCH] coreutils-df-direct.patch create mode 100755 tests/df/direct.sh diff --git a/doc/coreutils.texi b/doc/coreutils.texi -index d1c282f..6d1ee11 100644 +index 937d8af..11fa1d6 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi -@@ -12467,6 +12467,13 @@ some systems (notably Solaris), doing this yields more up to date results, +@@ -12588,6 +12588,13 @@ some systems (notably Solaris), doing this yields more up to date results, but in general this option makes @command{df} much slower, especially when there are many or very busy file systems. @@ -29,10 +29,10 @@ index d1c282f..6d1ee11 100644 @opindex --total @cindex grand total of file system size, usage and available space diff --git a/src/df.c b/src/df.c -index a969c5c..c465a3f 100644 +index 857f76c..07b21ea 100644 --- a/src/df.c +++ b/src/df.c -@@ -122,6 +122,9 @@ static bool print_type; +@@ -121,6 +121,9 @@ static bool print_type; /* If true, print a grand total at the end. */ static bool print_grand_total; @@ -42,7 +42,7 @@ index a969c5c..c465a3f 100644 /* Grand total data. */ static struct fs_usage grand_fsu; -@@ -249,13 +252,15 @@ enum +@@ -248,13 +251,15 @@ enum NO_SYNC_OPTION = CHAR_MAX + 1, SYNC_OPTION, TOTAL_OPTION, @@ -59,7 +59,7 @@ index a969c5c..c465a3f 100644 {"inodes", no_argument, nullptr, 'i'}, {"human-readable", no_argument, nullptr, 'h'}, {"si", no_argument, nullptr, 'H'}, -@@ -572,7 +577,10 @@ get_header (void) +@@ -571,7 +576,10 @@ get_header (void) for (idx_t col = 0; col < ncolumns; col++) { char *cell; @@ -71,7 +71,7 @@ index a969c5c..c465a3f 100644 if (columns[col]->field == SIZE_FIELD && (header_mode == DEFAULT_MODE -@@ -1454,6 +1462,17 @@ get_point (char const *point, const struct stat *statp) +@@ -1446,6 +1454,17 @@ get_point (char const *point, const struct stat *statp) static void get_entry (char const *name, struct stat const *statp) { @@ -89,7 +89,7 @@ index a969c5c..c465a3f 100644 if ((S_ISBLK (statp->st_mode) || S_ISCHR (statp->st_mode)) && get_device (name)) return; -@@ -1524,6 +1543,7 @@ or all file systems by default.\n\ +@@ -1516,6 +1535,7 @@ or all file systems by default.\n\ -B, --block-size=SIZE scale sizes by SIZE before printing them; e.g.,\n\ '-BM' prints sizes in units of 1,048,576 bytes;\n\ see SIZE format below\n\ @@ -97,7 +97,7 @@ index a969c5c..c465a3f 100644 -h, --human-readable print sizes in powers of 1024 (e.g., 1023M)\n\ -H, --si print sizes in powers of 1000 (e.g., 1.1G)\n\ "), stdout); -@@ -1618,6 +1638,9 @@ main (int argc, char **argv) +@@ -1610,6 +1630,9 @@ main (int argc, char **argv) xstrtol_fatal (e, oi, c, long_options, optarg); } break; @@ -107,7 +107,7 @@ index a969c5c..c465a3f 100644 case 'i': if (header_mode == OUTPUT_MODE) { -@@ -1714,6 +1737,13 @@ main (int argc, char **argv) +@@ -1706,6 +1729,13 @@ main (int argc, char **argv) } } @@ -183,5 +183,5 @@ index 0000000..8e4cfb8 + +Exit $fail -- -2.49.0 +2.51.0 diff --git a/coreutils-i18n.patch b/coreutils-i18n.patch index 2917075..92167bd 100644 --- a/coreutils-i18n.patch +++ b/coreutils-i18n.patch @@ -1,4 +1,4 @@ -From c0db8de625ca1ae0e0f4784c4eb2c779eae0047f Mon Sep 17 00:00:00 2001 +From c5b102c8d9ddf1cc1109858615de3a9d6d57b7e6 Mon Sep 17 00:00:00 2001 From: rpm-build Date: Wed, 30 Aug 2023 17:19:58 +0200 Subject: [PATCH] coreutils-i18n.patch @@ -7,17 +7,13 @@ Subject: [PATCH] coreutils-i18n.patch bootstrap.conf | 2 + configure.ac | 6 + lib/linebuffer.h | 8 + - lib/mbchar.c | 23 ++ - lib/mbchar.h | 383 +++++++++++++++++ lib/mbfile.c | 20 + lib/mbfile.h | 283 +++++++++++++ - m4/mbchar.m4 | 15 + m4/mbfile.m4 | 16 + src/cut.c | 508 +++++++++++++++++++++-- src/expand-common.c | 114 ++++++ src/expand-common.h | 12 + src/expand.c | 90 +++- - src/fold.c | 311 ++++++++++++-- src/local.mk | 4 +- src/pr.c | 443 ++++++++++++++++++-- src/sort.c | 790 +++++++++++++++++++++++++++++++++--- @@ -27,19 +23,15 @@ Subject: [PATCH] coreutils-i18n.patch tests/i18n/sort.sh | 29 ++ tests/local.mk | 4 + tests/misc/expand.pl | 42 ++ - tests/misc/fold.pl | 50 ++- tests/misc/sort-mb-tests.sh | 45 ++ tests/misc/unexpand.pl | 39 ++ tests/pr/pr-tests.pl | 49 +++ tests/sort/sort-merge.pl | 42 ++ tests/sort/sort.pl | 40 +- tests/unexpand/mb.sh | 172 ++++++++ - 30 files changed, 3632 insertions(+), 195 deletions(-) - create mode 100644 lib/mbchar.c - create mode 100644 lib/mbchar.h + 25 files changed, 2878 insertions(+), 167 deletions(-) create mode 100644 lib/mbfile.c create mode 100644 lib/mbfile.h - create mode 100644 m4/mbchar.m4 create mode 100644 m4/mbfile.m4 create mode 100644 tests/expand/mb.sh create mode 100644 tests/i18n/sort.sh @@ -47,10 +39,10 @@ Subject: [PATCH] coreutils-i18n.patch create mode 100644 tests/unexpand/mb.sh diff --git a/bootstrap.conf b/bootstrap.conf -index 94c164e..cecbf26 100644 +index b8feef9..ab1eb93 100644 --- a/bootstrap.conf +++ b/bootstrap.conf -@@ -166,6 +166,8 @@ gnulib_modules=" +@@ -169,6 +169,8 @@ gnulib_modules=" maintainer-makefile malloc-gnu manywarnings @@ -60,10 +52,10 @@ index 94c164e..cecbf26 100644 mbrtoc32 mbrtowc diff --git a/configure.ac b/configure.ac -index 775c4cc..e6b5c9c 100644 +index 274eff4..5a1cfa5 100644 --- a/configure.ac +++ b/configure.ac -@@ -504,6 +504,12 @@ fi +@@ -465,6 +465,12 @@ fi # I'm leaving it here for now. This whole thing needs to be modernized... gl_WINSIZE_IN_PTEM @@ -102,424 +94,6 @@ index ca56f80..509b7e6 100644 }; /* Initialize linebuffer LINEBUFFER for use. */ -diff --git a/lib/mbchar.c b/lib/mbchar.c -new file mode 100644 -index 0000000..713c2f7 ---- /dev/null -+++ b/lib/mbchar.c -@@ -0,0 +1,23 @@ -+/* Copyright (C) 2001, 2006, 2009-2025 Free Software Foundation, Inc. -+ -+ This file is free software: you can redistribute it and/or modify -+ it under the terms of the GNU Lesser General Public License as -+ published by the Free Software Foundation; either version 2.1 of the -+ License, or (at your option) any later version. -+ -+ This file is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public License -+ along with this program. If not, see . */ -+ -+ -+#include -+ -+#define MBCHAR_INLINE _GL_EXTERN_INLINE -+ -+#include -+ -+#include "mbchar.h" -diff --git a/lib/mbchar.h b/lib/mbchar.h -new file mode 100644 -index 0000000..d77168e ---- /dev/null -+++ b/lib/mbchar.h -@@ -0,0 +1,383 @@ -+/* Multibyte character data type. -+ Copyright (C) 2001, 2005-2007, 2009-2025 Free Software Foundation, Inc. -+ -+ This file is free software: you can redistribute it and/or modify -+ it under the terms of the GNU Lesser General Public License as -+ published by the Free Software Foundation; either version 2.1 of the -+ License, or (at your option) any later version. -+ -+ This file is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public License -+ along with this program. If not, see . */ -+ -+/* Written by Bruno Haible . */ -+ -+/* A multibyte character is a short subsequence of a char* string, -+ representing a single 32-bit wide character. -+ -+ We use multibyte characters instead of 32-bit wide characters because -+ of the following goals: -+ 1) correct multibyte handling, i.e. operate according to the LC_CTYPE -+ locale, -+ 2) ease of maintenance, i.e. the maintainer needs not know all details -+ of the ISO C 99 standard, -+ 3) don't fail grossly if the input is not in the encoding set by the -+ locale, because often different encodings are in use in the same -+ countries (ISO-8859-1/UTF-8, EUC-JP/Shift_JIS, ...), -+ 4) fast in the case of ASCII characters. -+ -+ Multibyte characters are only accessed through the mb* macros. -+ -+ mb_ptr (mbc) -+ return a pointer to the beginning of the multibyte sequence. -+ -+ mb_len (mbc) -+ returns the number of bytes occupied by the multibyte sequence. -+ Always > 0. -+ -+ mb_iseq (mbc, sc) -+ returns true if mbc is the standard ASCII character sc. -+ -+ mb_isnul (mbc) -+ returns true if mbc is the nul character. -+ -+ mb_cmp (mbc1, mbc2) -+ returns a positive, zero, or negative value depending on whether mbc1 -+ sorts after, same or before mbc2. -+ -+ mb_casecmp (mbc1, mbc2) -+ returns a positive, zero, or negative value depending on whether mbc1 -+ sorts after, same or before mbc2, modulo upper/lowercase conversion. -+ -+ mb_equal (mbc1, mbc2) -+ returns true if mbc1 and mbc2 are equal. -+ -+ mb_caseequal (mbc1, mbc2) -+ returns true if mbc1 and mbc2 are equal modulo upper/lowercase conversion. -+ -+ mb_isalnum (mbc) -+ returns true if mbc is alphanumeric. -+ -+ mb_isalpha (mbc) -+ returns true if mbc is alphabetic. -+ -+ mb_isascii(mbc) -+ returns true if mbc is plain ASCII. -+ -+ mb_isblank (mbc) -+ returns true if mbc is a blank. -+ -+ mb_iscntrl (mbc) -+ returns true if mbc is a control character. -+ -+ mb_isdigit (mbc) -+ returns true if mbc is a decimal digit. -+ -+ mb_isgraph (mbc) -+ returns true if mbc is a graphic character. -+ -+ mb_islower (mbc) -+ returns true if mbc is lowercase. -+ -+ mb_isprint (mbc) -+ returns true if mbc is a printable character. -+ -+ mb_ispunct (mbc) -+ returns true if mbc is a punctuation character. -+ -+ mb_isspace (mbc) -+ returns true if mbc is a space character. -+ -+ mb_isupper (mbc) -+ returns true if mbc is uppercase. -+ -+ mb_isxdigit (mbc) -+ returns true if mbc is a hexadecimal digit. -+ -+ mb_width (mbc) -+ returns the number of columns on the output device occupied by mbc. -+ Always >= 0. -+ -+ mb_putc (mbc, stream) -+ outputs mbc on stream, a byte oriented FILE stream opened for output. -+ -+ mb_setascii (&mbc, sc) -+ assigns the standard ASCII character sc to mbc. -+ (Only available if the 'mbfile' module is in use.) -+ -+ mb_copy (&destmbc, &srcmbc) -+ copies srcmbc to destmbc. -+ -+ Here are the function prototypes of the macros. -+ -+ extern const char * mb_ptr (const mbchar_t mbc); -+ extern size_t mb_len (const mbchar_t mbc); -+ extern bool mb_iseq (const mbchar_t mbc, char sc); -+ extern bool mb_isnul (const mbchar_t mbc); -+ extern int mb_cmp (const mbchar_t mbc1, const mbchar_t mbc2); -+ extern int mb_casecmp (const mbchar_t mbc1, const mbchar_t mbc2); -+ extern bool mb_equal (const mbchar_t mbc1, const mbchar_t mbc2); -+ extern bool mb_caseequal (const mbchar_t mbc1, const mbchar_t mbc2); -+ extern bool mb_isalnum (const mbchar_t mbc); -+ extern bool mb_isalpha (const mbchar_t mbc); -+ extern bool mb_isascii (const mbchar_t mbc); -+ extern bool mb_isblank (const mbchar_t mbc); -+ extern bool mb_iscntrl (const mbchar_t mbc); -+ extern bool mb_isdigit (const mbchar_t mbc); -+ extern bool mb_isgraph (const mbchar_t mbc); -+ extern bool mb_islower (const mbchar_t mbc); -+ extern bool mb_isprint (const mbchar_t mbc); -+ extern bool mb_ispunct (const mbchar_t mbc); -+ extern bool mb_isspace (const mbchar_t mbc); -+ extern bool mb_isupper (const mbchar_t mbc); -+ extern bool mb_isxdigit (const mbchar_t mbc); -+ extern int mb_width (const mbchar_t mbc); -+ extern void mb_putc (const mbchar_t mbc, FILE *stream); -+ extern void mb_setascii (mbchar_t *new, char sc); -+ extern void mb_copy (mbchar_t *new, const mbchar_t *old); -+ */ -+ -+#ifndef _MBCHAR_H -+#define _MBCHAR_H 1 -+ -+/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */ -+#if !_GL_CONFIG_H_INCLUDED -+ #error "Please include config.h first." -+#endif -+ -+#include -+#include -+ -+_GL_INLINE_HEADER_BEGIN -+#ifndef MBCHAR_INLINE -+# define MBCHAR_INLINE _GL_INLINE -+#endif -+ -+#ifdef __cplusplus -+extern "C" { -+#endif -+ -+ -+/* The longest multibyte characters, nowadays, are 4 bytes long. -+ Regardless of the values of MB_CUR_MAX and MB_LEN_MAX. */ -+#define MBCHAR_BUF_SIZE 4 -+ -+struct mbchar -+{ -+ const char *ptr; /* pointer to current character */ -+ size_t bytes; /* number of bytes of current character, > 0 */ -+ bool wc_valid; /* true if wc is a valid 32-bit wide character */ -+ char32_t wc; /* if wc_valid: the current character */ -+#if defined GNULIB_MBFILE -+ char buf[MBCHAR_BUF_SIZE]; /* room for the bytes, used for file input only */ -+#endif -+}; -+ -+/* EOF (not a real character) is represented with bytes = 0 and -+ wc_valid = false. */ -+ -+typedef struct mbchar mbchar_t; -+ -+/* Access the current character. */ -+#define mb_ptr(mbc) ((mbc).ptr) -+#define mb_len(mbc) ((mbc).bytes) -+ -+/* Comparison of characters. */ -+#define mb_iseq(mbc, sc) ((mbc).wc_valid && (mbc).wc == (sc)) -+#define mb_isnul(mbc) ((mbc).wc_valid && (mbc).wc == 0) -+#define mb_cmp(mbc1, mbc2) \ -+ ((mbc1).wc_valid \ -+ ? ((mbc2).wc_valid \ -+ ? _GL_CMP ((mbc1).wc, (mbc2).wc) \ -+ : -1) \ -+ : ((mbc2).wc_valid \ -+ ? 1 \ -+ : (mbc1).bytes == (mbc2).bytes \ -+ ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \ -+ : (mbc1).bytes < (mbc2).bytes \ -+ ? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \ -+ : (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).bytes) >= 0 ? 1 : -1))) -+#define mb_casecmp(mbc1, mbc2) \ -+ ((mbc1).wc_valid \ -+ ? ((mbc2).wc_valid \ -+ ? _GL_CMP (c32tolower ((mbc1).wc), c32tolower ((mbc2).wc)) \ -+ : -1) \ -+ : ((mbc2).wc_valid \ -+ ? 1 \ -+ : (mbc1).bytes == (mbc2).bytes \ -+ ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \ -+ : (mbc1).bytes < (mbc2).bytes \ -+ ? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \ -+ : (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).bytes) >= 0 ? 1 : -1))) -+#define mb_equal(mbc1, mbc2) \ -+ ((mbc1).wc_valid && (mbc2).wc_valid \ -+ ? (mbc1).wc == (mbc2).wc \ -+ : (mbc1).bytes == (mbc2).bytes \ -+ && memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) == 0) -+#define mb_caseequal(mbc1, mbc2) \ -+ ((mbc1).wc_valid && (mbc2).wc_valid \ -+ ? c32tolower ((mbc1).wc) == c32tolower ((mbc2).wc) \ -+ : (mbc1).bytes == (mbc2).bytes \ -+ && memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) == 0) -+ -+/* , classification. */ -+#define mb_isascii(mbc) \ -+ ((mbc).wc_valid && (mbc).wc >= 0 && (mbc).wc <= 127) -+#define mb_isalnum(mbc) ((mbc).wc_valid && c32isalnum ((mbc).wc)) -+#define mb_isalpha(mbc) ((mbc).wc_valid && c32isalpha ((mbc).wc)) -+#define mb_isblank(mbc) ((mbc).wc_valid && c32isblank ((mbc).wc)) -+#define mb_iscntrl(mbc) ((mbc).wc_valid && c32iscntrl ((mbc).wc)) -+#define mb_isdigit(mbc) ((mbc).wc_valid && c32isdigit ((mbc).wc)) -+#define mb_isgraph(mbc) ((mbc).wc_valid && c32isgraph ((mbc).wc)) -+#define mb_islower(mbc) ((mbc).wc_valid && c32islower ((mbc).wc)) -+#define mb_isprint(mbc) ((mbc).wc_valid && c32isprint ((mbc).wc)) -+#define mb_ispunct(mbc) ((mbc).wc_valid && c32ispunct ((mbc).wc)) -+#define mb_isspace(mbc) ((mbc).wc_valid && c32isspace ((mbc).wc)) -+#define mb_isupper(mbc) ((mbc).wc_valid && c32isupper ((mbc).wc)) -+#define mb_isxdigit(mbc) ((mbc).wc_valid && c32isxdigit ((mbc).wc)) -+ -+/* Extra function. */ -+ -+/* Unprintable characters appear as a small box of width 1. */ -+#define MB_UNPRINTABLE_WIDTH 1 -+ -+MBCHAR_INLINE int -+mb_width_aux (char32_t wc) -+{ -+ int w = c32width (wc); -+ /* For unprintable characters, arbitrarily return 0 for control characters -+ and MB_UNPRINTABLE_WIDTH otherwise. */ -+ return (w >= 0 ? w : c32iscntrl (wc) ? 0 : MB_UNPRINTABLE_WIDTH); -+} -+ -+#define mb_width(mbc) \ -+ ((mbc).wc_valid ? mb_width_aux ((mbc).wc) : MB_UNPRINTABLE_WIDTH) -+ -+/* Output. */ -+#define mb_putc(mbc, stream) fwrite ((mbc).ptr, 1, (mbc).bytes, (stream)) -+ -+#if defined GNULIB_MBFILE -+/* Assignment. */ -+# define mb_setascii(mbc, sc) \ -+ ((mbc)->ptr = (mbc)->buf, (mbc)->bytes = 1, (mbc)->wc_valid = 1, \ -+ (mbc)->wc = (mbc)->buf[0] = (sc)) -+#endif -+ -+/* Copying a character. */ -+MBCHAR_INLINE void -+mb_copy (mbchar_t *new_mbc, const mbchar_t *old_mbc) -+{ -+#if defined GNULIB_MBFILE -+ if (old_mbc->ptr == &old_mbc->buf[0]) -+ { -+ memcpy (&new_mbc->buf[0], &old_mbc->buf[0], old_mbc->bytes); -+ new_mbc->ptr = &new_mbc->buf[0]; -+ } -+ else -+#endif -+ new_mbc->ptr = old_mbc->ptr; -+ new_mbc->bytes = old_mbc->bytes; -+ if ((new_mbc->wc_valid = old_mbc->wc_valid)) -+ new_mbc->wc = old_mbc->wc; -+} -+ -+ -+/* is_basic(c) tests whether the single-byte character c is -+ - in the ISO C "basic character set" or is one of '@', '$', and '`' -+ which ISO C 23 § 5.2.1.1.(1) guarantees to be single-byte and in -+ practice are safe to treat as basic in the execution character set, -+ or -+ - in the POSIX "portable character set", which -+ -+ equally guarantees to be single-byte. -+ This is a convenience function, and is in this file only to share code -+ between mbiter.h, mbuiter.h, and mbfile.h. */ -+#if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ -+ && ('$' == 36) && ('%' == 37) && ('&' == 38) && ('\'' == 39) \ -+ && ('(' == 40) && (')' == 41) && ('*' == 42) && ('+' == 43) \ -+ && (',' == 44) && ('-' == 45) && ('.' == 46) && ('/' == 47) \ -+ && ('0' == 48) && ('1' == 49) && ('2' == 50) && ('3' == 51) \ -+ && ('4' == 52) && ('5' == 53) && ('6' == 54) && ('7' == 55) \ -+ && ('8' == 56) && ('9' == 57) && (':' == 58) && (';' == 59) \ -+ && ('<' == 60) && ('=' == 61) && ('>' == 62) && ('?' == 63) \ -+ && ('@' == 64) && ('A' == 65) && ('B' == 66) && ('C' == 67) \ -+ && ('D' == 68) && ('E' == 69) && ('F' == 70) && ('G' == 71) \ -+ && ('H' == 72) && ('I' == 73) && ('J' == 74) && ('K' == 75) \ -+ && ('L' == 76) && ('M' == 77) && ('N' == 78) && ('O' == 79) \ -+ && ('P' == 80) && ('Q' == 81) && ('R' == 82) && ('S' == 83) \ -+ && ('T' == 84) && ('U' == 85) && ('V' == 86) && ('W' == 87) \ -+ && ('X' == 88) && ('Y' == 89) && ('Z' == 90) && ('[' == 91) \ -+ && ('\\' == 92) && (']' == 93) && ('^' == 94) && ('_' == 95) \ -+ && ('`' == 96) && ('a' == 97) && ('b' == 98) && ('c' == 99) \ -+ && ('d' == 100) && ('e' == 101) && ('f' == 102) && ('g' == 103) \ -+ && ('h' == 104) && ('i' == 105) && ('j' == 106) && ('k' == 107) \ -+ && ('l' == 108) && ('m' == 109) && ('n' == 110) && ('o' == 111) \ -+ && ('p' == 112) && ('q' == 113) && ('r' == 114) && ('s' == 115) \ -+ && ('t' == 116) && ('u' == 117) && ('v' == 118) && ('w' == 119) \ -+ && ('x' == 120) && ('y' == 121) && ('z' == 122) && ('{' == 123) \ -+ && ('|' == 124) && ('}' == 125) && ('~' == 126) -+/* The character set is ISO-646, not EBCDIC. */ -+# define IS_BASIC_ASCII 1 -+ -+/* All locale encodings (see localcharset.h) map the characters 0x00..0x7F -+ to U+0000..U+007F, like ASCII, except for -+ CP864 different mapping of '%' -+ SHIFT_JIS different mappings of 0x5C, 0x7E -+ JOHAB different mapping of 0x5C -+ However, these characters in the range 0x20..0x7E are in the ISO C -+ "basic character set" and in the POSIX "portable character set", which -+ ISO C and POSIX guarantee to be single-byte. Thus, locales with these -+ encodings are not POSIX compliant. And they are most likely not in use -+ any more (as of 2023). */ -+# define is_basic(c) ((unsigned char) (c) < 0x80) -+ -+#else -+ -+MBCHAR_INLINE bool -+is_basic (char c) -+{ -+ switch (c) -+ { -+ case '\0': -+ case '\007': case '\010': -+ case '\t': case '\n': case '\v': case '\f': case '\r': -+ case ' ': case '!': case '"': case '#': case '$': case '%': -+ case '&': case '\'': case '(': case ')': case '*': -+ case '+': case ',': case '-': case '.': case '/': -+ case '0': case '1': case '2': case '3': case '4': -+ case '5': case '6': case '7': case '8': case '9': -+ case ':': case ';': case '<': case '=': case '>': -+ case '?': case '@': -+ case 'A': case 'B': case 'C': case 'D': case 'E': -+ case 'F': case 'G': case 'H': case 'I': case 'J': -+ case 'K': case 'L': case 'M': case 'N': case 'O': -+ case 'P': case 'Q': case 'R': case 'S': case 'T': -+ case 'U': case 'V': case 'W': case 'X': case 'Y': -+ case 'Z': -+ case '[': case '\\': case ']': case '^': case '_': case '`': -+ case 'a': case 'b': case 'c': case 'd': case 'e': -+ case 'f': case 'g': case 'h': case 'i': case 'j': -+ case 'k': case 'l': case 'm': case 'n': case 'o': -+ case 'p': case 'q': case 'r': case 's': case 't': -+ case 'u': case 'v': case 'w': case 'x': case 'y': -+ case 'z': case '{': case '|': case '}': case '~': -+ return 1; -+ default: -+ return 0; -+ } -+} -+ -+#endif -+ -+ -+#ifdef __cplusplus -+} -+#endif -+ -+_GL_INLINE_HEADER_END -+ -+#endif /* _MBCHAR_H */ diff --git a/lib/mbfile.c b/lib/mbfile.c new file mode 100644 index 0000000..f4e3e77 @@ -835,27 +409,6 @@ index 0000000..c852f31 +_GL_INLINE_HEADER_END + +#endif /* _MBFILE_H */ -diff --git a/m4/mbchar.m4 b/m4/mbchar.m4 -new file mode 100644 -index 0000000..b76f1d7 ---- /dev/null -+++ b/m4/mbchar.m4 -@@ -0,0 +1,15 @@ -+# mbchar.m4 -+# serial 9 -+dnl Copyright (C) 2005-2007, 2009-2025 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+dnl This file is offered as-is, without any warranty. -+ -+dnl autoconf tests required for use of mbchar.m4 -+dnl From Bruno Haible. -+ -+AC_DEFUN([gl_MBCHAR], -+[ -+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) -+]) diff --git a/m4/mbfile.m4 b/m4/mbfile.m4 new file mode 100644 index 0000000..1d126e0 @@ -879,7 +432,7 @@ index 0000000..1d126e0 + : +]) diff --git a/src/cut.c b/src/cut.c -index b424997..c9f181c 100644 +index f0effb9..36479d6 100644 --- a/src/cut.c +++ b/src/cut.c @@ -27,6 +27,11 @@ @@ -1539,7 +1092,7 @@ index b424997..c9f181c 100644 if (have_read_stdin && fclose (stdin) == EOF) diff --git a/src/expand-common.c b/src/expand-common.c -index 732123f..fdbef3f 100644 +index ca2ad4d..2ad24bf 100644 --- a/src/expand-common.c +++ b/src/expand-common.c @@ -19,6 +19,7 @@ @@ -1671,7 +1224,7 @@ index 732123f..fdbef3f 100644 to the list of tab stops. */ extern void diff --git a/src/expand-common.h b/src/expand-common.h -index fe6c8ed..80a1280 100644 +index 46ef4e3..e19469b 100644 --- a/src/expand-common.h +++ b/src/expand-common.h @@ -29,6 +29,18 @@ extern idx_t max_column_width; @@ -1848,414 +1401,11 @@ index 5ec7ce9..65ac315 100644 } } -diff --git a/src/fold.c b/src/fold.c -index b64aad4..a156337 100644 ---- a/src/fold.c -+++ b/src/fold.c -@@ -23,10 +23,32 @@ - #include - #include - -+/* Get mbstate_t, mbrtowc(), wcwidth(). */ -+#if HAVE_WCHAR_H -+# include -+#endif -+ -+/* Get iswprint(), iswblank(), wcwidth(). */ -+#if HAVE_WCTYPE_H -+# include -+#endif -+ - #include "system.h" - #include "fadvise.h" - #include "xdectoint.h" - -+/* MB_LEN_MAX is incorrectly defined to be 1 in at least one GCC -+ installation; work around this configuration error. */ -+#if !defined MB_LEN_MAX || MB_LEN_MAX < 2 -+# undef MB_LEN_MAX -+# define MB_LEN_MAX 16 -+#endif -+ -+/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */ -+#if HAVE_MBRTOWC && defined mbstate_t -+# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0) -+#endif -+ - #define TAB_WIDTH 8 - - /* The official name of this program (e.g., no 'g' prefix). */ -@@ -34,20 +56,41 @@ - - #define AUTHORS proper_name ("David MacKenzie") - -+#define FATAL_ERROR(Message) \ -+ do \ -+ { \ -+ error (0, 0, (Message)); \ -+ usage (2); \ -+ } \ -+ while (0) -+ -+enum operating_mode -+{ -+ /* Fold texts by columns that are at the given positions. */ -+ column_mode, -+ -+ /* Fold texts by bytes that are at the given positions. */ -+ byte_mode, -+ -+ /* Fold texts by characters that are at the given positions. */ -+ character_mode, -+}; -+ -+/* The argument shows current mode. (Default: column_mode) */ -+static enum operating_mode operating_mode; -+ - /* If nonzero, try to break on whitespace. */ - static bool break_spaces; - --/* If nonzero, count bytes, not column positions. */ --static bool count_bytes; -- - /* If nonzero, at least one of the files we read was standard input. */ - static bool have_read_stdin; - --static char const shortopts[] = "bsw:0::1::2::3::4::5::6::7::8::9::"; -+static char const shortopts[] = "bcsw:0::1::2::3::4::5::6::7::8::9::"; - - static struct option const longopts[] = - { - {"bytes", no_argument, nullptr, 'b'}, -+ {"characters", no_argument, nullptr, 'c'}, - {"spaces", no_argument, nullptr, 's'}, - {"width", required_argument, nullptr, 'w'}, - {GETOPT_HELP_OPTION_DECL}, -@@ -75,6 +118,7 @@ Wrap input lines in each FILE, writing to standard output.\n\ - - fputs (_("\ - -b, --bytes count bytes rather than columns\n\ -+ -c, --characters count characters rather than columns\n\ - -s, --spaces break at spaces\n\ - -w, --width=WIDTH use WIDTH columns instead of 80\n\ - "), stdout); -@@ -92,7 +136,7 @@ Wrap input lines in each FILE, writing to standard output.\n\ - static size_t - adjust_column (size_t column, char c) - { -- if (!count_bytes) -+ if (operating_mode != byte_mode) - { - if (c == '\b') - { -@@ -115,30 +159,14 @@ adjust_column (size_t column, char c) - to stdout, with maximum line length WIDTH. - Return true if successful. */ - --static bool --fold_file (char const *filename, size_t width) -+static void -+fold_text (FILE *istream, size_t width, int *saved_errno) - { -- FILE *istream; - int c; - size_t column = 0; /* Screen column where next char will go. */ - idx_t offset_out = 0; /* Index in 'line_out' for next char. */ - static char *line_out = nullptr; - static idx_t allocated_out = 0; -- int saved_errno; -- -- if (STREQ (filename, "-")) -- { -- istream = stdin; -- have_read_stdin = true; -- } -- else -- istream = fopen (filename, "r"); -- -- if (istream == nullptr) -- { -- error (0, errno, "%s", quotef (filename)); -- return false; -- } - - fadvise (istream, FADVISE_SEQUENTIAL); - -@@ -168,6 +196,15 @@ fold_file (char const *filename, size_t width) - bool found_blank = false; - idx_t logical_end = offset_out; - -+ /* If LINE_OUT has no wide character, -+ put a new wide character in LINE_OUT -+ if column is bigger than width. */ -+ if (offset_out == 0) -+ { -+ line_out[offset_out++] = c; -+ continue; -+ } -+ - /* Look for the last blank. */ - while (logical_end) - { -@@ -212,13 +249,224 @@ fold_file (char const *filename, size_t width) - line_out[offset_out++] = c; - } - -- saved_errno = errno; -+ *saved_errno = errno; - if (!ferror (istream)) -- saved_errno = 0; -+ *saved_errno = 0; - - if (offset_out) - fwrite (line_out, sizeof (char), offset_out, stdout); - -+} -+ -+#if HAVE_MBRTOWC -+static void -+fold_multibyte_text (FILE *istream, size_t width, int *saved_errno) -+{ -+ char buf[MB_LEN_MAX + BUFSIZ]; /* For spooling a read byte sequence. */ -+ size_t buflen = 0; /* The length of the byte sequence in buf. */ -+ char *bufpos = buf; /* Next read position of BUF. */ -+ wint_t wc; /* A gotten wide character. */ -+ size_t mblength; /* The byte size of a multibyte character which shows -+ as same character as WC. */ -+ mbstate_t state, state_bak; /* State of the stream. */ -+ int convfail = 0; /* 1, when conversion is failed. Otherwise 0. */ -+ -+ static char *line_out = NULL; -+ idx_t offset_out = 0; /* Index in `line_out' for next char. */ -+ static idx_t allocated_out = 0; -+ -+ int increment; -+ size_t column = 0; -+ -+ size_t last_blank_pos; -+ size_t last_blank_column; -+ int is_blank_seen; -+ int last_blank_increment = 0; -+ int is_bs_following_last_blank; -+ size_t bs_following_last_blank_num; -+ int is_cr_after_last_blank; -+ -+#define CLEAR_FLAGS \ -+ do \ -+ { \ -+ last_blank_pos = 0; \ -+ last_blank_column = 0; \ -+ is_blank_seen = 0; \ -+ is_bs_following_last_blank = 0; \ -+ bs_following_last_blank_num = 0; \ -+ is_cr_after_last_blank = 0; \ -+ } \ -+ while (0) -+ -+#define START_NEW_LINE \ -+ do \ -+ { \ -+ putchar ('\n'); \ -+ column = 0; \ -+ offset_out = 0; \ -+ CLEAR_FLAGS; \ -+ } \ -+ while (0) -+ -+ CLEAR_FLAGS; -+ memset (&state, '\0', sizeof(mbstate_t)); -+ -+ for (;; bufpos += mblength, buflen -= mblength) -+ { -+ if (buflen < MB_LEN_MAX && !feof (istream) && !ferror (istream)) -+ { -+ memmove (buf, bufpos, buflen); -+ buflen += fread (buf + buflen, sizeof(char), BUFSIZ, istream); -+ bufpos = buf; -+ } -+ -+ if (buflen < 1) -+ break; -+ -+ /* Get a wide character. */ -+ state_bak = state; -+ mblength = mbrtowc ((wchar_t *)&wc, bufpos, buflen, &state); -+ -+ switch (mblength) -+ { -+ case (size_t)-1: -+ case (size_t)-2: -+ convfail++; -+ state = state_bak; -+ /* Fall through. */ -+ -+ case 0: -+ mblength = 1; -+ break; -+ } -+ -+rescan: -+ if (convfail) -+ increment = 1; -+ else if (wc == L'\n') -+ { -+ /* preserve newline */ -+ fwrite (line_out, sizeof(char), offset_out, stdout); -+ START_NEW_LINE; -+ continue; -+ } -+ else if (operating_mode == byte_mode) /* byte mode */ -+ increment = mblength; -+ else if (operating_mode == character_mode) /* character mode */ -+ increment = 1; -+ else /* column mode */ -+ { -+ switch (wc) -+ { -+ case L'\b': -+ increment = (column > 0) ? -1 : 0; -+ break; -+ -+ case L'\r': -+ increment = -1 * column; -+ break; -+ -+ case L'\t': -+ increment = 8 - column % 8; -+ break; -+ -+ default: -+ increment = wcwidth (wc); -+ increment = (increment < 0) ? 0 : increment; -+ } -+ } -+ -+ if (column + increment > width && break_spaces && last_blank_pos) -+ { -+ fwrite (line_out, sizeof(char), last_blank_pos, stdout); -+ putchar ('\n'); -+ -+ offset_out = offset_out - last_blank_pos; -+ column = column - last_blank_column + ((is_cr_after_last_blank) -+ ? last_blank_increment : bs_following_last_blank_num); -+ memmove (line_out, line_out + last_blank_pos, offset_out); -+ CLEAR_FLAGS; -+ goto rescan; -+ } -+ -+ if (column + increment > width && column != 0) -+ { -+ fwrite (line_out, sizeof(char), offset_out, stdout); -+ START_NEW_LINE; -+ goto rescan; -+ } -+ -+ if (allocated_out - offset_out <= mblength) -+ { -+ line_out = xpalloc (line_out, &allocated_out, 1, -1, sizeof *line_out); -+ } -+ -+ memcpy (line_out + offset_out, bufpos, mblength); -+ offset_out += mblength; -+ column += increment; -+ -+ if (is_blank_seen && !convfail && wc == L'\r') -+ is_cr_after_last_blank = 1; -+ -+ if (is_bs_following_last_blank && !convfail && wc == L'\b') -+ ++bs_following_last_blank_num; -+ else -+ is_bs_following_last_blank = 0; -+ -+ if (break_spaces && !convfail && iswblank (wc)) -+ { -+ last_blank_pos = offset_out; -+ last_blank_column = column; -+ is_blank_seen = 1; -+ last_blank_increment = increment; -+ is_bs_following_last_blank = 1; -+ bs_following_last_blank_num = 0; -+ is_cr_after_last_blank = 0; -+ } -+ } -+ -+ *saved_errno = errno; -+ if (!ferror (istream)) -+ *saved_errno = 0; -+ -+ if (offset_out) -+ fwrite (line_out, sizeof (char), offset_out, stdout); -+ -+} -+#endif -+ -+/* Fold file FILENAME, or standard input if FILENAME is "-", -+ to stdout, with maximum line length WIDTH. -+ Return true if successful. */ -+ -+static bool -+fold_file (char const *filename, size_t width) -+{ -+ FILE *istream; -+ int saved_errno; -+ -+ if (STREQ (filename, "-")) -+ { -+ istream = stdin; -+ have_read_stdin = true; -+ } -+ else -+ istream = fopen (filename, "r"); -+ -+ if (istream == nullptr) -+ { -+ error (0, errno, "%s", filename); -+ return false; -+ } -+ -+ /* Define how ISTREAM is being folded. */ -+#if HAVE_MBRTOWC -+ if (MB_CUR_MAX > 1) -+ fold_multibyte_text (istream, width, &saved_errno); -+ else -+#endif -+ fold_text (istream, width, &saved_errno); -+ - if (STREQ (filename, "-")) - clearerr (istream); - else if (fclose (istream) != 0 && !saved_errno) -@@ -249,7 +497,8 @@ main (int argc, char **argv) - - atexit (close_stdout); - -- break_spaces = count_bytes = have_read_stdin = false; -+ operating_mode = column_mode; -+ break_spaces = have_read_stdin = false; - - while ((optc = getopt_long (argc, argv, shortopts, longopts, nullptr)) != -1) - { -@@ -258,7 +507,15 @@ main (int argc, char **argv) - switch (optc) - { - case 'b': /* Count bytes rather than columns. */ -- count_bytes = true; -+ if (operating_mode != column_mode) -+ FATAL_ERROR (_("only one way of folding may be specified")); -+ operating_mode = byte_mode; -+ break; -+ -+ case 'c': -+ if (operating_mode != column_mode) -+ FATAL_ERROR (_("only one way of folding may be specified")); -+ operating_mode = character_mode; - break; - - case 's': /* Break at word boundaries. */ diff --git a/src/local.mk b/src/local.mk -index 188dda1..7db5753 100644 +index 8f6d9a5..da16e59 100644 --- a/src/local.mk +++ b/src/local.mk -@@ -478,8 +478,8 @@ src_base32_CPPFLAGS = -DBASE_TYPE=32 $(AM_CPPFLAGS) +@@ -479,8 +479,8 @@ src_base32_CPPFLAGS = -DBASE_TYPE=32 $(AM_CPPFLAGS) src_basenc_SOURCES = src/basenc.c src_basenc_CPPFLAGS = -DBASE_TYPE=42 $(AM_CPPFLAGS) @@ -2267,7 +1417,7 @@ index 188dda1..7db5753 100644 src_wc_SOURCES = src/wc.c if USE_AVX2_WC_LINECOUNT diff --git a/src/pr.c b/src/pr.c -index e7081a0..19e0268 100644 +index 87974d0..999bae7 100644 --- a/src/pr.c +++ b/src/pr.c @@ -312,6 +312,24 @@ @@ -3038,7 +2188,7 @@ index e7081a0..19e0268 100644 looking for more options and printing the next batch of files. diff --git a/src/sort.c b/src/sort.c -index 7af1a25..d3dc684 100644 +index 5a6a963..0b1b941 100644 --- a/src/sort.c +++ b/src/sort.c @@ -29,6 +29,14 @@ @@ -3688,7 +2838,7 @@ index 7af1a25..d3dc684 100644 } @@ -2681,11 +3043,87 @@ diff_reversed (int diff, bool reversed) - return reversed ? (diff < 0) - (diff > 0) : diff; + return reversed ? _GL_CMP (0, diff) : diff; } +#if HAVE_MBRTOWC @@ -4006,7 +3156,7 @@ index 7af1a25..d3dc684 100644 { /* xmemcoll0 is a performance enhancement as it will not unconditionally write '\0' after the -@@ -4291,6 +4934,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype) +@@ -4289,6 +4932,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype) break; case 'f': key->translate = fold_toupper; @@ -4014,7 +3164,7 @@ index 7af1a25..d3dc684 100644 break; case 'g': key->general_numeric = true; -@@ -4370,7 +5014,7 @@ main (int argc, char **argv) +@@ -4368,7 +5012,7 @@ main (int argc, char **argv) initialize_exit_failure (SORT_FAILURE); hard_LC_COLLATE = hard_locale (LC_COLLATE); @@ -4023,7 +3173,7 @@ index 7af1a25..d3dc684 100644 hard_LC_TIME = hard_locale (LC_TIME); #endif -@@ -4393,6 +5037,29 @@ main (int argc, char **argv) +@@ -4391,6 +5035,29 @@ main (int argc, char **argv) thousands_sep = NON_CHAR; } @@ -4053,7 +3203,7 @@ index 7af1a25..d3dc684 100644 have_read_stdin = false; inittables (); -@@ -4663,13 +5330,34 @@ main (int argc, char **argv) +@@ -4661,13 +5328,34 @@ main (int argc, char **argv) case 't': { @@ -4086,13 +3236,13 @@ index 7af1a25..d3dc684 100644 +#endif + if (newtab_length == 1 && optarg[1]) { - if (STREQ (optarg, "\\0")) + if (streq (optarg, "\\0")) - newtab = '\0'; + newtab[0] = '\0'; else { /* Provoke with 'sort -txx'. Complain about -@@ -4680,9 +5368,11 @@ main (int argc, char **argv) +@@ -4678,9 +5366,11 @@ main (int argc, char **argv) quote (optarg)); } } @@ -4549,10 +3699,10 @@ index 0000000..26c95de + +Exit $fail diff --git a/tests/local.mk b/tests/local.mk -index b68df41..0fe8193 100644 +index 4aa199a..c553c81 100644 --- a/tests/local.mk +++ b/tests/local.mk -@@ -391,6 +391,8 @@ all_tests = \ +@@ -404,6 +404,8 @@ all_tests = \ tests/sort/sort-field-limit.sh \ tests/sort/sort-files0-from.pl \ tests/sort/sort-float.sh \ @@ -4561,7 +3711,7 @@ index b68df41..0fe8193 100644 tests/sort/sort-h-thousands-sep.sh \ tests/sort/sort-merge.pl \ tests/sort/sort-merge-fdlimit.sh \ -@@ -596,6 +598,7 @@ all_tests = \ +@@ -609,6 +611,7 @@ all_tests = \ tests/du/threshold.sh \ tests/du/trailing-slash.sh \ tests/du/two-args.sh \ @@ -4569,7 +3719,7 @@ index b68df41..0fe8193 100644 tests/id/gnu-zero-uids.sh \ tests/id/no-context.sh \ tests/id/context.sh \ -@@ -752,6 +755,7 @@ all_tests = \ +@@ -765,6 +768,7 @@ all_tests = \ tests/touch/read-only.sh \ tests/touch/relative.sh \ tests/touch/trailing-slash.sh \ @@ -4644,76 +3794,6 @@ index 4b07210..68b9ea1 100755 my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE}; -diff --git a/tests/misc/fold.pl b/tests/misc/fold.pl -index 877322e..ba889c8 100755 ---- a/tests/misc/fold.pl -+++ b/tests/misc/fold.pl -@@ -20,9 +20,17 @@ use strict; - - (my $program_name = $0) =~ s|.*/||; - -+my $prog = 'fold'; -+my $try = "Try \`$prog --help' for more information.\n"; -+my $inval = "$prog: invalid byte, character or field list\n$try"; -+ - # Turn off localization of executable's output. - @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; --my $prog = 'fold'; -+ -+# uncommented to enable multibyte paths -+my $mb_locale = $ENV{LOCALE_FR_UTF8}; -+! defined $mb_locale || $mb_locale eq 'none' -+ and $mb_locale = 'C'; - - my @Tests = - ( -@@ -44,6 +52,46 @@ my @Tests = - {OUT=>"123456\n7890\nabcdef\nghij\n123456\n7890"}], - ); - -+# Add _POSIX2_VERSION=199209 to the environment of each test -+# that uses an old-style option like +1. -+if ($mb_locale ne 'C') -+ { -+ # Duplicate each test vector, appending "-mb" to the test name and -+ # inserting {ENV => "LC_ALL=$mb_locale"} in the copy, so that we -+ # provide coverage for the distro-added multi-byte code paths. -+ my @new; -+ foreach my $t (@Tests) -+ { -+ my @new_t = @$t; -+ my $test_name = shift @new_t; -+ -+ # Depending on whether fold is multi-byte-patched, -+ # it emits different diagnostics: -+ # non-MB: invalid byte or field list -+ # MB: invalid byte, character or field list -+ # Adjust the expected error output accordingly. -+ if (grep {ref $_ eq 'HASH' && exists $_->{ERR} && $_->{ERR} eq $inval} -+ (@new_t)) -+ { -+ my $sub = {ERR_SUBST => 's/, character//'}; -+ push @new_t, $sub; -+ push @$t, $sub; -+ } -+ push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}]; -+ } -+ push @Tests, @new; -+ } -+ -+@Tests = triple_test \@Tests; -+ -+# Remember that triple_test creates from each test with exactly one "IN" -+# file two more tests (.p and .r suffix on name) corresponding to reading -+# input from a file and from a pipe. The pipe-reading test would fail -+# due to a race condition about 1 in 20 times. -+# Remove the IN_PIPE version of the "output-is-input" test above. -+# The others aren't susceptible because they have three inputs each. -+@Tests = grep {$_->[0] ne 'output-is-input.p'} @Tests; -+ - my $save_temps = $ENV{DEBUG}; - my $verbose = $ENV{VERBOSE}; - diff --git a/tests/misc/sort-mb-tests.sh b/tests/misc/sort-mb-tests.sh new file mode 100644 index 0000000..11836ba @@ -4952,7 +4032,7 @@ index a3204d3..40942a5 100755 my $verbose = $ENV{VERBOSE}; diff --git a/tests/sort/sort.pl b/tests/sort/sort.pl -index 2ee92c4..96c7965 100755 +index 5fa9d52..a66952a 100755 --- a/tests/sort/sort.pl +++ b/tests/sort/sort.pl @@ -24,10 +24,15 @@ my $prog = 'sort'; @@ -4972,7 +4052,7 @@ index 2ee92c4..96c7965 100755 # Since each test is run with a file name and with redirected stdin, # the name in the diagnostic is either the file name or "-". # Normalize each diagnostic to use '-'. -@@ -423,6 +428,38 @@ foreach my $t (@Tests) +@@ -428,6 +433,38 @@ foreach my $t (@Tests) } } @@ -5011,7 +4091,7 @@ index 2ee92c4..96c7965 100755 @Tests = triple_test \@Tests; # Remember that triple_test creates from each test with exactly one "IN" -@@ -432,6 +469,7 @@ foreach my $t (@Tests) +@@ -437,6 +474,7 @@ foreach my $t (@Tests) # Remove the IN_PIPE version of the "output-is-input" test above. # The others aren't susceptible because they have three inputs each. @Tests = grep {$_->[0] ne 'output-is-input.p'} @Tests; @@ -5198,5 +4278,5 @@ index 0000000..8a82d74 +LC_ALL=C unexpand in in > out || fail=1 +compare exp out > /dev/null 2>&1 || fail=1 -- -2.50.0 +2.51.0 diff --git a/coreutils-python3.patch b/coreutils-python3.patch index e6ff471..447fdbc 100644 --- a/coreutils-python3.patch +++ b/coreutils-python3.patch @@ -1,4 +1,4 @@ -From f1a6e8d840a28eb2ab7a488e0d06450b7192c76d Mon Sep 17 00:00:00 2001 +From 8927d505ecb5334f09c48ef98ef1f464f581d0f7 Mon Sep 17 00:00:00 2001 From: rpm-build Date: Tue, 2 Apr 2024 14:11:26 +0100 Subject: [PATCH] coreutils-python3.patch @@ -10,10 +10,10 @@ Subject: [PATCH] coreutils-python3.patch 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/init.cfg b/init.cfg -index 612d287..9a6fa2d 100644 +index ac05f7b..26d9516 100644 --- a/init.cfg +++ b/init.cfg -@@ -597,10 +597,10 @@ seek_data_capable_() +@@ -601,10 +601,10 @@ seek_data_capable_() # Skip the current test if "." lacks d_type support. require_dirent_d_type_() { @@ -37,7 +37,7 @@ index 1a2f76f..42d3924 100644 # Intended to exit 0 only on Linux/GNU systems. import os diff --git a/tests/du/move-dir-while-traversing.sh b/tests/du/move-dir-while-traversing.sh -index 1d0a359..bd03542 100755 +index adf482b..cf9214a 100755 --- a/tests/du/move-dir-while-traversing.sh +++ b/tests/du/move-dir-while-traversing.sh @@ -21,8 +21,8 @@ print_ver_ du @@ -61,5 +61,5 @@ index 1d0a359..bd03542 100755 import os,sys -- -2.48.1 +2.51.0 diff --git a/coreutils-selinux.patch b/coreutils-selinux.patch deleted file mode 100644 index 91bc5b5..0000000 --- a/coreutils-selinux.patch +++ /dev/null @@ -1,87 +0,0 @@ -From fc96cab095d704e8bf9934812dd8d6f87fbf4be4 Mon Sep 17 00:00:00 2001 -From: rpm-build -Date: Wed, 30 Aug 2023 17:19:58 +0200 -Subject: [PATCH] coreutils-selinux.patch - ---- - src/cp.c | 19 ++++++++++++++++++- - src/install.c | 12 +++++++++++- - 2 files changed, 29 insertions(+), 2 deletions(-) - -diff --git a/src/cp.c b/src/cp.c -index a0ec067..1169c6a 100644 ---- a/src/cp.c -+++ b/src/cp.c -@@ -996,7 +996,7 @@ main (int argc, char **argv) - selinux_enabled = (0 < is_selinux_enabled ()); - cp_option_init (&x); - -- while ((c = getopt_long (argc, argv, "abdfHilLnprst:uvxPRS:TZ", -+ while ((c = getopt_long (argc, argv, "abcdfHilLnprst:uvxPRS:TZ", - long_opts, nullptr)) - != -1) - { -@@ -1048,6 +1048,23 @@ main (int argc, char **argv) - copy_contents = true; - break; - -+ case 'c': -+ fprintf (stderr, "%s: warning: option '-c' is deprecated," -+ " please use '--preserve=context' instead\n", argv[0]); -+ if (x.set_security_context) -+ { -+ fprintf (stderr, -+ "%s: cannot force target context and preserve it\n", -+ argv[0]); -+ exit (1); -+ } -+ else if (selinux_enabled) -+ { -+ x.preserve_security_context = true; -+ x.require_preserve_context = true; -+ } -+ break; -+ - case 'd': - x.preserve_links = true; - x.dereference = DEREF_NEVER; -diff --git a/src/install.c b/src/install.c -index b3b26ab..2d2f072 100644 ---- a/src/install.c -+++ b/src/install.c -@@ -807,7 +807,7 @@ main (int argc, char **argv) - dir_arg = false; - umask (0); - -- while ((optc = getopt_long (argc, argv, "bcCsDdg:m:o:pt:TvS:Z", long_options, -+ while ((optc = getopt_long (argc, argv, "bcCsDdg:m:o:pPt:TvS:Z", long_options, - nullptr)) - != -1) - { -@@ -872,6 +872,9 @@ main (int argc, char **argv) - no_target_directory = true; - break; - -+ case 'P': -+ fprintf (stderr, "%s: warning: option '-P' is deprecated," -+ " please use '--preserve-context' instead\n", argv[0]); - case PRESERVE_CONTEXT_OPTION: - if (! selinux_enabled) - { -@@ -879,6 +882,13 @@ main (int argc, char **argv) - "this kernel is not SELinux-enabled")); - break; - } -+ if (x.set_security_context) -+ { -+ fprintf (stderr, -+ "%s: cannot force target context and preserve it\n", -+ argv[0]); -+ exit (1); -+ } - x.preserve_security_context = true; - use_default_selinux_context = false; - break; --- -2.48.1 - diff --git a/coreutils.spec b/coreutils.spec index 17e98b3..a82d750 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils -Version: 9.7 -Release: 5%{?dist} +Version: 9.8 +Release: 1%{?dist} # some used parts of gnulib are under various variants of LGPL License: GPL-3.0-or-later AND GFDL-1.3-no-invariants-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later Url: https://www.gnu.org/software/coreutils/ @@ -32,29 +32,9 @@ Patch103: coreutils-python3.patch # df --direct Patch104: coreutils-df-direct.patch -# cp/mv: do not fail when copying of trivial NFSv4 ACLs fails (rhbz#2363149) -# https://git.savannah.gnu.org/cgit/gnulib.git/patch?id=8a356b77717a2e4f735ec06e326880ca1f61aadb -# https://git.savannah.gnu.org/cgit/gnulib.git/patch?id=955360a66c99bdd9ac3688519a8b521b06958fd3 -Patch105: coreutils-9.6-cp-improve-nfsv4-acl-support.patch - -# sort: fix buffer under-read (CVE-2025-5278) -# https://cgit.git.savannah.gnu.org/cgit/coreutils.git/patch/?id=8c9602e3a145e9596dc1a63c6ed67865814b6633 -Patch106: coreutils-CVE-2025-5278.patch - -# stty: add support for arbitrary baud rates (rhbz#2375439) -# https://cgit.git.savannah.gnu.org/cgit/coreutils.git/patch/?id=357fda90d15fd3f7dba61e1ab322b183a48d0081 -# https://cgit.git.savannah.gnu.org/cgit/coreutils.git/patch/?id=efaec8078142996d958b6720b85a13b12497c3d0 -# https://cgit.git.savannah.gnu.org/cgit/coreutils.git/patch/?id=b7db7757831e93ca44ae59e1921bc4ebbc87974f -# https://cgit.git.savannah.gnu.org/cgit/coreutils.git/patch/?id=8b05eca972f70858749a946ac24f08d0718c1be6 -# https://cgit.git.savannah.gnu.org/cgit/coreutils.git/patch/?id=3d35b3c0e56bd556c90dc98c3e5e2e7289b0eb0d -Patch107: coreutils-9.7-stty-arbitrary-baud-rates.patch - # (sb) lin18nux/lsb compliance - multibyte functionality patch Patch800: coreutils-i18n.patch -# downstream SELinux options deprecated since 2009 -Patch950: coreutils-selinux.patch - Conflicts: filesystem < 3 # To avoid clobbering installs @@ -295,6 +275,10 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Wed Sep 24 2025 Lukáš Zaoral - 9.8-1 +- rebase to latest upstream release (rhbz#2397467) +- remove downstream patch for selinux options deprecated since 2009 + * Wed Jul 23 2025 Fedora Release Engineering - 9.7-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild diff --git a/sources b/sources index 0e9a66d..d1677b5 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (coreutils-9.7.tar.xz) = fe81e6ba4fb492095153d5baac1eca8f07ece0957849de746a2a858cf007893cc2ded595a31a5e5d43d13216cc44b9d74a3245d9f23221ecc8cd00f428f27414 -SHA512 (coreutils-9.7.tar.xz.sig) = 48d86a19cee3c153f01f7478847f4621685c02e59942540bb20b30e314df05230817b87d0e73acd953e79fab35718e5bea57f25fe511a2c275a85ced4b317bae +SHA512 (coreutils-9.8.tar.xz.sig) = 0fa9ab4404cd2157584797de22a1f28ec4e0353dae05a7476198dc77e23bf59aaeb1aabf9f7dc22f5d80df311e6ef1490add75ae1663b4091e58cc29db4dcfa3 +SHA512 (coreutils-9.8.tar.xz) = 7b6c420907f0e33e4aff3dd92270f8cbd3e94b2ae8cf7caa2d5d1cfd5e9958319904a6547127abd55ee63aae0316f5b1228586b2da34ea402da032e925a25e53 From 0095d94d91e464de7116672697c0766e15f611de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= Date: Thu, 25 Sep 2025 10:23:54 +0200 Subject: [PATCH 11/15] tail: fix tailing larger number of lines in regular files Resolves: rhbz#2398008 --- coreutils-i18n.patch | 12 +-- ...v9.8-tail-n-broken-for-regular-files.patch | 83 +++++++++++++++++++ coreutils.spec | 9 +- 3 files changed, 97 insertions(+), 7 deletions(-) create mode 100644 coreutils-v9.8-tail-n-broken-for-regular-files.patch diff --git a/coreutils-i18n.patch b/coreutils-i18n.patch index 92167bd..1fd522a 100644 --- a/coreutils-i18n.patch +++ b/coreutils-i18n.patch @@ -1,4 +1,4 @@ -From c5b102c8d9ddf1cc1109858615de3a9d6d57b7e6 Mon Sep 17 00:00:00 2001 +From d4945b936d0bbea48db45de5e6284cc333e68034 Mon Sep 17 00:00:00 2001 From: rpm-build Date: Wed, 30 Aug 2023 17:19:58 +0200 Subject: [PATCH] coreutils-i18n.patch @@ -39,7 +39,7 @@ Subject: [PATCH] coreutils-i18n.patch create mode 100644 tests/unexpand/mb.sh diff --git a/bootstrap.conf b/bootstrap.conf -index b8feef9..ab1eb93 100644 +index b8feef9..24a264d 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -169,6 +169,8 @@ gnulib_modules=" @@ -3699,10 +3699,10 @@ index 0000000..26c95de + +Exit $fail diff --git a/tests/local.mk b/tests/local.mk -index 4aa199a..c553c81 100644 +index c1e251b..a7654e8 100644 --- a/tests/local.mk +++ b/tests/local.mk -@@ -404,6 +404,8 @@ all_tests = \ +@@ -405,6 +405,8 @@ all_tests = \ tests/sort/sort-field-limit.sh \ tests/sort/sort-files0-from.pl \ tests/sort/sort-float.sh \ @@ -3711,7 +3711,7 @@ index 4aa199a..c553c81 100644 tests/sort/sort-h-thousands-sep.sh \ tests/sort/sort-merge.pl \ tests/sort/sort-merge-fdlimit.sh \ -@@ -609,6 +611,7 @@ all_tests = \ +@@ -610,6 +612,7 @@ all_tests = \ tests/du/threshold.sh \ tests/du/trailing-slash.sh \ tests/du/two-args.sh \ @@ -3719,7 +3719,7 @@ index 4aa199a..c553c81 100644 tests/id/gnu-zero-uids.sh \ tests/id/no-context.sh \ tests/id/context.sh \ -@@ -765,6 +768,7 @@ all_tests = \ +@@ -766,6 +769,7 @@ all_tests = \ tests/touch/read-only.sh \ tests/touch/relative.sh \ tests/touch/trailing-slash.sh \ diff --git a/coreutils-v9.8-tail-n-broken-for-regular-files.patch b/coreutils-v9.8-tail-n-broken-for-regular-files.patch new file mode 100644 index 0000000..2ce3f2e --- /dev/null +++ b/coreutils-v9.8-tail-n-broken-for-regular-files.patch @@ -0,0 +1,83 @@ +From f9249475026ef5eb18156e8ca6fc2cf3ab61d493 Mon Sep 17 00:00:00 2001 +From: Hannes Braun +Date: Wed, 24 Sep 2025 21:20:49 +0200 +Subject: [PATCH] tail: fix tailing larger number of lines in regular files + +* src/tail.c (file_lines): Seek to the previous block instead of the +beginning (or a little before) of the block that was just scanned. +Otherwise, the same block is read and scanned (at least partially) +again. This bug was introduced by commit v9.7-219-g976f8abc1. +* tests/tail/basic-seek.sh: Add a new test. +* tests/local.mk: Reference the new test. +* NEWS: mention the bug fix. + +(cherry-picked from commit 914972e80dbf82aac9ffe3ff1f67f1028e1a788b) +--- + src/tail.c | 2 +- + tests/local.mk | 1 + + tests/tail/basic-seek.sh | 28 ++++++++++++++++++++++++++++ + 3 files changed, 30 insertions(+), 1 deletion(-) + create mode 100755 tests/tail/basic-seek.sh + +diff --git a/src/tail.c b/src/tail.c +index b8bef1d..c7779c7 100644 +--- a/src/tail.c ++++ b/src/tail.c +@@ -596,7 +596,7 @@ file_lines (char const *prettyname, int fd, struct stat const *sb, + goto free_buffer; + } + +- pos = xlseek (fd, -bufsize, SEEK_CUR, prettyname); ++ pos = xlseek (fd, -(bufsize + bytes_read), SEEK_CUR, prettyname); + bytes_read = read (fd, buffer, bufsize); + if (bytes_read < 0) + { +diff --git a/tests/local.mk b/tests/local.mk +index 4aa199a..c1e251b 100644 +--- a/tests/local.mk ++++ b/tests/local.mk +@@ -179,6 +179,7 @@ all_tests = \ + tests/tty/tty-eof.pl \ + tests/misc/read-errors.sh \ + tests/misc/write-errors.sh \ ++ tests/tail/basic-seek.sh \ + tests/tail/inotify-hash-abuse.sh \ + tests/tail/inotify-hash-abuse2.sh \ + tests/tail/F-vs-missing.sh \ +diff --git a/tests/tail/basic-seek.sh b/tests/tail/basic-seek.sh +new file mode 100755 +index 0000000..307ed66 +--- /dev/null ++++ b/tests/tail/basic-seek.sh +@@ -0,0 +1,28 @@ ++#!/bin/sh ++# Verify that tail works when seeking within a file ++ ++# Copyright (C) 2025 Free Software Foundation, Inc. ++ ++# This program is free software: you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation, either version 3 of the License, or ++# (at your option) any later version. ++ ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++ ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src ++print_ver_ tail ++ ++yes '=================================' | ++ head -n1K > file.in || framework_failure_ ++ ++# This returned 139 in coreutils v9.8 ++test $(tail -n200 file.in | wc -l) = 200 || fail=1 ++ ++Exit $fail +-- +2.51.0 + diff --git a/coreutils.spec b/coreutils.spec index a82d750..f8de1d5 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 9.8 -Release: 1%{?dist} +Release: 2%{?dist} # some used parts of gnulib are under various variants of LGPL License: GPL-3.0-or-later AND GFDL-1.3-no-invariants-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later Url: https://www.gnu.org/software/coreutils/ @@ -32,6 +32,10 @@ Patch103: coreutils-python3.patch # df --direct Patch104: coreutils-df-direct.patch +# tail: fix tailing larger number of lines in regular files (rhbz#2398008) +# https://github.com/coreutils/coreutils/commit/914972e80dbf82aac9ffe3ff1f67f1028e1a788b +Patch105: coreutils-v9.8-tail-n-broken-for-regular-files.patch + # (sb) lin18nux/lsb compliance - multibyte functionality patch Patch800: coreutils-i18n.patch @@ -275,6 +279,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Thu Sep 25 2025 Lukáš Zaoral - 9.8-2 +- tail: fix tailing larger number of lines in regular files (rhbz#2398008) + * Wed Sep 24 2025 Lukáš Zaoral - 9.8-1 - rebase to latest upstream release (rhbz#2397467) - remove downstream patch for selinux options deprecated since 2009 From 0615d97b816fef35a8d2626b20545d9bd48f427b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= Date: Mon, 29 Sep 2025 12:14:21 +0200 Subject: [PATCH 12/15] require gnulib-l10n for translations of gnulib messages Resolves: rhbz#2393892 --- coreutils.spec | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/coreutils.spec b/coreutils.spec index f8de1d5..7e7ce12 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 9.8 -Release: 2%{?dist} +Release: 3%{?dist} # some used parts of gnulib are under various variants of LGPL License: GPL-3.0-or-later AND GFDL-1.3-no-invariants-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later Url: https://www.gnu.org/software/coreutils/ @@ -121,6 +121,9 @@ packaged as a single multicall binary. # https://bugzilla.redhat.com/show_bug.cgi?id=1107973#c7 Obsoletes: %{name} < 8.24-100 +# Gnulib translations are maintained seprately since coreutils 9.6 (#2393892) +Requires: gnulib-l10n + # info doc refers to "Specifying the Time Zone" from glibc-doc (#959597) Suggests: glibc-doc @@ -279,6 +282,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Mon Sep 29 2025 Lukáš Zaoral - 9.8-3 +- require gnulib-l10n for translations of gnulib messages (rhbz#2393892) + * Thu Sep 25 2025 Lukáš Zaoral - 9.8-2 - tail: fix tailing larger number of lines in regular files (rhbz#2398008) From 370c5aa4ee4bfa13f60db48576a674b84261a2d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= Date: Mon, 29 Sep 2025 13:44:38 +0200 Subject: [PATCH 13/15] require gnulib-l10n for translations of gnulib messages Resolves: rhbz#2393892 --- coreutils.spec | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/coreutils.spec b/coreutils.spec index 47c546e..9d0aec8 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 9.6 -Release: 5%{?dist} +Release: 6%{?dist} # some used parts of gnulib are under various variants of LGPL License: GPL-3.0-or-later AND GFDL-1.3-no-invariants-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later Url: https://www.gnu.org/software/coreutils/ @@ -142,6 +142,9 @@ packaged as a single multicall binary. # https://bugzilla.redhat.com/show_bug.cgi?id=1107973#c7 Obsoletes: %{name} < 8.24-100 +# Gnulib translations are maintained seprately since coreutils 9.6 (#2393892) +Requires: gnulib-l10n + # info doc refers to "Specifying the Time Zone" from glibc-doc (#959597) Suggests: glibc-doc @@ -300,6 +303,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Mon Sep 29 2025 Lukáš Zaoral - 9.6-6 +- require gnulib-l10n for translations of gnulib messages (rhbz#2393892) + * Tue Jul 08 2025 Lukáš Zaoral - 9.6-5 - ls: fix crash on systems with SELinux but without xattr support (rhbz#2376721) From eb04a0fe336b24ee60d1c9478d5856ac21d792fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= Date: Wed, 26 Nov 2025 14:54:16 +0100 Subject: [PATCH 14/15] rebase to latest upstream release Resolves: rhbz#2413803 --- coreutils-9.9-gnulib-c23.patch | 169 ++++++++++++++++++ coreutils-df-direct.patch | 10 +- coreutils-i18n.patch | 149 +++++++-------- ...v9.8-tail-n-broken-for-regular-files.patch | 83 --------- coreutils.spec | 15 +- sources | 4 +- 6 files changed, 260 insertions(+), 170 deletions(-) create mode 100644 coreutils-9.9-gnulib-c23.patch delete mode 100644 coreutils-v9.8-tail-n-broken-for-regular-files.patch diff --git a/coreutils-9.9-gnulib-c23.patch b/coreutils-9.9-gnulib-c23.patch new file mode 100644 index 0000000..82e3899 --- /dev/null +++ b/coreutils-9.9-gnulib-c23.patch @@ -0,0 +1,169 @@ +From 891761bca1aa78336e5b18c121075b6e4696c5d4 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Sun, 23 Nov 2025 00:50:40 -0800 +Subject: [PATCH] Port to C23 qualifier-generic fns like strchr +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This ports Gnulib to strict C23 platforms that reject code +like ‘char *q = strchr (P, 'x');’ when P is a pointer to const, +because in C23 strchr is a qualifier-generic function so +strchr (P, 'x') returns char const *. +This patch does not attempt to do the following two things, +which might be useful in the future: +1. When compiling on non-C23 platforms, check user code for +portability to platforms that define qualifier-generic functions. +2. Port Gnulib to platforms that have qualifier-generic functions +not listed in the C23 standard, e.g., strchrnul. I don’t know +of any such platforms. +* lib/mbschr.c (mbschr): +* lib/memchr2.c (memchr2): +Port to C23, where functions like strchr are qualifier-generic. +* lib/c++defs.h (_GL_FUNCDECL_SYS_NAME): New macro. +* lib/c++defs.h (_GL_FUNCDECL_SYS): +* lib/stdlib.in.h (bsearch): +Use it, to prevent C23 names like strchr from acting like macros. +* lib/string.in.h (memchr, strchr, strpbrk, strrchr): +Do not #undef when GNULIB_POSIXCHECK is defined, as this could +cause conforming C23 code to fail to conform. It’s not clear why +_GL_WARN_ON_USE_CXX; perhaps it was needed but isn’t any more? +But for now, limit the removal of #undef to these four functions +where #undeffing is clearly undesirable in C23. +* lib/wchar.in.h (wmemchr): Parenthesize function name in decl, +to prevent it from acting like a macro. + +Cherry-picked-by: Lukáš Zaoral +Upstream-commit: df17f4f37ed3ca373d23ad42eae51122bdb96626 +--- + lib/c++defs.h | 12 +++++++++++- + lib/mbschr.c | 2 +- + lib/memchr2.c | 2 +- + lib/stdlib.in.h | 6 +++--- + lib/string.in.h | 4 ---- + lib/wchar.in.h | 2 +- + 6 files changed, 17 insertions(+), 11 deletions(-) + +diff --git a/lib/c++defs.h b/lib/c++defs.h +index b77979a..7384457 100644 +--- a/lib/c++defs.h ++++ b/lib/c++defs.h +@@ -127,6 +127,16 @@ + #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters,...) \ + _GL_EXTERN_C_FUNC __VA_ARGS__ rettype rpl_func parameters + ++/* _GL_FUNCDECL_SYS_NAME (func) expands to plain func if C++, and to ++ parenthsized func otherwise. Parenthesization is needed in C23 if ++ the function is like strchr and so is a qualifier-generic macro ++ that expands to something more complicated. */ ++#ifdef __cplusplus ++# define _GL_FUNCDECL_SYS_NAME(func) func ++#else ++# define _GL_FUNCDECL_SYS_NAME(func) (func) ++#endif ++ + /* _GL_FUNCDECL_SYS (func, rettype, parameters, [attributes]); + declares the system function, named func, with the given prototype, + consisting of return type, parameters, and attributes. +@@ -139,7 +149,7 @@ + _GL_FUNCDECL_SYS (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD); + */ + #define _GL_FUNCDECL_SYS(func,rettype,parameters,...) \ +- _GL_EXTERN_C_FUNC __VA_ARGS__ rettype func parameters ++ _GL_EXTERN_C_FUNC __VA_ARGS__ rettype _GL_FUNCDECL_SYS_NAME (func) parameters + + /* _GL_CXXALIAS_RPL (func, rettype, parameters); + declares a C++ alias called GNULIB_NAMESPACE::func +diff --git a/lib/mbschr.c b/lib/mbschr.c +index c9e14b5..6582134 100644 +--- a/lib/mbschr.c ++++ b/lib/mbschr.c +@@ -65,5 +65,5 @@ mbschr (const char *string, int c) + return NULL; + } + else +- return strchr (string, c); ++ return (char *) strchr (string, c); + } +diff --git a/lib/memchr2.c b/lib/memchr2.c +index 7493823..d7724ae 100644 +--- a/lib/memchr2.c ++++ b/lib/memchr2.c +@@ -55,7 +55,7 @@ memchr2 (void const *s, int c1_in, int c2_in, size_t n) + c2 = (unsigned char) c2_in; + + if (c1 == c2) +- return memchr (s, c1, n); ++ return (void *) memchr (s, c1, n); + + /* Handle the first few bytes by reading one byte at a time. + Do this until VOID_PTR is aligned on a longword boundary. */ +diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h +index bef0aaa..fd0e1e0 100644 +--- a/lib/stdlib.in.h ++++ b/lib/stdlib.in.h +@@ -224,9 +224,9 @@ _GL_INLINE_HEADER_BEGIN + + /* Declarations for ISO C N3322. */ + #if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__ +-_GL_EXTERN_C void *bsearch (const void *__key, +- const void *__base, size_t __nmemb, size_t __size, +- int (*__compare) (const void *, const void *)) ++_GL_EXTERN_C void *_GL_FUNCDECL_SYS_NAME (bsearch) ++ (const void *__key, const void *__base, size_t __nmemb, size_t __size, ++ int (*__compare) (const void *, const void *)) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3) _GL_ARG_NONNULL ((5)); + _GL_EXTERN_C void qsort (void *__base, size_t __nmemb, size_t __size, + int (*__compare) (const void *, const void *)) +diff --git a/lib/string.in.h b/lib/string.in.h +index fdcdd21..8b56acf 100644 +--- a/lib/string.in.h ++++ b/lib/string.in.h +@@ -409,7 +409,6 @@ _GL_CXXALIASWARN1 (memchr, void const *, + _GL_CXXALIASWARN (memchr); + # endif + #elif defined GNULIB_POSIXCHECK +-# undef memchr + /* Assume memchr is always declared. */ + _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " + "use gnulib module memchr for portability" ); +@@ -674,7 +673,6 @@ _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - " + #if defined GNULIB_POSIXCHECK + /* strchr() does not work with multibyte strings if the locale encoding is + GB18030 and the character to be searched is a digit. */ +-# undef strchr + /* Assume strchr is always declared. */ + _GL_WARN_ON_USE_CXX (strchr, + const char *, char *, (const char *, int), +@@ -981,7 +979,6 @@ _GL_CXXALIASWARN (strpbrk); + Even in this simple case, it does not work with multibyte strings if the + locale encoding is GB18030 and one of the characters to be searched is a + digit. */ +-# undef strpbrk + _GL_WARN_ON_USE_CXX (strpbrk, + const char *, char *, (const char *, const char *), + "strpbrk cannot work correctly on character strings " +@@ -1011,7 +1008,6 @@ _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings " + #if defined GNULIB_POSIXCHECK + /* strrchr() does not work with multibyte strings if the locale encoding is + GB18030 and the character to be searched is a digit. */ +-# undef strrchr + /* Assume strrchr is always declared. */ + _GL_WARN_ON_USE_CXX (strrchr, + const char *, char *, (const char *, int), +diff --git a/lib/wchar.in.h b/lib/wchar.in.h +index ab602a2..6be4515 100644 +--- a/lib/wchar.in.h ++++ b/lib/wchar.in.h +@@ -301,7 +301,7 @@ _GL_EXTERN_C int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3); + # ifndef __cplusplus +-_GL_EXTERN_C wchar_t *wmemchr (const wchar_t *__s, wchar_t __wc, size_t __n) ++_GL_EXTERN_C wchar_t *(wmemchr) (const wchar_t *__s, wchar_t __wc, size_t __n) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3); + # endif + _GL_EXTERN_C wchar_t *wmemset (wchar_t *__s, wchar_t __wc, size_t __n) +-- +2.52.0 + diff --git a/coreutils-df-direct.patch b/coreutils-df-direct.patch index 2deacf7..341ee2c 100644 --- a/coreutils-df-direct.patch +++ b/coreutils-df-direct.patch @@ -1,4 +1,4 @@ -From ae768935e696a23e336601c5a239e147628ecf05 Mon Sep 17 00:00:00 2001 +From 91be1a584108a6a3d96f64382bbf206c4213b3db Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Mon, 29 Mar 2010 17:20:34 +0000 Subject: [PATCH] coreutils-df-direct.patch @@ -11,10 +11,10 @@ Subject: [PATCH] coreutils-df-direct.patch create mode 100755 tests/df/direct.sh diff --git a/doc/coreutils.texi b/doc/coreutils.texi -index 937d8af..11fa1d6 100644 +index b420606..0ccb368 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi -@@ -12588,6 +12588,13 @@ some systems (notably Solaris), doing this yields more up to date results, +@@ -12597,6 +12597,13 @@ some systems (notably Solaris), doing this yields more up to date results, but in general this option makes @command{df} much slower, especially when there are many or very busy file systems. @@ -29,7 +29,7 @@ index 937d8af..11fa1d6 100644 @opindex --total @cindex grand total of file system size, usage and available space diff --git a/src/df.c b/src/df.c -index 857f76c..07b21ea 100644 +index 75e638c..ef9f0a7 100644 --- a/src/df.c +++ b/src/df.c @@ -121,6 +121,9 @@ static bool print_type; @@ -183,5 +183,5 @@ index 0000000..8e4cfb8 + +Exit $fail -- -2.51.0 +2.52.0 diff --git a/coreutils-i18n.patch b/coreutils-i18n.patch index 1fd522a..83579e9 100644 --- a/coreutils-i18n.patch +++ b/coreutils-i18n.patch @@ -1,4 +1,4 @@ -From d4945b936d0bbea48db45de5e6284cc333e68034 Mon Sep 17 00:00:00 2001 +From a81b096084524e9aeef5e8b81fc829eb9efec581 Mon Sep 17 00:00:00 2001 From: rpm-build Date: Wed, 30 Aug 2023 17:19:58 +0200 Subject: [PATCH] coreutils-i18n.patch @@ -16,7 +16,7 @@ Subject: [PATCH] coreutils-i18n.patch src/expand.c | 90 +++- src/local.mk | 4 +- src/pr.c | 443 ++++++++++++++++++-- - src/sort.c | 790 +++++++++++++++++++++++++++++++++--- + src/sort.c | 791 +++++++++++++++++++++++++++++++++--- src/unexpand.c | 101 ++++- tests/Coreutils.pm | 3 + tests/expand/mb.sh | 183 +++++++++ @@ -29,7 +29,7 @@ Subject: [PATCH] coreutils-i18n.patch tests/sort/sort-merge.pl | 42 ++ tests/sort/sort.pl | 40 +- tests/unexpand/mb.sh | 172 ++++++++ - 25 files changed, 2878 insertions(+), 167 deletions(-) + 25 files changed, 2879 insertions(+), 167 deletions(-) create mode 100644 lib/mbfile.c create mode 100644 lib/mbfile.h create mode 100644 m4/mbfile.m4 @@ -39,20 +39,20 @@ Subject: [PATCH] coreutils-i18n.patch create mode 100644 tests/unexpand/mb.sh diff --git a/bootstrap.conf b/bootstrap.conf -index b8feef9..24a264d 100644 +index ec68ac8..ec2fbbe 100644 --- a/bootstrap.conf +++ b/bootstrap.conf -@@ -169,6 +169,8 @@ gnulib_modules=" - maintainer-makefile +@@ -171,6 +171,8 @@ gnulib_modules=" malloc-gnu manywarnings + mbbuf + mbchar + mbfile mbrlen mbrtoc32 mbrtowc diff --git a/configure.ac b/configure.ac -index 274eff4..5a1cfa5 100644 +index 5e99ef3..ac07577 100644 --- a/configure.ac +++ b/configure.ac @@ -465,6 +465,12 @@ fi @@ -1092,7 +1092,7 @@ index f0effb9..36479d6 100644 if (have_read_stdin && fclose (stdin) == EOF) diff --git a/src/expand-common.c b/src/expand-common.c -index ca2ad4d..2ad24bf 100644 +index 14dd804..0d8eaaa 100644 --- a/src/expand-common.c +++ b/src/expand-common.c @@ -19,6 +19,7 @@ @@ -1103,7 +1103,7 @@ index ca2ad4d..2ad24bf 100644 #include "system.h" #include "c-ctype.h" #include "fadvise.h" -@@ -123,6 +124,119 @@ set_increment_size (colno tabval) +@@ -132,6 +133,119 @@ set_increment_size (colno tabval) return ok; } @@ -1402,10 +1402,10 @@ index 5ec7ce9..65ac315 100644 } diff --git a/src/local.mk b/src/local.mk -index 8f6d9a5..da16e59 100644 +index a8ad6b4..b0e61ec 100644 --- a/src/local.mk +++ b/src/local.mk -@@ -479,8 +479,8 @@ src_base32_CPPFLAGS = -DBASE_TYPE=32 $(AM_CPPFLAGS) +@@ -490,8 +490,8 @@ src_base32_CPPFLAGS = -DBASE_TYPE=32 $(AM_CPPFLAGS) src_basenc_SOURCES = src/basenc.c src_basenc_CPPFLAGS = -DBASE_TYPE=42 $(AM_CPPFLAGS) @@ -1415,9 +1415,9 @@ index 8f6d9a5..da16e59 100644 +src_unexpand_SOURCES = src/unexpand.c src/expand-common.c lib/mbfile.c lib/mbchar.c src_wc_SOURCES = src/wc.c - if USE_AVX2_WC_LINECOUNT + if USE_AVX512_WC_LINECOUNT diff --git a/src/pr.c b/src/pr.c -index 87974d0..999bae7 100644 +index 10b8c52..079c86c 100644 --- a/src/pr.c +++ b/src/pr.c @@ -312,6 +312,24 @@ @@ -1764,7 +1764,7 @@ index 87974d0..999bae7 100644 h_next = h + chars_per_column; } } -@@ -1748,9 +1872,9 @@ static void +@@ -1751,9 +1875,9 @@ static void align_column (COLUMN *p) { padding_not_printed = p->start_position; @@ -1776,7 +1776,7 @@ index 87974d0..999bae7 100644 padding_not_printed = ANYWHERE; } -@@ -2024,13 +2148,13 @@ store_char (char c) +@@ -2030,13 +2154,13 @@ store_char (char c) /* May be too generous. */ buff = xpalloc (buff, &buff_allocated, 1, -1, sizeof *buff); } @@ -1792,7 +1792,7 @@ index 87974d0..999bae7 100644 char *s; int num_width; -@@ -2047,22 +2171,24 @@ add_line_number (COLUMN *p) +@@ -2053,22 +2177,24 @@ add_line_number (COLUMN *p) /* Tabification is assumed for multiple columns, also for n-separators, but 'default n-separator = TAB' hasn't been given priority over equal column_width also specified by POSIX. */ @@ -1821,7 +1821,7 @@ index 87974d0..999bae7 100644 output_position = POS_AFTER_TAB (chars_per_output_tab, output_position); } -@@ -2221,7 +2347,7 @@ print_white_space (void) +@@ -2227,7 +2353,7 @@ print_white_space (void) while (goal - h_old > 1 && (h_new = POS_AFTER_TAB (chars_per_output_tab, h_old)) <= goal) { @@ -1830,7 +1830,7 @@ index 87974d0..999bae7 100644 h_old = h_new; } while (++h_old <= goal) -@@ -2241,6 +2367,7 @@ print_sep_string (void) +@@ -2247,6 +2373,7 @@ print_sep_string (void) { char const *s = col_sep_string; int l = col_sep_length; @@ -1838,7 +1838,7 @@ index 87974d0..999bae7 100644 if (separators_not_printed <= 0) { -@@ -2252,6 +2379,7 @@ print_sep_string (void) +@@ -2258,6 +2385,7 @@ print_sep_string (void) { for (; separators_not_printed > 0; --separators_not_printed) { @@ -1846,7 +1846,7 @@ index 87974d0..999bae7 100644 while (l-- > 0) { /* 3 types of sep_strings: spaces only, spaces and chars, -@@ -2265,12 +2393,15 @@ print_sep_string (void) +@@ -2271,12 +2399,15 @@ print_sep_string (void) } else { @@ -1863,7 +1863,7 @@ index 87974d0..999bae7 100644 /* sep_string ends with some spaces */ if (spaces_not_printed > 0) print_white_space (); -@@ -2298,7 +2429,7 @@ print_clump (COLUMN *p, int n, char *clump) +@@ -2307,7 +2438,7 @@ print_clump (COLUMN *p, int n, char *clump) required number of tabs and spaces. */ static void @@ -1872,7 +1872,7 @@ index 87974d0..999bae7 100644 { if (tabify_output) { -@@ -2322,6 +2453,74 @@ print_char (char c) +@@ -2331,6 +2462,74 @@ print_char (char c) putchar (c); } @@ -1947,7 +1947,7 @@ index 87974d0..999bae7 100644 /* Skip to page PAGE before printing. PAGE may be larger than total number of pages. */ -@@ -2498,9 +2697,9 @@ read_line (COLUMN *p) +@@ -2507,9 +2706,9 @@ read_line (COLUMN *p) align_empty_cols = false; } @@ -1959,7 +1959,7 @@ index 87974d0..999bae7 100644 padding_not_printed = ANYWHERE; } -@@ -2569,7 +2768,7 @@ print_stored (COLUMN *p) +@@ -2578,7 +2777,7 @@ print_stored (COLUMN *p) COLUMN *q; int line = p->current_line++; @@ -1968,7 +1968,7 @@ index 87974d0..999bae7 100644 /* FIXME UMR: Uninitialized memory read: * This is occurring while in: -@@ -2581,7 +2780,7 @@ print_stored (COLUMN *p) +@@ -2590,7 +2789,7 @@ print_stored (COLUMN *p) xmalloc [xmalloc.c:94] init_store_cols [pr.c:1648] */ @@ -1977,7 +1977,7 @@ index 87974d0..999bae7 100644 pad_vertically = true; -@@ -2601,9 +2800,9 @@ print_stored (COLUMN *p) +@@ -2610,9 +2809,9 @@ print_stored (COLUMN *p) } } @@ -1989,7 +1989,7 @@ index 87974d0..999bae7 100644 padding_not_printed = ANYWHERE; } -@@ -2616,8 +2815,8 @@ print_stored (COLUMN *p) +@@ -2625,8 +2824,8 @@ print_stored (COLUMN *p) if (spaces_not_printed == 0) { output_position = p->start_position + end_vector[line]; @@ -2000,7 +2000,7 @@ index 87974d0..999bae7 100644 } return true; -@@ -2636,7 +2835,7 @@ print_stored (COLUMN *p) +@@ -2645,7 +2844,7 @@ print_stored (COLUMN *p) number of characters is 1.) */ static int @@ -2009,7 +2009,7 @@ index 87974d0..999bae7 100644 { unsigned char uc = c; char *s = clump_buff; -@@ -2646,10 +2845,10 @@ char_to_clump (char c) +@@ -2655,10 +2854,10 @@ char_to_clump (char c) int chars; int chars_per_c = 8; @@ -2022,7 +2022,7 @@ index 87974d0..999bae7 100644 { width = TAB_WIDTH (chars_per_c, input_position); -@@ -2730,6 +2929,164 @@ char_to_clump (char c) +@@ -2739,6 +2938,164 @@ char_to_clump (char c) return chars; } @@ -2188,13 +2188,14 @@ index 87974d0..999bae7 100644 looking for more options and printing the next batch of files. diff --git a/src/sort.c b/src/sort.c -index 5a6a963..0b1b941 100644 +index 05d00cc..eb51f20 100644 --- a/src/sort.c +++ b/src/sort.c -@@ -29,6 +29,14 @@ - #include +@@ -30,6 +30,15 @@ #include #include + #include ++ +#if HAVE_WCHAR_H +# include +#endif @@ -2206,7 +2207,7 @@ index 5a6a963..0b1b941 100644 #include "system.h" #include "argmatch.h" #include "assure.h" -@@ -158,14 +166,39 @@ static int thousands_sep; +@@ -160,14 +169,39 @@ static int thousands_sep; /* We currently ignore multi-byte grouping chars. */ static bool thousands_sep_ignored; @@ -2247,7 +2248,7 @@ index 5a6a963..0b1b941 100644 /* The kind of blanks for '-b' to skip in various options. */ enum blanktype { bl_start, bl_end, bl_both }; -@@ -342,13 +375,11 @@ static bool stable; +@@ -344,13 +378,11 @@ static bool stable; /* An int value outside char range. */ enum { NON_CHAR = CHAR_MAX + 1 }; @@ -2264,9 +2265,9 @@ index 5a6a963..0b1b941 100644 /* Flag to remove consecutive duplicate lines from the output. Only the last of a sequence of equal lines will be output. */ -@@ -806,6 +837,46 @@ reap_all (void) - reap (-1); - } +@@ -386,6 +418,46 @@ struct tempnode + static struct tempnode *volatile temphead; + static struct tempnode *volatile *temptail = &temphead; +/* Function pointers. */ +static void @@ -2311,7 +2312,7 @@ index 5a6a963..0b1b941 100644 /* Clean up any remaining temporary files. */ static void -@@ -1273,7 +1344,7 @@ zaptemp (char const *name) +@@ -1343,7 +1415,7 @@ zaptemp (char const *name) free (node); } @@ -2320,7 +2321,7 @@ index 5a6a963..0b1b941 100644 static int struct_month_cmp (void const *m1, void const *m2) -@@ -1288,7 +1359,7 @@ struct_month_cmp (void const *m1, void const *m2) +@@ -1358,7 +1430,7 @@ struct_month_cmp (void const *m1, void const *m2) /* Initialize the character class tables. */ static void @@ -2329,7 +2330,7 @@ index 5a6a963..0b1b941 100644 { size_t i; -@@ -1300,7 +1371,7 @@ inittables (void) +@@ -1370,7 +1442,7 @@ inittables (void) fold_toupper[i] = toupper (i); } @@ -2338,7 +2339,7 @@ index 5a6a963..0b1b941 100644 /* If we're not in the "C" locale, read different names for months. */ if (hard_LC_TIME) { -@@ -1380,6 +1451,84 @@ specify_nmerge (int oi, char c, char const *s) +@@ -1450,6 +1522,84 @@ specify_nmerge (int oi, char c, char const *s) xstrtol_fatal (e, oi, c, long_options, s); } @@ -2423,7 +2424,7 @@ index 5a6a963..0b1b941 100644 /* Specify the amount of main memory to use when sorting. */ static void specify_sort_size (int oi, char c, char const *s) -@@ -1611,7 +1760,7 @@ buffer_linelim (struct buffer const *buf) +@@ -1676,7 +1826,7 @@ buffer_linelim (struct buffer const *buf) by KEY in LINE. */ static char * @@ -2432,7 +2433,7 @@ index 5a6a963..0b1b941 100644 { char *ptr = line->text, *lim = ptr + line->length - 1; size_t sword = key->sword; -@@ -1620,10 +1769,10 @@ begfield (struct line const *line, struct keyfield const *key) +@@ -1685,10 +1835,10 @@ begfield (struct line const *line, struct keyfield const *key) /* The leading field separator itself is included in a field when -t is absent. */ @@ -2445,7 +2446,7 @@ index 5a6a963..0b1b941 100644 ++ptr; if (ptr < lim) ++ptr; -@@ -1653,12 +1802,71 @@ begfield (struct line const *line, struct keyfield const *key) +@@ -1718,12 +1868,71 @@ begfield (struct line const *line, struct keyfield const *key) return ptr; } @@ -2518,7 +2519,7 @@ index 5a6a963..0b1b941 100644 { char *ptr = line->text, *lim = ptr + line->length - 1; size_t eword = key->eword, echar = key->echar; -@@ -1673,10 +1881,10 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1738,10 +1947,10 @@ limfield (struct line const *line, struct keyfield const *key) 'beginning' is the first character following the delimiting TAB. Otherwise, leave PTR pointing at the first 'blank' character after the preceding field. */ @@ -2531,7 +2532,7 @@ index 5a6a963..0b1b941 100644 ++ptr; if (ptr < lim && (eword || echar)) ++ptr; -@@ -1722,10 +1930,10 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1787,10 +1996,10 @@ limfield (struct line const *line, struct keyfield const *key) */ /* Make LIM point to the end of (one byte past) the current field. */ @@ -2544,7 +2545,7 @@ index 5a6a963..0b1b941 100644 if (newlim) lim = newlim; } -@@ -1760,6 +1968,130 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1825,6 +2034,130 @@ limfield (struct line const *line, struct keyfield const *key) return ptr; } @@ -2675,7 +2676,7 @@ index 5a6a963..0b1b941 100644 /* Fill BUF reading from FP, moving buf->left bytes from the end of buf->buf to the beginning first. If EOF is reached and the file wasn't terminated by a newline, supply one. Set up BUF's line -@@ -1846,8 +2178,22 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file) +@@ -1911,8 +2244,22 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file) else { if (key->skipsblanks) @@ -2700,7 +2701,7 @@ index 5a6a963..0b1b941 100644 line->keybeg = line_start; } } -@@ -1985,12 +2331,10 @@ find_unit_order (char const *number) +@@ -2050,12 +2397,10 @@ find_unit_order (char const *number) ATTRIBUTE_PURE static int @@ -2716,7 +2717,7 @@ index 5a6a963..0b1b941 100644 int diff = find_unit_order (a) - find_unit_order (b); return (diff ? diff : strnumcmp (a, b, decimal_point, thousands_sep)); -@@ -2002,7 +2346,7 @@ human_numcompare (char const *a, char const *b) +@@ -2067,7 +2412,7 @@ human_numcompare (char const *a, char const *b) ATTRIBUTE_PURE static int @@ -2725,7 +2726,7 @@ index 5a6a963..0b1b941 100644 { while (blanks[to_uchar (*a)]) a++; -@@ -2012,6 +2356,25 @@ numcompare (char const *a, char const *b) +@@ -2077,6 +2422,25 @@ numcompare (char const *a, char const *b) return strnumcmp (a, b, decimal_point, thousands_sep); } @@ -2751,7 +2752,7 @@ index 5a6a963..0b1b941 100644 static int nan_compare (long double a, long double b) { -@@ -2053,7 +2416,7 @@ general_numcompare (char const *sa, char const *sb) +@@ -2118,7 +2482,7 @@ general_numcompare (char const *sa, char const *sb) Return 0 if the name in S is not recognized. */ static int @@ -2760,7 +2761,7 @@ index 5a6a963..0b1b941 100644 { size_t lo = 0; size_t hi = MONTHS_PER_YEAR; -@@ -2392,15 +2755,14 @@ debug_key (struct line const *line, struct keyfield const *key) +@@ -2457,15 +2821,14 @@ debug_key (struct line const *line, struct keyfield const *key) char saved = *lim; *lim = '\0'; @@ -2778,7 +2779,7 @@ index 5a6a963..0b1b941 100644 else if (key->general_numeric) ignore_value (strtold (beg, &tighter_lim)); else if (key->numeric || key->human_numeric) -@@ -2546,7 +2908,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2611,7 +2974,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) /* Warn about significant leading blanks. */ bool implicit_skip = key_numeric (key) || key->month; bool line_offset = key->eword == 0 && key->echar != 0; /* -k1.x,1.y */ @@ -2787,7 +2788,7 @@ index 5a6a963..0b1b941 100644 && ((!key->skipsblanks && !implicit_skip) || (!key->skipsblanks && key->schar) || (!key->skipeblanks && key->echar))) -@@ -2594,9 +2956,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2659,9 +3022,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) bool number_locale_warned = false; if (basic_numeric_field_span) { @@ -2800,7 +2801,7 @@ index 5a6a963..0b1b941 100644 { error (0, 0, _("field separator %s is treated as a " -@@ -2607,9 +2969,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2672,9 +3035,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) } if (basic_numeric_field_span || general_numeric_field_span) { @@ -2813,7 +2814,7 @@ index 5a6a963..0b1b941 100644 { error (0, 0, _("field separator %s is treated as a " -@@ -2617,19 +2979,19 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2682,19 +3045,19 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) quote (((char []) {decimal_point, 0}))); number_locale_warned = true; } @@ -2837,7 +2838,7 @@ index 5a6a963..0b1b941 100644 } } -@@ -2681,11 +3043,87 @@ diff_reversed (int diff, bool reversed) +@@ -2746,11 +3109,87 @@ diff_reversed (int diff, bool reversed) return reversed ? _GL_CMP (0, diff) : diff; } @@ -2926,7 +2927,7 @@ index 5a6a963..0b1b941 100644 { struct keyfield *key = keylist; -@@ -2766,7 +3204,7 @@ keycompare (struct line const *a, struct line const *b) +@@ -2831,7 +3270,7 @@ keycompare (struct line const *a, struct line const *b) else if (key->human_numeric) diff = human_numcompare (ta, tb); else if (key->month) @@ -2935,7 +2936,7 @@ index 5a6a963..0b1b941 100644 else if (key->random) diff = compare_random (ta, tlena, tb, tlenb); else if (key->version) -@@ -2876,6 +3314,211 @@ keycompare (struct line const *a, struct line const *b) +@@ -2941,6 +3380,211 @@ keycompare (struct line const *a, struct line const *b) return diff_reversed (diff, key->reverse); } @@ -3147,7 +3148,7 @@ index 5a6a963..0b1b941 100644 /* Compare two lines A and B, returning negative, zero, or positive depending on whether A compares less than, equal to, or greater than B. */ -@@ -2903,7 +3546,7 @@ compare (struct line const *a, struct line const *b) +@@ -2968,7 +3612,7 @@ compare (struct line const *a, struct line const *b) diff = - NONZERO (blen); else if (blen == 0) diff = 1; @@ -3156,7 +3157,7 @@ index 5a6a963..0b1b941 100644 { /* xmemcoll0 is a performance enhancement as it will not unconditionally write '\0' after the -@@ -4289,6 +4932,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype) +@@ -4340,6 +4984,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype) break; case 'f': key->translate = fold_toupper; @@ -3164,7 +3165,7 @@ index 5a6a963..0b1b941 100644 break; case 'g': key->general_numeric = true; -@@ -4368,7 +5012,7 @@ main (int argc, char **argv) +@@ -4419,7 +5064,7 @@ main (int argc, char **argv) initialize_exit_failure (SORT_FAILURE); hard_LC_COLLATE = hard_locale (LC_COLLATE); @@ -3173,7 +3174,7 @@ index 5a6a963..0b1b941 100644 hard_LC_TIME = hard_locale (LC_TIME); #endif -@@ -4391,6 +5035,29 @@ main (int argc, char **argv) +@@ -4442,6 +5087,29 @@ main (int argc, char **argv) thousands_sep = NON_CHAR; } @@ -3203,7 +3204,7 @@ index 5a6a963..0b1b941 100644 have_read_stdin = false; inittables (); -@@ -4661,13 +5328,34 @@ main (int argc, char **argv) +@@ -4717,13 +5385,34 @@ main (int argc, char **argv) case 't': { @@ -3242,7 +3243,7 @@ index 5a6a963..0b1b941 100644 else { /* Provoke with 'sort -txx'. Complain about -@@ -4678,9 +5366,11 @@ main (int argc, char **argv) +@@ -4734,9 +5423,11 @@ main (int argc, char **argv) quote (optarg)); } } @@ -3699,10 +3700,10 @@ index 0000000..26c95de + +Exit $fail diff --git a/tests/local.mk b/tests/local.mk -index c1e251b..a7654e8 100644 +index 53fc53e..0148422 100644 --- a/tests/local.mk +++ b/tests/local.mk -@@ -405,6 +405,8 @@ all_tests = \ +@@ -412,6 +412,8 @@ all_tests = \ tests/sort/sort-field-limit.sh \ tests/sort/sort-files0-from.pl \ tests/sort/sort-float.sh \ @@ -3711,7 +3712,7 @@ index c1e251b..a7654e8 100644 tests/sort/sort-h-thousands-sep.sh \ tests/sort/sort-merge.pl \ tests/sort/sort-merge-fdlimit.sh \ -@@ -610,6 +612,7 @@ all_tests = \ +@@ -618,6 +620,7 @@ all_tests = \ tests/du/threshold.sh \ tests/du/trailing-slash.sh \ tests/du/two-args.sh \ @@ -3719,7 +3720,7 @@ index c1e251b..a7654e8 100644 tests/id/gnu-zero-uids.sh \ tests/id/no-context.sh \ tests/id/context.sh \ -@@ -766,6 +769,7 @@ all_tests = \ +@@ -774,6 +777,7 @@ all_tests = \ tests/touch/read-only.sh \ tests/touch/relative.sh \ tests/touch/trailing-slash.sh \ @@ -3846,7 +3847,7 @@ index 0000000..11836ba + +Exit $fail diff --git a/tests/misc/unexpand.pl b/tests/misc/unexpand.pl -index 27d9c17..4976335 100755 +index bb7469c..c1dec95 100755 --- a/tests/misc/unexpand.pl +++ b/tests/misc/unexpand.pl @@ -27,6 +27,14 @@ my $limits = getlimits (); @@ -3864,7 +3865,7 @@ index 27d9c17..4976335 100755 my @Tests = ( ['a1', {IN=> ' 'x 1 ."y\n"}, {OUT=> ' 'x 1 ."y\n"}], -@@ -128,6 +136,37 @@ my @Tests = +@@ -132,6 +140,37 @@ my @Tests = ['ts2', '-t5,8', {IN=>"x\t \t y\n"}, {OUT=>"x\t\t y\n"}], ); @@ -4278,5 +4279,5 @@ index 0000000..8a82d74 +LC_ALL=C unexpand in in > out || fail=1 +compare exp out > /dev/null 2>&1 || fail=1 -- -2.51.0 +2.52.0 diff --git a/coreutils-v9.8-tail-n-broken-for-regular-files.patch b/coreutils-v9.8-tail-n-broken-for-regular-files.patch deleted file mode 100644 index 2ce3f2e..0000000 --- a/coreutils-v9.8-tail-n-broken-for-regular-files.patch +++ /dev/null @@ -1,83 +0,0 @@ -From f9249475026ef5eb18156e8ca6fc2cf3ab61d493 Mon Sep 17 00:00:00 2001 -From: Hannes Braun -Date: Wed, 24 Sep 2025 21:20:49 +0200 -Subject: [PATCH] tail: fix tailing larger number of lines in regular files - -* src/tail.c (file_lines): Seek to the previous block instead of the -beginning (or a little before) of the block that was just scanned. -Otherwise, the same block is read and scanned (at least partially) -again. This bug was introduced by commit v9.7-219-g976f8abc1. -* tests/tail/basic-seek.sh: Add a new test. -* tests/local.mk: Reference the new test. -* NEWS: mention the bug fix. - -(cherry-picked from commit 914972e80dbf82aac9ffe3ff1f67f1028e1a788b) ---- - src/tail.c | 2 +- - tests/local.mk | 1 + - tests/tail/basic-seek.sh | 28 ++++++++++++++++++++++++++++ - 3 files changed, 30 insertions(+), 1 deletion(-) - create mode 100755 tests/tail/basic-seek.sh - -diff --git a/src/tail.c b/src/tail.c -index b8bef1d..c7779c7 100644 ---- a/src/tail.c -+++ b/src/tail.c -@@ -596,7 +596,7 @@ file_lines (char const *prettyname, int fd, struct stat const *sb, - goto free_buffer; - } - -- pos = xlseek (fd, -bufsize, SEEK_CUR, prettyname); -+ pos = xlseek (fd, -(bufsize + bytes_read), SEEK_CUR, prettyname); - bytes_read = read (fd, buffer, bufsize); - if (bytes_read < 0) - { -diff --git a/tests/local.mk b/tests/local.mk -index 4aa199a..c1e251b 100644 ---- a/tests/local.mk -+++ b/tests/local.mk -@@ -179,6 +179,7 @@ all_tests = \ - tests/tty/tty-eof.pl \ - tests/misc/read-errors.sh \ - tests/misc/write-errors.sh \ -+ tests/tail/basic-seek.sh \ - tests/tail/inotify-hash-abuse.sh \ - tests/tail/inotify-hash-abuse2.sh \ - tests/tail/F-vs-missing.sh \ -diff --git a/tests/tail/basic-seek.sh b/tests/tail/basic-seek.sh -new file mode 100755 -index 0000000..307ed66 ---- /dev/null -+++ b/tests/tail/basic-seek.sh -@@ -0,0 +1,28 @@ -+#!/bin/sh -+# Verify that tail works when seeking within a file -+ -+# Copyright (C) 2025 Free Software Foundation, Inc. -+ -+# This program is free software: you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation, either version 3 of the License, or -+# (at your option) any later version. -+ -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+ -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src -+print_ver_ tail -+ -+yes '=================================' | -+ head -n1K > file.in || framework_failure_ -+ -+# This returned 139 in coreutils v9.8 -+test $(tail -n200 file.in | wc -l) = 200 || fail=1 -+ -+Exit $fail --- -2.51.0 - diff --git a/coreutils.spec b/coreutils.spec index 7e7ce12..13a7c9d 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils -Version: 9.8 -Release: 3%{?dist} +Version: 9.9 +Release: 1%{?dist} # some used parts of gnulib are under various variants of LGPL License: GPL-3.0-or-later AND GFDL-1.3-no-invariants-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later Url: https://www.gnu.org/software/coreutils/ @@ -32,9 +32,9 @@ Patch103: coreutils-python3.patch # df --direct Patch104: coreutils-df-direct.patch -# tail: fix tailing larger number of lines in regular files (rhbz#2398008) -# https://github.com/coreutils/coreutils/commit/914972e80dbf82aac9ffe3ff1f67f1028e1a788b -Patch105: coreutils-v9.8-tail-n-broken-for-regular-files.patch +# gnulib C23 support +# https://github.com/coreutils/gnulib/commit/df17f4f37ed3ca373d23ad42eae51122bdb96626 +Patch105: coreutils-9.9-gnulib-c23.patch # (sb) lin18nux/lsb compliance - multibyte functionality patch Patch800: coreutils-i18n.patch @@ -160,7 +160,7 @@ find tests -name '*.sh' -perm 0644 -print -exec chmod 0755 '{}' '+' # FIXME: Force a newer gettext version to workaround `autoreconf -i` errors # with coreutils 9.6 and bundled gettext 0.19.2 from gettext-common-devel. -sed -i 's/0.19.2/0.22.5/' bootstrap.conf configure.ac +sed -i "s/0.19.2/$(rpm -q --queryformat '%%{VERSION}\n' gettext-devel)/" bootstrap.conf configure.ac autoreconf -fiv @@ -282,6 +282,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Wed Nov 26 2025 Lukáš Zaoral - 9.9-1 +- rebase to latest upstream release (rhbz#2413803) + * Mon Sep 29 2025 Lukáš Zaoral - 9.8-3 - require gnulib-l10n for translations of gnulib messages (rhbz#2393892) diff --git a/sources b/sources index d1677b5..0952ab1 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (coreutils-9.8.tar.xz.sig) = 0fa9ab4404cd2157584797de22a1f28ec4e0353dae05a7476198dc77e23bf59aaeb1aabf9f7dc22f5d80df311e6ef1490add75ae1663b4091e58cc29db4dcfa3 -SHA512 (coreutils-9.8.tar.xz) = 7b6c420907f0e33e4aff3dd92270f8cbd3e94b2ae8cf7caa2d5d1cfd5e9958319904a6547127abd55ee63aae0316f5b1228586b2da34ea402da032e925a25e53 +SHA512 (coreutils-9.9.tar.xz.sig) = 0a3dfdfa6b4234e2e1d42142269f959bdf3cf8f6605a50270a27eff84dd22588f182121f7dd3eeb04be45f5109d02690215065b3d3b43882874d0e165a1435d0 +SHA512 (coreutils-9.9.tar.xz) = e7b0e59f7732d2c098ea4934014f470248bd5c4764210e9200a698010a8e3b95bbb26e543f0cd73ed5a4b8e1f8cda932c73f39954d68175e4deaa47526610c65 From f674e5fc9ccd33d82c2c5477a124604a3b4d0fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= Date: Tue, 13 Jan 2026 16:19:08 +0100 Subject: [PATCH 15/15] fix cut test failure on aarch64 rawhide Resolves: rhbz#2424302 --- coreutils-9.9-fix-cut-test-aarch64.patch | 28 ++++++++++++++++++++++++ coreutils.spec | 9 +++++++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 coreutils-9.9-fix-cut-test-aarch64.patch diff --git a/coreutils-9.9-fix-cut-test-aarch64.patch b/coreutils-9.9-fix-cut-test-aarch64.patch new file mode 100644 index 0000000..600f87b --- /dev/null +++ b/coreutils-9.9-fix-cut-test-aarch64.patch @@ -0,0 +1,28 @@ +From 95044cb5eaea83d02f768feb5ab79fcf5e6ad782 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?P=C3=A1draig=20Brady?= +Date: Mon, 22 Dec 2025 17:12:48 +0000 +Subject: [PATCH] tests: avoid false failure due to ulimit on aarch64 + +* tests/cut/cut-huge-range.sh: Add an extra 1MiB headroom, +which was seen with aarch64. +Reported at https://bugzilla.redhat.com/2424302 + +Cherry-picked-by: Lukáš Zaoral +Upstream-commit: 95044cb5eaea83d02f768feb5ab79fcf5e6ad782 +--- + tests/cut/cut-huge-range.sh | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/tests/cut/cut-huge-range.sh b/tests/cut/cut-huge-range.sh +index 4bd1b129d8..98d7e8f0b9 100755 +--- a/tests/cut/cut-huge-range.sh ++++ b/tests/cut/cut-huge-range.sh +@@ -22,6 +22,7 @@ getlimits_ + + vm=$(get_min_ulimit_v_ returns_ 0 cut -b1 /dev/null) \ + || skip_ 'shell lacks ulimit, or ASAN enabled' ++vm=$(($vm+1000)) # https://bugzilla.redhat.com/2424302 + + # Ensure we can cut up to our sentinel value. + # Don't use expr to subtract one, + diff --git a/coreutils.spec b/coreutils.spec index 13a7c9d..6712263 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 9.9 -Release: 1%{?dist} +Release: 2%{?dist} # some used parts of gnulib are under various variants of LGPL License: GPL-3.0-or-later AND GFDL-1.3-no-invariants-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later Url: https://www.gnu.org/software/coreutils/ @@ -36,6 +36,10 @@ Patch104: coreutils-df-direct.patch # https://github.com/coreutils/gnulib/commit/df17f4f37ed3ca373d23ad42eae51122bdb96626 Patch105: coreutils-9.9-gnulib-c23.patch +# fix cut test failure on aarch64 rawhide (rhbz#2424302) +# https://github.com/coreutils/coreutils/commit/95044cb5eaea83d02f768feb5ab79fcf5e6ad782 +Patch106: coreutils-9.9-fix-cut-test-aarch64.patch + # (sb) lin18nux/lsb compliance - multibyte functionality patch Patch800: coreutils-i18n.patch @@ -282,6 +286,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Tue Jan 13 2026 Lukáš Zaoral - 9.9-2 +- fix cut test failure on aarch64 rawhide (rhbz#2424302) + * Wed Nov 26 2025 Lukáš Zaoral - 9.9-1 - rebase to latest upstream release (rhbz#2413803)