From nobody Tue Jul 26 21:13:34 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4LsqQQ6Knfz4XD7C; Tue, 26 Jul 2022 21:13:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LsqQQ5tzWz3SVZ; Tue, 26 Jul 2022 21:13:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658870014; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eA77sD0gkh4ZmFGq456K9XhCQoVCvmq6HnCnVKzwzW0=; b=Zrn6Z8BCy3QJg7DmXuavZxTZNngMPzefyrWVQeFEWmANfYQJjoYwXtUsDXG5fKmRw/6wZn 1WYk0f8WuUOSIF/2LHkXw5V0ccx16lxYnthoYj9EpsXa/4XwhBtu+GL/uODvP/tZu1hESI PNHPrjjloEdtKr+8iptpz4Zsdjt+QOMIflvdtq472swLNDZqzWelSC8DyihoQ0P02xBLuo tqXlig1HP6aRu4HppXDj4nTPfGOVIJBUZORMhvdWv6n+9UPbUCuU49XeMjKbOEyozEsx0H wKAD2LsfFhys+BNZoN1wRFSzkmKFBmMKYUjDXQ/vmq8RxkDWYlZly84cExyxwA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4LsqQQ4w2Rzrwp; Tue, 26 Jul 2022 21:13:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 26QLDYlo070970; Tue, 26 Jul 2022 21:13:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26QLDY0M070969; Tue, 26 Jul 2022 21:13:34 GMT (envelope-from git) Date: Tue, 26 Jul 2022 21:13:34 GMT Message-Id: <202207262113.26QLDY0M070969@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Stefan=20E=C3=9Fer?= Subject: git: 9f3aa538e307 - main - sbin/md5.c: fix -q -c for BSD style versions List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: se X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9f3aa538e307743b2b5048d38f87b7fd32d0c596 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658870014; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eA77sD0gkh4ZmFGq456K9XhCQoVCvmq6HnCnVKzwzW0=; b=XzNwRLidqpcnxb3eBGbOjqIlANyegVVx9ysZ6+k/nXX7VzgmSmkaYxAXcB2cQkmGOPYc8O yXmWWz7ZW9ce2ELV3q8xkeI0fKe10UJs8RYYSEL8nYNAWqff/gw7L5FvzRjnvYy4nV5g8Q 42VKyBygUAhZYDqr9YG7Al4MUzGsLkIhHDo27mXnqCzkfm5Fj5ZCSnaJgczzzzFJ/Ht16m Ej+eixuVQjBVWEVRX9Oo4F0vD8S2ceEXWo0LYTpib+W3TVmQa1HyUVMpM/RHQNVDNYXzWc dbheTfsVDl/TE2CKeLmH1I/heLBGujGeJN+lnrXl+0Ny3e/ifsVyhv3MRWHwlw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658870014; a=rsa-sha256; cv=none; b=aM1kekYqVH3plpmiBqnMhvhSJmazD/yGe+BY0Be57XJSk0R6maQbbWxLGcP1z2i88wz+dC 4s3yoQPePjxW5MgPGmNK/otGIrpOo1keSfJm81BXeA4Y4Y22kI/A7gfe5X19ndLpnY9po1 Vyow3h95hJmrpYqt03ol32cE8CmZDmnv9uEUnjilx2hn1xOR3kOQqGiBRmF2X7SzjgGCIb t+haT29L9JZFwV8rntnnZ3UQX8m8s/md0GK7DwRfAUyOWWsAninwGz+4Z88HvXBZ4o2CPT Es40OYkyL3dMrg2gB3iglpbcH1IKE8QsGpvuslam5r8E2l2wUc7iUevB3NS1zw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=9f3aa538e307743b2b5048d38f87b7fd32d0c596 commit 9f3aa538e307743b2b5048d38f87b7fd32d0c596 Author: Stefan Eßer AuthorDate: 2022-07-26 21:04:57 +0000 Commit: Stefan Eßer CommitDate: 2022-07-26 21:04:57 +0000 sbin/md5.c: fix -q -c for BSD style versions The BSD style commands (with names not ending in "sum") ignored the -c options and the passed digest value when invoked with -q. The man page stated that -q causes only the calculated digest to be printed, but did not consider the case of both the -q and -c being used in combination. Since there is no warning that -c will be ignored when the -q option is used, users night (and did) expect that the exit code would reflect the matching of the calculated digest and the argument passed with -c. This update implements and documents this expected behavior. PR: 265461 Reported by: Dmitrij MFC after: 2 weeks --- sbin/md5/md5.1 | 11 +++++++---- sbin/md5/md5.c | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sbin/md5/md5.1 b/sbin/md5/md5.1 index 899e49ba3517..a3db48596606 100644 --- a/sbin/md5/md5.1 +++ b/sbin/md5/md5.1 @@ -1,5 +1,5 @@ .\" $FreeBSD$ -.Dd Feb 5, 2022 +.Dd July 26, 2022 .Dt MD5 1 .Os .Sh NAME @@ -86,6 +86,9 @@ coreutils versions of these programs. If the program was called with a name that does not end in .Nm sum , compare the digest of the file against this string. +If combined with the +.Fl q +option, the calculated digest is printed in addition to the exit status being set. .Pq Note that this option is not yet useful if multiple files are specified. .It Fl c Ar file If the program was called with a name that does end in @@ -94,7 +97,7 @@ the file passed as argument must contain digest lines generated by the same digest algorithm with or without the .Fl r option -.Pq i.e. in either classical BSD format or in GNU coreutils format . +.Pq i.e., in either classical BSD format or in GNU coreutils format . A line with the file name followed by a colon .Dq ":" and either OK or FAILED is written for each well-formed line in the digest file. @@ -164,7 +167,7 @@ d80bf36c332dc0fdc479366ec3fa44cd /etc/rc.conf .Pd The .Nm -sum -variants put 2 blank characters between hash and file name for full compatibility +variants put 2 blank characters between hash and file name for full compatibility with the coreutils versions of these commands. .Ed .Pp @@ -207,7 +210,7 @@ $ md5 -c digest /boot/loader.conf The digest file may contain any number of lines in the format generated with or without the .Fl r option -.Pq i.e. in either classical BSD format or in GNU coreutils format . +.Pq i.e., in either classical BSD format or in GNU coreutils format . If a hash value does not match the file, FAILED is printed instead of OK. .Sh SEE ALSO .Xr cksum 1 , diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c index 7235e6e0a39f..97c587efd63c 100644 --- a/sbin/md5/md5.c +++ b/sbin/md5/md5.c @@ -436,6 +436,8 @@ MDOutput(const Algorithm_t *alg, char *p, char *argv[]) printf("%s: %s\n", *argv, checkfailed ? "FAILED" : "OK"); } else if (qflag || argv == NULL) { printf("%s\n", p); + if (cflag) + checkfailed = strcasecmp(checkAgainst, p) != 0; } else { if (rflag) if (gnu_emu)