summaryrefslogtreecommitdiff
path: root/usr/src/lib/libscf/common/lowlevel.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libscf/common/lowlevel.c')
-rw-r--r--usr/src/lib/libscf/common/lowlevel.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/usr/src/lib/libscf/common/lowlevel.c b/usr/src/lib/libscf/common/lowlevel.c
index 2e31aa6e1f..ce40d0e74f 100644
--- a/usr/src/lib/libscf/common/lowlevel.c
+++ b/usr/src/lib/libscf/common/lowlevel.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -6871,3 +6871,49 @@ _scf_pg_is_read_protected(const scf_propertygroup_t *pg, boolean_t *out)
return (scf_set_error(SCF_ERROR_INTERNAL));
return (SCF_SUCCESS);
}
+
+/*
+ * _scf_set_annotation: a wrapper to set the annotation fields for SMF
+ * security auditing.
+ *
+ * Fails with following in scf_error_key thread specific data:
+ * _INVALID_ARGUMENT - operation or file too large
+ * _NOT_BOUND
+ * _CONNECTION_BROKEN
+ * _INTERNAL
+ * _NO_RESOURCES
+ */
+int
+_scf_set_annotation(scf_handle_t *h, const char *operation, const char *file)
+{
+ struct rep_protocol_annotation request;
+ struct rep_protocol_response response;
+ size_t copied;
+ int r;
+
+ request.rpr_request = REP_PROTOCOL_SET_AUDIT_ANNOTATION;
+ copied = strlcpy(request.rpr_operation,
+ (operation == NULL) ? "" : operation,
+ sizeof (request.rpr_operation));
+ if (copied >= sizeof (request.rpr_operation))
+ return (scf_set_error(SCF_ERROR_INVALID_ARGUMENT));
+
+ copied = strlcpy(request.rpr_file,
+ (file == NULL) ? "" : file,
+ sizeof (request.rpr_file));
+ if (copied >= sizeof (request.rpr_operation))
+ return (scf_set_error(SCF_ERROR_INVALID_ARGUMENT));
+
+ (void) pthread_mutex_lock(&h->rh_lock);
+ r = make_door_call(h, &request, sizeof (request),
+ &response, sizeof (response));
+ (void) pthread_mutex_unlock(&h->rh_lock);
+
+ if (r < 0) {
+ DOOR_ERRORS_BLOCK(r);
+ }
+
+ if (response.rpr_response != REP_PROTOCOL_SUCCESS)
+ return (scf_set_error(proto_error(response.rpr_response)));
+ return (0);
+}