Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F131928096
D16395.id45694.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D16395.id45694.diff
View Options
Index: etc/mtree/BSD.tests.dist
===================================================================
--- etc/mtree/BSD.tests.dist
+++ etc/mtree/BSD.tests.dist
@@ -432,6 +432,8 @@
..
audit
..
+ auditpipe
+ ..
capsicum
..
cddl
Index: tests/sys/Makefile
===================================================================
--- tests/sys/Makefile
+++ tests/sys/Makefile
@@ -7,6 +7,7 @@
TESTS_SUBDIRS+= acl
TESTS_SUBDIRS+= aio
TESTS_SUBDIRS+= audit
+TESTS_SUBDIRS+= auditpipe
TESTS_SUBDIRS+= capsicum
TESTS_SUBDIRS+= ${_cddl}
TESTS_SUBDIRS+= fifo
Index: tests/sys/auditpipe/Makefile
===================================================================
--- /dev/null
+++ tests/sys/auditpipe/Makefile
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+TESTSDIR= ${TESTSBASE}/sys/auditpipe
+
+ATF_TESTS_C= auditpipe_test
+
+TEST_METADATA+= required_user="root"
+WARNS?= 6
+
+.include <bsd.test.mk>
Index: tests/sys/auditpipe/auditpipe_test.c
===================================================================
--- /dev/null
+++ tests/sys/auditpipe/auditpipe_test.c
@@ -0,0 +1,185 @@
+/*-
+ * Copyright (c) 2018 Aniket Pandey
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/ioctl.h>
+
+#include <bsm/audit.h>
+#include <security/audit/audit_ioctl.h>
+
+#include <atf-c.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+
+static int filedesc;
+static FILE *fileptr;
+
+ATF_TC(auditpipe_get_qlen);
+ATF_TC_HEAD(auditpipe_get_qlen, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Verifies whether the auditpipe ioctl, "
+ "AUDITPIPE_GET_QLEN works properly");
+}
+
+ATF_TC_BODY(auditpipe_get_qlen, tc)
+{
+ int qlen = -1;
+ ATF_REQUIRE((filedesc = open("/dev/auditpipe", O_RDONLY)) != -1);
+ ATF_REQUIRE_EQ(0, ioctl(filedesc, AUDITPIPE_GET_QLEN, &qlen));
+ ATF_REQUIRE(qlen != -1);
+ close(filedesc);
+}
+
+
+ATF_TC(auditpipe_get_qlimit);
+ATF_TC_HEAD(auditpipe_get_qlimit, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Verifies whether the auditpipe ioctl, "
+ "AUDITPIPE_GET_QLIMIT works properly");
+}
+
+ATF_TC_BODY(auditpipe_get_qlimit, tc)
+{
+ int qlimit = -1;
+ ATF_REQUIRE((filedesc = open("/dev/auditpipe", O_RDONLY)) != -1);
+ ATF_REQUIRE_EQ(0, ioctl(filedesc, AUDITPIPE_GET_QLIMIT, &qlimit));
+ ATF_REQUIRE(qlimit != -1);
+ close(filedesc);
+}
+
+
+ATF_TC_WITH_CLEANUP(auditpipe_set_qlimit);
+ATF_TC_HEAD(auditpipe_set_qlimit, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Verifies whether the auditpipe ioctl, "
+ "AUDITPIPE_SET_QLIMIT works properly");
+}
+
+ATF_TC_BODY(auditpipe_set_qlimit, tc)
+{
+ int test_qlimit, curr_qlimit, recv_qlimit;
+
+ ATF_REQUIRE((filedesc = open("/dev/auditpipe", O_RDONLY)) != -1);
+ /* Retreive the current QLIMIT value and store it in a file */
+ ATF_REQUIRE_EQ(0, ioctl(filedesc, AUDITPIPE_GET_QLIMIT, &curr_qlimit));
+ ATF_REQUIRE((fileptr = fopen("qlimit_store", "a")) != NULL);
+ ATF_REQUIRE_EQ(sizeof(curr_qlimit),
+ fprintf(fileptr, "%d\n", curr_qlimit));
+
+ /*
+ * Set QLIMIT different from the current system value to confirm
+ * proper functioning of AUDITPIPE_SET_QLIMIT ioctl.
+ */
+ test_qlimit = curr_qlimit - 1;
+ ATF_REQUIRE_EQ(0, ioctl(filedesc, AUDITPIPE_SET_QLIMIT, &test_qlimit));
+ /* Receive modified value and check whether QLIMIT was set correctly */
+ ATF_REQUIRE_EQ(0, ioctl(filedesc, AUDITPIPE_GET_QLIMIT, &recv_qlimit));
+ ATF_REQUIRE_EQ(test_qlimit, recv_qlimit);
+
+ fclose(fileptr);
+ close(filedesc);
+}
+
+ATF_TC_CLEANUP(auditpipe_set_qlimit, tc)
+{
+ if (atf_utils_file_exists("qlimit_store")) {
+ int fd, curr_qlim;
+ ATF_REQUIRE((fileptr = fopen("qlimit_store", "r")) != NULL);
+ ATF_REQUIRE(fscanf(fileptr, "%d", &curr_qlim));
+
+ ATF_REQUIRE((fd = open("/dev/auditpipe", O_RDONLY)) != -1);
+ /* Set QLIMIT's value as it was prior to test-case invocation */
+ ATF_REQUIRE_EQ(0, ioctl(fd, AUDITPIPE_SET_QLIMIT, &curr_qlim));
+
+ close(fd);
+ fclose(fileptr);
+ }
+}
+
+
+ATF_TC(auditpipe_get_qlimit_min);
+ATF_TC_HEAD(auditpipe_get_qlimit_min, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Verifies whether the auditpipe ioctl, "
+ "AUDITPIPE_GET_QLIMIT_MIN works properly");
+}
+
+ATF_TC_BODY(auditpipe_get_qlimit_min, tc)
+{
+ int qlim_min = -1;
+ ATF_REQUIRE((filedesc = open("/dev/auditpipe", O_RDONLY)) != -1);
+ ATF_REQUIRE_EQ(0, ioctl(filedesc, AUDITPIPE_GET_QLIMIT_MIN, &qlim_min));
+ ATF_REQUIRE(qlim_min != -1);
+ close(filedesc);
+}
+
+
+ATF_TC(auditpipe_get_qlimit_max);
+ATF_TC_HEAD(auditpipe_get_qlimit_max, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Verifies whether the auditpipe ioctl, "
+ "AUDITPIPE_GET_QLIMIT_MAX works properly");
+}
+
+ATF_TC_BODY(auditpipe_get_qlimit_max, tc)
+{
+ int qlim_max = -1;
+ ATF_REQUIRE((filedesc = open("/dev/auditpipe", O_RDONLY)) != -1);
+ ATF_REQUIRE_EQ(0, ioctl(filedesc, AUDITPIPE_GET_QLIMIT_MAX, &qlim_max));
+ ATF_REQUIRE(qlim_max != -1);
+ close(filedesc);
+}
+
+
+ATF_TC(auditpipe_get_maxauditdata);
+ATF_TC_HEAD(auditpipe_get_maxauditdata, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Verifies whether the auditpipe ioctl, "
+ "AUDITPIPE_GET_MAXAUDITDATA works properly");
+}
+
+ATF_TC_BODY(auditpipe_get_maxauditdata, tc)
+{
+ int audata = -1;
+ ATF_REQUIRE((filedesc = open("/dev/auditpipe", O_RDONLY)) != -1);
+ ATF_REQUIRE_EQ(0, ioctl(filedesc, AUDITPIPE_GET_MAXAUDITDATA, &audata));
+ ATF_REQUIRE(audata != -1);
+ close(filedesc);
+}
+
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, auditpipe_get_qlen);
+ ATF_TP_ADD_TC(tp, auditpipe_get_qlimit);
+ ATF_TP_ADD_TC(tp, auditpipe_set_qlimit);
+ ATF_TP_ADD_TC(tp, auditpipe_get_qlimit_min);
+ ATF_TP_ADD_TC(tp, auditpipe_get_qlimit_max);
+ ATF_TP_ADD_TC(tp, auditpipe_get_maxauditdata);
+
+ return (atf_no_error());
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Oct 13, 6:54 AM (14 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
23663048
Default Alt Text
D16395.id45694.diff (6 KB)
Attached To
Mode
D16395: Introduce test-program for auditpipe(4)
Attached
Detach File
Event Timeline
Log In to Comment