turns printfs back on
[freebsd-src/fkvm-freebsd.git] / tools / regression / priv / priv_audit_getaudit.c
blobcccabeda28c6675018e35e2ec284078cf7cf88da
1 /*-
2 * Copyright (c) 2007 Robert M. M. Watson
3 * All rights reserved.
5 * This software was developed by Robert N. M. Watson for the TrustedBSD
6 * Project.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR, NCIRCLE NETWORK SECURITY,
21 * INC., OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
23 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * $FreeBSD$
33 * Confirm that privilege is required to query process audit state.
36 #include <sys/types.h>
38 #include <bsm/audit.h>
40 #include <err.h>
41 #include <errno.h>
42 #include <stdio.h>
44 #include "main.h"
46 int
47 priv_audit_getaudit_setup(int asroot, int injail, struct test *test)
51 * XXXRW: It would be nice if we checked for audit being configured
52 * here.
54 return (0);
57 void
58 priv_audit_getaudit(int asroot, int injail, struct test *test)
60 auditinfo_t ai;
61 int error;
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);
77 void
78 priv_audit_getaudit_addr(int asroot, int injail, struct test *test)
80 auditinfo_addr_t aia;
81 int error;
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);
98 void
99 priv_audit_getaudit_cleanup(int asroot, int injail, struct test *test)