summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2018-04-16 14:28:45 +0000
committerBob Beck <beck@cvs.openbsd.org>2018-04-16 14:28:45 +0000
commitc7798deb42e36bd1d12a7f77362885115048fd80 (patch)
treeaf78f35e53e72a39fa36a82c4adcb4b36fc7e07d /regress
parent2f6ebc40c3a51fb88b0c0e9a8958e45711722796 (diff)
Add regression test of unlinking and re-creating a pledgepathed file
Diffstat (limited to 'regress')
-rw-r--r--regress/sys/kern/pledge/pledgepath/syscalls.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/regress/sys/kern/pledge/pledgepath/syscalls.c b/regress/sys/kern/pledge/pledgepath/syscalls.c
index 48f469e37c7..4b5fe251c2e 100644
--- a/regress/sys/kern/pledge/pledgepath/syscalls.c
+++ b/regress/sys/kern/pledge/pledgepath/syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscalls.c,v 1.7 2017/11/30 00:01:50 beck Exp $ */
+/* $OpenBSD: syscalls.c,v 1.8 2018/04/16 14:28:44 beck Exp $ */
/*
* Copyright (c) 2017 Bob Beck <beck@openbsd.org>
@@ -109,6 +109,12 @@ test_open(int do_pp)
PP_SHOULD_FAIL(((dirfd3= open(pp_dir2, O_RDONLY | O_DIRECTORY)) == -1), "open");
PP_SHOULD_SUCCEED((open(pp_file1, O_RDWR) == -1), "open");
+ if (!do_pp) {
+ /* Unlink the pledgepathed file and make it again */
+ PP_SHOULD_SUCCEED((unlink(pp_file1) == -1), "unlink");
+ PP_SHOULD_SUCCEED((open(pp_file1, O_RDWR|O_CREAT) == -1), "open");
+ }
+ sleep(1);
PP_SHOULD_SUCCEED((open(pp_file1, O_RDWR) == -1), "open");
PP_SHOULD_SUCCEED((openat(dirfd, "etc/hosts", O_RDONLY) == -1), "openat");
PP_SHOULD_FAIL((openat(dirfd, pp_file2, O_RDWR) == -1), "openat");