xref: /titanic_41/usr/src/lib/libbsm/common/getfaudflgs.c (revision 0d928757379972073af9fb22bdc827b74e8ba6ac)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #include <sys/types.h>
26 #include <bsm/audit.h>
27 #include <bsm/libbsm.h>
28 
29 /*
30  * getfauditflags() - combines system event flag mask with user event
31  *	flag masks.
32  *
33  * input: usremasks->as_success - always audit on success
34  *	  usremasks->as_failure - always audit on failure
35  *	  usrdmasks->as_success - never audit on success
36  *	  usrdmasks->as_failure - never audit on failure
37  *
38  * output: lastmasks->as_success - audit on success
39  *	   lastmasks->as_failure - audit on failure
40  *
41  * returns:	 0 - ok
42  * 		-1 - error (cannot get attributable mask)
43  */
44 int
45 getfauditflags(au_mask_t *usremasks, au_mask_t *usrdmasks, au_mask_t *lastmasks)
46 {
47 	au_mask_t masks;
48 
49 	/* get system audit mask and convert to bit mask */
50 	if (auditon(A_GETAMASK, (caddr_t)&masks, sizeof (masks)) == -1) {
51 		return (-1);
52 	}
53 
54 	/* combine system and user event masks */
55 	lastmasks->as_success = masks.as_success;
56 	lastmasks->as_failure = masks.as_failure;
57 
58 	lastmasks->as_success |= usremasks->as_success;
59 	lastmasks->as_failure |= usremasks->as_failure;
60 
61 	lastmasks->as_success &= ~(usrdmasks->as_success);
62 	lastmasks->as_failure &= ~(usrdmasks->as_failure);
63 
64 	return (0);
65 }
66