/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/* auditd smf(5)/libscf(3LIB) interface - set and display audit parameters */
#include <audit_scf.h>
#include <audit_policy.h>
/* propvec array must be NULL terminated */
/*
* prt_error() - prt_error_va() wrapper; see prt_error_va() for more contextual
* information. Note, that the function disregards errno; if you need to print
* out strerror()/errno use directly prt_error_va().
* Inputs - program error format and message.
*/
/*PRINTFLIKE1*/
static void
{
errno = 0;
}
/*
* prt_error_va() - prints an error message along with corresponding system
* error number. Inputs - program error format and the va_list already prepared
* by the preceding functions.
*
*/
/*PRINTFLIKE1*/
void
{
if (errno)
}
/*
* prt_scf_err() - scf_error()/scf_strerror() wrapper.
*/
static void
prt_scf_err(void)
{
}
/*
* buf_concat() - concatenate two buffers.
*/
static boolean_t
{
char *dst_new;
return (B_FALSE);
}
if (src_len > 0) {
if (dst_sz_new > buf_limit) {
"size."));
return (B_FALSE);
}
return (B_FALSE);
}
*dst_sz = dst_sz_new;
}
return (B_FALSE);
}
return (B_TRUE);
}
/*
* remove_space() - removes a white space characters from the provided NUL
* terminated (or up to len characters) string. len = 0 - no len limit, wait for
* NUL character.
*/
static void
{
if (len == 0) {
} else {
len--;
}
}
if (!chklen) {
len++;
}
str++;
}
*str_ptr = '\0';
}
}
/*
* add_prop_vect_scf() - adds vector to the array of vectors later passed to
* get_/set_val_scf(). The first argument (vector) points to particular position
* in the vector of properties.
*/
static void
{
}
/*
* add_prop_vect_mval_scf() - updates vector in the array of vectors later
* passed to get_/set_val_scf() with a pointer to value of multivalued property.
* The first argument (vector) points to particular position in the vector of
* properties. The function is typically called several times based on amount of
* properties the multi-valued property should address; each of such calls
* preserves the vector (argument) pointing to the same position in the vector
* of properties, while it is expected that the prop_val_ptr changes.
* Use free_prop_vect_mval() for easy cleanup of the allocated resources.
*/
static boolean_t
{
}
return (B_FALSE);
}
} else {
}
}
return (B_TRUE);
}
/*
* get_val_scf() - get a property values from the audit service
*
* Arguments: vector = pointers to the head end of array of property vectors
* pgrp_name = property group of property in AUDITD_FMRI
*
*/
static boolean_t
{
/*
* Get the property vector from the editing snapshot (B_FALSE).
* For documentation on property vectors see <libscf_priv.h>.
*/
&bad_prop_vec) != SCF_SUCCESS) {
prt_scf_err();
if (bad_prop_vec != NULL) {
}
return (B_FALSE);
}
return (B_TRUE);
}
/*
* set_val_scf() - set property values of the audit service.
*
* arguments: vector = pointers to the head end of array of property vectors
* pgrp_name = property group of property in AUDITD_FMRI
*
*/
static boolean_t
{
/* for documentation on property vectors see <libscf_priv.h> */
&bad_prop_vec) != SCF_SUCCESS) {
prt_scf_err();
if (bad_prop_vec != NULL) {
}
return (B_FALSE);
}
return (B_TRUE);
}
/*
* free_prop_vect_mval() - deallocate heap memory used for multi-valued
* properties; see add_prop_vect_mval_scf().
*/
static void
free_prop_vect_mval(void)
{
if (prop_vect_ptr->pv_mval) {
while (pv_ptr_node != NULL) {
}
}
}
}
/*
* free_prop_vect() - deallocate heap memory used for propvect values.
*/
static void
free_prop_vect(void)
{
}
}
}
/*
* chk_prop_vect() - check for prop_vect boundaries and possibly process
* (typically) full prop_vect.
*/
static boolean_t
{
if (*prop_vect_ptr < prop_vect ||
return (B_FALSE);
}
}
return (B_TRUE);
}
/*
* scf_free() - free scf handles
*/
static void
{
return;
}
prt_scf_err();
}
}
}
/*
* scf_init() - initiate scf handles
*/
static boolean_t
{
prt_scf_err();
return (B_FALSE);
}
return (B_TRUE);
}
/*
* scf_free_iter() - free scf iter handles
*/
static void
{
if (handle_iter == NULL) {
return;
}
}
/*
* scf_init_iter() - initiate scf iter handles
*/
static boolean_t
{
prt_scf_err();
return (B_FALSE);
}
return (B_TRUE);
}
/*
* scf_free_iter_prop() - free scf iter handles (multi-valued property)
*/
static void
{
if (handle_iter_prop == NULL) {
return;
}
}
/*
* scf_init_iter_prop() - initiate scf iter handles (multi-valued property)
*/
static boolean_t
{
== NULL) {
prt_scf_err();
return (B_FALSE);
}
return (B_TRUE);
}
/*
* get_prop_str_singleval() - get the single-valued property key-val pair
*/
static boolean_t
{
char *val_buf;
char *att_buf;
int att_len;
prt_scf_err();
return (B_FALSE);
}
switch (prop_type) {
case SCF_TYPE_BOOLEAN: {
prt_scf_err();
return (B_FALSE);
}
if (att_len == -1) {
return (B_FALSE);
}
break;
}
case SCF_TYPE_ASTRING: {
if (val_buf_sz == -1) {
prt_scf_err();
return (B_FALSE);
}
return (B_FALSE);
}
val_buf_sz) == -1) {
prt_scf_err();
return (B_FALSE);
}
if (att_len == -1) {
return (B_FALSE);
}
break;
}
case SCF_TYPE_COUNT: {
prt_scf_err();
return (B_FALSE);
}
(unsigned long long) pval_count);
if (att_len == -1) {
return (B_FALSE);
}
break;
}
default:
return (B_FALSE);
}
return (B_FALSE);
}
return (B_TRUE);
}
/*
* get_prop_str_multival() - get the multi-valued property key-val pairs.
* Each of the values is represented by single key-val pair, where key is the
* same for all the values.
*/
static boolean_t
{
"(multi-valued property)."));
return (B_FALSE);
}
!= 0) {
prt_scf_err();
return (B_FALSE);
}
return (B_FALSE);
}
}
return (B_TRUE);
}
/*
* get_props_kva_all() - get all properties and fill in the pgrp_kva.
*/
static boolean_t
{
char *key_buf;
return (B_FALSE);
}
prt_scf_err();
return (B_FALSE);
}
return (B_FALSE);
}
key_buf_sz) == -1) {
prt_scf_err();
goto err_out;
}
handle_iter->prop_val) == 0) {
/* single-valued property call path */
goto err_out;
}
} else {
if (scf_error() != SCF_ERROR_CONSTRAINT_VIOLATED) {
prt_scf_err();
goto err_out;
}
/* multi-valued property call path */
goto err_out;
}
}
}
KV_DELIMITER)) == NULL) {
return (B_FALSE);
}
return (B_TRUE);
return (B_FALSE);
}
/*
* get_pgrp_kva() - get and save properties and values of given property group
* (or all properties and values of all property groups of type pgrp_type in
* case pgrp_name == NULL) into scf_pgrp_kva_node_t.
*/
static boolean_t
{
int rc;
prt_scf_err();
return (B_FALSE);
}
(const char *)pgrp_type) == -1) {
prt_scf_err();
return (B_FALSE);
}
if (pgrp_name_buf == NULL &&
return (B_FALSE);
}
pgrp_name_buf_sz) == -1) {
prt_scf_err();
return (B_FALSE);
}
continue;
}
return (B_FALSE);
}
}
}
prt_scf_err();
return (B_FALSE);
}
return (B_FALSE);
}
}
if (rc == -1) {
prt_scf_err();
return (B_FALSE);
}
#if DEBUG
{
while (node_debug != NULL) {
} else {
}
}
}
#endif
*pgrp_kva_ll = node_head;
return (B_TRUE);
}
/*
* chk_policy_context() - does some policy based checks, checks the context
* (zone, smf) in which the policy could make some sense.
*/
static boolean_t
{
/*
* "all" and "none" policy flags, since they represent
* AUDITD_FMRI service instance configuration.
*/
return (B_FALSE);
}
/*
* In the local zone (!= GLOBAL_ZONEID) we do not touch
* "ahlt" and "perzone" policy flags, since these are
* relevant only in the global zone.
*/
if ((getzoneid() != GLOBAL_ZONEID) &&
return (B_FALSE);
}
return (B_TRUE);
}
/*
* do_getqctrl_scf() - get the values of qctrl properties of the audit service
*/
{
return (B_FALSE);
}
return (B_TRUE);
}
/*
* do_getqbufsz_scf() - get the qbufsz audit service property value
*/
{
return (B_FALSE);
}
return (B_TRUE);
}
/*
* do_getqdelay_scf() - get the qdelay audit service property value
*/
{
return (B_FALSE);
}
return (B_TRUE);
}
/*
* do_getqhiwater_scf() - get the qhiwater audit service property value
*/
{
&cval_l);
return (B_FALSE);
}
return (B_TRUE);
}
/*
* do_getqlowater_scf() - get the qlowater audit service property value
*/
{
&cval_l);
return (B_FALSE);
}
return (B_TRUE);
}
/*
* do_getpolicy_scf() - get the audit policy flags from service
*/
{
int i;
char *cur_policy_str;
/* prepare the smf(5) query */
for (i = 0; i < POLICY_TBL_SZ; i++) {
/* Do some basic policy dependent checks */
if (!chk_policy_context(cur_policy_str)) {
continue;
}
}
return (B_FALSE);
}
/* set the policy mask */
*policy_mask = 0;
if (policy_arr_ptr->flag) {
}
}
return (B_TRUE);
}
/*
* do_setpolicy_scf() - sets the policy flags in audit service configuration
*/
{
int i;
char *cur_policy_str;
for (i = 0; i < POLICY_TBL_SZ; i++) {
/* Do some basic policy dependent checks */
if (!chk_policy_context(cur_policy_str)) {
continue;
}
*bool_arr_ptr = B_TRUE;
} else {
*bool_arr_ptr = B_FALSE;
}
}
}
/*
* do_setqctrl_scf() - set the values of qctrl properties of the audit service
*/
{
/* sanity checks */
if (cval_scf.scf_qhiwater == 0) {
}
if (cval_scf.scf_qlowater == 0) {
}
if (cval_scf.scf_qbufsz == 0) {
}
if (cval_scf.scf_qdelay == 0) {
}
"outside of allowed boundaries.\n"));
return (B_FALSE);
}
"outside of allowed boundaries.\n"));
return (B_FALSE);
}
"outside of allowed boundaries.\n"));
return (B_FALSE);
}
"outside of allowed boundaries.\n"));
return (B_FALSE);
}
}
/*
* do_setqbufsz_scf() - set the qbufsz property value of the audit service
*/
{
"outside of allowed boundaries.\n"));
return (B_FALSE);
}
}
/*
* do_setqdelay_scf() - set the qdelay property value of the audit service
*/
{
"outside of allowed boundaries.\n"));
return (B_FALSE);
}
}
/*
* do_setqhiwater_scf() - set the qhiwater property value of the audit service
*/
{
if (!do_getqlowater_scf(&cval_lowater)) {
"queue lowater mark.\n"));
return (B_FALSE);
}
if (cval_lowater == 0) {
}
"outside of allowed boundaries.\n"));
return (B_FALSE);
}
&cval_l);
}
/*
* do_setqlowater_scf() - set the qlowater property value of the audit service
*/
{
if (!do_getqhiwater_scf(&cval_hiwater)) {
"queue hiwater mark.\n"));
return (B_FALSE);
}
if (cval_hiwater == 0) {
}
"outside of allowed boundaries.\n"));
return (B_FALSE);
}
&cval_l);
}
/*
* do_getflags_scf() - get the audit attributable flags from service
*/
{
flags);
}
/*
* do_getnaflags_scf() - get the audit non-attributable flags from service
*/
{
naflags);
}
/*
* do_getars_scf() - get the audit remote server configuration (server)
*/
{
return (B_FALSE);
}
}
return (B_TRUE);
}
/*
* do_setflags_scf() - set the attributable mask property value of the audit
* service
*/
{
flags);
}
/*
* do_setnaflags_scf() - set the attributable mask property value of the audit
* service
*/
{
naflags);
}
/*
* do_destroypgrp_scf() - destroy a property group.
*/
{
char *asi_fmri;
return (B_FALSE);
}
/*
* scf_init() creates slightly more handles than is needed; this is
* perceived as acceptable since it allows better code readability
* while it has marginal impact on the executed command.
*/
return (B_FALSE);
}
goto err_out;
}
goto err_out;
}
return (B_TRUE);
prt_scf_err();
return (B_FALSE);
}
/*
* do_createpgrp_scf() - create a property group.
*/
{
/*
* scf_init() creates slightly more handles then is needed; this
* is perceived as acceptable since it allows better code readibility
* while it has marginal impact on the executed command.
*/
return (B_FALSE);
}
goto err_out;
}
goto err_out;
}
return (B_TRUE);
}
if (!do_destroypgrp_scf(pgrp_name)) {
"group: %s"), pgrp_name);
}
prt_scf_err();
return (B_FALSE);
}
/*
* do_createcgrp_scf() - create a property group representing connection group
* in the audit remote server model. All properties are to be set to their
* default values.
*/
{
};
SCF_TYPE_ASTRING, "solaris.smf.manage.audit") ||
"solaris.smf.value.audit")) {
goto out;
}
SCF_TYPE_ASTRING, "solaris.smf.value.audit");
out:
return (rval);
}
/*
* pgrp_avail_scf() - look for the property group in the audit service
* configuration. Test availability of: plugins, connection groups.
*/
{
char *asi_fmri;
return (B_FALSE);
}
return (B_FALSE);
}
/*
* scf_init() creates slightly more handles then is needed; this
* is perceived as acceptable since it allows better code readibility
* while it has marginal impact on the executed command.
*/
return (B_FALSE);
}
if (scf_error() != SCF_ERROR_NOT_FOUND) {
prt_scf_err();
}
}
return (rv);
}
/*
* pgrp_ctr_scf() - return the number of property groups of given type; -1 on
* error. Test availability of: plugins, connection groups.
*/
int
{
int rc;
int ctr = 0;
return (-1);
}
return (-1);
}
prt_scf_err();
return (-1);
}
return (-1);
}
(const char *)pgrp_type) == -1) {
prt_scf_err();
return (-1);
}
ctr++;
}
if (rc == -1) {
prt_scf_err();
ctr = -1;
}
return (ctr);
}
/*
* do_getpgrp_scf() - get contents of property group from the audit service
* instance configuration.
*/
{
char *asi_fmri;
return (B_FALSE);
}
} else {
return (B_FALSE);
}
}
return (B_FALSE);
}
SCF_DECODE_FMRI_EXACT) == -1) {
prt_scf_err();
return (B_FALSE);
}
return (B_FALSE);
}
return (rv);
}
/*
* do_setpgrp_scf() - set key-val pairs for the given property group. Attributes
* in pgrp_att_rm are removed from the set of attributes before the properties
* update process.
*/
{
int cnt;
int cnt_kva = 0;
int cnt_dup;
/* get rid of white-space chars */
return (B_FALSE);
}
/* remove unwanted attributes */
if (pgrp_att_rm != NULL) {
char *key;
char *lasts;
}
}
/* set attributes */
while (cnt > 0) {
cnt--;
cnt_kva++;
data++;
continue;
}
/* detect key duplicates */
if (cnt_kva > 0) {
data_dup--;
goto err_out;
}
}
}
cnt_kva++;
goto err_out;
}
prt_scf_err();
goto err_out;
}
prt_scf_err();
goto err_out;
}
switch (pgrp_prop_type) {
case SCF_TYPE_BOOLEAN: {
goto err_out;
}
break;
}
case SCF_TYPE_ASTRING: {
char *pval_str;
goto err_out;
}
break;
}
case SCF_TYPE_COUNT: {
if (pval_count == NULL) {
goto err_out;
}
break;
}
default:
break;
}
data++;
cnt--;
}
}
return (rval);
}
/*
* pgrp_kva_ll_free() - free the memory used by property group kva linked list.
*/
void
{
return;
}
}
}
}
/*
* get_policy() - get policy mask entry.
*/
{
int i;
for (i = 0; i < POLICY_TBL_SZ; i++) {
return (policy_table[i].policy_mask);
}
}
return (0);
}
/*
* get_laudit_cfg_state() - get per-configuration local audit state.
*/
{
return (B_FALSE);
}
break;
}
}
if (plugin_kva_ll == NULL) {
return (B_FALSE);
}
return (B_TRUE);
}
/*
* get_raudit_cfg_state() - get per-configuration remote audit state.
*/
{
char *att_str;
/* general ARS switch */
if (!do_getars_scf(&ars_cfg)) {
"configuration."));
return (B_FALSE);
}
return (B_FALSE);
}
/* at least one active connection group */
"configuration."));
return (B_FALSE);
}
while (cgrp_kva_ll_ptr != NULL) {
CGRP_ACTIVE)) == NULL) {
"connection group: %s"),
break;
}
break;
}
}
return (rc);
}