1 /*- 2 * Copyright (c) 2007 Robert M. M. Watson 3 * All rights reserved. 4 * 5 * This software was developed by Robert N. M. Watson for the TrustedBSD 6 * Project. 7 * 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. 16 * 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. 28 */ 29 30 /* 31 * Confirm that privilege is required to submit an audit record; we don't 32 * actually submit a record, but instead rely on the fact that length 33 * validation of the record will occur after the kernel privilege check. 34 * 35 * XXX: It might be better to submit a nul record of some sort. 36 */ 37 38 #include <sys/types.h> 39 40 #include <bsm/audit.h> 41 42 #include <err.h> 43 #include <errno.h> 44 #include <stdio.h> 45 #include <string.h> 46 47 #include "main.h" 48 49 int 50 priv_audit_submit_setup(int asroot, int injail, struct test *test) 51 { 52 53 /* 54 * XXXRW: It would be nice if we checked for audit being configured 55 * here. 56 */ 57 return (0); 58 } 59 60 void 61 priv_audit_submit(int asroot, int injail, struct test *test) 62 { 63 char record[MAX_AUDIT_RECORD_SIZE+10]; 64 int error; 65 66 bzero(record, sizeof(record)); 67 error = audit(record, sizeof(record)); 68 if (asroot && injail) 69 expect("priv_audit_submit(asroot, injail)", error, -1, 70 ENOSYS); 71 if (asroot && !injail) 72 expect("priv_audit_submit(asroot, !injail)", error, -1, 73 EINVAL); 74 if (!asroot && injail) 75 expect("priv_audit_submit(!asroot, injail)", error, -1, 76 ENOSYS); 77 if (!asroot && !injail) 78 expect("priv_audit_submit(!asroot, !injail)", error, -1, 79 EPERM); 80 } 81 82 void 83 priv_audit_submit_cleanup(int asroot, int injail, struct test *test) 84 { 85 86 } 87