149f52650SAlan Somers /*-
249f52650SAlan Somers * Copyright (c) 2018 Aniket Pandey
349f52650SAlan Somers *
449f52650SAlan Somers * Redistribution and use in source and binary forms, with or without
549f52650SAlan Somers * modification, are permitted provided that the following conditions
649f52650SAlan Somers * are met:
749f52650SAlan Somers * 1. Redistributions of source code must retain the above copyright
849f52650SAlan Somers * notice, this list of conditions and the following disclaimer.
949f52650SAlan Somers * 2. Redistributions in binary form must reproduce the above copyright
1049f52650SAlan Somers * notice, this list of conditions and the following disclaimer in the
1149f52650SAlan Somers * documentation and/or other materials provided with the distribution.
1249f52650SAlan Somers *
1349f52650SAlan Somers * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1449f52650SAlan Somers * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1549f52650SAlan Somers * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1649f52650SAlan Somers * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1749f52650SAlan Somers * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1849f52650SAlan Somers * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1949f52650SAlan Somers * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2049f52650SAlan Somers * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2149f52650SAlan Somers * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2249f52650SAlan Somers * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2349f52650SAlan Somers * SUCH DAMAGE.
2449f52650SAlan Somers */
2549f52650SAlan Somers
2649f52650SAlan Somers #include <sys/param.h>
2749f52650SAlan Somers #include <sys/mount.h>
28af045bbfSAlan Somers #include <sys/reboot.h>
29af045bbfSAlan Somers #include <sys/stat.h>
30af045bbfSAlan Somers #include <sys/sysctl.h>
3149f52650SAlan Somers #include <sys/time.h>
32af045bbfSAlan Somers #include <sys/timespec.h>
33af045bbfSAlan Somers #include <sys/timex.h>
34af045bbfSAlan Somers
35af045bbfSAlan Somers #include <bsm/audit.h>
36af045bbfSAlan Somers #include <bsm/audit_kevents.h>
37af045bbfSAlan Somers #include <ufs/ufs/quota.h>
3849f52650SAlan Somers
3949f52650SAlan Somers #include <atf-c.h>
400f1d973cSAlan Somers #include <errno.h>
4149f52650SAlan Somers #include <fcntl.h>
42af045bbfSAlan Somers #include <stdlib.h>
43af045bbfSAlan Somers #include <time.h>
4449f52650SAlan Somers #include <unistd.h>
4549f52650SAlan Somers
4649f52650SAlan Somers #include "utils.h"
4749f52650SAlan Somers
4849f52650SAlan Somers static pid_t pid;
4949f52650SAlan Somers static int filedesc;
500f1d973cSAlan Somers /* Default argument for handling ENOSYS in auditon(2) functions */
510f1d973cSAlan Somers static int auditon_def = 0;
5249f52650SAlan Somers static mode_t mode = 0777;
5349f52650SAlan Somers static struct pollfd fds[1];
54ff150beaSAlan Somers static char adregex[80];
5549f52650SAlan Somers static const char *auclass = "ad";
5649f52650SAlan Somers static const char *path = "fileforaudit";
57af045bbfSAlan Somers static const char *successreg = "fileforaudit.*return,success";
5849f52650SAlan Somers
5949f52650SAlan Somers
6049f52650SAlan Somers ATF_TC_WITH_CLEANUP(settimeofday_success);
ATF_TC_HEAD(settimeofday_success,tc)6149f52650SAlan Somers ATF_TC_HEAD(settimeofday_success, tc)
6249f52650SAlan Somers {
6349f52650SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
6449f52650SAlan Somers "settimeofday(2) call");
6549f52650SAlan Somers }
6649f52650SAlan Somers
ATF_TC_BODY(settimeofday_success,tc)6749f52650SAlan Somers ATF_TC_BODY(settimeofday_success, tc)
6849f52650SAlan Somers {
6949f52650SAlan Somers pid = getpid();
7049f52650SAlan Somers snprintf(adregex, sizeof(adregex), "settimeofday.*%d.*success", pid);
7149f52650SAlan Somers
7249f52650SAlan Somers struct timeval tp;
7349f52650SAlan Somers struct timezone tzp;
7449f52650SAlan Somers ATF_REQUIRE_EQ(0, gettimeofday(&tp, &tzp));
7549f52650SAlan Somers
7649f52650SAlan Somers FILE *pipefd = setup(fds, auclass);
7749f52650SAlan Somers /* Setting the same time as obtained by gettimeofday(2) */
7849f52650SAlan Somers ATF_REQUIRE_EQ(0, settimeofday(&tp, &tzp));
7949f52650SAlan Somers check_audit(fds, adregex, pipefd);
8049f52650SAlan Somers }
8149f52650SAlan Somers
ATF_TC_CLEANUP(settimeofday_success,tc)8249f52650SAlan Somers ATF_TC_CLEANUP(settimeofday_success, tc)
8349f52650SAlan Somers {
8449f52650SAlan Somers cleanup();
8549f52650SAlan Somers }
8649f52650SAlan Somers
8749f52650SAlan Somers
8849f52650SAlan Somers ATF_TC_WITH_CLEANUP(settimeofday_failure);
ATF_TC_HEAD(settimeofday_failure,tc)8949f52650SAlan Somers ATF_TC_HEAD(settimeofday_failure, tc)
9049f52650SAlan Somers {
9149f52650SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
9249f52650SAlan Somers "settimeofday(2) call");
9349f52650SAlan Somers }
9449f52650SAlan Somers
ATF_TC_BODY(settimeofday_failure,tc)9549f52650SAlan Somers ATF_TC_BODY(settimeofday_failure, tc)
9649f52650SAlan Somers {
9749f52650SAlan Somers pid = getpid();
9849f52650SAlan Somers snprintf(adregex, sizeof(adregex), "settimeofday.*%d.*failure", pid);
9949f52650SAlan Somers
10049f52650SAlan Somers struct timeval tp;
10149f52650SAlan Somers struct timezone tzp;
10249f52650SAlan Somers ATF_REQUIRE_EQ(0, gettimeofday(&tp, &tzp));
10349f52650SAlan Somers
10449f52650SAlan Somers FILE *pipefd = setup(fds, auclass);
10549f52650SAlan Somers tp.tv_sec = -1;
10649f52650SAlan Somers /* Failure reason: Invalid value for tp.tv_sec; */
10749f52650SAlan Somers ATF_REQUIRE_EQ(-1, settimeofday(&tp, &tzp));
10849f52650SAlan Somers check_audit(fds, adregex, pipefd);
10949f52650SAlan Somers }
11049f52650SAlan Somers
ATF_TC_CLEANUP(settimeofday_failure,tc)11149f52650SAlan Somers ATF_TC_CLEANUP(settimeofday_failure, tc)
11249f52650SAlan Somers {
11349f52650SAlan Somers cleanup();
11449f52650SAlan Somers }
11549f52650SAlan Somers
11649f52650SAlan Somers
117af045bbfSAlan Somers ATF_TC_WITH_CLEANUP(clock_settime_success);
ATF_TC_HEAD(clock_settime_success,tc)118af045bbfSAlan Somers ATF_TC_HEAD(clock_settime_success, tc)
119af045bbfSAlan Somers {
120af045bbfSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
121af045bbfSAlan Somers "clock_settime(2) call");
122af045bbfSAlan Somers }
123af045bbfSAlan Somers
ATF_TC_BODY(clock_settime_success,tc)124af045bbfSAlan Somers ATF_TC_BODY(clock_settime_success, tc)
125af045bbfSAlan Somers {
126af045bbfSAlan Somers pid = getpid();
127af045bbfSAlan Somers snprintf(adregex, sizeof(adregex), "clock_settime.*%d.*success", pid);
128af045bbfSAlan Somers
129af045bbfSAlan Somers struct timespec tp;
130af045bbfSAlan Somers ATF_REQUIRE_EQ(0, clock_gettime(CLOCK_REALTIME, &tp));
131af045bbfSAlan Somers
132af045bbfSAlan Somers FILE *pipefd = setup(fds, auclass);
133af045bbfSAlan Somers /* Setting the same time as obtained by clock_gettime(2) */
134af045bbfSAlan Somers ATF_REQUIRE_EQ(0, clock_settime(CLOCK_REALTIME, &tp));
135af045bbfSAlan Somers check_audit(fds, adregex, pipefd);
136af045bbfSAlan Somers }
137af045bbfSAlan Somers
ATF_TC_CLEANUP(clock_settime_success,tc)138af045bbfSAlan Somers ATF_TC_CLEANUP(clock_settime_success, tc)
139af045bbfSAlan Somers {
140af045bbfSAlan Somers cleanup();
141af045bbfSAlan Somers }
142af045bbfSAlan Somers
143af045bbfSAlan Somers
144af045bbfSAlan Somers ATF_TC_WITH_CLEANUP(clock_settime_failure);
ATF_TC_HEAD(clock_settime_failure,tc)145af045bbfSAlan Somers ATF_TC_HEAD(clock_settime_failure, tc)
146af045bbfSAlan Somers {
147af045bbfSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
148af045bbfSAlan Somers "clock_settime(2) call");
149af045bbfSAlan Somers }
150af045bbfSAlan Somers
ATF_TC_BODY(clock_settime_failure,tc)151af045bbfSAlan Somers ATF_TC_BODY(clock_settime_failure, tc)
152af045bbfSAlan Somers {
153af045bbfSAlan Somers pid = getpid();
154af045bbfSAlan Somers snprintf(adregex, sizeof(adregex), "clock_settime.*%d.*failure", pid);
155af045bbfSAlan Somers
156af045bbfSAlan Somers struct timespec tp;
157af045bbfSAlan Somers ATF_REQUIRE_EQ(0, clock_gettime(CLOCK_MONOTONIC, &tp));
158af045bbfSAlan Somers
159af045bbfSAlan Somers FILE *pipefd = setup(fds, auclass);
160af045bbfSAlan Somers /* Failure reason: cannot use CLOCK_MONOTONIC to set the system time */
161af045bbfSAlan Somers ATF_REQUIRE_EQ(-1, clock_settime(CLOCK_MONOTONIC, &tp));
162af045bbfSAlan Somers check_audit(fds, adregex, pipefd);
163af045bbfSAlan Somers }
164af045bbfSAlan Somers
ATF_TC_CLEANUP(clock_settime_failure,tc)165af045bbfSAlan Somers ATF_TC_CLEANUP(clock_settime_failure, tc)
166af045bbfSAlan Somers {
167af045bbfSAlan Somers cleanup();
168af045bbfSAlan Somers }
169af045bbfSAlan Somers
170af045bbfSAlan Somers
17149f52650SAlan Somers ATF_TC_WITH_CLEANUP(adjtime_success);
ATF_TC_HEAD(adjtime_success,tc)17249f52650SAlan Somers ATF_TC_HEAD(adjtime_success, tc)
17349f52650SAlan Somers {
17449f52650SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
17549f52650SAlan Somers "adjtime(2) call");
17649f52650SAlan Somers }
17749f52650SAlan Somers
ATF_TC_BODY(adjtime_success,tc)17849f52650SAlan Somers ATF_TC_BODY(adjtime_success, tc)
17949f52650SAlan Somers {
18049f52650SAlan Somers pid = getpid();
18149f52650SAlan Somers snprintf(adregex, sizeof(adregex), "adjtime.*%d.*return,success", pid);
18249f52650SAlan Somers
18349f52650SAlan Somers FILE *pipefd = setup(fds, auclass);
18449f52650SAlan Somers /* We don't want to change the system time, hence NULL */
18549f52650SAlan Somers ATF_REQUIRE_EQ(0, adjtime(NULL, NULL));
18649f52650SAlan Somers check_audit(fds, adregex, pipefd);
18749f52650SAlan Somers }
18849f52650SAlan Somers
ATF_TC_CLEANUP(adjtime_success,tc)18949f52650SAlan Somers ATF_TC_CLEANUP(adjtime_success, tc)
19049f52650SAlan Somers {
19149f52650SAlan Somers cleanup();
19249f52650SAlan Somers }
19349f52650SAlan Somers
19449f52650SAlan Somers
19549f52650SAlan Somers ATF_TC_WITH_CLEANUP(adjtime_failure);
ATF_TC_HEAD(adjtime_failure,tc)19649f52650SAlan Somers ATF_TC_HEAD(adjtime_failure, tc)
19749f52650SAlan Somers {
19849f52650SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
19949f52650SAlan Somers "adjtime(2) call");
20049f52650SAlan Somers }
20149f52650SAlan Somers
ATF_TC_BODY(adjtime_failure,tc)20249f52650SAlan Somers ATF_TC_BODY(adjtime_failure, tc)
20349f52650SAlan Somers {
20449f52650SAlan Somers pid = getpid();
20549f52650SAlan Somers snprintf(adregex, sizeof(adregex), "adjtime.*%d.*return,failure", pid);
20649f52650SAlan Somers
20749f52650SAlan Somers FILE *pipefd = setup(fds, auclass);
20849f52650SAlan Somers ATF_REQUIRE_EQ(-1, adjtime((struct timeval *)(-1), NULL));
20949f52650SAlan Somers check_audit(fds, adregex, pipefd);
21049f52650SAlan Somers }
21149f52650SAlan Somers
ATF_TC_CLEANUP(adjtime_failure,tc)21249f52650SAlan Somers ATF_TC_CLEANUP(adjtime_failure, tc)
21349f52650SAlan Somers {
21449f52650SAlan Somers cleanup();
21549f52650SAlan Somers }
21649f52650SAlan Somers
21749f52650SAlan Somers
218af045bbfSAlan Somers ATF_TC_WITH_CLEANUP(ntp_adjtime_success);
ATF_TC_HEAD(ntp_adjtime_success,tc)219af045bbfSAlan Somers ATF_TC_HEAD(ntp_adjtime_success, tc)
220af045bbfSAlan Somers {
221af045bbfSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
222af045bbfSAlan Somers "ntp_adjtime(2) call");
223af045bbfSAlan Somers }
224af045bbfSAlan Somers
ATF_TC_BODY(ntp_adjtime_success,tc)225af045bbfSAlan Somers ATF_TC_BODY(ntp_adjtime_success, tc)
226af045bbfSAlan Somers {
227af045bbfSAlan Somers struct timex timebuff;
228af045bbfSAlan Somers bzero(&timebuff, sizeof(timebuff));
229af045bbfSAlan Somers
230af045bbfSAlan Somers pid = getpid();
231af045bbfSAlan Somers snprintf(adregex, sizeof(adregex), "ntp_adjtime.*%d.*success", pid);
232af045bbfSAlan Somers
233af045bbfSAlan Somers FILE *pipefd = setup(fds, auclass);
234af045bbfSAlan Somers ATF_REQUIRE(ntp_adjtime(&timebuff) != -1);
235af045bbfSAlan Somers check_audit(fds, adregex, pipefd);
236af045bbfSAlan Somers }
237af045bbfSAlan Somers
ATF_TC_CLEANUP(ntp_adjtime_success,tc)238af045bbfSAlan Somers ATF_TC_CLEANUP(ntp_adjtime_success, tc)
239af045bbfSAlan Somers {
240af045bbfSAlan Somers cleanup();
241af045bbfSAlan Somers }
242af045bbfSAlan Somers
243af045bbfSAlan Somers
244af045bbfSAlan Somers ATF_TC_WITH_CLEANUP(ntp_adjtime_failure);
ATF_TC_HEAD(ntp_adjtime_failure,tc)245af045bbfSAlan Somers ATF_TC_HEAD(ntp_adjtime_failure, tc)
246af045bbfSAlan Somers {
247af045bbfSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
248af045bbfSAlan Somers "ntp_adjtime(2) call");
249af045bbfSAlan Somers }
250af045bbfSAlan Somers
ATF_TC_BODY(ntp_adjtime_failure,tc)251af045bbfSAlan Somers ATF_TC_BODY(ntp_adjtime_failure, tc)
252af045bbfSAlan Somers {
253af045bbfSAlan Somers pid = getpid();
254af045bbfSAlan Somers snprintf(adregex, sizeof(adregex), "ntp_adjtime.*%d.*failure", pid);
255af045bbfSAlan Somers
256af045bbfSAlan Somers FILE *pipefd = setup(fds, auclass);
257af045bbfSAlan Somers ATF_REQUIRE_EQ(-1, ntp_adjtime(NULL));
258af045bbfSAlan Somers check_audit(fds, adregex, pipefd);
259af045bbfSAlan Somers }
260af045bbfSAlan Somers
ATF_TC_CLEANUP(ntp_adjtime_failure,tc)261af045bbfSAlan Somers ATF_TC_CLEANUP(ntp_adjtime_failure, tc)
262af045bbfSAlan Somers {
263af045bbfSAlan Somers cleanup();
264af045bbfSAlan Somers }
265af045bbfSAlan Somers
26649f52650SAlan Somers
26749f52650SAlan Somers ATF_TC_WITH_CLEANUP(nfs_getfh_success);
ATF_TC_HEAD(nfs_getfh_success,tc)26849f52650SAlan Somers ATF_TC_HEAD(nfs_getfh_success, tc)
26949f52650SAlan Somers {
27049f52650SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
27149f52650SAlan Somers "getfh(2) call");
27249f52650SAlan Somers }
27349f52650SAlan Somers
ATF_TC_BODY(nfs_getfh_success,tc)27449f52650SAlan Somers ATF_TC_BODY(nfs_getfh_success, tc)
27549f52650SAlan Somers {
27649f52650SAlan Somers fhandle_t fhp;
27749f52650SAlan Somers pid = getpid();
27849f52650SAlan Somers snprintf(adregex, sizeof(adregex), "nfs_getfh.*%d.*ret.*success", pid);
27949f52650SAlan Somers
28049f52650SAlan Somers /* File needs to exist to call getfh(2) */
2815641c23fSAlan Somers ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
28249f52650SAlan Somers FILE *pipefd = setup(fds, auclass);
28349f52650SAlan Somers ATF_REQUIRE_EQ(0, getfh(path, &fhp));
28449f52650SAlan Somers check_audit(fds, adregex, pipefd);
28549f52650SAlan Somers close(filedesc);
28649f52650SAlan Somers }
28749f52650SAlan Somers
ATF_TC_CLEANUP(nfs_getfh_success,tc)28849f52650SAlan Somers ATF_TC_CLEANUP(nfs_getfh_success, tc)
28949f52650SAlan Somers {
29049f52650SAlan Somers cleanup();
29149f52650SAlan Somers }
29249f52650SAlan Somers
29349f52650SAlan Somers
29449f52650SAlan Somers ATF_TC_WITH_CLEANUP(nfs_getfh_failure);
ATF_TC_HEAD(nfs_getfh_failure,tc)29549f52650SAlan Somers ATF_TC_HEAD(nfs_getfh_failure, tc)
29649f52650SAlan Somers {
29749f52650SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
29849f52650SAlan Somers "getfh(2) call");
29949f52650SAlan Somers }
30049f52650SAlan Somers
ATF_TC_BODY(nfs_getfh_failure,tc)30149f52650SAlan Somers ATF_TC_BODY(nfs_getfh_failure, tc)
30249f52650SAlan Somers {
30349f52650SAlan Somers pid = getpid();
30449f52650SAlan Somers snprintf(adregex, sizeof(adregex), "nfs_getfh.*%d.*ret.*failure", pid);
30549f52650SAlan Somers
30649f52650SAlan Somers FILE *pipefd = setup(fds, auclass);
30749f52650SAlan Somers /* Failure reason: file does not exist */
30849f52650SAlan Somers ATF_REQUIRE_EQ(-1, getfh(path, NULL));
30949f52650SAlan Somers check_audit(fds, adregex, pipefd);
31049f52650SAlan Somers }
31149f52650SAlan Somers
ATF_TC_CLEANUP(nfs_getfh_failure,tc)31249f52650SAlan Somers ATF_TC_CLEANUP(nfs_getfh_failure, tc)
31349f52650SAlan Somers {
31449f52650SAlan Somers cleanup();
31549f52650SAlan Somers }
31649f52650SAlan Somers
31749f52650SAlan Somers
318af045bbfSAlan Somers ATF_TC_WITH_CLEANUP(auditctl_success);
ATF_TC_HEAD(auditctl_success,tc)319af045bbfSAlan Somers ATF_TC_HEAD(auditctl_success, tc)
320af045bbfSAlan Somers {
321af045bbfSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
322af045bbfSAlan Somers "auditctl(2) call");
323af045bbfSAlan Somers }
324af045bbfSAlan Somers
ATF_TC_BODY(auditctl_success,tc)325af045bbfSAlan Somers ATF_TC_BODY(auditctl_success, tc)
326af045bbfSAlan Somers {
327af045bbfSAlan Somers /* File needs to exist in order to call auditctl(2) */
328af045bbfSAlan Somers ATF_REQUIRE((filedesc = open(path, O_CREAT | O_WRONLY, mode)) != -1);
329af045bbfSAlan Somers FILE *pipefd = setup(fds, auclass);
330af045bbfSAlan Somers ATF_REQUIRE_EQ(0, auditctl(path));
331af045bbfSAlan Somers check_audit(fds, successreg, pipefd);
332af045bbfSAlan Somers close(filedesc);
333af045bbfSAlan Somers }
334af045bbfSAlan Somers
ATF_TC_CLEANUP(auditctl_success,tc)335af045bbfSAlan Somers ATF_TC_CLEANUP(auditctl_success, tc)
336af045bbfSAlan Somers {
337af045bbfSAlan Somers /*
338af045bbfSAlan Somers * auditctl(2) disables audit log at /var/audit and initiates auditing
339af045bbfSAlan Somers * at the configured path. To reset this, we need to stop and start the
340af045bbfSAlan Somers * auditd(8) again. Here, we check if auditd(8) was running already
341af045bbfSAlan Somers * before the test started. If so, we stop and start it again.
342df093aa9SAlex Richardson *
343df093aa9SAlex Richardson * TODO: should we skip this test if auditd(8) is already running to
344df093aa9SAlex Richardson * avoid restarting it?
345af045bbfSAlan Somers */
346df093aa9SAlex Richardson if (!atf_utils_file_exists("started_fake_auditd")) {
347af045bbfSAlan Somers system("service auditd onestop > /dev/null 2>&1");
348af045bbfSAlan Somers system("service auditd onestart > /dev/null 2>&1");
349df093aa9SAlex Richardson } else {
350df093aa9SAlex Richardson cleanup();
351df093aa9SAlex Richardson }
352af045bbfSAlan Somers }
353af045bbfSAlan Somers
354af045bbfSAlan Somers
355af045bbfSAlan Somers ATF_TC_WITH_CLEANUP(auditctl_failure);
ATF_TC_HEAD(auditctl_failure,tc)356af045bbfSAlan Somers ATF_TC_HEAD(auditctl_failure, tc)
357af045bbfSAlan Somers {
358af045bbfSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
359af045bbfSAlan Somers "auditctl(2) call");
360af045bbfSAlan Somers }
361af045bbfSAlan Somers
ATF_TC_BODY(auditctl_failure,tc)362af045bbfSAlan Somers ATF_TC_BODY(auditctl_failure, tc)
363af045bbfSAlan Somers {
364af045bbfSAlan Somers pid = getpid();
365af045bbfSAlan Somers snprintf(adregex, sizeof(adregex), "auditctl.*%d.*return,failure", pid);
366af045bbfSAlan Somers
367af045bbfSAlan Somers FILE *pipefd = setup(fds, auclass);
368af045bbfSAlan Somers /* Failure reason: file does not exist */
369af045bbfSAlan Somers ATF_REQUIRE_EQ(-1, auditctl(NULL));
370af045bbfSAlan Somers check_audit(fds, adregex, pipefd);
371af045bbfSAlan Somers }
372af045bbfSAlan Somers
ATF_TC_CLEANUP(auditctl_failure,tc)373af045bbfSAlan Somers ATF_TC_CLEANUP(auditctl_failure, tc)
374af045bbfSAlan Somers {
375af045bbfSAlan Somers cleanup();
376af045bbfSAlan Somers }
377af045bbfSAlan Somers
378af045bbfSAlan Somers
379af045bbfSAlan Somers ATF_TC_WITH_CLEANUP(acct_success);
ATF_TC_HEAD(acct_success,tc)380af045bbfSAlan Somers ATF_TC_HEAD(acct_success, tc)
381af045bbfSAlan Somers {
382af045bbfSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
383af045bbfSAlan Somers "acct(2) call");
3847fe3fd48SAlan Somers atf_tc_set_md_var(tc, "require.files",
3857fe3fd48SAlan Somers "/etc/rc.d/accounting /etc/rc.d/auditd");
386af045bbfSAlan Somers }
387af045bbfSAlan Somers
ATF_TC_BODY(acct_success,tc)388af045bbfSAlan Somers ATF_TC_BODY(acct_success, tc)
389af045bbfSAlan Somers {
390af045bbfSAlan Somers int acctinfo, filedesc2;
391af045bbfSAlan Somers size_t len = sizeof(acctinfo);
392af045bbfSAlan Somers const char *acctname = "kern.acct_configured";
393af045bbfSAlan Somers ATF_REQUIRE_EQ(0, sysctlbyname(acctname, &acctinfo, &len, NULL, 0));
394af045bbfSAlan Somers
395af045bbfSAlan Somers /* File needs to exist to start system accounting */
396af045bbfSAlan Somers ATF_REQUIRE((filedesc = open(path, O_CREAT | O_RDWR, mode)) != -1);
397af045bbfSAlan Somers
398af045bbfSAlan Somers /*
399af045bbfSAlan Somers * acctinfo = 0: System accounting was disabled
400af045bbfSAlan Somers * acctinfo = 1: System accounting was enabled
401af045bbfSAlan Somers */
402af045bbfSAlan Somers if (acctinfo) {
403af045bbfSAlan Somers ATF_REQUIRE((filedesc2 = open("acct_ok", O_CREAT, mode)) != -1);
404af045bbfSAlan Somers close(filedesc2);
405af045bbfSAlan Somers }
406af045bbfSAlan Somers
407af045bbfSAlan Somers pid = getpid();
408af045bbfSAlan Somers snprintf(adregex, sizeof(adregex),
409af045bbfSAlan Somers "acct.*%s.*%d.*return,success", path, pid);
410af045bbfSAlan Somers
411af045bbfSAlan Somers /*
412af045bbfSAlan Somers * We temporarily switch the accounting record to a file at
413af045bbfSAlan Somers * our own configured path in order to confirm acct(2)'s successful
414af045bbfSAlan Somers * auditing. Then we set everything back to its original state.
415af045bbfSAlan Somers */
416af045bbfSAlan Somers FILE *pipefd = setup(fds, auclass);
417af045bbfSAlan Somers ATF_REQUIRE_EQ(0, acct(path));
418af045bbfSAlan Somers check_audit(fds, adregex, pipefd);
419af045bbfSAlan Somers close(filedesc);
420af045bbfSAlan Somers }
421af045bbfSAlan Somers
ATF_TC_CLEANUP(acct_success,tc)422af045bbfSAlan Somers ATF_TC_CLEANUP(acct_success, tc)
423af045bbfSAlan Somers {
424af045bbfSAlan Somers /* Reset accounting configured path */
425af045bbfSAlan Somers ATF_REQUIRE_EQ(0, system("service accounting onestop"));
426af045bbfSAlan Somers if (atf_utils_file_exists("acct_ok")) {
427af045bbfSAlan Somers ATF_REQUIRE_EQ(0, system("service accounting onestart"));
428af045bbfSAlan Somers }
429af045bbfSAlan Somers cleanup();
430af045bbfSAlan Somers }
431af045bbfSAlan Somers
432af045bbfSAlan Somers
433af045bbfSAlan Somers ATF_TC_WITH_CLEANUP(acct_failure);
ATF_TC_HEAD(acct_failure,tc)434af045bbfSAlan Somers ATF_TC_HEAD(acct_failure, tc)
435af045bbfSAlan Somers {
436af045bbfSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
437af045bbfSAlan Somers "acct(2) call");
438af045bbfSAlan Somers }
439af045bbfSAlan Somers
ATF_TC_BODY(acct_failure,tc)440af045bbfSAlan Somers ATF_TC_BODY(acct_failure, tc)
441af045bbfSAlan Somers {
442af045bbfSAlan Somers pid = getpid();
443af045bbfSAlan Somers snprintf(adregex, sizeof(adregex), "acct.*%d.*return,failure", pid);
444af045bbfSAlan Somers
445af045bbfSAlan Somers FILE *pipefd = setup(fds, auclass);
446af045bbfSAlan Somers /* Failure reason: File does not exist */
447af045bbfSAlan Somers ATF_REQUIRE_EQ(-1, acct(path));
448af045bbfSAlan Somers check_audit(fds, adregex, pipefd);
449af045bbfSAlan Somers }
450af045bbfSAlan Somers
ATF_TC_CLEANUP(acct_failure,tc)451af045bbfSAlan Somers ATF_TC_CLEANUP(acct_failure, tc)
452af045bbfSAlan Somers {
453af045bbfSAlan Somers cleanup();
454af045bbfSAlan Somers }
455af045bbfSAlan Somers
456af045bbfSAlan Somers
457ff150beaSAlan Somers ATF_TC_WITH_CLEANUP(getauid_success);
ATF_TC_HEAD(getauid_success,tc)458ff150beaSAlan Somers ATF_TC_HEAD(getauid_success, tc)
459ff150beaSAlan Somers {
460ff150beaSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
461ff150beaSAlan Somers "getauid(2) call");
462ff150beaSAlan Somers }
463ff150beaSAlan Somers
ATF_TC_BODY(getauid_success,tc)464ff150beaSAlan Somers ATF_TC_BODY(getauid_success, tc)
465ff150beaSAlan Somers {
466ff150beaSAlan Somers au_id_t auid;
467ff150beaSAlan Somers pid = getpid();
468ff150beaSAlan Somers snprintf(adregex, sizeof(adregex), "getauid.*%d.*return,success", pid);
469ff150beaSAlan Somers
470ff150beaSAlan Somers FILE *pipefd = setup(fds, auclass);
471ff150beaSAlan Somers ATF_REQUIRE_EQ(0, getauid(&auid));
472ff150beaSAlan Somers check_audit(fds, adregex, pipefd);
473ff150beaSAlan Somers }
474ff150beaSAlan Somers
ATF_TC_CLEANUP(getauid_success,tc)475ff150beaSAlan Somers ATF_TC_CLEANUP(getauid_success, tc)
476ff150beaSAlan Somers {
477ff150beaSAlan Somers cleanup();
478ff150beaSAlan Somers }
479ff150beaSAlan Somers
480ff150beaSAlan Somers
481ff150beaSAlan Somers ATF_TC_WITH_CLEANUP(getauid_failure);
ATF_TC_HEAD(getauid_failure,tc)482ff150beaSAlan Somers ATF_TC_HEAD(getauid_failure, tc)
483ff150beaSAlan Somers {
484ff150beaSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
485ff150beaSAlan Somers "getauid(2) call");
486ff150beaSAlan Somers }
487ff150beaSAlan Somers
ATF_TC_BODY(getauid_failure,tc)488ff150beaSAlan Somers ATF_TC_BODY(getauid_failure, tc)
489ff150beaSAlan Somers {
490ff150beaSAlan Somers pid = getpid();
491ff150beaSAlan Somers snprintf(adregex, sizeof(adregex), "getauid.*%d.*return,failure", pid);
492ff150beaSAlan Somers
493ff150beaSAlan Somers FILE *pipefd = setup(fds, auclass);
494ff150beaSAlan Somers /* Failure reason: Bad address */
495ff150beaSAlan Somers ATF_REQUIRE_EQ(-1, getauid(NULL));
496ff150beaSAlan Somers check_audit(fds, adregex, pipefd);
497ff150beaSAlan Somers }
498ff150beaSAlan Somers
ATF_TC_CLEANUP(getauid_failure,tc)499ff150beaSAlan Somers ATF_TC_CLEANUP(getauid_failure, tc)
500ff150beaSAlan Somers {
501ff150beaSAlan Somers cleanup();
502ff150beaSAlan Somers }
503ff150beaSAlan Somers
504ff150beaSAlan Somers
505ff150beaSAlan Somers ATF_TC_WITH_CLEANUP(setauid_success);
ATF_TC_HEAD(setauid_success,tc)506ff150beaSAlan Somers ATF_TC_HEAD(setauid_success, tc)
507ff150beaSAlan Somers {
508ff150beaSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
509ff150beaSAlan Somers "setauid(2) call");
510ff150beaSAlan Somers }
511ff150beaSAlan Somers
ATF_TC_BODY(setauid_success,tc)512ff150beaSAlan Somers ATF_TC_BODY(setauid_success, tc)
513ff150beaSAlan Somers {
514ff150beaSAlan Somers au_id_t auid;
515ff150beaSAlan Somers pid = getpid();
516ff150beaSAlan Somers snprintf(adregex, sizeof(adregex), "setauid.*%d.*return,success", pid);
517ff150beaSAlan Somers ATF_REQUIRE_EQ(0, getauid(&auid));
518ff150beaSAlan Somers
519ff150beaSAlan Somers FILE *pipefd = setup(fds, auclass);
520ff150beaSAlan Somers ATF_REQUIRE_EQ(0, setauid(&auid));
521ff150beaSAlan Somers check_audit(fds, adregex, pipefd);
522ff150beaSAlan Somers }
523ff150beaSAlan Somers
ATF_TC_CLEANUP(setauid_success,tc)524ff150beaSAlan Somers ATF_TC_CLEANUP(setauid_success, tc)
525ff150beaSAlan Somers {
526ff150beaSAlan Somers cleanup();
527ff150beaSAlan Somers }
528ff150beaSAlan Somers
529ff150beaSAlan Somers
530ff150beaSAlan Somers ATF_TC_WITH_CLEANUP(setauid_failure);
ATF_TC_HEAD(setauid_failure,tc)531ff150beaSAlan Somers ATF_TC_HEAD(setauid_failure, tc)
532ff150beaSAlan Somers {
533ff150beaSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
534ff150beaSAlan Somers "setauid(2) call");
535ff150beaSAlan Somers }
536ff150beaSAlan Somers
ATF_TC_BODY(setauid_failure,tc)537ff150beaSAlan Somers ATF_TC_BODY(setauid_failure, tc)
538ff150beaSAlan Somers {
539ff150beaSAlan Somers pid = getpid();
540ff150beaSAlan Somers snprintf(adregex, sizeof(adregex), "setauid.*%d.*return,failure", pid);
541ff150beaSAlan Somers
542ff150beaSAlan Somers FILE *pipefd = setup(fds, auclass);
543ff150beaSAlan Somers /* Failure reason: Bad address */
544ff150beaSAlan Somers ATF_REQUIRE_EQ(-1, setauid(NULL));
545ff150beaSAlan Somers check_audit(fds, adregex, pipefd);
546ff150beaSAlan Somers }
547ff150beaSAlan Somers
ATF_TC_CLEANUP(setauid_failure,tc)548ff150beaSAlan Somers ATF_TC_CLEANUP(setauid_failure, tc)
549ff150beaSAlan Somers {
550ff150beaSAlan Somers cleanup();
551ff150beaSAlan Somers }
552ff150beaSAlan Somers
553ff150beaSAlan Somers
554ff150beaSAlan Somers ATF_TC_WITH_CLEANUP(getaudit_success);
ATF_TC_HEAD(getaudit_success,tc)555ff150beaSAlan Somers ATF_TC_HEAD(getaudit_success, tc)
556ff150beaSAlan Somers {
557ff150beaSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
558ff150beaSAlan Somers "getaudit(2) call");
559ff150beaSAlan Somers }
560ff150beaSAlan Somers
ATF_TC_BODY(getaudit_success,tc)561ff150beaSAlan Somers ATF_TC_BODY(getaudit_success, tc)
562ff150beaSAlan Somers {
563ff150beaSAlan Somers pid = getpid();
564ff150beaSAlan Somers auditinfo_t auditinfo;
565ff150beaSAlan Somers snprintf(adregex, sizeof(adregex), "getaudit.*%d.*return,success", pid);
566ff150beaSAlan Somers
567ff150beaSAlan Somers FILE *pipefd = setup(fds, auclass);
568ff150beaSAlan Somers ATF_REQUIRE_EQ(0, getaudit(&auditinfo));
569ff150beaSAlan Somers check_audit(fds, adregex, pipefd);
570ff150beaSAlan Somers }
571ff150beaSAlan Somers
ATF_TC_CLEANUP(getaudit_success,tc)572ff150beaSAlan Somers ATF_TC_CLEANUP(getaudit_success, tc)
573ff150beaSAlan Somers {
574ff150beaSAlan Somers cleanup();
575ff150beaSAlan Somers }
576ff150beaSAlan Somers
577ff150beaSAlan Somers
578ff150beaSAlan Somers ATF_TC_WITH_CLEANUP(getaudit_failure);
ATF_TC_HEAD(getaudit_failure,tc)579ff150beaSAlan Somers ATF_TC_HEAD(getaudit_failure, tc)
580ff150beaSAlan Somers {
581ff150beaSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
582ff150beaSAlan Somers "getaudit(2) call");
583ff150beaSAlan Somers }
584ff150beaSAlan Somers
ATF_TC_BODY(getaudit_failure,tc)585ff150beaSAlan Somers ATF_TC_BODY(getaudit_failure, tc)
586ff150beaSAlan Somers {
587ff150beaSAlan Somers pid = getpid();
588ff150beaSAlan Somers snprintf(adregex, sizeof(adregex), "getaudit.*%d.*return,failure", pid);
589ff150beaSAlan Somers
590ff150beaSAlan Somers FILE *pipefd = setup(fds, auclass);
591ff150beaSAlan Somers /* Failure reason: Bad address */
592ff150beaSAlan Somers ATF_REQUIRE_EQ(-1, getaudit(NULL));
593ff150beaSAlan Somers check_audit(fds, adregex, pipefd);
594ff150beaSAlan Somers }
595ff150beaSAlan Somers
ATF_TC_CLEANUP(getaudit_failure,tc)596ff150beaSAlan Somers ATF_TC_CLEANUP(getaudit_failure, tc)
597ff150beaSAlan Somers {
598ff150beaSAlan Somers cleanup();
599ff150beaSAlan Somers }
600ff150beaSAlan Somers
601ff150beaSAlan Somers
602ff150beaSAlan Somers ATF_TC_WITH_CLEANUP(setaudit_success);
ATF_TC_HEAD(setaudit_success,tc)603ff150beaSAlan Somers ATF_TC_HEAD(setaudit_success, tc)
604ff150beaSAlan Somers {
605ff150beaSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
606ff150beaSAlan Somers "setaudit(2) call");
607ff150beaSAlan Somers }
608ff150beaSAlan Somers
ATF_TC_BODY(setaudit_success,tc)609ff150beaSAlan Somers ATF_TC_BODY(setaudit_success, tc)
610ff150beaSAlan Somers {
611ff150beaSAlan Somers pid = getpid();
612ff150beaSAlan Somers auditinfo_t auditinfo;
613ff150beaSAlan Somers snprintf(adregex, sizeof(adregex), "setaudit.*%d.*return,success", pid);
614ff150beaSAlan Somers ATF_REQUIRE_EQ(0, getaudit(&auditinfo));
615ff150beaSAlan Somers
616ff150beaSAlan Somers FILE *pipefd = setup(fds, auclass);
617ff150beaSAlan Somers ATF_REQUIRE_EQ(0, setaudit(&auditinfo));
618ff150beaSAlan Somers check_audit(fds, adregex, pipefd);
619ff150beaSAlan Somers }
620ff150beaSAlan Somers
ATF_TC_CLEANUP(setaudit_success,tc)621ff150beaSAlan Somers ATF_TC_CLEANUP(setaudit_success, tc)
622ff150beaSAlan Somers {
623ff150beaSAlan Somers cleanup();
624ff150beaSAlan Somers }
625ff150beaSAlan Somers
626ff150beaSAlan Somers
627ff150beaSAlan Somers ATF_TC_WITH_CLEANUP(setaudit_failure);
ATF_TC_HEAD(setaudit_failure,tc)628ff150beaSAlan Somers ATF_TC_HEAD(setaudit_failure, tc)
629ff150beaSAlan Somers {
630ff150beaSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
631ff150beaSAlan Somers "setaudit(2) call");
632ff150beaSAlan Somers }
633ff150beaSAlan Somers
ATF_TC_BODY(setaudit_failure,tc)634ff150beaSAlan Somers ATF_TC_BODY(setaudit_failure, tc)
635ff150beaSAlan Somers {
636ff150beaSAlan Somers pid = getpid();
637ff150beaSAlan Somers snprintf(adregex, sizeof(adregex), "setaudit.*%d.*return,failure", pid);
638ff150beaSAlan Somers
639ff150beaSAlan Somers FILE *pipefd = setup(fds, auclass);
640ff150beaSAlan Somers /* Failure reason: Bad address */
641ff150beaSAlan Somers ATF_REQUIRE_EQ(-1, setaudit(NULL));
642ff150beaSAlan Somers check_audit(fds, adregex, pipefd);
643ff150beaSAlan Somers }
644ff150beaSAlan Somers
ATF_TC_CLEANUP(setaudit_failure,tc)645ff150beaSAlan Somers ATF_TC_CLEANUP(setaudit_failure, tc)
646ff150beaSAlan Somers {
647ff150beaSAlan Somers cleanup();
648ff150beaSAlan Somers }
649ff150beaSAlan Somers
650ff150beaSAlan Somers
651ff150beaSAlan Somers ATF_TC_WITH_CLEANUP(getaudit_addr_success);
ATF_TC_HEAD(getaudit_addr_success,tc)652ff150beaSAlan Somers ATF_TC_HEAD(getaudit_addr_success, tc)
653ff150beaSAlan Somers {
654ff150beaSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
655ff150beaSAlan Somers "getaudit_addr(2) call");
656ff150beaSAlan Somers }
657ff150beaSAlan Somers
ATF_TC_BODY(getaudit_addr_success,tc)658ff150beaSAlan Somers ATF_TC_BODY(getaudit_addr_success, tc)
659ff150beaSAlan Somers {
660ff150beaSAlan Somers pid = getpid();
661ff150beaSAlan Somers auditinfo_addr_t auditinfo;
662ff150beaSAlan Somers snprintf(adregex, sizeof(adregex),
663ff150beaSAlan Somers "getaudit_addr.*%d.*return,success", pid);
664ff150beaSAlan Somers
665ff150beaSAlan Somers FILE *pipefd = setup(fds, auclass);
666ff150beaSAlan Somers ATF_REQUIRE_EQ(0, getaudit_addr(&auditinfo, sizeof(auditinfo)));
667ff150beaSAlan Somers check_audit(fds, adregex, pipefd);
668ff150beaSAlan Somers }
669ff150beaSAlan Somers
ATF_TC_CLEANUP(getaudit_addr_success,tc)670ff150beaSAlan Somers ATF_TC_CLEANUP(getaudit_addr_success, tc)
671ff150beaSAlan Somers {
672ff150beaSAlan Somers cleanup();
673ff150beaSAlan Somers }
674ff150beaSAlan Somers
675ff150beaSAlan Somers
676ff150beaSAlan Somers ATF_TC_WITH_CLEANUP(getaudit_addr_failure);
ATF_TC_HEAD(getaudit_addr_failure,tc)677ff150beaSAlan Somers ATF_TC_HEAD(getaudit_addr_failure, tc)
678ff150beaSAlan Somers {
679ff150beaSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
680ff150beaSAlan Somers "getaudit_addr(2) call");
681ff150beaSAlan Somers }
682ff150beaSAlan Somers
ATF_TC_BODY(getaudit_addr_failure,tc)683ff150beaSAlan Somers ATF_TC_BODY(getaudit_addr_failure, tc)
684ff150beaSAlan Somers {
685ff150beaSAlan Somers pid = getpid();
686ff150beaSAlan Somers snprintf(adregex, sizeof(adregex),
687ff150beaSAlan Somers "getaudit_addr.*%d.*return,failure", pid);
688ff150beaSAlan Somers
689ff150beaSAlan Somers FILE *pipefd = setup(fds, auclass);
690ff150beaSAlan Somers /* Failure reason: Bad address */
691ff150beaSAlan Somers ATF_REQUIRE_EQ(-1, getaudit_addr(NULL, 0));
692ff150beaSAlan Somers check_audit(fds, adregex, pipefd);
693ff150beaSAlan Somers }
694ff150beaSAlan Somers
ATF_TC_CLEANUP(getaudit_addr_failure,tc)695ff150beaSAlan Somers ATF_TC_CLEANUP(getaudit_addr_failure, tc)
696ff150beaSAlan Somers {
697ff150beaSAlan Somers cleanup();
698ff150beaSAlan Somers }
699ff150beaSAlan Somers
700ff150beaSAlan Somers
701ff150beaSAlan Somers ATF_TC_WITH_CLEANUP(setaudit_addr_success);
ATF_TC_HEAD(setaudit_addr_success,tc)702ff150beaSAlan Somers ATF_TC_HEAD(setaudit_addr_success, tc)
703ff150beaSAlan Somers {
704ff150beaSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
705ff150beaSAlan Somers "setaudit_addr(2) call");
706ff150beaSAlan Somers }
707ff150beaSAlan Somers
ATF_TC_BODY(setaudit_addr_success,tc)708ff150beaSAlan Somers ATF_TC_BODY(setaudit_addr_success, tc)
709ff150beaSAlan Somers {
710ff150beaSAlan Somers pid = getpid();
711ff150beaSAlan Somers auditinfo_addr_t auditinfo;
712ff150beaSAlan Somers snprintf(adregex, sizeof(adregex),
713ff150beaSAlan Somers "setaudit_addr.*%d.*return,success", pid);
714ff150beaSAlan Somers
715ff150beaSAlan Somers ATF_REQUIRE_EQ(0, getaudit_addr(&auditinfo, sizeof(auditinfo)));
716ff150beaSAlan Somers FILE *pipefd = setup(fds, auclass);
717ff150beaSAlan Somers ATF_REQUIRE_EQ(0, setaudit_addr(&auditinfo, sizeof(auditinfo)));
718ff150beaSAlan Somers check_audit(fds, adregex, pipefd);
719ff150beaSAlan Somers }
720ff150beaSAlan Somers
ATF_TC_CLEANUP(setaudit_addr_success,tc)721ff150beaSAlan Somers ATF_TC_CLEANUP(setaudit_addr_success, tc)
722ff150beaSAlan Somers {
723ff150beaSAlan Somers cleanup();
724ff150beaSAlan Somers }
725ff150beaSAlan Somers
726ff150beaSAlan Somers
727ff150beaSAlan Somers ATF_TC_WITH_CLEANUP(setaudit_addr_failure);
ATF_TC_HEAD(setaudit_addr_failure,tc)728ff150beaSAlan Somers ATF_TC_HEAD(setaudit_addr_failure, tc)
729ff150beaSAlan Somers {
730ff150beaSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
731ff150beaSAlan Somers "setaudit_addr(2) call");
732ff150beaSAlan Somers }
733ff150beaSAlan Somers
ATF_TC_BODY(setaudit_addr_failure,tc)734ff150beaSAlan Somers ATF_TC_BODY(setaudit_addr_failure, tc)
735ff150beaSAlan Somers {
736ff150beaSAlan Somers pid = getpid();
737ff150beaSAlan Somers snprintf(adregex, sizeof(adregex),
738ff150beaSAlan Somers "setaudit_addr.*%d.*return,failure", pid);
739ff150beaSAlan Somers
740ff150beaSAlan Somers FILE *pipefd = setup(fds, auclass);
741ff150beaSAlan Somers /* Failure reason: Bad address */
742ff150beaSAlan Somers ATF_REQUIRE_EQ(-1, setaudit_addr(NULL, 0));
743ff150beaSAlan Somers check_audit(fds, adregex, pipefd);
744ff150beaSAlan Somers }
745ff150beaSAlan Somers
ATF_TC_CLEANUP(setaudit_addr_failure,tc)746ff150beaSAlan Somers ATF_TC_CLEANUP(setaudit_addr_failure, tc)
747ff150beaSAlan Somers {
748ff150beaSAlan Somers cleanup();
749ff150beaSAlan Somers }
750ff150beaSAlan Somers
7510f1d973cSAlan Somers /*
7520f1d973cSAlan Somers * Note: The test-case uses A_GETFSIZE as the command argument but since it is
7530f1d973cSAlan Somers * not an independent audit event, it will be used to check the default mode
7540f1d973cSAlan Somers * auditing of auditon(2) system call.
7550f1d973cSAlan Somers *
7560f1d973cSAlan Somers * Please See: sys/security/audit/audit_bsm_klib.c
7570f1d973cSAlan Somers * function(): au_event_t auditon_command_event() :: case A_GETFSIZE:
7580f1d973cSAlan Somers */
7590f1d973cSAlan Somers ATF_TC_WITH_CLEANUP(auditon_default_success);
ATF_TC_HEAD(auditon_default_success,tc)7600f1d973cSAlan Somers ATF_TC_HEAD(auditon_default_success, tc)
7610f1d973cSAlan Somers {
7620f1d973cSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
7630f1d973cSAlan Somers "auditon(2) call");
7640f1d973cSAlan Somers }
7650f1d973cSAlan Somers
ATF_TC_BODY(auditon_default_success,tc)7660f1d973cSAlan Somers ATF_TC_BODY(auditon_default_success, tc)
7670f1d973cSAlan Somers {
7680f1d973cSAlan Somers au_fstat_t fsize_arg;
7690f1d973cSAlan Somers bzero(&fsize_arg, sizeof(au_fstat_t));
7700f1d973cSAlan Somers
7710f1d973cSAlan Somers pid = getpid();
7720f1d973cSAlan Somers snprintf(adregex, sizeof(adregex), "auditon.*%d.*return,success", pid);
7730f1d973cSAlan Somers
7740f1d973cSAlan Somers FILE *pipefd = setup(fds, auclass);
7750f1d973cSAlan Somers ATF_REQUIRE_EQ(0, auditon(A_GETFSIZE, &fsize_arg, sizeof(fsize_arg)));
7760f1d973cSAlan Somers check_audit(fds, adregex, pipefd);
7770f1d973cSAlan Somers }
7780f1d973cSAlan Somers
ATF_TC_CLEANUP(auditon_default_success,tc)7790f1d973cSAlan Somers ATF_TC_CLEANUP(auditon_default_success, tc)
7800f1d973cSAlan Somers {
7810f1d973cSAlan Somers cleanup();
7820f1d973cSAlan Somers }
7830f1d973cSAlan Somers
7840f1d973cSAlan Somers
7850f1d973cSAlan Somers ATF_TC_WITH_CLEANUP(auditon_default_failure);
ATF_TC_HEAD(auditon_default_failure,tc)7860f1d973cSAlan Somers ATF_TC_HEAD(auditon_default_failure, tc)
7870f1d973cSAlan Somers {
7880f1d973cSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
7890f1d973cSAlan Somers "auditon(2) call");
7900f1d973cSAlan Somers }
7910f1d973cSAlan Somers
ATF_TC_BODY(auditon_default_failure,tc)7920f1d973cSAlan Somers ATF_TC_BODY(auditon_default_failure, tc)
7930f1d973cSAlan Somers {
7940f1d973cSAlan Somers pid = getpid();
7950f1d973cSAlan Somers snprintf(adregex, sizeof(adregex), "auditon.*%d.*return,failure", pid);
7960f1d973cSAlan Somers
7970f1d973cSAlan Somers FILE *pipefd = setup(fds, auclass);
7980f1d973cSAlan Somers /* Failure reason: Invalid argument */
7990f1d973cSAlan Somers ATF_REQUIRE_EQ(-1, auditon(A_GETFSIZE, NULL, 0));
8000f1d973cSAlan Somers check_audit(fds, adregex, pipefd);
8010f1d973cSAlan Somers }
8020f1d973cSAlan Somers
ATF_TC_CLEANUP(auditon_default_failure,tc)8030f1d973cSAlan Somers ATF_TC_CLEANUP(auditon_default_failure, tc)
8040f1d973cSAlan Somers {
8050f1d973cSAlan Somers cleanup();
8060f1d973cSAlan Somers }
8070f1d973cSAlan Somers
808ff150beaSAlan Somers
80919fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_getpolicy_success);
ATF_TC_HEAD(auditon_getpolicy_success,tc)81019fa6fe6SAlan Somers ATF_TC_HEAD(auditon_getpolicy_success, tc)
81119fa6fe6SAlan Somers {
81219fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
81319fa6fe6SAlan Somers "auditon(2) call for cmd: A_GETPOLICY");
81419fa6fe6SAlan Somers }
81519fa6fe6SAlan Somers
ATF_TC_BODY(auditon_getpolicy_success,tc)81619fa6fe6SAlan Somers ATF_TC_BODY(auditon_getpolicy_success, tc)
81719fa6fe6SAlan Somers {
81819fa6fe6SAlan Somers int aupolicy;
81919fa6fe6SAlan Somers pid = getpid();
82019fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "GPOLICY command.*%d.*success", pid);
82119fa6fe6SAlan Somers
82219fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
82319fa6fe6SAlan Somers ATF_REQUIRE_EQ(0, auditon(A_GETPOLICY, &aupolicy, sizeof(aupolicy)));
82419fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
82519fa6fe6SAlan Somers }
82619fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_getpolicy_success,tc)82719fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_getpolicy_success, tc)
82819fa6fe6SAlan Somers {
82919fa6fe6SAlan Somers cleanup();
83019fa6fe6SAlan Somers }
83119fa6fe6SAlan Somers
83219fa6fe6SAlan Somers
83319fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_getpolicy_failure);
ATF_TC_HEAD(auditon_getpolicy_failure,tc)83419fa6fe6SAlan Somers ATF_TC_HEAD(auditon_getpolicy_failure, tc)
83519fa6fe6SAlan Somers {
83619fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
83719fa6fe6SAlan Somers "auditon(2) call for cmd: A_GETPOLICY");
83819fa6fe6SAlan Somers }
83919fa6fe6SAlan Somers
ATF_TC_BODY(auditon_getpolicy_failure,tc)84019fa6fe6SAlan Somers ATF_TC_BODY(auditon_getpolicy_failure, tc)
84119fa6fe6SAlan Somers {
84219fa6fe6SAlan Somers pid = getpid();
84319fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "GPOLICY command.*%d.*failure", pid);
84419fa6fe6SAlan Somers
84519fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
84619fa6fe6SAlan Somers /* Failure reason: Invalid argument */
84719fa6fe6SAlan Somers ATF_REQUIRE_EQ(-1, auditon(A_GETPOLICY, NULL, 0));
84819fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
84919fa6fe6SAlan Somers }
85019fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_getpolicy_failure,tc)85119fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_getpolicy_failure, tc)
85219fa6fe6SAlan Somers {
85319fa6fe6SAlan Somers cleanup();
85419fa6fe6SAlan Somers }
85519fa6fe6SAlan Somers
85619fa6fe6SAlan Somers
85719fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_setpolicy_success);
ATF_TC_HEAD(auditon_setpolicy_success,tc)85819fa6fe6SAlan Somers ATF_TC_HEAD(auditon_setpolicy_success, tc)
85919fa6fe6SAlan Somers {
86019fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
86119fa6fe6SAlan Somers "auditon(2) call for cmd: A_SETPOLICY");
86219fa6fe6SAlan Somers }
86319fa6fe6SAlan Somers
ATF_TC_BODY(auditon_setpolicy_success,tc)86419fa6fe6SAlan Somers ATF_TC_BODY(auditon_setpolicy_success, tc)
86519fa6fe6SAlan Somers {
86619fa6fe6SAlan Somers int aupolicy;
86719fa6fe6SAlan Somers pid = getpid();
86819fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "SPOLICY command.*%d.*success", pid);
86919fa6fe6SAlan Somers
87019fa6fe6SAlan Somers /* Retrieve the current auditing policy, to be used with A_SETPOLICY */
87119fa6fe6SAlan Somers ATF_REQUIRE_EQ(0, auditon(A_GETPOLICY, &aupolicy, sizeof(aupolicy)));
87219fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
87319fa6fe6SAlan Somers ATF_REQUIRE_EQ(0, auditon(A_SETPOLICY, &aupolicy, sizeof(aupolicy)));
87419fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
87519fa6fe6SAlan Somers }
87619fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_setpolicy_success,tc)87719fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_setpolicy_success, tc)
87819fa6fe6SAlan Somers {
87919fa6fe6SAlan Somers cleanup();
88019fa6fe6SAlan Somers }
88119fa6fe6SAlan Somers
88219fa6fe6SAlan Somers
88319fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_setpolicy_failure);
ATF_TC_HEAD(auditon_setpolicy_failure,tc)88419fa6fe6SAlan Somers ATF_TC_HEAD(auditon_setpolicy_failure, tc)
88519fa6fe6SAlan Somers {
88619fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
88719fa6fe6SAlan Somers "auditon(2) call for cmd: A_SETPOLICY");
88819fa6fe6SAlan Somers }
88919fa6fe6SAlan Somers
ATF_TC_BODY(auditon_setpolicy_failure,tc)89019fa6fe6SAlan Somers ATF_TC_BODY(auditon_setpolicy_failure, tc)
89119fa6fe6SAlan Somers {
89219fa6fe6SAlan Somers pid = getpid();
89319fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "SPOLICY command.*%d.*failure", pid);
89419fa6fe6SAlan Somers
89519fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
89619fa6fe6SAlan Somers /* Failure reason: Invalid argument */
89719fa6fe6SAlan Somers ATF_REQUIRE_EQ(-1, auditon(A_SETPOLICY, NULL, 0));
89819fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
89919fa6fe6SAlan Somers }
90019fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_setpolicy_failure,tc)90119fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_setpolicy_failure, tc)
90219fa6fe6SAlan Somers {
90319fa6fe6SAlan Somers cleanup();
90419fa6fe6SAlan Somers }
90519fa6fe6SAlan Somers
90619fa6fe6SAlan Somers
90719fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_getkmask_success);
ATF_TC_HEAD(auditon_getkmask_success,tc)90819fa6fe6SAlan Somers ATF_TC_HEAD(auditon_getkmask_success, tc)
90919fa6fe6SAlan Somers {
91019fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
91119fa6fe6SAlan Somers "auditon(2) call for cmd: A_GETKMASK");
91219fa6fe6SAlan Somers }
91319fa6fe6SAlan Somers
ATF_TC_BODY(auditon_getkmask_success,tc)91419fa6fe6SAlan Somers ATF_TC_BODY(auditon_getkmask_success, tc)
91519fa6fe6SAlan Somers {
91619fa6fe6SAlan Somers pid = getpid();
91719fa6fe6SAlan Somers au_mask_t evmask;
91819fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "get kernel mask.*%d.*success", pid);
91919fa6fe6SAlan Somers
92019fa6fe6SAlan Somers bzero(&evmask, sizeof(evmask));
92119fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
92219fa6fe6SAlan Somers ATF_REQUIRE_EQ(0, auditon(A_GETKMASK, &evmask, sizeof(evmask)));
92319fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
92419fa6fe6SAlan Somers }
92519fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_getkmask_success,tc)92619fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_getkmask_success, tc)
92719fa6fe6SAlan Somers {
92819fa6fe6SAlan Somers cleanup();
92919fa6fe6SAlan Somers }
93019fa6fe6SAlan Somers
93119fa6fe6SAlan Somers
93219fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_getkmask_failure);
ATF_TC_HEAD(auditon_getkmask_failure,tc)93319fa6fe6SAlan Somers ATF_TC_HEAD(auditon_getkmask_failure, tc)
93419fa6fe6SAlan Somers {
93519fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
93619fa6fe6SAlan Somers "auditon(2) call for cmd: A_GETKMASK");
93719fa6fe6SAlan Somers }
93819fa6fe6SAlan Somers
ATF_TC_BODY(auditon_getkmask_failure,tc)93919fa6fe6SAlan Somers ATF_TC_BODY(auditon_getkmask_failure, tc)
94019fa6fe6SAlan Somers {
94119fa6fe6SAlan Somers pid = getpid();
94219fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "get kernel mask.*%d.*failure", pid);
94319fa6fe6SAlan Somers
94419fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
94519fa6fe6SAlan Somers /* Failure reason: Invalid au_mask_t structure */
94619fa6fe6SAlan Somers ATF_REQUIRE_EQ(-1, auditon(A_GETKMASK, NULL, 0));
94719fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
94819fa6fe6SAlan Somers }
94919fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_getkmask_failure,tc)95019fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_getkmask_failure, tc)
95119fa6fe6SAlan Somers {
95219fa6fe6SAlan Somers cleanup();
95319fa6fe6SAlan Somers }
95419fa6fe6SAlan Somers
95519fa6fe6SAlan Somers
95619fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_setkmask_success);
ATF_TC_HEAD(auditon_setkmask_success,tc)95719fa6fe6SAlan Somers ATF_TC_HEAD(auditon_setkmask_success, tc)
95819fa6fe6SAlan Somers {
95919fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
96019fa6fe6SAlan Somers "auditon(2) call for cmd: A_SETKMASK");
96119fa6fe6SAlan Somers }
96219fa6fe6SAlan Somers
ATF_TC_BODY(auditon_setkmask_success,tc)96319fa6fe6SAlan Somers ATF_TC_BODY(auditon_setkmask_success, tc)
96419fa6fe6SAlan Somers {
96519fa6fe6SAlan Somers pid = getpid();
96619fa6fe6SAlan Somers au_mask_t evmask;
96719fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "set kernel mask.*%d.*success", pid);
96819fa6fe6SAlan Somers
96919fa6fe6SAlan Somers /* Retrieve the current audit mask to be used with A_SETKMASK */
97019fa6fe6SAlan Somers bzero(&evmask, sizeof(evmask));
97119fa6fe6SAlan Somers ATF_REQUIRE_EQ(0, auditon(A_GETKMASK, &evmask, sizeof(evmask)));
97219fa6fe6SAlan Somers
97319fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
97419fa6fe6SAlan Somers ATF_REQUIRE_EQ(0, auditon(A_SETKMASK, &evmask, sizeof(evmask)));
97519fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
97619fa6fe6SAlan Somers }
97719fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_setkmask_success,tc)97819fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_setkmask_success, tc)
97919fa6fe6SAlan Somers {
98019fa6fe6SAlan Somers cleanup();
98119fa6fe6SAlan Somers }
98219fa6fe6SAlan Somers
98319fa6fe6SAlan Somers
98419fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_setkmask_failure);
ATF_TC_HEAD(auditon_setkmask_failure,tc)98519fa6fe6SAlan Somers ATF_TC_HEAD(auditon_setkmask_failure, tc)
98619fa6fe6SAlan Somers {
98719fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
98819fa6fe6SAlan Somers "auditon(2) call for cmd: A_SETKMASK");
98919fa6fe6SAlan Somers }
99019fa6fe6SAlan Somers
ATF_TC_BODY(auditon_setkmask_failure,tc)99119fa6fe6SAlan Somers ATF_TC_BODY(auditon_setkmask_failure, tc)
99219fa6fe6SAlan Somers {
99319fa6fe6SAlan Somers pid = getpid();
99419fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "set kernel mask.*%d.*failure", pid);
99519fa6fe6SAlan Somers
99619fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
99719fa6fe6SAlan Somers /* Failure reason: Invalid au_mask_t structure */
99819fa6fe6SAlan Somers ATF_REQUIRE_EQ(-1, auditon(A_SETKMASK, NULL, 0));
99919fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
100019fa6fe6SAlan Somers }
100119fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_setkmask_failure,tc)100219fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_setkmask_failure, tc)
100319fa6fe6SAlan Somers {
100419fa6fe6SAlan Somers cleanup();
100519fa6fe6SAlan Somers }
100619fa6fe6SAlan Somers
100719fa6fe6SAlan Somers
100819fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_getqctrl_success);
ATF_TC_HEAD(auditon_getqctrl_success,tc)100919fa6fe6SAlan Somers ATF_TC_HEAD(auditon_getqctrl_success, tc)
101019fa6fe6SAlan Somers {
101119fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
101219fa6fe6SAlan Somers "auditon(2) call for cmd: A_GETQCTRL");
101319fa6fe6SAlan Somers }
101419fa6fe6SAlan Somers
ATF_TC_BODY(auditon_getqctrl_success,tc)101519fa6fe6SAlan Somers ATF_TC_BODY(auditon_getqctrl_success, tc)
101619fa6fe6SAlan Somers {
101719fa6fe6SAlan Somers pid = getpid();
101819fa6fe6SAlan Somers au_qctrl_t evqctrl;
101919fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "GQCTRL command.*%d.*success", pid);
102019fa6fe6SAlan Somers
102119fa6fe6SAlan Somers bzero(&evqctrl, sizeof(evqctrl));
102219fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
102319fa6fe6SAlan Somers ATF_REQUIRE_EQ(0, auditon(A_GETQCTRL, &evqctrl, sizeof(evqctrl)));
102419fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
102519fa6fe6SAlan Somers }
102619fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_getqctrl_success,tc)102719fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_getqctrl_success, tc)
102819fa6fe6SAlan Somers {
102919fa6fe6SAlan Somers cleanup();
103019fa6fe6SAlan Somers }
103119fa6fe6SAlan Somers
103219fa6fe6SAlan Somers
103319fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_getqctrl_failure);
ATF_TC_HEAD(auditon_getqctrl_failure,tc)103419fa6fe6SAlan Somers ATF_TC_HEAD(auditon_getqctrl_failure, tc)
103519fa6fe6SAlan Somers {
103619fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
103719fa6fe6SAlan Somers "auditon(2) call for cmd: A_GETQCTRL");
103819fa6fe6SAlan Somers }
103919fa6fe6SAlan Somers
ATF_TC_BODY(auditon_getqctrl_failure,tc)104019fa6fe6SAlan Somers ATF_TC_BODY(auditon_getqctrl_failure, tc)
104119fa6fe6SAlan Somers {
104219fa6fe6SAlan Somers pid = getpid();
104319fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "GQCTRL command.*%d.*failure", pid);
104419fa6fe6SAlan Somers
104519fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
104619fa6fe6SAlan Somers /* Failure reason: Invalid au_qctrl_t structure */
104719fa6fe6SAlan Somers ATF_REQUIRE_EQ(-1, auditon(A_GETQCTRL, NULL, 0));
104819fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
104919fa6fe6SAlan Somers }
105019fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_getqctrl_failure,tc)105119fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_getqctrl_failure, tc)
105219fa6fe6SAlan Somers {
105319fa6fe6SAlan Somers cleanup();
105419fa6fe6SAlan Somers }
105519fa6fe6SAlan Somers
105619fa6fe6SAlan Somers
105719fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_setqctrl_success);
ATF_TC_HEAD(auditon_setqctrl_success,tc)105819fa6fe6SAlan Somers ATF_TC_HEAD(auditon_setqctrl_success, tc)
105919fa6fe6SAlan Somers {
106019fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
106119fa6fe6SAlan Somers "auditon(2) call for cmd: A_SETKMASK");
106219fa6fe6SAlan Somers }
106319fa6fe6SAlan Somers
ATF_TC_BODY(auditon_setqctrl_success,tc)106419fa6fe6SAlan Somers ATF_TC_BODY(auditon_setqctrl_success, tc)
106519fa6fe6SAlan Somers {
106619fa6fe6SAlan Somers pid = getpid();
106719fa6fe6SAlan Somers au_qctrl_t evqctrl;
106819fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "SQCTRL command.*%d.*success", pid);
106919fa6fe6SAlan Somers
107019fa6fe6SAlan Somers /* Retrieve the current audit mask to be used with A_SETQCTRL */
107119fa6fe6SAlan Somers bzero(&evqctrl, sizeof(evqctrl));
107219fa6fe6SAlan Somers ATF_REQUIRE_EQ(0, auditon(A_GETQCTRL, &evqctrl, sizeof(evqctrl)));
107319fa6fe6SAlan Somers
107419fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
107519fa6fe6SAlan Somers ATF_REQUIRE_EQ(0, auditon(A_SETQCTRL, &evqctrl, sizeof(evqctrl)));
107619fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
107719fa6fe6SAlan Somers }
107819fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_setqctrl_success,tc)107919fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_setqctrl_success, tc)
108019fa6fe6SAlan Somers {
108119fa6fe6SAlan Somers cleanup();
108219fa6fe6SAlan Somers }
108319fa6fe6SAlan Somers
108419fa6fe6SAlan Somers
108519fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_setqctrl_failure);
ATF_TC_HEAD(auditon_setqctrl_failure,tc)108619fa6fe6SAlan Somers ATF_TC_HEAD(auditon_setqctrl_failure, tc)
108719fa6fe6SAlan Somers {
108819fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
108919fa6fe6SAlan Somers "auditon(2) call for cmd: A_SETKMASK");
109019fa6fe6SAlan Somers }
109119fa6fe6SAlan Somers
ATF_TC_BODY(auditon_setqctrl_failure,tc)109219fa6fe6SAlan Somers ATF_TC_BODY(auditon_setqctrl_failure, tc)
109319fa6fe6SAlan Somers {
109419fa6fe6SAlan Somers pid = getpid();
109519fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "SQCTRL command.*%d.*failure", pid);
109619fa6fe6SAlan Somers
109719fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
109819fa6fe6SAlan Somers /* Failure reason: Invalid au_qctrl_t structure */
109919fa6fe6SAlan Somers ATF_REQUIRE_EQ(-1, auditon(A_SETQCTRL, NULL, 0));
110019fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
110119fa6fe6SAlan Somers }
110219fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_setqctrl_failure,tc)110319fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_setqctrl_failure, tc)
110419fa6fe6SAlan Somers {
110519fa6fe6SAlan Somers cleanup();
110619fa6fe6SAlan Somers }
110719fa6fe6SAlan Somers
110819fa6fe6SAlan Somers
110919fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_getclass_success);
ATF_TC_HEAD(auditon_getclass_success,tc)111019fa6fe6SAlan Somers ATF_TC_HEAD(auditon_getclass_success, tc)
111119fa6fe6SAlan Somers {
111219fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
111319fa6fe6SAlan Somers "auditon(2) call for cmd: A_GETCLASS");
111419fa6fe6SAlan Somers }
111519fa6fe6SAlan Somers
ATF_TC_BODY(auditon_getclass_success,tc)111619fa6fe6SAlan Somers ATF_TC_BODY(auditon_getclass_success, tc)
111719fa6fe6SAlan Somers {
111819fa6fe6SAlan Somers pid = getpid();
111919fa6fe6SAlan Somers au_evclass_map_t evclass;
112019fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "get event class.*%d.*success", pid);
112119fa6fe6SAlan Somers
112219fa6fe6SAlan Somers /* Initialize evclass to get the event-class mapping for auditon(2) */
112319fa6fe6SAlan Somers evclass.ec_number = AUE_AUDITON;
112419fa6fe6SAlan Somers evclass.ec_class = 0;
112519fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
112619fa6fe6SAlan Somers ATF_REQUIRE_EQ(0, auditon(A_GETCLASS, &evclass, sizeof(evclass)));
112719fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
112819fa6fe6SAlan Somers }
112919fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_getclass_success,tc)113019fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_getclass_success, tc)
113119fa6fe6SAlan Somers {
113219fa6fe6SAlan Somers cleanup();
113319fa6fe6SAlan Somers }
113419fa6fe6SAlan Somers
113519fa6fe6SAlan Somers
113619fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_getclass_failure);
ATF_TC_HEAD(auditon_getclass_failure,tc)113719fa6fe6SAlan Somers ATF_TC_HEAD(auditon_getclass_failure, tc)
113819fa6fe6SAlan Somers {
113919fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
114019fa6fe6SAlan Somers "auditon(2) call for cmd: A_GETCLASS");
114119fa6fe6SAlan Somers }
114219fa6fe6SAlan Somers
ATF_TC_BODY(auditon_getclass_failure,tc)114319fa6fe6SAlan Somers ATF_TC_BODY(auditon_getclass_failure, tc)
114419fa6fe6SAlan Somers {
114519fa6fe6SAlan Somers pid = getpid();
114619fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "get event class.*%d.*failure", pid);
114719fa6fe6SAlan Somers
114819fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
114919fa6fe6SAlan Somers /* Failure reason: Invalid au_evclass_map_t structure */
115019fa6fe6SAlan Somers ATF_REQUIRE_EQ(-1, auditon(A_GETCLASS, NULL, 0));
115119fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
115219fa6fe6SAlan Somers }
115319fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_getclass_failure,tc)115419fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_getclass_failure, tc)
115519fa6fe6SAlan Somers {
115619fa6fe6SAlan Somers cleanup();
115719fa6fe6SAlan Somers }
115819fa6fe6SAlan Somers
115919fa6fe6SAlan Somers
116019fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_setclass_success);
ATF_TC_HEAD(auditon_setclass_success,tc)116119fa6fe6SAlan Somers ATF_TC_HEAD(auditon_setclass_success, tc)
116219fa6fe6SAlan Somers {
116319fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
116419fa6fe6SAlan Somers "auditon(2) call for cmd: A_SETCLASS");
116519fa6fe6SAlan Somers }
116619fa6fe6SAlan Somers
ATF_TC_BODY(auditon_setclass_success,tc)116719fa6fe6SAlan Somers ATF_TC_BODY(auditon_setclass_success, tc)
116819fa6fe6SAlan Somers {
116919fa6fe6SAlan Somers pid = getpid();
117019fa6fe6SAlan Somers au_evclass_map_t evclass;
117119fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "set event class.*%d.*success", pid);
117219fa6fe6SAlan Somers
117319fa6fe6SAlan Somers /* Initialize evclass and get the event-class mapping for auditon(2) */
117419fa6fe6SAlan Somers evclass.ec_number = AUE_AUDITON;
117519fa6fe6SAlan Somers evclass.ec_class = 0;
117619fa6fe6SAlan Somers ATF_REQUIRE_EQ(0, auditon(A_GETCLASS, &evclass, sizeof(evclass)));
117719fa6fe6SAlan Somers
117819fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
117919fa6fe6SAlan Somers ATF_REQUIRE_EQ(0, auditon(A_SETCLASS, &evclass, sizeof(evclass)));
118019fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
118119fa6fe6SAlan Somers }
118219fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_setclass_success,tc)118319fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_setclass_success, tc)
118419fa6fe6SAlan Somers {
118519fa6fe6SAlan Somers cleanup();
118619fa6fe6SAlan Somers }
118719fa6fe6SAlan Somers
118819fa6fe6SAlan Somers
118919fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_setclass_failure);
ATF_TC_HEAD(auditon_setclass_failure,tc)119019fa6fe6SAlan Somers ATF_TC_HEAD(auditon_setclass_failure, tc)
119119fa6fe6SAlan Somers {
119219fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
119319fa6fe6SAlan Somers "auditon(2) call for cmd: A_SETCLASS");
119419fa6fe6SAlan Somers }
119519fa6fe6SAlan Somers
ATF_TC_BODY(auditon_setclass_failure,tc)119619fa6fe6SAlan Somers ATF_TC_BODY(auditon_setclass_failure, tc)
119719fa6fe6SAlan Somers {
119819fa6fe6SAlan Somers pid = getpid();
119919fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "set event class.*%d.*failure", pid);
120019fa6fe6SAlan Somers
120119fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
120219fa6fe6SAlan Somers /* Failure reason: Invalid au_evclass_map_t structure */
120319fa6fe6SAlan Somers ATF_REQUIRE_EQ(-1, auditon(A_SETCLASS, NULL, 0));
120419fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
120519fa6fe6SAlan Somers }
120619fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_setclass_failure,tc)120719fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_setclass_failure, tc)
120819fa6fe6SAlan Somers {
120919fa6fe6SAlan Somers cleanup();
121019fa6fe6SAlan Somers }
121119fa6fe6SAlan Somers
121219fa6fe6SAlan Somers
121319fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_getcond_success);
ATF_TC_HEAD(auditon_getcond_success,tc)121419fa6fe6SAlan Somers ATF_TC_HEAD(auditon_getcond_success, tc)
121519fa6fe6SAlan Somers {
121619fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
121719fa6fe6SAlan Somers "auditon(2) call for cmd: A_GETCOND");
121819fa6fe6SAlan Somers }
121919fa6fe6SAlan Somers
ATF_TC_BODY(auditon_getcond_success,tc)122019fa6fe6SAlan Somers ATF_TC_BODY(auditon_getcond_success, tc)
122119fa6fe6SAlan Somers {
122219fa6fe6SAlan Somers int auditcond;
122319fa6fe6SAlan Somers pid = getpid();
122419fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "get audit state.*%d.*success", pid);
122519fa6fe6SAlan Somers
122619fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
122719fa6fe6SAlan Somers ATF_REQUIRE_EQ(0, auditon(A_GETCOND, &auditcond, sizeof(auditcond)));
122819fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
122919fa6fe6SAlan Somers }
123019fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_getcond_success,tc)123119fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_getcond_success, tc)
123219fa6fe6SAlan Somers {
123319fa6fe6SAlan Somers cleanup();
123419fa6fe6SAlan Somers }
123519fa6fe6SAlan Somers
123619fa6fe6SAlan Somers
123719fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_getcond_failure);
ATF_TC_HEAD(auditon_getcond_failure,tc)123819fa6fe6SAlan Somers ATF_TC_HEAD(auditon_getcond_failure, tc)
123919fa6fe6SAlan Somers {
124019fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
124119fa6fe6SAlan Somers "auditon(2) call for cmd: A_GETCOND");
124219fa6fe6SAlan Somers }
124319fa6fe6SAlan Somers
ATF_TC_BODY(auditon_getcond_failure,tc)124419fa6fe6SAlan Somers ATF_TC_BODY(auditon_getcond_failure, tc)
124519fa6fe6SAlan Somers {
124619fa6fe6SAlan Somers pid = getpid();
124719fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "get audit state.*%d.*failure", pid);
124819fa6fe6SAlan Somers
124919fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
125019fa6fe6SAlan Somers /* Failure reason: Invalid argument */
125119fa6fe6SAlan Somers ATF_REQUIRE_EQ(-1, auditon(A_GETCOND, NULL, 0));
125219fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
125319fa6fe6SAlan Somers }
125419fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_getcond_failure,tc)125519fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_getcond_failure, tc)
125619fa6fe6SAlan Somers {
125719fa6fe6SAlan Somers cleanup();
125819fa6fe6SAlan Somers }
125919fa6fe6SAlan Somers
126019fa6fe6SAlan Somers
126119fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_setcond_success);
ATF_TC_HEAD(auditon_setcond_success,tc)126219fa6fe6SAlan Somers ATF_TC_HEAD(auditon_setcond_success, tc)
126319fa6fe6SAlan Somers {
126419fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
126519fa6fe6SAlan Somers "auditon(2) call for cmd: A_SETCOND");
126619fa6fe6SAlan Somers }
126719fa6fe6SAlan Somers
ATF_TC_BODY(auditon_setcond_success,tc)126819fa6fe6SAlan Somers ATF_TC_BODY(auditon_setcond_success, tc)
126919fa6fe6SAlan Somers {
127019fa6fe6SAlan Somers int auditcond = AUC_AUDITING;
127119fa6fe6SAlan Somers pid = getpid();
127219fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "set audit state.*%d.*success", pid);
127319fa6fe6SAlan Somers
127419fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
127519fa6fe6SAlan Somers /* At this point auditd is running, so the audit state is AUC_AUDITING */
127619fa6fe6SAlan Somers ATF_REQUIRE_EQ(0, auditon(A_SETCOND, &auditcond, sizeof(auditcond)));
127719fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
127819fa6fe6SAlan Somers }
127919fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_setcond_success,tc)128019fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_setcond_success, tc)
128119fa6fe6SAlan Somers {
128219fa6fe6SAlan Somers cleanup();
128319fa6fe6SAlan Somers }
128419fa6fe6SAlan Somers
128519fa6fe6SAlan Somers
128619fa6fe6SAlan Somers ATF_TC_WITH_CLEANUP(auditon_setcond_failure);
ATF_TC_HEAD(auditon_setcond_failure,tc)128719fa6fe6SAlan Somers ATF_TC_HEAD(auditon_setcond_failure, tc)
128819fa6fe6SAlan Somers {
128919fa6fe6SAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
129019fa6fe6SAlan Somers "auditon(2) call for cmd: A_SETCOND");
129119fa6fe6SAlan Somers }
129219fa6fe6SAlan Somers
ATF_TC_BODY(auditon_setcond_failure,tc)129319fa6fe6SAlan Somers ATF_TC_BODY(auditon_setcond_failure, tc)
129419fa6fe6SAlan Somers {
129519fa6fe6SAlan Somers pid = getpid();
129619fa6fe6SAlan Somers snprintf(adregex, sizeof(adregex), "set audit state.*%d.*failure", pid);
129719fa6fe6SAlan Somers
129819fa6fe6SAlan Somers FILE *pipefd = setup(fds, auclass);
129919fa6fe6SAlan Somers /* Failure reason: Invalid argument */
130019fa6fe6SAlan Somers ATF_REQUIRE_EQ(-1, auditon(A_SETCOND, NULL, 0));
130119fa6fe6SAlan Somers check_audit(fds, adregex, pipefd);
130219fa6fe6SAlan Somers }
130319fa6fe6SAlan Somers
ATF_TC_CLEANUP(auditon_setcond_failure,tc)130419fa6fe6SAlan Somers ATF_TC_CLEANUP(auditon_setcond_failure, tc)
130519fa6fe6SAlan Somers {
130619fa6fe6SAlan Somers cleanup();
130719fa6fe6SAlan Somers }
130819fa6fe6SAlan Somers
13090f1d973cSAlan Somers /*
13100f1d973cSAlan Somers * Following test-cases for auditon(2) are all in failure mode only as although
13110f1d973cSAlan Somers * auditable, they have not been implemented and return ENOSYS whenever called.
13120f1d973cSAlan Somers *
13130f1d973cSAlan Somers * Commands: A_GETCWD A_GETCAR A_GETSTAT A_SETSTAT A_SETUMASK A_SETSMASK
13140f1d973cSAlan Somers */
13150f1d973cSAlan Somers
13160f1d973cSAlan Somers ATF_TC_WITH_CLEANUP(auditon_getcwd_failure);
ATF_TC_HEAD(auditon_getcwd_failure,tc)13170f1d973cSAlan Somers ATF_TC_HEAD(auditon_getcwd_failure, tc)
13180f1d973cSAlan Somers {
13190f1d973cSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
13200f1d973cSAlan Somers "auditon(2) call for cmd: A_GETCWD");
13210f1d973cSAlan Somers }
13220f1d973cSAlan Somers
ATF_TC_BODY(auditon_getcwd_failure,tc)13230f1d973cSAlan Somers ATF_TC_BODY(auditon_getcwd_failure, tc)
13240f1d973cSAlan Somers {
13250f1d973cSAlan Somers pid = getpid();
13260f1d973cSAlan Somers snprintf(adregex, sizeof(adregex), "get cwd.*%d.*failure", pid);
13270f1d973cSAlan Somers
13280f1d973cSAlan Somers FILE *pipefd = setup(fds, auclass);
13290f1d973cSAlan Somers ATF_REQUIRE_ERRNO(ENOSYS, auditon(A_GETCWD, &auditon_def,
13300f1d973cSAlan Somers sizeof(auditon_def)) == -1);
13310f1d973cSAlan Somers check_audit(fds, adregex, pipefd);
13320f1d973cSAlan Somers }
13330f1d973cSAlan Somers
ATF_TC_CLEANUP(auditon_getcwd_failure,tc)13340f1d973cSAlan Somers ATF_TC_CLEANUP(auditon_getcwd_failure, tc)
13350f1d973cSAlan Somers {
13360f1d973cSAlan Somers cleanup();
13370f1d973cSAlan Somers }
13380f1d973cSAlan Somers
13390f1d973cSAlan Somers
13400f1d973cSAlan Somers ATF_TC_WITH_CLEANUP(auditon_getcar_failure);
ATF_TC_HEAD(auditon_getcar_failure,tc)13410f1d973cSAlan Somers ATF_TC_HEAD(auditon_getcar_failure, tc)
13420f1d973cSAlan Somers {
13430f1d973cSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
13440f1d973cSAlan Somers "auditon(2) call for cmd: A_GETCAR");
13450f1d973cSAlan Somers }
13460f1d973cSAlan Somers
ATF_TC_BODY(auditon_getcar_failure,tc)13470f1d973cSAlan Somers ATF_TC_BODY(auditon_getcar_failure, tc)
13480f1d973cSAlan Somers {
13490f1d973cSAlan Somers pid = getpid();
13500f1d973cSAlan Somers snprintf(adregex, sizeof(adregex), "get car.*%d.*failure", pid);
13510f1d973cSAlan Somers
13520f1d973cSAlan Somers FILE *pipefd = setup(fds, auclass);
13530f1d973cSAlan Somers ATF_REQUIRE_ERRNO(ENOSYS, auditon(A_GETCAR, &auditon_def,
13540f1d973cSAlan Somers sizeof(auditon_def)) == -1);
13550f1d973cSAlan Somers check_audit(fds, adregex, pipefd);
13560f1d973cSAlan Somers }
13570f1d973cSAlan Somers
ATF_TC_CLEANUP(auditon_getcar_failure,tc)13580f1d973cSAlan Somers ATF_TC_CLEANUP(auditon_getcar_failure, tc)
13590f1d973cSAlan Somers {
13600f1d973cSAlan Somers cleanup();
13610f1d973cSAlan Somers }
13620f1d973cSAlan Somers
13630f1d973cSAlan Somers
13640f1d973cSAlan Somers ATF_TC_WITH_CLEANUP(auditon_getstat_failure);
ATF_TC_HEAD(auditon_getstat_failure,tc)13650f1d973cSAlan Somers ATF_TC_HEAD(auditon_getstat_failure, tc)
13660f1d973cSAlan Somers {
13670f1d973cSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
13680f1d973cSAlan Somers "auditon(2) call for cmd: A_GETSTAT");
13690f1d973cSAlan Somers }
13700f1d973cSAlan Somers
ATF_TC_BODY(auditon_getstat_failure,tc)13710f1d973cSAlan Somers ATF_TC_BODY(auditon_getstat_failure, tc)
13720f1d973cSAlan Somers {
13730f1d973cSAlan Somers pid = getpid();
13740f1d973cSAlan Somers snprintf(adregex, sizeof(adregex),
13750f1d973cSAlan Somers "get audit statistics.*%d.*return,failure", pid);
13760f1d973cSAlan Somers
13770f1d973cSAlan Somers FILE *pipefd = setup(fds, auclass);
13780f1d973cSAlan Somers ATF_REQUIRE_ERRNO(ENOSYS, auditon(A_GETSTAT, &auditon_def,
13790f1d973cSAlan Somers sizeof(auditon_def)) == -1);
13800f1d973cSAlan Somers check_audit(fds, adregex, pipefd);
13810f1d973cSAlan Somers }
13820f1d973cSAlan Somers
ATF_TC_CLEANUP(auditon_getstat_failure,tc)13830f1d973cSAlan Somers ATF_TC_CLEANUP(auditon_getstat_failure, tc)
13840f1d973cSAlan Somers {
13850f1d973cSAlan Somers cleanup();
13860f1d973cSAlan Somers }
13870f1d973cSAlan Somers
13880f1d973cSAlan Somers
13890f1d973cSAlan Somers ATF_TC_WITH_CLEANUP(auditon_setstat_failure);
ATF_TC_HEAD(auditon_setstat_failure,tc)13900f1d973cSAlan Somers ATF_TC_HEAD(auditon_setstat_failure, tc)
13910f1d973cSAlan Somers {
13920f1d973cSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
13930f1d973cSAlan Somers "auditon(2) call for cmd: A_SETSTAT");
13940f1d973cSAlan Somers }
13950f1d973cSAlan Somers
ATF_TC_BODY(auditon_setstat_failure,tc)13960f1d973cSAlan Somers ATF_TC_BODY(auditon_setstat_failure, tc)
13970f1d973cSAlan Somers {
13980f1d973cSAlan Somers pid = getpid();
13990f1d973cSAlan Somers snprintf(adregex, sizeof(adregex),
14000f1d973cSAlan Somers "set audit statistics.*%d.*return,failure", pid);
14010f1d973cSAlan Somers
14020f1d973cSAlan Somers FILE *pipefd = setup(fds, auclass);
14030f1d973cSAlan Somers ATF_REQUIRE_ERRNO(ENOSYS, auditon(A_SETSTAT, &auditon_def,
14040f1d973cSAlan Somers sizeof(auditon_def)) == -1);
14050f1d973cSAlan Somers check_audit(fds, adregex, pipefd);
14060f1d973cSAlan Somers }
14070f1d973cSAlan Somers
ATF_TC_CLEANUP(auditon_setstat_failure,tc)14080f1d973cSAlan Somers ATF_TC_CLEANUP(auditon_setstat_failure, tc)
14090f1d973cSAlan Somers {
14100f1d973cSAlan Somers cleanup();
14110f1d973cSAlan Somers }
14120f1d973cSAlan Somers
14130f1d973cSAlan Somers
14140f1d973cSAlan Somers ATF_TC_WITH_CLEANUP(auditon_setumask_failure);
ATF_TC_HEAD(auditon_setumask_failure,tc)14150f1d973cSAlan Somers ATF_TC_HEAD(auditon_setumask_failure, tc)
14160f1d973cSAlan Somers {
14170f1d973cSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
14180f1d973cSAlan Somers "auditon(2) call for cmd: A_SETUMASK");
14190f1d973cSAlan Somers }
14200f1d973cSAlan Somers
ATF_TC_BODY(auditon_setumask_failure,tc)14210f1d973cSAlan Somers ATF_TC_BODY(auditon_setumask_failure, tc)
14220f1d973cSAlan Somers {
14230f1d973cSAlan Somers pid = getpid();
14240f1d973cSAlan Somers snprintf(adregex, sizeof(adregex),
14250f1d973cSAlan Somers "set mask per uid.*%d.*return,failure", pid);
14260f1d973cSAlan Somers
14270f1d973cSAlan Somers FILE *pipefd = setup(fds, auclass);
14280f1d973cSAlan Somers ATF_REQUIRE_ERRNO(ENOSYS, auditon(A_SETUMASK, &auditon_def,
14290f1d973cSAlan Somers sizeof(auditon_def)) == -1);
14300f1d973cSAlan Somers check_audit(fds, adregex, pipefd);
14310f1d973cSAlan Somers }
14320f1d973cSAlan Somers
ATF_TC_CLEANUP(auditon_setumask_failure,tc)14330f1d973cSAlan Somers ATF_TC_CLEANUP(auditon_setumask_failure, tc)
14340f1d973cSAlan Somers {
14350f1d973cSAlan Somers cleanup();
14360f1d973cSAlan Somers }
14370f1d973cSAlan Somers
14380f1d973cSAlan Somers
14390f1d973cSAlan Somers ATF_TC_WITH_CLEANUP(auditon_setsmask_failure);
ATF_TC_HEAD(auditon_setsmask_failure,tc)14400f1d973cSAlan Somers ATF_TC_HEAD(auditon_setsmask_failure, tc)
14410f1d973cSAlan Somers {
14420f1d973cSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
14430f1d973cSAlan Somers "auditon(2) call for cmd: A_SETSMASK");
14440f1d973cSAlan Somers }
14450f1d973cSAlan Somers
ATF_TC_BODY(auditon_setsmask_failure,tc)14460f1d973cSAlan Somers ATF_TC_BODY(auditon_setsmask_failure, tc)
14470f1d973cSAlan Somers {
14480f1d973cSAlan Somers pid = getpid();
14490f1d973cSAlan Somers snprintf(adregex, sizeof(adregex),
14500f1d973cSAlan Somers "set mask per session.*%d.*return,failure", pid);
14510f1d973cSAlan Somers
14520f1d973cSAlan Somers FILE *pipefd = setup(fds, auclass);
14530f1d973cSAlan Somers ATF_REQUIRE_ERRNO(ENOSYS, auditon(A_SETSMASK, &auditon_def,
14540f1d973cSAlan Somers sizeof(auditon_def)) == -1);
14550f1d973cSAlan Somers check_audit(fds, adregex, pipefd);
14560f1d973cSAlan Somers }
14570f1d973cSAlan Somers
ATF_TC_CLEANUP(auditon_setsmask_failure,tc)14580f1d973cSAlan Somers ATF_TC_CLEANUP(auditon_setsmask_failure, tc)
14590f1d973cSAlan Somers {
14600f1d973cSAlan Somers cleanup();
14610f1d973cSAlan Somers }
14620f1d973cSAlan Somers
146319fa6fe6SAlan Somers
1464af045bbfSAlan Somers /*
1465af045bbfSAlan Somers * Audit of reboot(2) cannot be tested in normal conditions as we don't want
1466af045bbfSAlan Somers * to reboot the system while running the tests
1467af045bbfSAlan Somers */
1468af045bbfSAlan Somers
1469af045bbfSAlan Somers
1470af045bbfSAlan Somers ATF_TC_WITH_CLEANUP(reboot_failure);
ATF_TC_HEAD(reboot_failure,tc)1471af045bbfSAlan Somers ATF_TC_HEAD(reboot_failure, tc)
1472af045bbfSAlan Somers {
1473af045bbfSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
1474af045bbfSAlan Somers "reboot(2) call");
1475af045bbfSAlan Somers }
1476af045bbfSAlan Somers
ATF_TC_BODY(reboot_failure,tc)1477af045bbfSAlan Somers ATF_TC_BODY(reboot_failure, tc)
1478af045bbfSAlan Somers {
1479af045bbfSAlan Somers pid = getpid();
1480af045bbfSAlan Somers snprintf(adregex, sizeof(adregex), "reboot.*%d.*return,failure", pid);
1481af045bbfSAlan Somers
1482af045bbfSAlan Somers FILE *pipefd = setup(fds, auclass);
1483af045bbfSAlan Somers ATF_REQUIRE_EQ(-1, reboot(-1));
1484af045bbfSAlan Somers check_audit(fds, adregex, pipefd);
1485af045bbfSAlan Somers }
1486af045bbfSAlan Somers
ATF_TC_CLEANUP(reboot_failure,tc)1487af045bbfSAlan Somers ATF_TC_CLEANUP(reboot_failure, tc)
1488af045bbfSAlan Somers {
1489af045bbfSAlan Somers cleanup();
1490af045bbfSAlan Somers }
1491af045bbfSAlan Somers
1492af045bbfSAlan Somers
1493af045bbfSAlan Somers /*
1494af045bbfSAlan Somers * Audit of quotactl(2) cannot be tested in normal conditions as we don't want
1495af045bbfSAlan Somers * to tamper with filesystem quotas
1496af045bbfSAlan Somers */
1497af045bbfSAlan Somers
1498af045bbfSAlan Somers
1499af045bbfSAlan Somers ATF_TC_WITH_CLEANUP(quotactl_failure);
ATF_TC_HEAD(quotactl_failure,tc)1500af045bbfSAlan Somers ATF_TC_HEAD(quotactl_failure, tc)
1501af045bbfSAlan Somers {
1502af045bbfSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
1503af045bbfSAlan Somers "quotactl(2) call");
1504af045bbfSAlan Somers }
1505af045bbfSAlan Somers
ATF_TC_BODY(quotactl_failure,tc)1506af045bbfSAlan Somers ATF_TC_BODY(quotactl_failure, tc)
1507af045bbfSAlan Somers {
1508af045bbfSAlan Somers pid = getpid();
1509af045bbfSAlan Somers snprintf(adregex, sizeof(adregex), "quotactl.*%d.*return,failure", pid);
1510af045bbfSAlan Somers
1511af045bbfSAlan Somers FILE *pipefd = setup(fds, auclass);
1512af045bbfSAlan Somers ATF_REQUIRE_EQ(-1, quotactl(NULL, 0, 0, NULL));
1513af045bbfSAlan Somers check_audit(fds, adregex, pipefd);
1514af045bbfSAlan Somers }
1515af045bbfSAlan Somers
ATF_TC_CLEANUP(quotactl_failure,tc)1516af045bbfSAlan Somers ATF_TC_CLEANUP(quotactl_failure, tc)
1517af045bbfSAlan Somers {
1518af045bbfSAlan Somers cleanup();
1519af045bbfSAlan Somers }
1520af045bbfSAlan Somers
1521af045bbfSAlan Somers
1522af045bbfSAlan Somers ATF_TC_WITH_CLEANUP(mount_failure);
ATF_TC_HEAD(mount_failure,tc)1523af045bbfSAlan Somers ATF_TC_HEAD(mount_failure, tc)
1524af045bbfSAlan Somers {
1525af045bbfSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
1526af045bbfSAlan Somers "mount(2) call");
1527af045bbfSAlan Somers }
1528af045bbfSAlan Somers
ATF_TC_BODY(mount_failure,tc)1529af045bbfSAlan Somers ATF_TC_BODY(mount_failure, tc)
1530af045bbfSAlan Somers {
1531af045bbfSAlan Somers pid = getpid();
1532af045bbfSAlan Somers snprintf(adregex, sizeof(adregex), "mount.*%d.*return,failure", pid);
1533af045bbfSAlan Somers
1534af045bbfSAlan Somers FILE *pipefd = setup(fds, auclass);
1535af045bbfSAlan Somers ATF_REQUIRE_EQ(-1, mount(NULL, NULL, 0, NULL));
1536af045bbfSAlan Somers check_audit(fds, adregex, pipefd);
1537af045bbfSAlan Somers }
1538af045bbfSAlan Somers
ATF_TC_CLEANUP(mount_failure,tc)1539af045bbfSAlan Somers ATF_TC_CLEANUP(mount_failure, tc)
1540af045bbfSAlan Somers {
1541af045bbfSAlan Somers cleanup();
1542af045bbfSAlan Somers }
1543af045bbfSAlan Somers
1544af045bbfSAlan Somers
1545af045bbfSAlan Somers ATF_TC_WITH_CLEANUP(nmount_failure);
ATF_TC_HEAD(nmount_failure,tc)1546af045bbfSAlan Somers ATF_TC_HEAD(nmount_failure, tc)
1547af045bbfSAlan Somers {
1548af045bbfSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
1549af045bbfSAlan Somers "nmount(2) call");
1550af045bbfSAlan Somers }
1551af045bbfSAlan Somers
ATF_TC_BODY(nmount_failure,tc)1552af045bbfSAlan Somers ATF_TC_BODY(nmount_failure, tc)
1553af045bbfSAlan Somers {
1554af045bbfSAlan Somers pid = getpid();
1555af045bbfSAlan Somers snprintf(adregex, sizeof(adregex), "nmount.*%d.*return,failure", pid);
1556af045bbfSAlan Somers
1557af045bbfSAlan Somers FILE *pipefd = setup(fds, auclass);
1558af045bbfSAlan Somers ATF_REQUIRE_EQ(-1, nmount(NULL, 0, 0));
1559af045bbfSAlan Somers check_audit(fds, adregex, pipefd);
1560af045bbfSAlan Somers }
1561af045bbfSAlan Somers
ATF_TC_CLEANUP(nmount_failure,tc)1562af045bbfSAlan Somers ATF_TC_CLEANUP(nmount_failure, tc)
1563af045bbfSAlan Somers {
1564af045bbfSAlan Somers cleanup();
1565af045bbfSAlan Somers }
1566af045bbfSAlan Somers
1567af045bbfSAlan Somers
1568af045bbfSAlan Somers ATF_TC_WITH_CLEANUP(swapon_failure);
ATF_TC_HEAD(swapon_failure,tc)1569af045bbfSAlan Somers ATF_TC_HEAD(swapon_failure, tc)
1570af045bbfSAlan Somers {
1571af045bbfSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
1572af045bbfSAlan Somers "swapon(2) call");
1573af045bbfSAlan Somers }
1574af045bbfSAlan Somers
ATF_TC_BODY(swapon_failure,tc)1575af045bbfSAlan Somers ATF_TC_BODY(swapon_failure, tc)
1576af045bbfSAlan Somers {
1577af045bbfSAlan Somers pid = getpid();
1578af045bbfSAlan Somers snprintf(adregex, sizeof(adregex), "swapon.*%d.*return,failure", pid);
1579af045bbfSAlan Somers
1580af045bbfSAlan Somers FILE *pipefd = setup(fds, auclass);
1581af045bbfSAlan Somers /* Failure reason: Block device required */
1582af045bbfSAlan Somers ATF_REQUIRE_EQ(-1, swapon(path));
1583af045bbfSAlan Somers check_audit(fds, adregex, pipefd);
1584af045bbfSAlan Somers }
1585af045bbfSAlan Somers
ATF_TC_CLEANUP(swapon_failure,tc)1586af045bbfSAlan Somers ATF_TC_CLEANUP(swapon_failure, tc)
1587af045bbfSAlan Somers {
1588af045bbfSAlan Somers cleanup();
1589af045bbfSAlan Somers }
1590af045bbfSAlan Somers
1591af045bbfSAlan Somers
1592af045bbfSAlan Somers ATF_TC_WITH_CLEANUP(swapoff_failure);
ATF_TC_HEAD(swapoff_failure,tc)1593af045bbfSAlan Somers ATF_TC_HEAD(swapoff_failure, tc)
1594af045bbfSAlan Somers {
1595af045bbfSAlan Somers atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
1596af045bbfSAlan Somers "swapoff(2) call");
1597af045bbfSAlan Somers }
1598af045bbfSAlan Somers
ATF_TC_BODY(swapoff_failure,tc)1599af045bbfSAlan Somers ATF_TC_BODY(swapoff_failure, tc)
1600af045bbfSAlan Somers {
1601af045bbfSAlan Somers pid = getpid();
1602af045bbfSAlan Somers snprintf(adregex, sizeof(adregex), "swapoff.*%d.*return,failure", pid);
1603af045bbfSAlan Somers
1604af045bbfSAlan Somers FILE *pipefd = setup(fds, auclass);
1605af045bbfSAlan Somers /* Failure reason: Block device required */
1606*b49b6e0fSKonstantin Belousov ATF_REQUIRE_EQ(-1, swapoff(path, 0));
1607af045bbfSAlan Somers check_audit(fds, adregex, pipefd);
1608af045bbfSAlan Somers }
1609af045bbfSAlan Somers
ATF_TC_CLEANUP(swapoff_failure,tc)1610af045bbfSAlan Somers ATF_TC_CLEANUP(swapoff_failure, tc)
1611af045bbfSAlan Somers {
1612af045bbfSAlan Somers cleanup();
1613af045bbfSAlan Somers }
1614af045bbfSAlan Somers
1615af045bbfSAlan Somers
ATF_TP_ADD_TCS(tp)161649f52650SAlan Somers ATF_TP_ADD_TCS(tp)
161749f52650SAlan Somers {
161849f52650SAlan Somers ATF_TP_ADD_TC(tp, settimeofday_success);
161949f52650SAlan Somers ATF_TP_ADD_TC(tp, settimeofday_failure);
1620af045bbfSAlan Somers ATF_TP_ADD_TC(tp, clock_settime_success);
1621af045bbfSAlan Somers ATF_TP_ADD_TC(tp, clock_settime_failure);
162249f52650SAlan Somers ATF_TP_ADD_TC(tp, adjtime_success);
162349f52650SAlan Somers ATF_TP_ADD_TC(tp, adjtime_failure);
1624af045bbfSAlan Somers ATF_TP_ADD_TC(tp, ntp_adjtime_success);
1625af045bbfSAlan Somers ATF_TP_ADD_TC(tp, ntp_adjtime_failure);
162649f52650SAlan Somers
162749f52650SAlan Somers ATF_TP_ADD_TC(tp, nfs_getfh_success);
162849f52650SAlan Somers ATF_TP_ADD_TC(tp, nfs_getfh_failure);
1629af045bbfSAlan Somers ATF_TP_ADD_TC(tp, acct_success);
1630af045bbfSAlan Somers ATF_TP_ADD_TC(tp, acct_failure);
1631af045bbfSAlan Somers ATF_TP_ADD_TC(tp, auditctl_success);
1632af045bbfSAlan Somers ATF_TP_ADD_TC(tp, auditctl_failure);
163349f52650SAlan Somers
1634ff150beaSAlan Somers ATF_TP_ADD_TC(tp, getauid_success);
1635ff150beaSAlan Somers ATF_TP_ADD_TC(tp, getauid_failure);
1636ff150beaSAlan Somers ATF_TP_ADD_TC(tp, setauid_success);
1637ff150beaSAlan Somers ATF_TP_ADD_TC(tp, setauid_failure);
1638ff150beaSAlan Somers
1639ff150beaSAlan Somers ATF_TP_ADD_TC(tp, getaudit_success);
1640ff150beaSAlan Somers ATF_TP_ADD_TC(tp, getaudit_failure);
1641ff150beaSAlan Somers ATF_TP_ADD_TC(tp, setaudit_success);
1642ff150beaSAlan Somers ATF_TP_ADD_TC(tp, setaudit_failure);
1643ff150beaSAlan Somers
1644ff150beaSAlan Somers ATF_TP_ADD_TC(tp, getaudit_addr_success);
1645ff150beaSAlan Somers ATF_TP_ADD_TC(tp, getaudit_addr_failure);
1646ff150beaSAlan Somers ATF_TP_ADD_TC(tp, setaudit_addr_success);
1647ff150beaSAlan Somers ATF_TP_ADD_TC(tp, setaudit_addr_failure);
1648ff150beaSAlan Somers
16490f1d973cSAlan Somers ATF_TP_ADD_TC(tp, auditon_default_success);
16500f1d973cSAlan Somers ATF_TP_ADD_TC(tp, auditon_default_failure);
16510f1d973cSAlan Somers
165219fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_getpolicy_success);
165319fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_getpolicy_failure);
165419fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_setpolicy_success);
165519fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_setpolicy_failure);
165619fa6fe6SAlan Somers
165719fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_getkmask_success);
165819fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_getkmask_failure);
165919fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_setkmask_success);
166019fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_setkmask_failure);
166119fa6fe6SAlan Somers
166219fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_getqctrl_success);
166319fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_getqctrl_failure);
166419fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_setqctrl_success);
166519fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_setqctrl_failure);
166619fa6fe6SAlan Somers
166719fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_getclass_success);
166819fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_getclass_failure);
166919fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_setclass_success);
167019fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_setclass_failure);
167119fa6fe6SAlan Somers
167219fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_getcond_success);
167319fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_getcond_failure);
167419fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_setcond_success);
167519fa6fe6SAlan Somers ATF_TP_ADD_TC(tp, auditon_setcond_failure);
167619fa6fe6SAlan Somers
16770f1d973cSAlan Somers ATF_TP_ADD_TC(tp, auditon_getcwd_failure);
16780f1d973cSAlan Somers ATF_TP_ADD_TC(tp, auditon_getcar_failure);
16790f1d973cSAlan Somers ATF_TP_ADD_TC(tp, auditon_getstat_failure);
16800f1d973cSAlan Somers ATF_TP_ADD_TC(tp, auditon_setstat_failure);
16810f1d973cSAlan Somers ATF_TP_ADD_TC(tp, auditon_setumask_failure);
16820f1d973cSAlan Somers ATF_TP_ADD_TC(tp, auditon_setsmask_failure);
16830f1d973cSAlan Somers
1684af045bbfSAlan Somers ATF_TP_ADD_TC(tp, reboot_failure);
1685af045bbfSAlan Somers ATF_TP_ADD_TC(tp, quotactl_failure);
1686af045bbfSAlan Somers ATF_TP_ADD_TC(tp, mount_failure);
1687af045bbfSAlan Somers ATF_TP_ADD_TC(tp, nmount_failure);
1688af045bbfSAlan Somers ATF_TP_ADD_TC(tp, swapon_failure);
1689af045bbfSAlan Somers ATF_TP_ADD_TC(tp, swapoff_failure);
1690af045bbfSAlan Somers
169149f52650SAlan Somers return (atf_no_error());
169249f52650SAlan Somers }
1693