diff options
author | Mariusz Zaborski <oshogbo@FreeBSD.org> | 2016-10-07 17:56:57 +0000 |
---|---|---|
committer | Mariusz Zaborski <oshogbo@FreeBSD.org> | 2016-10-07 17:56:57 +0000 |
commit | a4e3fc54a0b2fe6f829b80fde801516aec045e9b (patch) | |
tree | 4424a1a9b97739eaca0f53e9c3b01ffebbcdd0b5 /usr.bin/elfdump | |
parent | f2af6f7bf146ad0dedb26ae20a53b9743a5fbe5c (diff) | |
download | src-test2-a4e3fc54a0b2fe6f829b80fde801516aec045e9b.tar.gz src-test2-a4e3fc54a0b2fe6f829b80fde801516aec045e9b.zip |
Notes
Diffstat (limited to 'usr.bin/elfdump')
-rw-r--r-- | usr.bin/elfdump/elfdump.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/usr.bin/elfdump/elfdump.c b/usr.bin/elfdump/elfdump.c index 3a70326270c8..3cffc9138743 100644 --- a/usr.bin/elfdump/elfdump.c +++ b/usr.bin/elfdump/elfdump.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include <sys/endian.h> #include <sys/mman.h> #include <sys/stat.h> +#include <capsicum_helpers.h> #include <err.h> #include <errno.h> #include <fcntl.h> @@ -44,7 +45,6 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <termios.h> #include <unistd.h> #define ED_DYN (1<<0) @@ -505,7 +505,6 @@ main(int ac, char **av) u_int64_t name; u_int64_t type; struct stat sb; - unsigned long cmd; u_int flags; Elf32_Ehdr *e; void *p; @@ -573,14 +572,11 @@ main(int ac, char **av) cap_rights_init(&rights, CAP_MMAP_R); if (cap_rights_limit(fd, &rights) < 0 && errno != ENOSYS) err(1, "unable to limit rights for %s", *av); - cap_rights_limit(STDIN_FILENO, cap_rights_init(&rights)); - cap_rights_init(&rights, CAP_FSTAT, CAP_IOCTL, CAP_WRITE); - cmd = TIOCGETA; /* required by isatty(3) in printf(3) */ - if ((cap_rights_limit(STDOUT_FILENO, &rights) < 0 && errno != ENOSYS) || - (cap_ioctls_limit(STDOUT_FILENO, &cmd, 1) < 0 && errno != ENOSYS) || - (cap_rights_limit(STDERR_FILENO, &rights) < 0 && errno != ENOSYS) || - (cap_ioctls_limit(STDERR_FILENO, &cmd, 1) < 0 && errno != ENOSYS)) - err(1, "unable to limit rights for stdout/stderr"); + cap_rights_init(&rights); + if ((cap_rights_limit(STDIN_FILENO, &rights) < 0 && errno != ENOSYS) || + caph_limit_stdout() < 0 || caph_limit_stderr() < 0) { + err(1, "unable to limit rights for stdio"); + } if (cap_enter() < 0 && errno != ENOSYS) err(1, "unable to enter capability mode"); e = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0); |