From nobody Thu Feb 09 20:17:34 2023 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 4PCSpR1MmQz3nZrC; Thu, 9 Feb 2023 20:17:35 +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 4PCSpR09Jbz3tnX; Thu, 9 Feb 2023 20:17:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675973855; 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=wSYvO8vixZydR8MdVQMrVGPDrjNxdsVPx5CZs7Q+pSw=; b=nHYX0I5c+9OktLa7Alvd+TF1KWHKrhK3eSV3xnJJTqFq1QhQDRKKoqx6oDa+DplB4pZEHw gfOfWfKKIE5kV8BYuN4IlFYM5z6nQO4DljCF6DSjtDyLX1d2mXwiGpiXayO7H5SafGWDT/ B/wgnY3JssWKqU9tmPC7l7A+hduuUuXh3vSO7Ubh/dnsh1VsUb/9TbcRunDGFmfrGyR61C 3Y2BayhoxdfSWLM0TWy7pCpB6wcqPS51L+g9M7MZOzCY9TWMnHTyzDdugsECjeGupQNbt9 RM5X72ysGcTYtb1m6k+SVklEqr8Kd9KQjq/PTLh2Xp8PJN4yGst35JoERwNTOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675973855; 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=wSYvO8vixZydR8MdVQMrVGPDrjNxdsVPx5CZs7Q+pSw=; b=aiPA9SQX3TOWgKDSjOZVjIcHmqJoMHAeymmCprBsxoMPnBoc9ECQc/lWUkQbamTsTt2eYk 3dYm91K4TbAXwGi2YkqIWNoQCUqnkwBkZsQz6qFEcvlzXBv/NSiAZ2vopNEHGmzkdqT1pz Hygk4W1SXEVR+0cIlY3LulNtjdKx4qm+kDgzZLVrsIgH1gfrgAv0t3fPsm7EC3slWelB0D MQTOMhjfI5xQzFc5Rd+1tqvrTeci7fqgLF1oGmy9Ka7/moJhf9pKKgxmoUr1xE/Xc+e2rS KHGEX6p/sYkAmiNIK0v7FtpPvcTzTcqDfrVRmHsUoiPeoycxbc2RTvvnTLQx2g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675973855; a=rsa-sha256; cv=none; b=vSArrqCvSxqhuAdntR5JJTSdJn2Dn0juhSLA8m7lWpf1lc2xpYmzPf1xmC198Scb88xVjd md93FK03jccb5PyQX3p6kkhAnqUPaKIWNm7dIw89gHcaZG0ZJdMljQPQ3ndQKR2vyZT0ps zvwDW/uYm6ZY3mYLseI+BavzyqWYkFepq7z8FBZnMNLV+5bF9y9x7Cdn+H+6Iju8Z8E2UC 2NE6NhSIPOlUhPRysikJ7PElV1563dB3j+pnVoNyH+2LSFY4GlROW/mEEQJTogdaqCAEGK jAWrxYDBUjaWZ0kWz0eYHBMirJ/+yBm9ThygPBZW7MegTCyQ4ETOtXARugjCAA== 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 4PCSpQ5FVhzqx3; Thu, 9 Feb 2023 20:17: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 319KHY8c056925; Thu, 9 Feb 2023 20:17:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 319KHYjj056924; Thu, 9 Feb 2023 20:17:34 GMT (envelope-from git) Date: Thu, 9 Feb 2023 20:17:34 GMT Message-Id: <202302092017.319KHYjj056924@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Stefan=20E=C3=9Fer?= Subject: git: a9c97a5ba1ec - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: a9c97a5ba1ec3fc8ed2aa802c0d085a394e8450d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=a9c97a5ba1ec3fc8ed2aa802c0d085a394e8450d commit a9c97a5ba1ec3fc8ed2aa802c0d085a394e8450d Author: Stefan Eßer AuthorDate: 2022-07-26 21:04:57 +0000 Commit: Stefan Eßer CommitDate: 2023-02-09 20:17:13 +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 (cherry picked from commit 9f3aa538e307743b2b5048d38f87b7fd32d0c596) --- 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)