diff options
author | 2018-04-26 18:11:12 +0000 | |
---|---|---|
committer | 2018-04-26 18:11:12 +0000 | |
commit | e10ff9ff1e349a7733b05d95ab899a7e29481150 (patch) | |
tree | 26f74355d1a073fe528dd7953abdf01e4fa94d11 | |
parent | Cast a multiplicand to ino_t to avoid overflow in 32*32=64 calculations (diff) | |
download | wireguard-openbsd-e10ff9ff1e349a7733b05d95ab899a7e29481150.tar.xz wireguard-openbsd-e10ff9ff1e349a7733b05d95ab899a7e29481150.zip |
tests for clearing out flags
-rw-r--r-- | regress/sys/kern/pledge/pledgepath/syscalls.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/regress/sys/kern/pledge/pledgepath/syscalls.c b/regress/sys/kern/pledge/pledgepath/syscalls.c index 2d74e7f6c60..69b8d46aa84 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.16 2018/04/26 13:57:16 beck Exp $ */ +/* $OpenBSD: syscalls.c,v 1.17 2018/04/26 18:11:12 beck Exp $ */ /* * Copyright (c) 2017 Bob Beck <beck@openbsd.org> @@ -202,6 +202,22 @@ test_open(int do_pp) PP_SHOULD_FAIL((open(filename, O_RDWR|O_CREAT) == -1), "open"); if (do_pp) { + printf("testing clearing flags\n"); + if (pledgepath(pp_dir1, "") == -1) + err(1, "%s:%d - pledgepath", __FILE__, __LINE__); + } + (void) snprintf(filename, sizeof(filename), "%s/%s", pp_dir1, "noflagsiamboned"); + PP_SHOULD_FAIL((open(filename, O_RDWR|O_CREAT) == -1), "open"); + + if (do_pp) { + printf("testing restoring flags\n"); + if (pledgepath(pp_dir1, "rwxc") == -1) + err(1, "%s:%d - pledgepath", __FILE__, __LINE__); + } + + PP_SHOULD_SUCCEED((open(pp_file1, O_RDONLY) == -1), "open"); + PP_SHOULD_FAIL((open(pp_file2, O_RDWR) == -1), "open"); + if (do_pp) { printf("testing O_RDONLY\n"); if (pledgepath(pp_file1, "r") == -1) err(1, "%s:%d - pledgepath", __FILE__, __LINE__); @@ -553,6 +569,6 @@ main (int argc, char *argv[]) failures += runcompare(test_chmod); failures += runcompare(test_exec); failures += runcompare(test_exec2); - exit(failures); + } |