summaryrefslogtreecommitdiff
path: root/regress/sys/kern
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2017-11-27 19:44:41 +0000
committerBob Beck <beck@cvs.openbsd.org>2017-11-27 19:44:41 +0000
commit778ecf69c6dcac479c7e30faf1afa2e0ea756323 (patch)
treea9cee8b9778b356130a836e289de00f3f84f1487 /regress/sys/kern
parentc4aa8306e03c290da31bf228793b4c73c148bfe0 (diff)
readlink and friends
Diffstat (limited to 'regress/sys/kern')
-rw-r--r--regress/sys/kern/pledge/pledgepath/syscalls.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/regress/sys/kern/pledge/pledgepath/syscalls.c b/regress/sys/kern/pledge/pledgepath/syscalls.c
index 9737b9f22fc..f8584b47a4a 100644
--- a/regress/sys/kern/pledge/pledgepath/syscalls.c
+++ b/regress/sys/kern/pledge/pledgepath/syscalls.c
@@ -7,6 +7,8 @@
#include <sys/errno.h>
#include <sys/wait.h>
#include <sys/stat.h>
+#include <sys/param.h>
+#include <sys/mount.h>
pid_t child;
char pp_dir1[] = "/tmp/ppdir1.XXXXXX"; /* pledgepathed */
@@ -266,13 +268,33 @@ test_stat(int do_pp)
}
static int
+test_statfs(int do_pp)
+{
+ if (do_pp) {
+ printf("testing statfs\n");
+ do_pledgepath();
+ }
+ struct statfs sb;
+
+ PP_SHOULD_SUCCEED((pledge("stdio rpath", NULL) == -1), "pledge");
+ PP_SHOULD_SUCCEED((statfs(pp_file1, &sb) == -1), "statfs");
+ PP_SHOULD_FAIL((statfs(pp_file2, &sb) == -1), "statfs");
+ PP_SHOULD_SUCCEED((statfs(pp_dir1, &sb) == -1), "statfs");
+ PP_SHOULD_FAIL((statfs(pp_dir2, &sb) == -1), "statfs");
+
+ return 0;
+}
+
+static int
test_symlink(int do_pp)
{
char filename[256];
char filename2[256];
+ char buf[256];
+ struct stat sb;
if (do_pp) {
- printf("testing link\n");
+ printf("testing symlink and lstat and readlink\n");
do_pledgepath();
}
@@ -285,14 +307,20 @@ test_symlink(int do_pp)
unlink(filename);
unlink(filename2);
PP_SHOULD_SUCCEED((symlink(pp_file1, filename) == -1), "symlink");
+ PP_SHOULD_SUCCEED((lstat(filename, &sb) == -1), "lstat");
+ PP_SHOULD_SUCCEED((lstat(pp_file1, &sb) == -1), "lstat");
+ PP_SHOULD_SUCCEED((readlink(filename, buf, sizeof(buf)) == -1), "readlink");
unlink(filename);
PP_SHOULD_SUCCEED((symlink(pp_file2, filename) == -1), "symlink");
+ PP_SHOULD_SUCCEED((lstat(filename, &sb) == -1), "lstat");
+ PP_SHOULD_SUCCEED((readlink(filename, buf, sizeof(buf)) == -1), "readlink");
+ PP_SHOULD_FAIL((lstat(pp_file2, &sb) == -1), "lstat");
PP_SHOULD_FAIL((symlink(pp_file1, filename2) == -1), "symlink");
+ PP_SHOULD_FAIL((readlink(filename2, buf, sizeof(buf)) == -1), "readlink");
return 0;
}
-
int
main (int argc, char *argv[])
{
@@ -313,6 +341,7 @@ main (int argc, char *argv[])
failures += runcompare(test_access);
failures += runcompare(test_chflags);
failures += runcompare(test_stat);
+ failures += runcompare(test_statfs);
failures += runcompare(test_symlink);
exit(failures);