From owner-dev-commits-src-all@freebsd.org Tue Jan 26 21:22:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D56B14E10D9; Tue, 26 Jan 2021 21:22:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DQKSN5bshz4Vb3; Tue, 26 Jan 2021 21:22:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B3C4810EAB; Tue, 26 Jan 2021 21:22:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 10QLMC2r097932; Tue, 26 Jan 2021 21:22:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10QLMCXW097931; Tue, 26 Jan 2021 21:22:12 GMT (envelope-from git) Date: Tue, 26 Jan 2021 21:22:12 GMT Message-Id: <202101262122.10QLMCXW097931@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Cochard Subject: git: f1c010d9f9cb - main - tests: Skip cap_fileargs if build without capsicum capabilities MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olivier X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f1c010d9f9cbc28412d491689e7f594e56085bcb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2021 21:22:12 -0000 The branch main has been updated by olivier (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=f1c010d9f9cbc28412d491689e7f594e56085bcb commit f1c010d9f9cbc28412d491689e7f594e56085bcb Author: Olivier Cochard AuthorDate: 2021-01-26 21:19:36 +0000 Commit: Olivier Cochard CommitDate: 2021-01-26 21:19:36 +0000 tests: Skip cap_fileargs if build without capsicum capabilities Approved by: oshogbo Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D2834 --- lib/libcasper/services/cap_fileargs/tests/Makefile | 2 ++ .../services/cap_fileargs/tests/fileargs_test.c | 29 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/lib/libcasper/services/cap_fileargs/tests/Makefile b/lib/libcasper/services/cap_fileargs/tests/Makefile index 51674c5f778e..4d63605e794b 100644 --- a/lib/libcasper/services/cap_fileargs/tests/Makefile +++ b/lib/libcasper/services/cap_fileargs/tests/Makefile @@ -4,6 +4,8 @@ ATF_TESTS_C= fileargs_test +CFLAGS+= -I${SRCTOP}/tests + .if ${MK_CASPER} != "no" LIBADD+= casper LIBADD+= cap_fileargs diff --git a/lib/libcasper/services/cap_fileargs/tests/fileargs_test.c b/lib/libcasper/services/cap_fileargs/tests/fileargs_test.c index 9a7f9dfcb9aa..a12afd734998 100644 --- a/lib/libcasper/services/cap_fileargs/tests/fileargs_test.c +++ b/lib/libcasper/services/cap_fileargs/tests/fileargs_test.c @@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include "freebsd_test_suite/macros.h" + #define MAX_FILES 200 static char *files[MAX_FILES]; @@ -46,6 +48,13 @@ static int fds[MAX_FILES]; #define TEST_FILE "/etc/passwd" +static void +check_capsicum(void) +{ + ATF_REQUIRE_FEATURE("security_capabilities"); + ATF_REQUIRE_FEATURE("security_capability_mode"); +} + static void prepare_files(size_t num, bool create) { @@ -281,6 +290,8 @@ ATF_TC_BODY(fileargs__open_read, tc) size_t i; int fd; + check_capsicum(); + prepare_files(MAX_FILES, true); cap_rights_init(&rights, CAP_READ | CAP_FCNTL); @@ -326,6 +337,8 @@ ATF_TC_BODY(fileargs__open_write, tc) size_t i; int fd; + check_capsicum(); + prepare_files(MAX_FILES, true); cap_rights_init(&rights, CAP_WRITE | CAP_FCNTL); @@ -371,6 +384,8 @@ ATF_TC_BODY(fileargs__open_create, tc) size_t i; int fd; + check_capsicum(); + prepare_files(MAX_FILES, false); cap_rights_init(&rights, CAP_WRITE | CAP_FCNTL | CAP_READ); @@ -414,6 +429,8 @@ ATF_TC_BODY(fileargs__open_with_casper, tc) size_t i; int fd; + check_capsicum(); + prepare_files(MAX_FILES, true); capcas = cap_init(); @@ -448,6 +465,8 @@ ATF_TC_BODY(fileargs__fopen_read, tc) FILE *pfile; int fd; + check_capsicum(); + prepare_files(MAX_FILES, true); cap_rights_init(&rights, CAP_READ | CAP_FCNTL); @@ -496,6 +515,8 @@ ATF_TC_BODY(fileargs__fopen_write, tc) FILE *pfile; int fd; + check_capsicum(); + prepare_files(MAX_FILES, true); cap_rights_init(&rights, CAP_WRITE | CAP_FCNTL); @@ -544,6 +565,8 @@ ATF_TC_BODY(fileargs__fopen_create, tc) FILE *pfile; int fd; + check_capsicum(); + prepare_files(MAX_FILES, false); cap_rights_init(&rights, CAP_READ | CAP_WRITE | CAP_FCNTL); @@ -585,6 +608,8 @@ ATF_TC_BODY(fileargs__lstat, tc) size_t i; int fd; + check_capsicum(); + prepare_files(MAX_FILES, true); fa = fileargs_init(MAX_FILES, files, 0, 0, NULL, FA_LSTAT); @@ -646,6 +671,8 @@ ATF_TC_BODY(fileargs__open_lstat, tc) size_t i; int fd; + check_capsicum(); + prepare_files(MAX_FILES, true); cap_rights_init(&rights, CAP_READ | CAP_FCNTL); @@ -692,6 +719,8 @@ ATF_TC_BODY(fileargs__open_realpath, tc) size_t i; int fd; + check_capsicum(); + prepare_files(MAX_FILES, true); cap_rights_init(&rights, CAP_READ | CAP_FCNTL);