10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
54893Stz204579 * Common Development and Distribution License (the "License").
64893Stz204579 * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate /*
22*12918SJan.Friedel@Sun.COM * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate */
240Sstevel@tonic-gate
250Sstevel@tonic-gate #include <sys/types.h>
260Sstevel@tonic-gate #include <bsm/audit.h>
27*12918SJan.Friedel@Sun.COM #include <bsm/libbsm.h>
280Sstevel@tonic-gate
290Sstevel@tonic-gate /*
300Sstevel@tonic-gate * getfauditflags() - combines system event flag mask with user event
310Sstevel@tonic-gate * flag masks.
320Sstevel@tonic-gate *
330Sstevel@tonic-gate * input: usremasks->as_success - always audit on success
34*12918SJan.Friedel@Sun.COM * usremasks->as_failure - always audit on failure
35*12918SJan.Friedel@Sun.COM * usrdmasks->as_success - never audit on success
36*12918SJan.Friedel@Sun.COM * usrdmasks->as_failure - never audit on failure
370Sstevel@tonic-gate *
380Sstevel@tonic-gate * output: lastmasks->as_success - audit on success
39*12918SJan.Friedel@Sun.COM * lastmasks->as_failure - audit on failure
400Sstevel@tonic-gate *
41*12918SJan.Friedel@Sun.COM * returns: 0 - ok
42*12918SJan.Friedel@Sun.COM * -1 - error (cannot get attributable mask)
430Sstevel@tonic-gate */
440Sstevel@tonic-gate int
getfauditflags(au_mask_t * usremasks,au_mask_t * usrdmasks,au_mask_t * lastmasks)45*12918SJan.Friedel@Sun.COM getfauditflags(au_mask_t *usremasks, au_mask_t *usrdmasks, au_mask_t *lastmasks)
460Sstevel@tonic-gate {
47*12918SJan.Friedel@Sun.COM au_mask_t masks;
480Sstevel@tonic-gate
490Sstevel@tonic-gate /* get system audit mask and convert to bit mask */
50*12918SJan.Friedel@Sun.COM if (auditon(A_GETAMASK, (caddr_t)&masks, sizeof (masks)) == -1) {
51*12918SJan.Friedel@Sun.COM return (-1);
52*12918SJan.Friedel@Sun.COM }
530Sstevel@tonic-gate
540Sstevel@tonic-gate /* combine system and user event masks */
55*12918SJan.Friedel@Sun.COM lastmasks->as_success = masks.as_success;
56*12918SJan.Friedel@Sun.COM lastmasks->as_failure = masks.as_failure;
57*12918SJan.Friedel@Sun.COM
58*12918SJan.Friedel@Sun.COM lastmasks->as_success |= usremasks->as_success;
59*12918SJan.Friedel@Sun.COM lastmasks->as_failure |= usremasks->as_failure;
600Sstevel@tonic-gate
61*12918SJan.Friedel@Sun.COM lastmasks->as_success &= ~(usrdmasks->as_success);
62*12918SJan.Friedel@Sun.COM lastmasks->as_failure &= ~(usrdmasks->as_failure);
630Sstevel@tonic-gate
64*12918SJan.Friedel@Sun.COM return (0);
650Sstevel@tonic-gate }
66