1172106Srwatson/*-
2172106Srwatson * Copyright (c) 2007 Robert M. M. Watson
3172106Srwatson * All rights reserved.
4172106Srwatson *
5172106Srwatson * This software was developed by Robert N. M. Watson for the TrustedBSD
6172106Srwatson * Project.
7172106Srwatson *
8172106Srwatson * Redistribution and use in source and binary forms, with or without
9172106Srwatson * modification, are permitted provided that the following conditions
10172106Srwatson * are met:
11172106Srwatson * 1. Redistributions of source code must retain the above copyright
12172106Srwatson *    notice, this list of conditions and the following disclaimer.
13172106Srwatson * 2. Redistributions in binary form must reproduce the above copyright
14172106Srwatson *    notice, this list of conditions and the following disclaimer in the
15172106Srwatson *    documentation and/or other materials provided with the distribution.
16172106Srwatson *
17172106Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18172106Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19172106Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20172106Srwatson * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR, NCIRCLE NETWORK SECURITY,
21172106Srwatson * INC., OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22172106Srwatson * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
23172106Srwatson * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24172106Srwatson * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25172106Srwatson * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26172106Srwatson * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27172106Srwatson * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28172106Srwatson *
29172106Srwatson * $FreeBSD: releng/10.3/tools/regression/priv/priv_audit_submit.c 172106 2007-09-09 23:08:39Z rwatson $
30172106Srwatson */
31172106Srwatson
32172106Srwatson/*
33172106Srwatson * Confirm that privilege is required to submit an audit record; we don't
34172106Srwatson * actually submit a record, but instead rely on the fact that length
35172106Srwatson * validation of the record will occur after the kernel privilege check.
36172106Srwatson *
37172106Srwatson * XXX: It might be better to submit a nul record of some sort.
38172106Srwatson */
39172106Srwatson
40172106Srwatson#include <sys/types.h>
41172106Srwatson
42172106Srwatson#include <bsm/audit.h>
43172106Srwatson
44172106Srwatson#include <err.h>
45172106Srwatson#include <errno.h>
46172106Srwatson#include <stdio.h>
47172106Srwatson#include <string.h>
48172106Srwatson
49172106Srwatson#include "main.h"
50172106Srwatson
51172106Srwatsonint
52172106Srwatsonpriv_audit_submit_setup(int asroot, int injail, struct test *test)
53172106Srwatson{
54172106Srwatson
55172106Srwatson	/*
56172106Srwatson	 * XXXRW: It would be nice if we checked for audit being configured
57172106Srwatson	 * here.
58172106Srwatson	 */
59172106Srwatson	return (0);
60172106Srwatson}
61172106Srwatson
62172106Srwatsonvoid
63172106Srwatsonpriv_audit_submit(int asroot, int injail, struct test *test)
64172106Srwatson{
65172106Srwatson	char record[MAX_AUDIT_RECORD_SIZE+10];
66172106Srwatson	int error;
67172106Srwatson
68172106Srwatson	bzero(record, sizeof(record));
69172106Srwatson	error = audit(record, sizeof(record));
70172106Srwatson	if (asroot && injail)
71172106Srwatson		expect("priv_audit_submit(asroot, injail)", error, -1,
72172106Srwatson		    ENOSYS);
73172106Srwatson	if (asroot && !injail)
74172106Srwatson		expect("priv_audit_submit(asroot, !injail)", error, -1,
75172106Srwatson		    EINVAL);
76172106Srwatson	if (!asroot && injail)
77172106Srwatson		expect("priv_audit_submit(!asroot, injail)", error, -1,
78172106Srwatson		    ENOSYS);
79172106Srwatson	if (!asroot && !injail)
80172106Srwatson		expect("priv_audit_submit(!asroot, !injail)", error, -1,
81172106Srwatson		    EPERM);
82172106Srwatson}
83172106Srwatson
84172106Srwatsonvoid
85172106Srwatsonpriv_audit_submit_cleanup(int asroot, int injail, struct test *test)
86172106Srwatson{
87172106Srwatson
88172106Srwatson}
89