aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/cmp
diff options
context:
space:
mode:
authorMariusz Zaborski <oshogbo@FreeBSD.org>2016-10-07 17:56:57 +0000
committerMariusz Zaborski <oshogbo@FreeBSD.org>2016-10-07 17:56:57 +0000
commita4e3fc54a0b2fe6f829b80fde801516aec045e9b (patch)
tree4424a1a9b97739eaca0f53e9c3b01ffebbcdd0b5 /usr.bin/cmp
parentf2af6f7bf146ad0dedb26ae20a53b9743a5fbe5c (diff)
Notes
Diffstat (limited to 'usr.bin/cmp')
-rw-r--r--usr.bin/cmp/cmp.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/usr.bin/cmp/cmp.c b/usr.bin/cmp/cmp.c
index b1e0c4cc91063..2aa5603e49ef4 100644
--- a/usr.bin/cmp/cmp.c
+++ b/usr.bin/cmp/cmp.c
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
#include <sys/capsicum.h>
#include <sys/stat.h>
+#include <capsicum_helpers.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
@@ -53,7 +54,6 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <termios.h>
#include <unistd.h>
#include "extern.h"
@@ -70,7 +70,6 @@ main(int argc, char *argv[])
int ch, fd1, fd2, oflag, special;
const char *file1, *file2;
cap_rights_t rights;
- unsigned long cmd;
uint32_t fcntls;
oflag = O_RDONLY;
@@ -165,20 +164,10 @@ main(int argc, char *argv[])
if (cap_fcntls_limit(fd2, fcntls) < 0 && errno != ENOSYS)
err(ERR_EXIT, "unable to limit fcntls for %s", file2);
- cap_rights_init(&rights, CAP_FSTAT, CAP_WRITE, CAP_IOCTL);
- if (cap_rights_limit(STDOUT_FILENO, &rights) < 0 && errno != ENOSYS)
- err(ERR_EXIT, "unable to limit rights for stdout");
+ if (caph_limit_stdout() == -1 || caph_limit_stderr() == -1)
+ err(ERR_EXIT, "unable to limit stdio");
- /* Required for printf(3) via isatty(3). */
- cmd = TIOCGETA;
- if (cap_ioctls_limit(STDOUT_FILENO, &cmd, 1) < 0 && errno != ENOSYS)
- err(ERR_EXIT, "unable to limit ioctls for stdout");
-
- /*
- * Cache NLS data, for strerror, for err(3), before entering capability
- * mode.
- */
- (void)catopen("libc", NL_CAT_LOCALE);
+ caph_cache_catpages();
if (cap_enter() < 0 && errno != ENOSYS)
err(ERR_EXIT, "unable to enter capability mode");