getfaudflgs.c (d75d0dc9) getfaudflgs.c (f8994074)
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

--- 4 unchanged lines hidden (view full) ---

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 */
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

--- 4 unchanged lines hidden (view full) ---

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#pragma ident "%Z%%M% %I% %E% SMI"
22
23/*
21/*
24 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
22 * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
26 */
27
28#include <sys/types.h>
29#include <bsm/audit.h>
23 */
24
25#include <sys/types.h>
26#include <bsm/audit.h>
27#include <bsm/libbsm.h>
30
28
31#define MAXSTRLEN 360
32
33/* getfaudflgs.c */
34
35/*
36 * getfauditflags() - combines system event flag mask with user event
37 * flag masks.
38 *
39 * input: usremasks->as_success - always audit on success
29/*
30 * getfauditflags() - combines system event flag mask with user event
31 * flag masks.
32 *
33 * input: usremasks->as_success - always audit on success
40 * usremasks->as_failure - always audit on failure
41 * usrdmasks->as_success - never audit on success
42 * usrdmasks->as_failure - never audit on failure
34 * usremasks->as_failure - always audit on failure
35 * usrdmasks->as_success - never audit on success
36 * usrdmasks->as_failure - never audit on failure
43 *
44 * output: lastmasks->as_success - audit on success
37 *
38 * output: lastmasks->as_success - audit on success
45 * lastmasks->as_failure - audit on failure
39 * lastmasks->as_failure - audit on failure
46 *
40 *
47 * returns: 0 - ok
48 * -1 - error
41 * returns: 0 - ok
42 * -1 - error (cannot get attributable mask)
49 */
43 */
50
51extern int getauditflagsbin();
52extern int getacflg();
53
54int
44int
55getfauditflags(usremasks, usrdmasks, lastmasks)
56au_mask_t *usremasks;
57au_mask_t *usrdmasks;
58au_mask_t *lastmasks;
45getfauditflags(au_mask_t *usremasks, au_mask_t *usrdmasks, au_mask_t *lastmasks)
59{
46{
60 int len = MAXSTRLEN, retstat = 0;
61 char s_auditstring[MAXSTRLEN];
62 audit_state_t masks;
47 au_mask_t masks;
63
48
64 masks.as_success = 0;
65 masks.as_failure = 0;
66 /* get system audit mask and convert to bit mask */
49 /* get system audit mask and convert to bit mask */
67 if ((getacflg(s_auditstring, len)) >= 0) {
68 if ((getauditflagsbin(s_auditstring, &masks)) != 0)
69 retstat = -1;
70 } else
71 retstat = -1;
50 if (auditon(A_GETAMASK, (caddr_t)&masks, sizeof (masks)) == -1) {
51 return (-1);
52 }
72
73 /* combine system and user event masks */
53
54 /* combine system and user event masks */
74 if (retstat == 0) {
75 lastmasks->as_success = masks.as_success;
76 lastmasks->as_failure = masks.as_failure;
55 lastmasks->as_success = masks.as_success;
56 lastmasks->as_failure = masks.as_failure;
77
57
78 lastmasks->as_success |= usremasks->as_success;
79 lastmasks->as_failure |= usremasks->as_failure;
58 lastmasks->as_success |= usremasks->as_success;
59 lastmasks->as_failure |= usremasks->as_failure;
80
60
81 lastmasks->as_success &= ~(usrdmasks->as_success);
82 lastmasks->as_failure &= ~(usrdmasks->as_failure);
83 }
84 return (retstat);
61 lastmasks->as_success &= ~(usrdmasks->as_success);
62 lastmasks->as_failure &= ~(usrdmasks->as_failure);
63
64 return (0);
85}
65}