summaryrefslogtreecommitdiff
path: root/regress/sys
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2021-08-30 08:07:23 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2021-08-30 08:07:23 +0000
commitb96fc5380110ab52504c69daacac94f81375876a (patch)
tree7edd74663b47ce8361946a2cba215b6acea1c720 /regress/sys
parentfc224f83be6078b508f9eb2c40ee19e78a711585 (diff)
Check that fchdir() works. The problem in unveil was fixed some time ago.
Diffstat (limited to 'regress/sys')
-rw-r--r--regress/sys/kern/unveil/syscalls.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/regress/sys/kern/unveil/syscalls.c b/regress/sys/kern/unveil/syscalls.c
index 0828a5c1504..4de3666b7b2 100644
--- a/regress/sys/kern/unveil/syscalls.c
+++ b/regress/sys/kern/unveil/syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscalls.c,v 1.28 2021/08/30 08:06:02 claudio Exp $ */
+/* $OpenBSD: syscalls.c,v 1.29 2021/08/30 08:07:22 claudio Exp $ */
/*
* Copyright (c) 2017-2019 Bob Beck <beck@openbsd.org>
@@ -914,6 +914,25 @@ test_pathdiscover(int do_uv)
return 0;
}
+static int
+test_fchdir(int do_uv)
+{
+ int fd2, fd;
+
+ UV_SHOULD_SUCCEED(((fd2 = open(uv_dir2, O_RDONLY | O_DIRECTORY)) == -1), "open");
+
+ if (do_uv) {
+ printf("testing fchdir\n");
+ do_unveil2();
+ }
+
+ UV_SHOULD_SUCCEED((pledge("stdio fattr rpath", NULL) == -1), "pledge");
+ UV_SHOULD_SUCCEED((chdir(uv_dir1) == -1), "chdir");
+ UV_SHOULD_SUCCEED((fchdir(fd2) == -1), "fchdir");
+ UV_SHOULD_ENOENT((fd = (open("subdir", O_RDONLY | O_DIRECTORY)) == -1), "open");
+
+ return 0;
+}
int
main (int argc, char *argv[])
@@ -963,5 +982,6 @@ main (int argc, char *argv[])
failures += runcompare(test_dotdotup);
failures += runcompare(test_kn);
failures += runcompare(test_pathdiscover);
+ failures += runcompare(test_fchdir);
exit(failures);
}