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 /*
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #include <sys/types.h>
28 #include <bsm/adt.h>
29 #include <bsm/adt_event.h>
30
31 #include <libnwam_priv.h>
32
33 /*
34 * Record libnwam's audit events (enable, disable, update and remove profiles).
35 */
36 void
nwam_record_audit_event(const ucred_t * ucr,au_event_t eid,char * name,char * descr_arg,int status,int error)37 nwam_record_audit_event(const ucred_t *ucr, au_event_t eid,
38 char *name, char *descr_arg, int status, int error)
39 {
40 adt_session_data_t *ah;
41 adt_event_data_t *edata;
42
43 if (adt_start_session(&ah, NULL, 0) != 0)
44 return;
45
46 if (adt_set_from_ucred(ah, ucr, ADT_NEW) != 0) {
47 (void) adt_end_session(ah);
48 return;
49 }
50
51 if ((edata = adt_alloc_event(ah, eid)) == NULL) {
52 (void) adt_end_session(ah);
53 return;
54 }
55
56 switch (eid) {
57 case ADT_nwam_enable:
58 edata->adt_nwam_enable.profile_name = name;
59 edata->adt_nwam_enable.profile_type = descr_arg;
60 break;
61 case ADT_nwam_disable:
62 edata->adt_nwam_disable.profile_name = name;
63 edata->adt_nwam_disable.profile_type = descr_arg;
64 break;
65 case ADT_netcfg_update:
66 edata->adt_netcfg_update.object_name = name;
67 edata->adt_netcfg_update.parent_file = descr_arg;
68 break;
69 case ADT_netcfg_remove:
70 edata->adt_netcfg_remove.object_name = name;
71 edata->adt_netcfg_remove.parent_file = descr_arg;
72 break;
73 default:
74 goto out;
75 }
76
77 (void) adt_put_event(edata, status, error);
78
79 out:
80 adt_free_event(edata);
81 (void) adt_end_session(ah);
82 }
83