From ba253c9b48e4962abf50afbf26dd315727cb50ea Mon Sep 17 00:00:00 2001 From: beck Date: Tue, 28 Aug 2018 02:49:47 +0000 Subject: [PATCH] Add regress test of stat all the way to a nonexistant terminal --- regress/sys/kern/unveil/syscalls.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/regress/sys/kern/unveil/syscalls.c b/regress/sys/kern/unveil/syscalls.c index 31ab0e10798..4284ddf63d3 100644 --- a/regress/sys/kern/unveil/syscalls.c +++ b/regress/sys/kern/unveil/syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syscalls.c,v 1.16 2018/08/04 16:23:00 beck Exp $ */ +/* $OpenBSD: syscalls.c,v 1.17 2018/08/28 02:49:47 beck Exp $ */ /* * Copyright (c) 2017-2018 Bob Beck @@ -593,6 +593,25 @@ test_stat(int do_uv) return 0; } +static int +test_stat2(int do_uv) +{ + if (do_uv) { + printf("testing stat components to nonexistant \"rw\"\n"); + if (unveil("/usr/share/man/nonexistant", "rw") == -1) + err(1, "%s:%d - unveil", __FILE__, __LINE__); + } + struct stat sb; + + UV_SHOULD_SUCCEED((pledge("stdio fattr rpath", NULL) == -1), "pledge"); + UV_SHOULD_SUCCEED((stat("/", &sb) == -1), "stat"); + UV_SHOULD_SUCCEED((stat("/usr", &sb) == -1), "stat"); + UV_SHOULD_SUCCEED((stat("/usr/share", &sb) == -1), "stat"); + UV_SHOULD_SUCCEED((stat("/usr/share/man", &sb) == -1), "stat"); + UV_SHOULD_ENOENT((stat("/usr/share/man/nonexistant", &sb) == -1), "stat"); + return 0; +} + static int test_statfs(int do_uv) { @@ -840,6 +859,7 @@ main (int argc, char *argv[]) failures += runcompare(test_access); failures += runcompare(test_chflags); failures += runcompare(test_stat); + failures += runcompare(test_stat2); failures += runcompare(test_statfs); failures += runcompare(test_symlink); failures += runcompare(test_chmod); -- 2.20.1