1d903306aSRobert Watson /*-
2d903306aSRobert Watson * Copyright (c) 2007 Robert M. M. Watson
3d903306aSRobert Watson * All rights reserved.
4d903306aSRobert Watson *
5d903306aSRobert Watson * This software was developed by Robert N. M. Watson for the TrustedBSD
6d903306aSRobert Watson * Project.
7d903306aSRobert Watson *
8d903306aSRobert Watson * Redistribution and use in source and binary forms, with or without
9d903306aSRobert Watson * modification, are permitted provided that the following conditions
10d903306aSRobert Watson * are met:
11d903306aSRobert Watson * 1. Redistributions of source code must retain the above copyright
12d903306aSRobert Watson * notice, this list of conditions and the following disclaimer.
13d903306aSRobert Watson * 2. Redistributions in binary form must reproduce the above copyright
14d903306aSRobert Watson * notice, this list of conditions and the following disclaimer in the
15d903306aSRobert Watson * documentation and/or other materials provided with the distribution.
16d903306aSRobert Watson *
17d903306aSRobert Watson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18d903306aSRobert Watson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19d903306aSRobert Watson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20d903306aSRobert Watson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR, NCIRCLE NETWORK SECURITY,
21d903306aSRobert Watson * INC., OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22d903306aSRobert Watson * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
23d903306aSRobert Watson * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24d903306aSRobert Watson * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25d903306aSRobert Watson * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26d903306aSRobert Watson * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27d903306aSRobert Watson * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28d903306aSRobert Watson */
29d903306aSRobert Watson
30d903306aSRobert Watson /*
31d903306aSRobert Watson * Confirm that privilege is required to query process audit state.
32d903306aSRobert Watson */
33d903306aSRobert Watson
34d903306aSRobert Watson #include <sys/types.h>
35d903306aSRobert Watson
36d903306aSRobert Watson #include <bsm/audit.h>
37d903306aSRobert Watson
38d903306aSRobert Watson #include <err.h>
39d903306aSRobert Watson #include <errno.h>
40d903306aSRobert Watson #include <stdio.h>
41d903306aSRobert Watson
42d903306aSRobert Watson #include "main.h"
43d903306aSRobert Watson
44d903306aSRobert Watson int
priv_audit_getaudit_setup(int asroot,int injail,struct test * test)45d903306aSRobert Watson priv_audit_getaudit_setup(int asroot, int injail, struct test *test)
46d903306aSRobert Watson {
47d903306aSRobert Watson
48d903306aSRobert Watson /*
49d903306aSRobert Watson * XXXRW: It would be nice if we checked for audit being configured
50d903306aSRobert Watson * here.
51d903306aSRobert Watson */
52d903306aSRobert Watson return (0);
53d903306aSRobert Watson }
54d903306aSRobert Watson
55d903306aSRobert Watson void
priv_audit_getaudit(int asroot,int injail,struct test * test)56d903306aSRobert Watson priv_audit_getaudit(int asroot, int injail, struct test *test)
57d903306aSRobert Watson {
58d903306aSRobert Watson auditinfo_t ai;
59d903306aSRobert Watson int error;
60d903306aSRobert Watson
61d903306aSRobert Watson error = getaudit(&ai);
62d903306aSRobert Watson if (asroot && injail)
63d903306aSRobert Watson expect("priv_audit_getaudit(asroot, injail)", error, -1,
64d903306aSRobert Watson ENOSYS);
65d903306aSRobert Watson if (asroot && !injail)
66d903306aSRobert Watson expect("priv_audit_getaudit(asroot, !injail)", error, 0, 0);
67d903306aSRobert Watson if (!asroot && injail)
68d903306aSRobert Watson expect("priv_audit_getaudit(!asroot, injail)", error, -1,
69d903306aSRobert Watson ENOSYS);
70d903306aSRobert Watson if (!asroot && !injail)
71d903306aSRobert Watson expect("priv_audit_getaudit(!asroot, !injail)", error, -1,
72d903306aSRobert Watson EPERM);
73d903306aSRobert Watson }
74d903306aSRobert Watson
75d903306aSRobert Watson void
priv_audit_getaudit_addr(int asroot,int injail,struct test * test)76d903306aSRobert Watson priv_audit_getaudit_addr(int asroot, int injail, struct test *test)
77d903306aSRobert Watson {
78d903306aSRobert Watson auditinfo_addr_t aia;
79d903306aSRobert Watson int error;
80d903306aSRobert Watson
81d903306aSRobert Watson error = getaudit_addr(&aia, sizeof(aia));
82d903306aSRobert Watson if (asroot && injail)
83d903306aSRobert Watson expect("priv_audit_getaudit_addr(asroot, injail)", error, -1,
84d903306aSRobert Watson ENOSYS);
85d903306aSRobert Watson if (asroot && !injail)
86d903306aSRobert Watson expect("priv_audit_getaudit_addr(asroot, !injail)", error, 0,
87d903306aSRobert Watson 0);
88d903306aSRobert Watson if (!asroot && injail)
89d903306aSRobert Watson expect("priv_audit_getaudit_addr(!asroot, injail)", error,
90d903306aSRobert Watson -1, ENOSYS);
91d903306aSRobert Watson if (!asroot && !injail)
92d903306aSRobert Watson expect("priv_audit_getaudit_addr(!asroot, !injail)", error,
93d903306aSRobert Watson -1, EPERM);
94d903306aSRobert Watson }
95d903306aSRobert Watson
96d903306aSRobert Watson void
priv_audit_getaudit_cleanup(int asroot,int injail,struct test * test)97d903306aSRobert Watson priv_audit_getaudit_cleanup(int asroot, int injail, struct test *test)
98d903306aSRobert Watson {
99d903306aSRobert Watson
100d903306aSRobert Watson }
101