rebase to latest upstream version

- sync i18n patch with SUSE (Kudos to Berny Völker!)
- add some test dependencies to execute additional part of the upstream test-suite
- enable LTO on ppc64le

Resolves: RHEL-39977
This commit is contained in:
Lukáš Zaoral 2024-07-04 13:34:05 +02:00
parent ffccc44673
commit 91fcc50078
No known key found for this signature in database
GPG Key ID: 39157506DD67752D
9 changed files with 650 additions and 1213 deletions

View File

@ -1,31 +0,0 @@
From c4c5ed8f4e9cd55a12966d4f520e3a13101637d9 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 16 Jan 2024 13:48:32 -0800
Subject: [PATCH] split: do not shrink hold buffer
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* src/split.c (line_bytes_split): Do not shrink hold buffer.
If its large for this batch its likely to be large for the next
batch, and for split its not worth the complexity/CPU hassle to
shrink it. Do not assume hold_size can be bufsize.
---
src/split.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/split.c b/src/split.c
index 64020c859..037960a59 100644
--- a/src/split.c
+++ b/src/split.c
@@ -809,10 +809,7 @@ line_bytes_split (intmax_t n_bytes, char *buf, idx_t bufsize)
{
cwrite (n_out == 0, hold, n_hold);
n_out += n_hold;
- if (n_hold > bufsize)
- hold = xirealloc (hold, bufsize);
n_hold = 0;
- hold_size = bufsize;
}
/* Output to eol if present. */

View File

