summaryrefslogtreecommitdiff
path: root/regress/sys
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2018-07-13 08:59:03 +0000
committerBob Beck <beck@cvs.openbsd.org>2018-07-13 08:59:03 +0000
commitc6a37843c7155cd159956f76268da7cf2782105d (patch)
treef556f37ead5d1c4e6c9268b2b957a6c7754a94bf /regress/sys
parent83ef6899b20e2eb3021321ba5ba88986e98e959d (diff)
tests for next steps in unveil
Diffstat (limited to 'regress/sys')
-rw-r--r--regress/sys/kern/unveil/syscalls.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/regress/sys/kern/unveil/syscalls.c b/regress/sys/kern/unveil/syscalls.c
index 8f462861d0b..8d58dc97d97 100644
--- a/regress/sys/kern/unveil/syscalls.c
+++ b/regress/sys/kern/unveil/syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscalls.c,v 1.8 2018/07/12 12:20:11 beck Exp $ */
+/* $OpenBSD: syscalls.c,v 1.9 2018/07/13 08:59:02 beck Exp $ */
/*
* Copyright (c) 2017-2018 Bob Beck <beck@openbsd.org>
@@ -695,6 +695,40 @@ test_exec2(int do_uv)
return 0;
}
+static int
+test_slash(int do_uv)
+{
+ extern char **environ;
+ if (do_uv) {
+ if (unveil("/bin/sh", "x") == -1)
+ err(1, "%s:%d - unveil", __FILE__, __LINE__);
+ if (unveil("/", "r") == -1)
+ err(1, "%s:%d - unveil", __FILE__, __LINE__);
+ }
+ return 0;
+}
+
+static int
+test_fork(int do_uv)
+{
+ int status;
+ if (do_uv) {
+ if (unveil("/etc/passswd", "r") == -1)
+ err(1, "%s:%d - unveil", __FILE__, __LINE__);
+ }
+ pid_t pid = fork();
+ if (pid == 0) {
+ printf ("testing child\n");
+ if (do_uv) {
+ if (open("/etc/hosts", O_RDONLY) != -1)
+ err(1, "open /etc/hosts worked");
+ if (open("/etc/passwd", O_RDONLY) == -1)
+ err(1, "open /etc/passwd failed");
+ }
+ exit(0);
+ }
+}
+
int
main (int argc, char *argv[])
{
@@ -735,5 +769,7 @@ main (int argc, char *argv[])
failures += runcompare(test_exec2);
failures += runcompare(test_realpath);
failures += runcompare(test_parent_dir);
+ failures += runcompare(test_slash);
+ failures += runcompare(test_fork);
exit(failures);
}