dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / libbsm / common / audit_scf.h
blob3d14ca7b047053aca465f8dfebff7ab6b353f91f
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
22 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
25 #ifndef _AUDIT_SCF_H
26 #define _AUDIT_SCF_H
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
33 * auditd smf(5)/libscf(3LIB) interface - set and display audit parameters
36 #include <audit_plugin.h>
37 #include <bsm/libbsm.h>
38 #include <ctype.h>
39 #include <libintl.h>
40 #include <libscf_priv.h>
41 #include <stdlib.h>
42 #include <strings.h>
43 #include <sys/varargs.h>
44 #include <ucontext.h>
45 #include <zone.h>
47 #ifndef DEBUG
48 #define DEBUG 0
49 #endif
51 #if DEBUG
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); }
55 #else /* ! DEBUG */
56 #define DPRINT(x)
57 #endif
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"
84 struct policy_sw {
85 char *policy;
86 boolean_t flag;
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"
95 struct scf_qctrl {
96 uint64_t scf_qhiwater;
97 uint64_t scf_qlowater;
98 uint64_t scf_qbufsz;
99 uint64_t scf_qdelay;
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];
122 kva_t *plugin_kva;
124 typedef struct scf_plugin_kva_node scf_plugin_kva_node_t;
126 /* Boundary checking macros for the queuectrl parameters. */
127 #define AQ_MINLOW 1
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 || \
133 (high) > AQ_MAXHIGH)
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);
165 #ifdef __cplusplus
167 #endif
169 #endif /* _AUDIT_SCF_H */