priv_audit_getaudit.c revision 172106
1119377Smarcel/*-
2119377Smarcel * Copyright (c) 2007 Robert M. M. Watson
3119377Smarcel * All rights reserved.
4119377Smarcel *
5119377Smarcel * This software was developed by Robert N. M. Watson for the TrustedBSD
6119377Smarcel * Project.
7119377Smarcel *
8119377Smarcel * Redistribution and use in source and binary forms, with or without
9119377Smarcel * modification, are permitted provided that the following conditions
10119377Smarcel * are met:
11119377Smarcel * 1. Redistributions of source code must retain the above copyright
12119377Smarcel *    notice, this list of conditions and the following disclaimer.
13119377Smarcel * 2. Redistributions in binary form must reproduce the above copyright
14119377Smarcel *    notice, this list of conditions and the following disclaimer in the
15119377Smarcel *    documentation and/or other materials provided with the distribution.
16119377Smarcel *
17119377Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18119377Smarcel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19119377Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20119377Smarcel * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR, NCIRCLE NETWORK SECURITY,
21119377Smarcel * INC., OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22119377Smarcel * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
23119377Smarcel * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24119377Smarcel * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25119377Smarcel * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26119906Smarcel * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27119906Smarcel * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28119906Smarcel *
29119906Smarcel * $FreeBSD: head/tools/regression/priv/priv_audit_getaudit.c 172106 2007-09-09 23:08:39Z rwatson $
30119906Smarcel */
31119377Smarcel
32119377Smarcel/*
33119377Smarcel * Confirm that privilege is required to query process audit state.
34119469Smarcel */
35119377Smarcel
36119377Smarcel#include <sys/types.h>
37119377Smarcel
38119377Smarcel#include <bsm/audit.h>
39119377Smarcel
40119377Smarcel#include <err.h>
41119377Smarcel#include <errno.h>
42119377Smarcel#include <stdio.h>
43119377Smarcel
44119377Smarcel#include "main.h"
45119377Smarcel
46119377Smarcelint
47119377Smarcelpriv_audit_getaudit_setup(int asroot, int injail, struct test *test)
48119377Smarcel{
49119377Smarcel
50119377Smarcel	/*
51119377Smarcel	 * XXXRW: It would be nice if we checked for audit being configured
52119377Smarcel	 * here.
53119377Smarcel	 */
54	return (0);
55}
56
57void
58priv_audit_getaudit(int asroot, int injail, struct test *test)
59{
60	auditinfo_t ai;
61	int error;
62
63	error = getaudit(&ai);
64	if (asroot && injail)
65		expect("priv_audit_getaudit(asroot, injail)", error, -1,
66		    ENOSYS);
67	if (asroot && !injail)
68		expect("priv_audit_getaudit(asroot, !injail)", error, 0, 0);
69	if (!asroot && injail)
70		expect("priv_audit_getaudit(!asroot, injail)", error, -1,
71		    ENOSYS);
72	if (!asroot && !injail)
73		expect("priv_audit_getaudit(!asroot, !injail)", error, -1,
74		    EPERM);
75}
76
77void
78priv_audit_getaudit_addr(int asroot, int injail, struct test *test)
79{
80	auditinfo_addr_t aia;
81	int error;
82
83	error = getaudit_addr(&aia, sizeof(aia));
84	if (asroot && injail)
85		expect("priv_audit_getaudit_addr(asroot, injail)", error, -1,
86		    ENOSYS);
87	if (asroot && !injail)
88		expect("priv_audit_getaudit_addr(asroot, !injail)", error, 0,
89		    0);
90	if (!asroot && injail)
91		expect("priv_audit_getaudit_addr(!asroot, injail)", error,
92		    -1, ENOSYS);
93	if (!asroot && !injail)
94		expect("priv_audit_getaudit_addr(!asroot, !injail)", error,
95		    -1, EPERM);
96}
97
98void
99priv_audit_getaudit_cleanup(int asroot, int injail, struct test *test)
100{
101
102}
103