Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F172810735
D7928.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D7928.id.diff
View Options
Index: head/usr.bin/tr/tr.c
===================================================================
--- head/usr.bin/tr/tr.c
+++ head/usr.bin/tr/tr.c
@@ -41,16 +41,19 @@
static const char sccsid[] = "@(#)tr.c 8.2 (Berkeley) 5/4/95";
#endif
+#include <sys/capsicum.h>
#include <sys/types.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>
@@ -69,6 +72,8 @@
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;
@@ -77,6 +82,27 @@
(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 (cap_enter() < 0 && errno != ENOSYS)
+ err(1, "unable to enter capability mode");
+
Cflag = cflag = dflag = sflag = 0;
while ((ch = getopt(argc, argv, "Ccdsu")) != -1)
switch((char)ch) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Sep 22, 4:40 AM (4 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39402474
Default Alt Text
D7928.id.diff (1 KB)
Attached To
Mode
D7928: tr(1): Capsicumify
Attached
Detach File
Event Timeline
Log In to Comment