git: ac068edaa804 - stable/14 - perror(1): Capsicumise

From: Mariusz Zaborski <oshogbo_at_FreeBSD.org>
Date: Wed, 29 Jan 2025 12:35:54 UTC
The branch stable/14 has been updated by oshogbo:

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

commit ac068edaa804922e708af99c32a69cb2e68c0388
Author:     Faraz Vahedi <kfv@kfv.io>
AuthorDate: 2024-10-26 18:38:08 +0000
Commit:     Mariusz Zaborski <oshogbo@FreeBSD.org>
CommitDate: 2025-01-29 09:51:10 +0000

    perror(1): Capsicumise
    
    Signed-off-by: Faraz Vahedi <kfv@kfv.io>
    Reviewed by:    markj, oshogbo
    MFC after:      1 week
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/1492
    
    (cherry picked from commit adc02d5e3cfad9c9d7e12f776cad651795d9ad78)
---
 usr.bin/perror/perror.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/usr.bin/perror/perror.c b/usr.bin/perror/perror.c
index 2ef65adf56e2..bdf19e2423cf 100644
--- a/usr.bin/perror/perror.c
+++ b/usr.bin/perror/perror.c
@@ -35,6 +35,8 @@
 #include <locale.h>
 #include <sys/errno.h>
 
+#include <capsicum_helpers.h>
+
 static void usage(void) __dead2;
 
 int 
@@ -45,6 +47,11 @@ main(int argc, char **argv)
 	long errnum;
 
 	(void) setlocale(LC_MESSAGES, "");
+
+	caph_cache_catpages();
+	if (caph_limit_stdio() < 0 || caph_enter() < 0)
+		err(EXIT_FAILURE, "capsicum");
+
 	if (argc != 2)
 		usage();