summaryrefslogtreecommitdiff
path: root/usr.bin/tr/tr.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/tr/tr.c')
-rw-r--r--usr.bin/tr/tr.c24
1 files changed, 3 insertions, 21 deletions
diff --git a/usr.bin/tr/tr.c b/usr.bin/tr/tr.c
index b22ae7d3e248a..a6490db720dd4 100644
--- a/usr.bin/tr/tr.c
+++ b/usr.bin/tr/tr.c
@@ -44,16 +44,15 @@ static const char sccsid[] = "@(#)tr.c 8.2 (Berkeley) 5/4/95";
#include <sys/types.h>
#include <sys/capsicum.h>
+#include <capsicum_helpers.h>
#include <ctype.h>
#include <err.h>
-#include <errno.h>
#include <limits.h>
#include <locale.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <termios.h>
#include <unistd.h>
#include <wchar.h>
#include <wctype.h>
@@ -72,8 +71,6 @@ int
main(int argc, char **argv)
{
static int carray[NCHARS_SB];
- cap_rights_t rights;
- unsigned long cmd;
struct cmap *map;
struct cset *delete, *squeeze;
int n, *p;
@@ -82,23 +79,8 @@ main(int argc, char **argv)
(void)setlocale(LC_ALL, "");
- cap_rights_init(&rights, CAP_FSTAT, CAP_IOCTL, 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_IOCTL, CAP_WRITE);
- if (cap_rights_limit(STDOUT_FILENO, &rights) < 0 && errno != ENOSYS)
- err(1, "unable to limit rights for stdout");
- if (cap_rights_limit(STDERR_FILENO, &rights) < 0 && errno != ENOSYS)
- err(1, "unable to limit rights for stderr");
-
- /* Required for isatty(3). */
- cmd = TIOCGETA;
- if (cap_ioctls_limit(STDIN_FILENO, &cmd, 1) < 0 && errno != ENOSYS)
- err(1, "unable to limit ioctls for stdin");
- if (cap_ioctls_limit(STDOUT_FILENO, &cmd, 1) < 0 && errno != ENOSYS)
- err(1, "unable to limit ioctls for stdout");
- if (cap_ioctls_limit(STDERR_FILENO, &cmd, 1) < 0 && errno != ENOSYS)
- err(1, "unable to limit ioctls for stderr");
+ if (caph_limit_stdio() == -1)
+ err(1, "unable to limit stdio");
if (cap_enter() < 0 && errno != ENOSYS)
err(1, "unable to enter capability mode");