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.
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.
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]
22 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
33 * auditd smf(5)/libscf(3LIB) interface - set and display audit parameters
36 #include <audit_plugin.h>
37 #include <bsm/libbsm.h>
40 #include <libscf_priv.h>
43 #include <sys/varargs.h>
52 FILE *dbfp
; /* debug file pointer */
53 #define DPRINT(x) { if (dbfp == NULL) dbfp = __auditd_debug_file_open(); \
54 (void) fprintf x; (void) fflush(dbfp); }
59 /* Audit subsystem service instances */
60 #define AUDITD_FMRI "svc:/system/auditd:default"
61 #define AUDITSET_FMRI "svc:/system/auditset:default"
63 /* (ASI) Audit service instance SCF handles - libscf(3LIB) */
64 struct asi_scfhandle
{
65 scf_handle_t
*hndl
; /* base scf handle */
66 scf_instance_t
*inst
; /* service instance handle */
67 scf_propertygroup_t
*pgrp
; /* property group handle */
68 scf_property_t
*prop
; /* property handle */
70 typedef struct asi_scfhandle asi_scfhandle_t
;
72 struct asi_scfhandle_iter
{
73 scf_iter_t
*pgrp
; /* property group iter handle */
74 scf_iter_t
*prop
; /* property iter handle */
75 scf_value_t
*prop_val
; /* property value */
77 typedef struct asi_scfhandle_iter asi_scfhandle_iter_t
;
80 * (ASI) Audit service instance (svc:/system/auditd:default) related
81 * configuration parameters.
83 #define ASI_PGROUP_POLICY "policy"
88 typedef struct policy_sw policy_sw_t
;
90 #define ASI_PGROUP_QUEUECTRL "queuectrl"
91 #define QUEUECTRL_QBUFSZ "qbufsz"
92 #define QUEUECTRL_QDELAY "qdelay"
93 #define QUEUECTRL_QHIWATER "qhiwater"
94 #define QUEUECTRL_QLOWATER "qlowater"
96 uint64_t scf_qhiwater
;
97 uint64_t scf_qlowater
;
101 typedef struct scf_qctrl scf_qctrl_t
;
103 #define ASI_PGROUP_PRESELECTION "preselection"
104 #define PRESELECTION_FLAGS "flags"
105 #define PRESELECTION_NAFLAGS "naflags"
106 #define PRESELECTION_MAXBUF 256 /* max. length of na/flags */
108 /* auditd(1M) plugin related well known properties */
109 #define PLUGIN_ACTIVE "active" /* plugin state */
110 #define PLUGIN_PATH "path" /* plugin shared object */
111 #define PLUGIN_QSIZE "qsize" /* plugin queue size */
113 #define PLUGIN_MAX 256 /* max. amount of plugins */
114 #define PLUGIN_MAXBUF 256 /* max. length of plugin name */
115 #define PLUGIN_MAXATT 256 /* max. length of plugin attr */
116 #define PLUGIN_MAXKEY 256 /* max. length of plugin key */
117 #define PLUGIN_MAXVAL 256 /* max. length of plugin val */
118 struct scf_plugin_kva_node
{
119 struct scf_plugin_kva_node
*next
;
120 struct scf_plugin_kva_node
*prev
;
121 char plugin_name
[PLUGIN_MAXBUF
];
124 typedef struct scf_plugin_kva_node scf_plugin_kva_node_t
;
126 /* Boundary checking macros for the queuectrl parameters. */
128 #define CHK_BDRY_QBUFSZ(x) !((x) < AQ_BUFSZ || (x) > AQ_MAXBUFSZ)
129 #define CHK_BDRY_QDELAY(x) !((x) == 0 || (x) > AQ_MAXDELAY)
130 #define CHK_BDRY_QLOWATER(low, high) !((low) < AQ_MINLOW || (low) >= (high))
131 #define CHK_BDRY_QHIWATER(low, high) !((high) <= (low) || \
132 (high) < AQ_LOWATER || \
136 * MAX_PROPVECS maximum number of audit properties that will
137 * fit in the uint32_t audit policy mask.
139 #define MAX_PROPVECS 32
141 boolean_t
do_getflags_scf(char **);
142 boolean_t
do_getnaflags_scf(char **);
143 boolean_t
do_getpluginconfig_scf(char *, scf_plugin_kva_node_t
**);
144 boolean_t
do_getpolicy_scf(uint32_t *);
145 boolean_t
do_getqbufsz_scf(size_t *);
146 boolean_t
do_getqctrl_scf(struct au_qctrl
*);
147 boolean_t
do_getqdelay_scf(clock_t *);
148 boolean_t
do_getqhiwater_scf(size_t *);
149 boolean_t
do_getqlowater_scf(size_t *);
150 boolean_t
do_setflags_scf(char *);
151 boolean_t
do_setnaflags_scf(char *);
152 boolean_t
do_setpluginconfig_scf(char *, boolean_t
, char *, int);
153 boolean_t
do_setpolicy_scf(uint32_t);
154 boolean_t
do_setqbufsz_scf(size_t *);
155 boolean_t
do_setqctrl_scf(struct au_qctrl
*);
156 boolean_t
do_setqdelay_scf(clock_t *);
157 boolean_t
do_setqhiwater_scf(size_t *);
158 boolean_t
do_setqlowater_scf(size_t *);
159 void free_static_att_kva(kva_t
*);
160 uint32_t get_policy(char *);
161 boolean_t
plugin_avail_scf(const char *);
162 void plugin_kva_ll_free(scf_plugin_kva_node_t
*);
163 void prt_error_va(char *, va_list);
169 #endif /* _AUDIT_SCF_H */