@ -1,28 +0,0 @@
From 2616c6be1c244424617997151c67bcab2dacbcfe Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Thu, 31 Aug 2023 14:34:05 +0200
Subject: [PATCH] coreutils-9.4-systemd-coredump.patch
Cherry picked from gnulib upstream commits:
* 1e6a26f9312bb47e070f94b17b14dc1a6ffbb74f ("readutmp: fix core dump if --enable-systemd")
* 3af1d7b0ce3a8e3ae565e7cea10cee6fd7cb8109 ("readutmp: Fix memory leak introduced by last commit.")
---
lib/readutmp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/readutmp.c b/lib/readutmp.c
index 0173b7e..ec09feb 100644
--- a/lib/readutmp.c
+++ b/lib/readutmp.c
@@ -795,7 +795,7 @@ read_utmp_from_systemd (idx_t *n_entries, STRUCT_UTMP **utmp_buf, int options)
{
char **sessions;
int num_sessions = sd_get_sessions (&sessions);
- if (num_sessions >= 0)
+ if (num_sessions >= 0 && sessions != NULL)
{
char **session_ptr;
for (session_ptr = sessions; *session_ptr != NULL; session_ptr++)
--
2.41.0

View File

@ -1,205 +0,0 @@
From 73d119f4f8052a9fb6cef13cd9e75d5a4e23311a Mon Sep 17 00:00:00 2001
From: dann frazier <dann.frazier@canonical.com>
Date: Wed, 29 Nov 2023 18:32:34 -0700
Subject: [PATCH] tail: fix tailing sysfs files where PAGE_SIZE > BUFSIZ
* src/tail.c (file_lines): Ensure we use a buffer size >= PAGE_SIZE when
searching backwards to avoid seeking within a file,
which on sysfs files is accepted but also returns no data.
* tests/tail/tail-sysfs.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/67490
Upstream-commit: 73d119f4f8052a9fb6cef13cd9e75d5a4e23311a
Cherry-picked-by: Lukáš Zaoral <lzaoral@redhat.com>
---
src/tail.c | 57 +++++++++++++++++++++++++++++-----------
tests/local.mk | 1 +
tests/tail/tail-sysfs.sh | 34 ++++++++++++++++++++++++
3 files changed, 77 insertions(+), 15 deletions(-)
create mode 100755 tests/tail/tail-sysfs.sh
diff --git a/src/tail.c b/src/tail.c
index c45f3b65a..6979e0ba3 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -208,6 +208,9 @@ static int nbpids = 0;
that is writing to all followed files. */
static pid_t pid;
+/* Used to determine the buffer size when scanning backwards in a file. */
+static idx_t page_size;
+
/* True if we have ever read standard input. */
static bool have_read_stdin;
@@ -515,22 +518,40 @@ xlseek (int fd, off_t offset, int whence, char const *filename)
Return true if successful. */
static bool
-file_lines (char const *pretty_filename, int fd, uintmax_t n_lines,
- off_t start_pos, off_t end_pos, uintmax_t *read_pos)
+file_lines (char const *pretty_filename, int fd, struct stat const *sb,
+ uintmax_t n_lines, off_t start_pos, off_t end_pos,
+ uintmax_t *read_pos)
{
- char buffer[BUFSIZ];
+ char *buffer;
size_t bytes_read;
+ blksize_t bufsize = BUFSIZ;
off_t pos = end_pos;
+ bool ok = true;
if (n_lines == 0)
return true;
+ /* Be careful with files with sizes that are a multiple of the page size,
+ as on /proc or /sys file systems these files accept seeking to within
+ the file, but then return no data when read. So use a buffer that's
+ at least PAGE_SIZE to avoid seeking within such files.
+
+ We could also indirectly use a large enough buffer through io_blksize()
+ however this would be less efficient in the common case, as it would
+ generally pick a larger buffer size, resulting in reading more data
+ from the end of the file. */
+ affirm (S_ISREG (sb->st_mode));
+ if (sb->st_size % page_size == 0)
+ bufsize = MAX (BUFSIZ, page_size);
+
+ buffer = xmalloc (bufsize);
+
/* Set 'bytes_read' to the size of the last, probably partial, buffer;
- 0 < 'bytes_read' <= 'BUFSIZ'. */
- bytes_read = (pos - start_pos) % BUFSIZ;
+ 0 < 'bytes_read' <= 'bufsize'. */
+ bytes_read = (pos - start_pos) % bufsize;
if (bytes_read == 0)
- bytes_read = BUFSIZ;
- /* Make 'pos' a multiple of 'BUFSIZ' (0 if the file is short), so that all
+ bytes_read = bufsize;
+ /* Make 'pos' a multiple of 'bufsize' (0 if the file is short), so that all
reads will be on block boundaries, which might increase efficiency. */
pos -= bytes_read;
xlseek (fd, pos, SEEK_SET, pretty_filename);
@@ -538,7 +559,8 @@ file_lines (char const *pretty_filename, int fd, uintmax_t n_lines,
if (bytes_read == SAFE_READ_ERROR)
{
error (0, errno, _("error reading %s"), quoteaf (pretty_filename));
- return false;
+ ok = false;
+ goto free_buffer;
}
*read_pos = pos + bytes_read;
@@ -565,7 +587,7 @@ file_lines (char const *pretty_filename, int fd, uintmax_t n_lines,
xwrite_stdout (nl + 1, bytes_read - (n + 1));
*read_pos += dump_remainder (false, pretty_filename, fd,
end_pos - (pos + bytes_read));
- return true;
+ goto free_buffer;
}
}
@@ -577,23 +599,26 @@ file_lines (char const *pretty_filename, int fd, uintmax_t n_lines,
xlseek (fd, start_pos, SEEK_SET, pretty_filename);
*read_pos = start_pos + dump_remainder (false, pretty_filename, fd,
end_pos);
- return true;
+ goto free_buffer;
}
- pos -= BUFSIZ;
+ pos -= bufsize;
xlseek (fd, pos, SEEK_SET, pretty_filename);
- bytes_read = safe_read (fd, buffer, BUFSIZ);
+ bytes_read = safe_read (fd, buffer, bufsize);
if (bytes_read == SAFE_READ_ERROR)
{
error (0, errno, _("error reading %s"), quoteaf (pretty_filename));
- return false;
+ ok = false;
+ goto free_buffer;
}
*read_pos = pos + bytes_read;
}
while (bytes_read > 0);
- return true;
+free_buffer:
+ free (buffer);
+ return ok;
}
/* Print the last N_LINES lines from the end of the standard input,
@@ -1915,7 +1940,7 @@ tail_lines (char const *pretty_filename, int fd, uintmax_t n_lines,
{
*read_pos = end_pos;
if (end_pos != 0
- && ! file_lines (pretty_filename, fd, n_lines,
+ && ! file_lines (pretty_filename, fd, &stats, n_lines,
start_pos, end_pos, read_pos))
return false;
}
@@ -2337,6 +2362,8 @@ main (int argc, char **argv)
atexit (close_stdout);
+ page_size = getpagesize ();
+
have_read_stdin = false;
count_lines = true;
diff --git a/tests/local.mk b/tests/local.mk
index db4ee7ed8..bf03238c3 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -257,6 +257,7 @@ all_tests = \
tests/seq/seq-precision.sh \
tests/head/head.pl \
tests/head/head-elide-tail.pl \
+ tests/tail/tail-sysfs.sh \
tests/tail/tail-n0f.sh \
tests/ls/ls-misc.pl \
tests/date/date.pl \
diff --git a/tests/tail/tail-sysfs.sh b/tests/tail/tail-sysfs.sh
new file mode 100755
index 000000000..00874b3dc
--- /dev/null
+++ b/tests/tail/tail-sysfs.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+# sysfs files have weird properties that can be influenced by page size
+
+# Copyright 2023 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 <https://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ tail
+
+file='/sys/kernel/profiling'
+
+test -r "$file" || skip_ "No $file file"
+
+cp -f "$file" exp || framework_failure_
+
+tail -n1 "$file" > out || fail=1
+compare exp out || fail=1
+
+tail -c2 "$file" > out || fail=1
+compare exp out || fail=1
+
+Exit $fail

View File

@ -1,4 +1,4 @@
From 6e36198f10a2f63b89c89ebb5d5c185b20fb3a63 Mon Sep 17 00:00:00 2001
From f072852456c545bd89296bc88cf59ccd63287a68 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
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 5b9a597..6810c15 100644
index 8f7f43e..230f1f1 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -12074,6 +12074,13 @@ some systems (notably Solaris), doing this yields more up to date results,
@@ -12427,6 +12427,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 5b9a597..6810c15 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 48025b9..c8efa5b 100644
index 994f0e3..ceee209 100644
--- a/src/df.c
+++ b/src/df.c
@@ -125,6 +125,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 48025b9..c8efa5b 100644
/* Grand total data. */
static struct fs_usage grand_fsu;
@@ -252,13 +255,15 @@ enum
@@ -247,13 +250,15 @@ enum
NO_SYNC_OPTION = CHAR_MAX + 1,
SYNC_OPTION,
TOTAL_OPTION,
@ -59,7 +59,7 @@ index 48025b9..c8efa5b 100644
{"inodes", no_argument, nullptr, 'i'},
{"human-readable", no_argument, nullptr, 'h'},
{"si", no_argument, nullptr, 'H'},
@@ -583,7 +588,10 @@ get_header (void)
@@ -574,7 +579,10 @@ get_header (void)
for (col = 0; col < ncolumns; col++)
{
char *cell = nullptr;
@ -71,7 +71,7 @@ index 48025b9..c8efa5b 100644
if (columns[col]->field == SIZE_FIELD
&& (header_mode == DEFAULT_MODE
@@ -1486,6 +1494,17 @@ get_point (char const *point, const struct stat *statp)
@@ -1471,6 +1479,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 48025b9..c8efa5b 100644
if ((S_ISBLK (statp->st_mode) || S_ISCHR (statp->st_mode))
&& get_device (name))
return;
@@ -1556,6 +1575,7 @@ or all file systems by default.\n\
@@ -1541,6 +1560,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 48025b9..c8efa5b 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);
@@ -1646,6 +1666,9 @@ main (int argc, char **argv)
@@ -1631,6 +1651,9 @@ main (int argc, char **argv)
xstrtol_fatal (e, oi, c, long_options, optarg);
}
break;
@ -107,7 +107,7 @@ index 48025b9..c8efa5b 100644
case 'i':
if (header_mode == OUTPUT_MODE)
{
@@ -1742,6 +1765,13 @@ main (int argc, char **argv)
@@ -1727,6 +1750,13 @@ main (int argc, char **argv)
}
}
@ -183,5 +183,5 @@ index 0000000..8e4cfb8
+
+Exit $fail
--
2.31.1
2.44.0

File diff suppressed because it is too large Load Diff

65
coreutils-python3.patch Normal file
View File

@ -0,0 +1,65 @@
From cef9cccce395cd80cd5ac42a4fe6c3909be1c0b5 Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Tue, 2 Apr 2024 14:11:26 +0100
Subject: [PATCH] coreutils-python3.patch
---
init.cfg | 4 ++--
tests/d_type-check | 2 +-
tests/du/move-dir-while-traversing.sh | 6 +++---
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/init.cfg b/init.cfg
index b06965a..08413ee 100644
--- a/init.cfg
+++ b/init.cfg
@@ -581,10 +581,10 @@ seek_data_capable_()
# Skip the current test if "." lacks d_type support.
require_dirent_d_type_()
{
- python < /dev/null \
+ python3 < /dev/null \
|| skip_ python missing: assuming no d_type support
- python "$abs_srcdir"/tests/d_type-check \
+ python3 "$abs_srcdir"/tests/d_type-check \
|| skip_ requires d_type support
}
diff --git a/tests/d_type-check b/tests/d_type-check
index 1a2f76f..42d3924 100644
--- a/tests/d_type-check
+++ b/tests/d_type-check
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
# Exit 0 if "." and "./tempfile" have useful d_type information, else 1.
# 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 830a69e..7344ddf 100755
--- a/tests/du/move-dir-while-traversing.sh
+++ b/tests/du/move-dir-while-traversing.sh
@@ -21,8 +21,8 @@ print_ver_ du
require_trap_signame_
# We use a python-inotify script, so...
-python -m pyinotify -h > /dev/null \
- || skip_ 'python inotify package not installed'
+python3 -m pyinotify -h > /dev/null \
+ || skip_ 'python3 inotify package not installed'
# Move a directory "up" while du is processing its sub-directories.
# While du is processing a hierarchy .../B/C/D/... this script
@@ -33,7 +33,7 @@ python -m pyinotify -h > /dev/null \
# rename syscall before du finishes processing the subtree under D/.
cat <<'EOF' > inotify-watch-for-dir-access.py
-#!/usr/bin/env python
+#!/usr/bin/env python3
import pyinotify as pn
import os,sys
--
2.44.0

View File

@ -1,4 +1,4 @@
From 88ba186955add2b230c017749d5622f7a0d62177 Mon Sep 17 00:00:00 2001
From 78970c915b8556fcec4622e948a37dd8e34efe6d Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Wed, 30 Aug 2023 17:19:58 +0200
Subject: [PATCH] coreutils-selinux.patch
@ -9,10 +9,10 @@ Subject: [PATCH] coreutils-selinux.patch
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/cp.c b/src/cp.c
index 04a5cbe..7a364e5 100644
index 28b0217..897379f 100644
--- a/src/cp.c
+++ b/src/cp.c
@@ -989,7 +989,7 @@ main (int argc, char **argv)
@@ -997,7 +997,7 @@ main (int argc, char **argv)
selinux_enabled = (0 < is_selinux_enabled ());
cp_option_init (&x);
@ -21,7 +21,7 @@ index 04a5cbe..7a364e5 100644
long_opts, nullptr))
!= -1)
{
@@ -1041,6 +1041,23 @@ main (int argc, char **argv)
@@ -1049,6 +1049,23 @@ main (int argc, char **argv)
copy_contents = true;
break;
@ -46,7 +46,7 @@ index 04a5cbe..7a364e5 100644
x.preserve_links = true;
x.dereference = DEREF_NEVER;
diff --git a/src/install.c b/src/install.c
index 31a48f1..ce9fa2d 100644
index accd0fd..b686fe9 100644
--- a/src/install.c
+++ b/src/install.c
@@ -807,7 +807,7 @@ main (int argc, char **argv)
@ -83,5 +83,5 @@ index 31a48f1..ce9fa2d 100644
use_default_selinux_context = false;
break;
--
2.41.0
2.44.0

View File

@ -1,7 +1,7 @@
Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils
Version: 9.4
Release: 7%{?dist}
Version: 9.5
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/
@ -26,18 +26,12 @@ Patch101: coreutils-8.26-selinuxenable.patch
# downstream changes to default DIR_COLORS
Patch102: coreutils-8.32-DIR_COLORS.patch
# use python3 in tests
Patch103: coreutils-python3.patch
# df --direct
Patch104: coreutils-df-direct.patch
# fix crash with --enable-systemd
Patch105: coreutils-9.4-systemd-coredump.patch
# fix buffer overflow in split (CVE-2024-0684)
Patch106: coreutils-9.4-CVE-2024-0684.patch
# fix tail on kernels with 64k pagesize
Patch107: coreutils-9.4-tail-64k-pages.patch
# (sb) lin18nux/lsb compliance - multibyte functionality patch
Patch800: coreutils-i18n.patch
@ -70,13 +64,27 @@ BuildRequires: texinfo
BuildRequires: gnupg2
# test-only dependencies
BuildRequires: acl
BuildRequires: gdb
BuildRequires: perl-interpreter
BuildRequires: perl(FileHandle)
BuildRequires: python3
BuildRequires: tzdata
%ifarch %valgrind_arches
BuildRequires: valgrind
%endif
%if 0%{?fedora}
BuildRequires: perl(Expect)
BuildRequires: python3-inotify
%endif
%if 23 < 0%{?fedora} || 7 < 0%{?rhel}
# needed by i18n test-cases
BuildRequires: glibc-langpack-en
BuildRequires: glibc-langpack-fr
BuildRequires: glibc-langpack-ko
BuildRequires: glibc-langpack-sv
%endif
Requires: %{name}-common = %{version}-%{release}
@ -150,11 +158,6 @@ autoreconf -fiv
%build
export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -fpic"
# disable -flto on ppc64le to make test-float pass (#1789115)
%ifarch ppc64le
CFLAGS="$CFLAGS -fno-lto"
%endif
# Upstream suggests to build with -Dlint for static analyzers:
# https://lists.gnu.org/archive/html/coreutils/2018-06/msg00110.html
# ... and even for production binary RPMs:
@ -262,6 +265,12 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir
%license COPYING
%changelog
* Thu Jul 04 2024 Lukáš Zaoral <lzaoral@redhat.com> - 9.5-1
- rebase to latest upstream version
- sync i18n patch with SUSE (Kudos to Berny Völker!)
- add some test dependencies to execute additional part of the upstream test-suite
- enable LTO on ppc64le (RHEL-39977)
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 9.4-7
- Bump release for June 2024 mass rebuild

View File

@ -1,2 +1,2 @@
SHA512 (coreutils-9.4.tar.xz) = 7c55ee23b685a0462bbbd118b04d25278c902604a0dcf3bf4f8bf81faa0500dee5a7813cba6f586d676c98e520cafd420f16479619305e94ea6798d8437561f5
SHA512 (coreutils-9.4.tar.xz.sig) = 9674f783f592c4f3e5c708ff31426ac009bf132fd0005019571bf39c8a1627efb5351c6cecc7faecb1eff8fa2970318666593bffc0eda9c750159e174ef42524
SHA512 (coreutils-9.5.tar.xz) = 2ca0deac4dc10a80fd0c6fd131252e99d457fd03b7bd626a6bc74fe5a0529c0a3d48ce1f5da1d3b3a7a150a1ce44f0fbb6b68a6ac543dfd5baa3e71f5d65401c
SHA512 (coreutils-9.5.tar.xz.sig) = 029997e0f4ee64e561853cff7c8a124f58cc891598595b44c4a46f9813b4b71c9d677464bc8a26d294e9971832f4b87c23777fea4fac6e8e30f06ad93b9957d5