git: adc02d5e3cfa - main - perror(1): Capsicumise

From: Mariusz Zaborski <oshogbo_at_FreeBSD.org>
Date: Wed, 27 Nov 2024 14:26:58 UTC
The branch main has been updated by oshogbo:

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

commit adc02d5e3cfad9c9d7e12f776cad651795d9ad78
Author:     Faraz Vahedi <kfv@kfv.io>
AuthorDate: 2024-10-26 18:38:08 +0000
Commit:     Mariusz Zaborski <oshogbo@FreeBSD.org>
CommitDate: 2024-11-27 14:26:51 +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
---
 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 9b7eda8d9f70..6341928e9024 100644
--- a/usr.bin/perror/perror.c
+++ b/usr.bin/perror/perror.c
@@ -36,6 +36,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <capsicum_helpers.h>
+
 static void usage(void) __dead2;
 
 int 
@@ -46,6 +48,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();