git: 17d5b027c192 - main - md5: Clean up input stream rights.

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Fri, 16 Feb 2024 12:50:53 UTC
The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=17d5b027c1921d0c6ba2de7993dd808dbf4df078

commit 17d5b027c1921d0c6ba2de7993dd808dbf4df078
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2024-02-16 12:37:08 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2024-02-16 12:37:41 +0000

    md5: Clean up input stream rights.
    
    Keep it simple, caph_limit_stdio() and fileargs_fopen() already take
    care of everything for us.
    
    MFC after:      1 week
    Reviewed by:    markj, jhb, emaste
    Differential Revision:  https://reviews.freebsd.org/D43897
---
 sbin/md5/md5.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c
index 2045b623ff57..b6405635a5a1 100644
--- a/sbin/md5/md5.c
+++ b/sbin/md5/md5.c
@@ -574,7 +574,7 @@ main(int argc, char *argv[])
 	argv += optind;
 
 #ifdef HAVE_CAPSICUM
-	if (caph_limit_stdout() < 0 || caph_limit_stderr() < 0)
+	if (caph_limit_stdio() < 0)
 		err(1, "unable to limit rights for stdio");
 #endif
 
@@ -629,10 +629,6 @@ main(int argc, char *argv[])
 					rec = rec->next;
 				continue;
 			}
-#ifdef HAVE_CAPSICUM
-			if (caph_rights_limit(fileno(f), &rights) < 0)
-				err(1, "capsicum");
-#endif
 			if (cflag && mode != mode_bsd) {
 				checkAgainst = rec->chksum;
 				rec = rec->next;
@@ -643,10 +639,6 @@ main(int argc, char *argv[])
 			MDOutput(&Algorithm[digest], p, filename);
 		} while (*++argv);
 	} else if (!cflag && string == NULL && !skip) {
-#ifdef HAVE_CAPSICUM
-		if (caph_limit_stdin() < 0)
-			err(1, "capsicum");
-#endif
 		if (mode == mode_bsd)
 			output_mode = output_bare;
 		p = MDInput(&Algorithm[digest], stdin, buf, pflag);