summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordoug <doug@openbsd.org>2015-10-10 05:35:22 +0000
committerdoug <doug@openbsd.org>2015-10-10 05:35:22 +0000
commita2428f0ba33370268c7a1104d4261fc4395efa18 (patch)
treecba54a7a963f0e8b56c62314beb156d9797536db
parentpledge to only use "stdio rpath"; ok doug (diff)
downloadwireguard-openbsd-a2428f0ba33370268c7a1104d4261fc4395efa18.tar.xz
wireguard-openbsd-a2428f0ba33370268c7a1104d4261fc4395efa18.zip
Add pledge support to cmp(1).
This is a simple case of using "stdio rpath" until all files are opened and then dropping down to "stdio" since it includes "rw" on open fds. ok deraadt@
-rw-r--r--usr.bin/cmp/cmp.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/usr.bin/cmp/cmp.c b/usr.bin/cmp/cmp.c
index 80c9a1db8c8..0b5c86345a1 100644
--- a/usr.bin/cmp/cmp.c
+++ b/usr.bin/cmp/cmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmp.c,v 1.12 2009/10/27 23:59:36 deraadt Exp $ */
+/* $OpenBSD: cmp.c,v 1.13 2015/10/10 05:35:22 doug Exp $ */
/* $NetBSD: cmp.c,v 1.7 1995/09/08 03:22:56 tls Exp $ */
/*
@@ -57,6 +57,9 @@ main(int argc, char *argv[])
setlocale(LC_ALL, "");
+ if (pledge("stdio rpath", NULL) == -1)
+ err(1, "pledge");
+
while ((ch = getopt(argc, argv, "ls")) != -1)
switch (ch) {
case 'l': /* print all differences */
@@ -109,6 +112,9 @@ main(int argc, char *argv[])
err(ERR_EXIT, "%s", file2);
}
+ if (pledge("stdio", NULL) == -1)
+ err(1, "pledge");
+
skip1 = argc > 2 ? strtoq(argv[2], NULL, 0) : 0;
skip2 = argc == 4 ? strtoq(argv[3], NULL, 0) : 0;