Changeset View
Standalone View
tests/sys/audit/utils.c
Show All 19 Lines | |||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
* | * | ||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#include <sys/types.h> | |||||
#include <sys/extattr.h> | |||||
#include <sys/ioctl.h> | #include <sys/ioctl.h> | ||||
#include <bsm/libbsm.h> | #include <bsm/libbsm.h> | ||||
#include <security/audit/audit_ioctl.h> | #include <security/audit/audit_ioctl.h> | ||||
#include <atf-c.h> | #include <atf-c.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <fcntl.h> | #include <fcntl.h> | ||||
▲ Show 20 Lines • Show All 161 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void | void | ||||
check_audit(struct pollfd fd[], const char *auditrgx, FILE *pipestream) { | check_audit(struct pollfd fd[], const char *auditrgx, FILE *pipestream) { | ||||
check_auditpipe(fd, auditrgx, pipestream); | check_auditpipe(fd, auditrgx, pipestream); | ||||
/* Teardown: /dev/auditpipe's instance opened for this test-suite */ | /* Teardown: /dev/auditpipe's instance opened for this test-suite */ | ||||
ATF_REQUIRE_EQ(0, fclose(pipestream)); | ATF_REQUIRE_EQ(0, fclose(pipestream)); | ||||
} | |||||
void | |||||
skip_if_extattr_not_supported(const char *path) | |||||
{ | |||||
ssize_t result; | |||||
/* | |||||
* Some file systems (e.g. tmpfs) do not support extattr, so we need | |||||
* skip tests that use extattrs. To detect this we can check whether | |||||
* the extattr_list_file returns EOPNOTSUPP. | |||||
*/ | |||||
asomers: Hard-coding the list of unsupported file systems is hard to maintain. Better if we can… | |||||
Done Inline ActionsYes, they return EOPNOTSUPP. Checking for that return value sounds good to me. I could add a basic extattr query call here and skip the entire test if it returns EOPNOTSUPP. That would avoid starting and stopping auditd. arichardson: Yes, they return EOPNOTSUPP. Checking for that return value sounds good to me.
I could add a… | |||||
result = extattr_list_file(path, EXTATTR_NAMESPACE_USER, NULL, 0); | |||||
Not Done Inline ActionsA test case marked as an expected failure indicates a bug that ought to be fixed. Your problem is that your setup isn't capable of running this test. So you should call atf_tc_skip instead. See for example the cap_enter_success test. asomers: A test case marked as an expected failure indicates a bug that ought to be fixed. Your problem… | |||||
Done Inline ActionsI assumed that lack of extattr support in tmpfs is a temporary problem that will be fixed eventually rather than a fundamental design conflict. In that case the tests will report XPASS once it's implemented and the condition can be updated. It might make it more likely than skip that someone goes ahead and fixes it. skip would have the benefit that the auditd startup/stop can be omitted though so maybe that's better. arichardson: I assumed that lack of extattr support in tmpfs is a temporary problem that will be fixed… | |||||
Not Done Inline ActionsBut the purpose of these tests isn't to exercise tmpfs, it's to exercise audit. A lack of extattr support in the file system doesn't indicate any kind of trouble with audit. So better to skip. asomers: But the purpose of these tests isn't to exercise tmpfs, it's to exercise audit. A lack of… | |||||
if (result == -1 && errno == EOPNOTSUPP) { | |||||
atf_tc_skip("File system does not support extattrs."); | |||||
} | |||||
} | } | ||||
FILE | FILE | ||||
*setup(struct pollfd fd[], const char *name) | *setup(struct pollfd fd[], const char *name) | ||||
{ | { | ||||
au_mask_t fmask, nomask; | au_mask_t fmask, nomask; | ||||
fmask = get_audit_mask(name); | fmask = get_audit_mask(name); | ||||
nomask = get_audit_mask("no"); | nomask = get_audit_mask("no"); | ||||
Show All 34 Lines |
Hard-coding the list of unsupported file systems is hard to maintain. Better if we can determine at runtime whether the file system under test supports extattrs. Adding a pathconf variable would be one way. Another way would be to attempt the test unconditionally, but call atf_tc_skip if one of the extattr syscalls returns EOPNOTSUPP (I"m just guessing that's what will happen on tmpfs; I don't know).