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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 1992 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 #include <sys/types.h> 30 #include <sys/label.h> 31 #include <sys/audit.h> 32 33 #define MAXSTRLEN 360 34 35 /* getfaudflgs.c */ 36 37 /* 38 * getfauditflags() - combines system event flag mask with user event 39 * flag masks. 40 * 41 * input: usremasks->as_success - always audit on success 42 * usremasks->as_failure - always audit on failure 43 * usrdmasks->as_success - never audit on success 44 * usrdmasks->as_failure - never audit on failure 45 * 46 * output: lastmasks->as_success - audit on success 47 * lastmasks->as_failure - audit on failure 48 * 49 * returns: 0 - ok 50 * -1 - error 51 */ 52 53 int 54 getfauditflags(audit_state_t *usremasks, audit_state_t *usrdmasks, 55 audit_state_t *lastmasks) 56 { 57 int len = MAXSTRLEN, retstat = 0; 58 char s_auditstring[MAXSTRLEN]; 59 audit_state_t masks; 60 61 masks.as_success = 0; 62 masks.as_failure = 0; 63 /* 64 * get system audit mask and convert to bit mask 65 */ 66 if ((getacflg(s_auditstring, len)) >= 0) { 67 if ((getauditflagsbin(s_auditstring, &masks)) != 0) 68 retstat = -1; 69 } else 70 retstat = -1; 71 72 /* 73 * combine system and user event masks 74 */ 75 if (retstat == 0) { 76 lastmasks->as_success = masks.as_success; 77 lastmasks->as_failure = masks.as_failure; 78 79 lastmasks->as_success |= usremasks->as_success; 80 lastmasks->as_failure |= usremasks->as_failure; 81 82 lastmasks->as_success &= ~(usrdmasks->as_success); 83 lastmasks->as_failure &= ~(usrdmasks->as_failure); 84 } 85 return (retstat); 86 } 87