From 4c0894ca8858f4a5a8f17b97c465ff65b8f91f25 Mon Sep 17 00:00:00 2001 From: Bob Beck Date: Fri, 27 Apr 2018 18:05:45 +0000 Subject: Add test for stat behavior to make sure we can stat executable only --- regress/sys/kern/pledge/pledgepath/syscalls.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'regress') diff --git a/regress/sys/kern/pledge/pledgepath/syscalls.c b/regress/sys/kern/pledge/pledgepath/syscalls.c index 5803db5f813..108ab10bf01 100644 --- a/regress/sys/kern/pledge/pledgepath/syscalls.c +++ b/regress/sys/kern/pledge/pledgepath/syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syscalls.c,v 1.21 2018/04/27 15:28:00 beck Exp $ */ +/* $OpenBSD: syscalls.c,v 1.22 2018/04/27 18:05:44 beck Exp $ */ /* * Copyright (c) 2017 Bob Beck @@ -239,12 +239,15 @@ test_rw(int do_pp) static int test_x(int do_pp) { + struct stat sb; if (do_pp) { printf("testing \"x\"\n"); if (pledgepath(pp_file1, "x") == -1) err(1, "%s:%d - pledgepath", __FILE__, __LINE__); } PP_SHOULD_SUCCEED((pledgepath(NULL, NULL) == -1), "pledgepath"); + PP_SHOULD_SUCCEED((lstat(pp_file1, &sb) == -1), "lstat"); + PP_SHOULD_FAIL((open(pp_file1, O_RDONLY) == -1), "open"); PP_SHOULD_FAIL((open(pp_file1, O_RDONLY) == -1), "open"); PP_SHOULD_FAIL((open(pp_file2, O_RDWR) == -1), "open"); return 0; @@ -610,5 +613,4 @@ main (int argc, char *argv[]) failures += runcompare(test_exec); failures += runcompare(test_exec2); exit(failures); - } -- cgit v1.2.3