diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-05-02 12:22:24 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-05-02 12:22:24 +0000 |
commit | e5ea68e766a512597664c9a0f444eb9ac12b6e9d (patch) | |
tree | 5b056856fe8be85dbbb968badb18718b10b2937c /usr.bin/col | |
parent | 078fd35f793c105b8a6c6886da1bc52429704524 (diff) | |
download | src-test-e5ea68e766a512597664c9a0f444eb9ac12b6e9d.tar.gz src-test-e5ea68e766a512597664c9a0f444eb9ac12b6e9d.zip |
Capsicumize col(1)
Notes
Notes:
svn path=/head/; revision=282342
Diffstat (limited to 'usr.bin/col')
-rw-r--r-- | usr.bin/col/col.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/usr.bin/col/col.c b/usr.bin/col/col.c index fa98cdbc1aab8..74c59b6a4b89e 100644 --- a/usr.bin/col/col.c +++ b/usr.bin/col/col.c @@ -45,11 +45,15 @@ static char sccsid[] = "@(#)col.c 8.5 (Berkeley) 5/4/95"; #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/capsicum.h> + #include <err.h> +#include <errno.h> #include <locale.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <termios.h> #include <unistd.h> #include <wchar.h> #include <wctype.h> @@ -129,9 +133,24 @@ main(int argc, char **argv) int this_line; /* line l points to */ int nflushd_lines; /* number of lines that were flushed */ int adjust, opt, warned, width; + cap_rights_t rights; + unsigned long cmd; (void)setlocale(LC_CTYPE, ""); + cap_rights_init(&rights, CAP_FSTAT, CAP_READ); + if (cap_rights_limit(STDIN_FILENO, &rights) < 0 && errno != ENOSYS) + err(1, "unable to limit rights for stdin"); + cap_rights_init(&rights, CAP_FSTAT, CAP_WRITE, CAP_IOCTL); + if (cap_rights_limit(STDOUT_FILENO, &rights) < 0 && errno != ENOSYS) + err(1, "unable to limit rights for stdout"); + cmd = TIOCGETA; /* required by isatty(3) in printf(3) */ + if (cap_ioctls_limit(STDOUT_FILENO, &cmd, 1) < 0 && errno != ENOSYS) + err(1, "unable to limit ioctls for stdout"); + + if (cap_enter() < 0 && errno != ENOSYS) + err(1, "unable to enter capability mode"); + max_bufd_lines = 128; compress_spaces = 1; /* compress spaces into tabs */ while ((opt = getopt(argc, argv, "bfhl:px")) != -1) |