From: claudio Date: Mon, 30 Aug 2021 08:07:22 +0000 (+0000) Subject: Check that fchdir() works. The problem in unveil was fixed some time ago. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2f30fa3d4214bfafe58f2e34416e654f0156a53e;p=openbsd Check that fchdir() works. The problem in unveil was fixed some time ago. --- 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 @@ -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); }