summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbeck <beck@openbsd.org>2018-08-04 16:23:00 +0000
committerbeck <beck@openbsd.org>2018-08-04 16:23:00 +0000
commit2a042deb0ec80ddd99c44fee8c4d7d67a8eae55e (patch)
tree466a7c5b338f882824750436c3ab06439cc8a166
parentUse POSIX getline(3) rather than the non-standard and error-prone fgetln(3). (diff)
downloadwireguard-openbsd-2a042deb0ec80ddd99c44fee8c4d7d67a8eae55e.tar.xz
wireguard-openbsd-2a042deb0ec80ddd99c44fee8c4d7d67a8eae55e.zip
Add regress test to ensure that chmod fails when unveiled with "r"
(problem noticed by semarie@ - fix forthcoming)
-rw-r--r--regress/sys/kern/unveil/syscalls.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/regress/sys/kern/unveil/syscalls.c b/regress/sys/kern/unveil/syscalls.c
index 6d8242ac070..31ab0e10798 100644
--- a/regress/sys/kern/unveil/syscalls.c
+++ b/regress/sys/kern/unveil/syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscalls.c,v 1.15 2018/08/02 04:39:58 beck Exp $ */
+/* $OpenBSD: syscalls.c,v 1.16 2018/08/04 16:23:00 beck Exp $ */
/*
* Copyright (c) 2017-2018 Bob Beck <beck@openbsd.org>
@@ -669,12 +669,17 @@ test_chmod(int do_uv)
printf("testing chmod\n");
do_unveil();
}
- UV_SHOULD_SUCCEED((pledge("stdio fattr rpath", NULL) == -1), "pledge");
+ UV_SHOULD_SUCCEED((pledge("stdio fattr rpath unveil", NULL) == -1), "pledge");
UV_SHOULD_SUCCEED((chmod(uv_file1, S_IRWXU) == -1), "chmod");
UV_SHOULD_ENOENT((chmod(uv_file2, S_IRWXU) == -1), "chmod");
UV_SHOULD_SUCCEED((chmod(uv_dir1, S_IRWXU) == -1), "chmod");
UV_SHOULD_ENOENT((chmod(uv_dir2, S_IRWXU) == -1), "chmod");
-
+ if (do_uv) {
+ printf("testing chmod should fail for read\n");
+ if (unveil(uv_file1, "r") == -1)
+ err(1, "%s:%d - unveil", __FILE__, __LINE__);
+ }
+ UV_SHOULD_EACCES((chmod(uv_file1, S_IRWXU) == -1), "chmod");
return 0;
}