Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153932247
D1009.id2115.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
D1009.id2115.diff
View Options
Index: usr.bin/elfdump/elfdump.c
===================================================================
--- usr.bin/elfdump/elfdump.c
+++ usr.bin/elfdump/elfdump.c
@@ -28,6 +28,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <sys/capsicum.h>
#include <sys/types.h>
#include <sys/elf32.h>
#include <sys/elf64.h>
@@ -35,6 +36,7 @@
#include <sys/mman.h>
#include <sys/stat.h>
#include <err.h>
+#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <stddef.h>
@@ -486,6 +488,7 @@
int fd;
int ch;
int i;
+ cap_rights_t rights;
out = stdout;
flags = 0;
@@ -527,6 +530,9 @@
case 'w':
if ((out = fopen(optarg, "w")) == NULL)
err(1, "%s", optarg);
+ cap_rights_init(&rights, CAP_FSTAT, CAP_WRITE);
+ if (cap_rights_limit(fileno(out), &rights) < 0 && errno != ENOSYS)
+ err(1, "unable to limit rights for %s", optarg);
break;
case '?':
default:
@@ -539,6 +545,13 @@
if ((fd = open(*av, O_RDONLY)) < 0 ||
fstat(fd, &sb) < 0)
err(1, "%s", *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);
+
+ 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);
if (e == MAP_FAILED)
err(1, NULL);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 25, 9:56 PM (12 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32144032
Default Alt Text
D1009.id2115.diff (1 KB)
Attached To
Mode
D1009: Enter capability mode and limit descriptors in elfdump(1)
Attached
Detach File
Event Timeline
Log In to Comment