priv_audit_submit.c revision 172106
1162271Srwatson/*- 2162271Srwatson * Copyright (c) 2007 Robert M. M. Watson 3162271Srwatson * All rights reserved. 4162271Srwatson * 5162271Srwatson * This software was developed by Robert N. M. Watson for the TrustedBSD 6162271Srwatson * Project. 7162271Srwatson * 8162271Srwatson * Redistribution and use in source and binary forms, with or without 9162271Srwatson * modification, are permitted provided that the following conditions 10162271Srwatson * are met: 11162271Srwatson * 1. Redistributions of source code must retain the above copyright 12162271Srwatson * notice, this list of conditions and the following disclaimer. 13162271Srwatson * 2. Redistributions in binary form must reproduce the above copyright 14162271Srwatson * notice, this list of conditions and the following disclaimer in the 15162271Srwatson * documentation and/or other materials provided with the distribution. 16162271Srwatson * 17162271Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18162271Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19162271Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20162271Srwatson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR, NCIRCLE NETWORK SECURITY, 21162271Srwatson * INC., OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22162271Srwatson * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23162271Srwatson * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24162271Srwatson * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25162271Srwatson * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26162271Srwatson * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27162271Srwatson * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28162271Srwatson * 29162271Srwatson * $FreeBSD: head/tools/regression/priv/priv_audit_submit.c 172106 2007-09-09 23:08:39Z rwatson $ 30162271Srwatson */ 31162271Srwatson 32162271Srwatson/* 33162271Srwatson * Confirm that privilege is required to submit an audit record; we don't 34162271Srwatson * actually submit a record, but instead rely on the fact that length 35162271Srwatson * validation of the record will occur after the kernel privilege check. 36162271Srwatson * 37162271Srwatson * XXX: It might be better to submit a nul record of some sort. 38162271Srwatson */ 39162271Srwatson 40162271Srwatson#include <sys/types.h> 41162271Srwatson 42162271Srwatson#include <bsm/audit.h> 43162271Srwatson 44162271Srwatson#include <err.h> 45162271Srwatson#include <errno.h> 46162271Srwatson#include <stdio.h> 47162271Srwatson#include <string.h> 48162271Srwatson 49162271Srwatson#include "main.h" 50162271Srwatson 51162271Srwatsonint 52162271Srwatsonpriv_audit_submit_setup(int asroot, int injail, struct test *test) 53162271Srwatson{ 54162271Srwatson 55162271Srwatson /* 56162271Srwatson * XXXRW: It would be nice if we checked for audit being configured 57162271Srwatson * here. 58162271Srwatson */ 59162271Srwatson return (0); 60162271Srwatson} 61162271Srwatson 62162271Srwatsonvoid 63162271Srwatsonpriv_audit_submit(int asroot, int injail, struct test *test) 64162271Srwatson{ 65162271Srwatson char record[MAX_AUDIT_RECORD_SIZE+10]; 66162271Srwatson int error; 67162271Srwatson 68162271Srwatson bzero(record, sizeof(record)); 69162271Srwatson error = audit(record, sizeof(record)); 70162271Srwatson if (asroot && injail) 71162271Srwatson expect("priv_audit_submit(asroot, injail)", error, -1, 72162271Srwatson ENOSYS); 73162271Srwatson if (asroot && !injail) 74162271Srwatson expect("priv_audit_submit(asroot, !injail)", error, -1, 75162271Srwatson EINVAL); 76162271Srwatson if (!asroot && injail) 77162271Srwatson expect("priv_audit_submit(!asroot, injail)", error, -1, 78162271Srwatson ENOSYS); 79162271Srwatson if (!asroot && !injail) 80162271Srwatson expect("priv_audit_submit(!asroot, !injail)", error, -1, 81162271Srwatson EPERM); 82162271Srwatson} 83162271Srwatson 84162271Srwatsonvoid 85162271Srwatsonpriv_audit_submit_cleanup(int asroot, int injail, struct test *test) 86162271Srwatson{ 87162271Srwatson 88162271Srwatson} 89162271Srwatson