Changeset View
Changeset View
Standalone View
Standalone View
tests/sys/audit/utils.c
Show First 20 Lines • Show All 205 Lines • ▼ Show 20 Lines | *setup(struct pollfd fd[], const char *name) | ||||
fmask = get_audit_mask(name); | fmask = get_audit_mask(name); | ||||
nomask = get_audit_mask("no"); | nomask = get_audit_mask("no"); | ||||
FILE *pipestream; | FILE *pipestream; | ||||
ATF_REQUIRE((fd[0].fd = open("/dev/auditpipe", O_RDONLY)) != -1); | ATF_REQUIRE((fd[0].fd = open("/dev/auditpipe", O_RDONLY)) != -1); | ||||
ATF_REQUIRE((pipestream = fdopen(fd[0].fd, "r")) != NULL); | ATF_REQUIRE((pipestream = fdopen(fd[0].fd, "r")) != NULL); | ||||
fd[0].events = POLLIN; | fd[0].events = POLLIN; | ||||
/* | |||||
* Disable stream buffering for read operations from /dev/auditpipe. | |||||
* Otherwise it is possible that fread(3), called via au_read_rec(3), | |||||
asomers: Technically it's not possible, not since you use `setvbuf`. I would say something more like… | |||||
* can store buffered data in user-space at the time ppoll(2) reports | |||||
* that /dev/auditpipe is empty. | |||||
*/ | |||||
ATF_REQUIRE_EQ(0, setvbuf(pipestream, NULL, _IONBF, 0)); | |||||
/* Set local preselection audit_class as "no" for audit startup */ | /* Set local preselection audit_class as "no" for audit startup */ | ||||
set_preselect_mode(fd[0].fd, &nomask); | set_preselect_mode(fd[0].fd, &nomask); | ||||
ATF_REQUIRE_EQ(0, system("service auditd onestatus || \ | ATF_REQUIRE_EQ(0, system("service auditd onestatus || \ | ||||
{ service auditd onestart && touch started_auditd ; }")); | { service auditd onestart && touch started_auditd ; }")); | ||||
/* If 'started_auditd' exists, that means we started auditd(8) */ | /* If 'started_auditd' exists, that means we started auditd(8) */ | ||||
if (atf_utils_file_exists("started_auditd")) | if (atf_utils_file_exists("started_auditd")) | ||||
check_audit_startup(fd, "audit startup", pipestream); | check_audit_startup(fd, "audit startup", pipestream); | ||||
Show All 12 Lines |
Technically it's not possible, not since you use setvbuf. I would say something more like "disable stream buffering so fread(3) (called via au_read_rec(3)) doesn't buffer data unbeknownst to ppoll(2)"