diff options
author | Conrad Meyer <cem@FreeBSD.org> | 2016-10-19 21:50:57 +0000 |
---|---|---|
committer | Conrad Meyer <cem@FreeBSD.org> | 2016-10-19 21:50:57 +0000 |
commit | 1532e6565c52b8de156553d9acaab4fdd183031d (patch) | |
tree | d0c81a77a33ee4bef9a7202aeb04e3c09ba13712 /usr.bin/jot | |
parent | ba2cde94c611ad8fd43c6c64e950e70e094e65db (diff) | |
download | src-1532e6565c52b8de156553d9acaab4fdd183031d.tar.gz src-1532e6565c52b8de156553d9acaab4fdd183031d.zip |
Notes
Diffstat (limited to 'usr.bin/jot')
-rw-r--r-- | usr.bin/jot/jot.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/usr.bin/jot/jot.c b/usr.bin/jot/jot.c index 779a4b968dee..881be16d69c5 100644 --- a/usr.bin/jot/jot.c +++ b/usr.bin/jot/jot.c @@ -47,8 +47,11 @@ __FBSDID("$FreeBSD$"); * Author: John Kunze, Office of Comp. Affairs, UCB */ +#include <sys/capsicum.h> +#include <capsicum_helpers.h> #include <ctype.h> #include <err.h> +#include <errno.h> #include <limits.h> #include <stdio.h> #include <stdint.h> @@ -89,6 +92,7 @@ static void usage(void); int main(int argc, char **argv) { + cap_rights_t rights; bool have_format = false; bool infinity = false; bool nofinalnl = false; @@ -105,6 +109,21 @@ main(int argc, char **argv) long i; long reps = REPS_DEF; + if (caph_limit_stdio() < 0) + err(1, "unable to limit rights for stdio"); + cap_rights_init(&rights); + if (cap_rights_limit(STDIN_FILENO, &rights) < 0 && errno != ENOSYS) + err(1, "unable to limit rights for stdin"); + + /* + * Cache NLS data, for strerror, for err(3), before entering capability + * mode. + */ + caph_cache_catpages(); + + if (cap_enter() < 0 && errno != ENOSYS) + err(1, "unable to enter capability mode"); + while ((ch = getopt(argc, argv, "b:cnp:rs:w:")) != -1) switch (ch) { case 'b': |