Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Jan 2025 12:36:00 GMT
From:      Mariusz Zaborski <oshogbo@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 6285abfcf3c2 - stable/14 - nl(1): Capsicumise the utility
Message-ID:  <202501291236.50TCa00T051438@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by oshogbo:

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

commit 6285abfcf3c2ba5faefed44a38604823f7ced9b1
Author:     Faraz Vahedi <kfv@kfv.io>
AuthorDate: 2024-10-13 20:03:25 +0000
Commit:     Mariusz Zaborski <oshogbo@FreeBSD.org>
CommitDate: 2025-01-29 09:51:31 +0000

    nl(1): Capsicumise the utility
    
    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/1465
    
    (cherry picked from commit dfd52321b7beba716fa2bdd4f54e57e9ac806e96)
---
 usr.bin/nl/nl.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/usr.bin/nl/nl.c b/usr.bin/nl/nl.c
index de4314155ff1..e0c9f21b45d4 100644
--- a/usr.bin/nl/nl.c
+++ b/usr.bin/nl/nl.c
@@ -49,6 +49,8 @@ __COPYRIGHT(
 #include <unistd.h>
 #include <wchar.h>
 
+#include <capsicum_helpers.h>
+
 typedef enum {
 	number_all,		/* number all lines */
 	number_nonempty,	/* number non-empty lines */
@@ -251,6 +253,11 @@ main(int argc, char *argv[])
 		/* NOTREACHED */
 	}
 
+	/* Limit standard descriptors and enter capability mode */
+	caph_cache_catpages();
+	if (caph_limit_stdio() < 0 || caph_enter() < 0)
+		err(EXIT_FAILURE, "capsicum");
+
 	/* Generate the delimiter sequence */
 	memcpy(delim, delim1, delim1len);
 	memcpy(delim + delim1len, delim2, delim2len);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202501291236.50TCa00T051438>