1*6ba597c5SAnurag S. Maskey /*
2*6ba597c5SAnurag S. Maskey  * CDDL HEADER START
3*6ba597c5SAnurag S. Maskey  *
4*6ba597c5SAnurag S. Maskey  * The contents of this file are subject to the terms of the
5*6ba597c5SAnurag S. Maskey  * Common Development and Distribution License (the "License").
6*6ba597c5SAnurag S. Maskey  * You may not use this file except in compliance with the License.
7*6ba597c5SAnurag S. Maskey  *
8*6ba597c5SAnurag S. Maskey  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*6ba597c5SAnurag S. Maskey  * or http://www.opensolaris.org/os/licensing.
10*6ba597c5SAnurag S. Maskey  * See the License for the specific language governing permissions
11*6ba597c5SAnurag S. Maskey  * and limitations under the License.
12*6ba597c5SAnurag S. Maskey  *
13*6ba597c5SAnurag S. Maskey  * When distributing Covered Code, include this CDDL HEADER in each
14*6ba597c5SAnurag S. Maskey  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*6ba597c5SAnurag S. Maskey  * If applicable, add the following below this CDDL HEADER, with the
16*6ba597c5SAnurag S. Maskey  * fields enclosed by brackets "[]" replaced with your own identifying
17*6ba597c5SAnurag S. Maskey  * information: Portions Copyright [yyyy] [name of copyright owner]
18*6ba597c5SAnurag S. Maskey  *
19*6ba597c5SAnurag S. Maskey  * CDDL HEADER END
20*6ba597c5SAnurag S. Maskey  */
21*6ba597c5SAnurag S. Maskey 
22*6ba597c5SAnurag S. Maskey /*
23*6ba597c5SAnurag S. Maskey  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24*6ba597c5SAnurag S. Maskey  * Use is subject to license terms.
25*6ba597c5SAnurag S. Maskey  */
26*6ba597c5SAnurag S. Maskey 
27*6ba597c5SAnurag S. Maskey #include <sys/types.h>
28*6ba597c5SAnurag S. Maskey #include <bsm/adt.h>
29*6ba597c5SAnurag S. Maskey #include <bsm/adt_event.h>
30*6ba597c5SAnurag S. Maskey 
31*6ba597c5SAnurag S. Maskey #include <libnwam_priv.h>
32*6ba597c5SAnurag S. Maskey 
33*6ba597c5SAnurag S. Maskey /*
34*6ba597c5SAnurag S. Maskey  * Record libnwam's audit events (enable, disable, update and remove profiles).
35*6ba597c5SAnurag S. Maskey  */
36*6ba597c5SAnurag S. Maskey void
nwam_record_audit_event(const ucred_t * ucr,au_event_t eid,char * name,char * descr_arg,int status,int error)37*6ba597c5SAnurag S. Maskey nwam_record_audit_event(const ucred_t *ucr, au_event_t eid,
38*6ba597c5SAnurag S. Maskey     char *name, char *descr_arg, int status, int error)
39*6ba597c5SAnurag S. Maskey {
40*6ba597c5SAnurag S. Maskey 	adt_session_data_t *ah;
41*6ba597c5SAnurag S. Maskey 	adt_event_data_t *edata;
42*6ba597c5SAnurag S. Maskey 
43*6ba597c5SAnurag S. Maskey 	if (adt_start_session(&ah, NULL, 0) != 0)
44*6ba597c5SAnurag S. Maskey 		return;
45*6ba597c5SAnurag S. Maskey 
46*6ba597c5SAnurag S. Maskey 	if (adt_set_from_ucred(ah, ucr, ADT_NEW) != 0) {
47*6ba597c5SAnurag S. Maskey 		(void) adt_end_session(ah);
48*6ba597c5SAnurag S. Maskey 		return;
49*6ba597c5SAnurag S. Maskey 	}
50*6ba597c5SAnurag S. Maskey 
51*6ba597c5SAnurag S. Maskey 	if ((edata = adt_alloc_event(ah, eid)) == NULL) {
52*6ba597c5SAnurag S. Maskey 		(void) adt_end_session(ah);
53*6ba597c5SAnurag S. Maskey 		return;
54*6ba597c5SAnurag S. Maskey 	}
55*6ba597c5SAnurag S. Maskey 
56*6ba597c5SAnurag S. Maskey 	switch (eid) {
57*6ba597c5SAnurag S. Maskey 	case ADT_nwam_enable:
58*6ba597c5SAnurag S. Maskey 		edata->adt_nwam_enable.profile_name = name;
59*6ba597c5SAnurag S. Maskey 		edata->adt_nwam_enable.profile_type = descr_arg;
60*6ba597c5SAnurag S. Maskey 		break;
61*6ba597c5SAnurag S. Maskey 	case ADT_nwam_disable:
62*6ba597c5SAnurag S. Maskey 		edata->adt_nwam_disable.profile_name = name;
63*6ba597c5SAnurag S. Maskey 		edata->adt_nwam_disable.profile_type = descr_arg;
64*6ba597c5SAnurag S. Maskey 		break;
65*6ba597c5SAnurag S. Maskey 	case ADT_netcfg_update:
66*6ba597c5SAnurag S. Maskey 		edata->adt_netcfg_update.object_name = name;
67*6ba597c5SAnurag S. Maskey 		edata->adt_netcfg_update.parent_file = descr_arg;
68*6ba597c5SAnurag S. Maskey 		break;
69*6ba597c5SAnurag S. Maskey 	case ADT_netcfg_remove:
70*6ba597c5SAnurag S. Maskey 		edata->adt_netcfg_remove.object_name = name;
71*6ba597c5SAnurag S. Maskey 		edata->adt_netcfg_remove.parent_file = descr_arg;
72*6ba597c5SAnurag S. Maskey 		break;
73*6ba597c5SAnurag S. Maskey 	default:
74*6ba597c5SAnurag S. Maskey 		goto out;
75*6ba597c5SAnurag S. Maskey 	}
76*6ba597c5SAnurag S. Maskey 
77*6ba597c5SAnurag S. Maskey 	(void) adt_put_event(edata, status, error);
78*6ba597c5SAnurag S. Maskey 
79*6ba597c5SAnurag S. Maskey out:
80*6ba597c5SAnurag S. Maskey 	adt_free_event(edata);
81*6ba597c5SAnurag S. Maskey 	(void) adt_end_session(ah);
82*6ba597c5SAnurag S. Maskey }
83