git: 24a7303821ad - main - leave(1): Capsicumise

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

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

commit 24a7303821ad2343b9239ab3d12a569a70a2b99a
Author:     Faraz Vahedi <kfv@kfv.io>
AuthorDate: 2024-10-27 16:34:33 +0000
Commit:     Mariusz Zaborski <oshogbo@FreeBSD.org>
CommitDate: 2024-11-27 14:10:29 +0000

    leave(1): Capsicumise
    
    Signed-off-by: Faraz Vahedi <kfv@kfv.io>
    Reviewed by:    oshogbo
    MFC after:      1 week
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/1499
---
 usr.bin/leave/leave.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/usr.bin/leave/leave.c b/usr.bin/leave/leave.c
index d4db4349d4de..73507190369e 100644
--- a/usr.bin/leave/leave.c
+++ b/usr.bin/leave/leave.c
@@ -37,6 +37,8 @@
 #include <time.h>
 #include <unistd.h>
 
+#include <capsicum_helpers.h>
+
 static void doalarm(u_int);
 static void usage(void) __dead2;
 
@@ -61,6 +63,10 @@ main(int argc, char **argv)
 	if (setlocale(LC_TIME, "") == NULL)
 		warn("setlocale");
 
+	caph_cache_catpages();
+	if (caph_limit_stdio() < 0 || caph_enter() < 0)
+		err(EXIT_FAILURE, "capsicum");
+
 	if (argc < 2) {
 #define	MSG1	"When do you have to leave? "
 		(void)write(STDOUT_FILENO, MSG1, sizeof(MSG1) - 1);