summaryrefslogtreecommitdiff
path: root/regress/sys/kern/pledge/generic/main.c
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2017-02-19 19:59:13 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2017-02-19 19:59:13 +0000
commita6716fde212083ccc166a423de6b48f2f1d74560 (patch)
treec1e9505d8e5ab18ff1345f04420b8ad5abdd6076 /regress/sys/kern/pledge/generic/main.c
parent854541e5787e18564071f9a86a584881e1b7819d (diff)
Clean up regress/sys/kern/pledge/generic tests: many tests failed because
wlpaths is disabled in GENERIC kernels: remove or disable failing test cases. Also remove the test_mmap() function testing the prot_exec promise since it would need to be run on a wxallowed partition. from semarie
Diffstat (limited to 'regress/sys/kern/pledge/generic/main.c')
-rw-r--r--regress/sys/kern/pledge/generic/main.c40
1 files changed, 10 insertions, 30 deletions
diff --git a/regress/sys/kern/pledge/generic/main.c b/regress/sys/kern/pledge/generic/main.c
index 3297d590b87..76a555402e3 100644
--- a/regress/sys/kern/pledge/generic/main.c
+++ b/regress/sys/kern/pledge/generic/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.8 2015/10/30 07:24:20 semarie Exp $ */
+/* $OpenBSD: main.c,v 1.9 2017/02/19 19:59:12 tb Exp $ */
/*
* Copyright (c) 2015 Sebastien Marie <semarie@openbsd.org>
*
@@ -61,6 +61,7 @@ test_kill()
kill(0, SIGINT);
}
+#ifdef WLPATHS
static void
open_close(const char *filename)
{
@@ -96,16 +97,16 @@ test_wpaths()
printf("\n");
exit(EXIT_SUCCESS);
}
+#endif
static void
test_pledge()
{
- const char *wpaths[] = { "/sbin", NULL };
-
- if (pledge("stdio rpath", wpaths) != 0)
+ if (pledge("stdio rpath", NULL) != 0)
_exit(errno);
}
+#ifdef WLPATHS
static void
do_stat(const char *path)
{
@@ -150,25 +151,7 @@ test_stat()
printf("\n");
exit(EXIT_SUCCESS);
}
-
-static void
-test_mmap()
-{
- int fd;
- void * data;
-
- if ((fd = open("/dev/zero", O_RDONLY, 0)) == -1)
- _exit(errno);
-
- data = mmap(NULL, 4096, PROT_READ|PROT_WRITE|PROT_EXEC,
- MAP_FILE|MAP_SHARED, fd, 0);
-
- if (data == MAP_FAILED)
- _exit(errno);
-
- munmap(data, 4096);
- close(fd);
-}
+#endif
static void
test_rpath()
@@ -247,6 +230,7 @@ main(int argc, char *argv[])
start_test(&ret, "stdio wpath", NULL, test_wpath);
start_test(&ret, "cpath", NULL, test_cpath);
+#if WLPATHS
/*
* test whitelist path
*/
@@ -261,6 +245,7 @@ main(int argc, char *argv[])
start_test1(&ret, "stdio rpath", "generic", test_wpaths);
start_test1(&ret, "stdio rpath", "", test_wpaths);
start_test1(&ret, "stdio rpath", ".", test_wpaths);
+#endif
/*
* test pledge(2) arguments
@@ -269,20 +254,15 @@ main(int argc, char *argv[])
start_test(&ret, "stdio rpath", NULL, test_pledge);
/* reduce request */
start_test(&ret, "stdio rpath wpath", NULL, test_pledge);
- /* reduce request (with same/other wpaths) */
- start_test1(&ret, "stdio rpath wpath", "/sbin", test_pledge);
- start_test1(&ret, "stdio rpath wpath", "/", test_pledge);
/* add request */
start_test(&ret, "stdio", NULL, test_pledge);
/* change request */
start_test(&ret, "stdio unix", NULL, test_pledge);
/* test stat(2) */
+#if WLPATHS
start_test1(&ret, "stdio rpath", "/usr/share/man", test_stat);
-
- /* mmap */
- start_test1(&ret, "stdio rpath prot_exec", "/dev/zero", test_mmap);
- start_test1(&ret, "stdio rpath", "/dev/zero", test_mmap);
+#endif
/* stdio */
start_test(&ret, NULL, NULL, test_request_stdio);