Related: #2180056 - cksum: fix reporting of failed checks

This commit is contained in:
Kamil Dudka 2023-03-24 16:17:40 +01:00
parent 2c4d4b8151
commit 24c306d28d
2 changed files with 74 additions and 1 deletions

View File

@ -0,0 +1,67 @@
From b9fa05c7f08581b175d87b94fb751643dda53187 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Thu, 23 Mar 2023 12:31:24 +0000
Subject: [PATCH] cksum: fix reporting of failed checks
This applies to all checksumming utilities,
where we incorrectly report all subsequent files as checking 'OK'
once any file has passed a digest check.
The exit status was not impacted, only the printed status.
* src/digest.c (digest_check): Use the correct state variable
to determine if the _current_ file has passed or not.
* tests/misc/md5sum.pl: Add a test case.
Fixes https://bugs.gnu.org/62403
Upstream-commit: 76f2fb627118a26c25003dbd98c22c153b7ee1d2
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/digest.c | 4 ++--
tests/misc/md5sum.pl | 10 ++++++++++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/digest.c b/src/digest.c
index 6ee8a48..ab32968 100644
--- a/src/digest.c
+++ b/src/digest.c
@@ -1254,14 +1254,14 @@ digest_check (char const *checkfile_name)
if (!status_only)
{
- if ( ! matched_checksums || ! quiet)
+ if (! match || ! quiet)
{
if (needs_escape)
putchar ('\\');
print_filename (filename, needs_escape);
}
- if ( ! matched_checksums)
+ if (! match)
printf (": %s\n", _("FAILED"));
else if (!quiet)
printf (": %s\n", _("OK"));
diff --git a/tests/misc/md5sum.pl b/tests/misc/md5sum.pl
index 186aca9..d712664 100755
--- a/tests/misc/md5sum.pl
+++ b/tests/misc/md5sum.pl
@@ -101,6 +101,16 @@ my @Tests =
. "md5sum: WARNING: 1 line is improperly formatted\n"
. "md5sum: WARNING: 2 computed checksums did NOT match\n"},
{EXIT=> 1}],
+ # Ensure we use appropriate state to track failures (broken in 9.2)
+ ['check-multifail-state', '--check', '--warn',
+ {IN=>{'f.md5' =>
+ "$degenerate f\n"
+ . "$degenerate g\n"
+ . "$degenerate f\n" }},
+ {AUX=> {f=> ''}}, {AUX=> {g=> 'a'}},
+ {OUT=>"f: OK\ng: FAILED\nf: OK\n"},
+ {ERR=>"md5sum: WARNING: 1 computed checksum did NOT match\n"},
+ {EXIT=> 1}],
# The sha1sum and md5sum drivers share a lot of code.
# Ensure that md5sum does *not* share the part that makes
# sha1sum accept BSD format.
--
2.39.2

View File

@ -1,7 +1,7 @@
Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils
Version: 9.2
Release: 2%{?dist}
Release: 3%{?dist}
License: GPLv3+
Url: https://www.gnu.org/software/coreutils/
Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz
@ -14,6 +14,9 @@ Source51: coreutils-provides.inc
Source105: coreutils-colorls.sh
Source106: coreutils-colorls.csh
# cksum: fix reporting of failed checks (#2180056)
Patch1: coreutils-9.2-cksum-check.patch
# do not make coreutils-single depend on /usr/bin/coreutils
%global __requires_exclude ^%{_bindir}/coreutils$
@ -252,6 +255,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir
%license COPYING
%changelog
* Fri Mar 24 2023 Kamil Dudka <kdudka@redhat.com> - 9.2-3
- cksum: fix reporting of failed checks (#2180056)
* Wed Mar 22 2023 Kamil Dudka <kdudka@redhat.com> - 9.2-2
- coreutils-getgrouplist.patch: drop a patch no longer needed