From 935a41a04c3f638134fa905503fc41ddbd18902f Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 9 Nov 2004 06:11:33 +0000 Subject: 2004-11-09 Colin Walters * dbus/dbus-string.c (_dbus_string_get_length): New function, writes DBusString to C buffer. * dbus/dbus-string.h: Prototype it. * dbus/dbus-message.c (dbus_message_type_to_string): New function, converts message type into C string. * dbus/dbus-message.h: Prototype it. * bus/selinux.c (bus_selinux_check): Take source pid, target pid, and audit data. Pass audit data to avc_has_perm. (log_audit_callback): New function, appends extra audit information. (bus_selinux_allows_acquire_service): Also take service name, add it to audit data. (bus_selinux_allows_send): Also take message type, interface, method member, error name, and destination, and add them to audit data. (log_cb): Initialize func_audit. * bus/selinux.h (bus_selinux_allows_acquire_service) (bus_selinux_allows_send): Update prototypes * bus/services.c (bus_registry_acquire_service): Pass service name to bus_selinux_allows_acquire_service. * bus/bus.c (bus_context_check_security_policy): Pass additional audit data. Move assignment of dest to its own line. --- dbus/dbus-string.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'dbus/dbus-string.c') diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c index 2061e8be..7381dab2 100644 --- a/dbus/dbus-string.c +++ b/dbus/dbus-string.c @@ -756,6 +756,30 @@ _dbus_string_copy_data_len (const DBusString *str, return TRUE; } +/** + * Copies the contents of a DBusString into a different + * buffer. The resulting buffer will be nul-terminated. + * + * @param str a string + * @param buffer a C buffer to copy data to + * @param len maximum length of C buffer + */ +void +_dbus_string_copy_to_buffer (const DBusString *str, + char *buffer, + int avail_len) +{ + int copy_len; + DBUS_CONST_STRING_PREAMBLE (str); + + _dbus_assert (avail_len >= 0); + + copy_len = MIN (avail_len, real->len+1); + memcpy (buffer, real->str, copy_len); + if (avail_len > 0 && avail_len == copy_len) + buffer[avail_len-1] = '\0'; +} + /** * Gets the length of a string (not including nul termination). * -- cgit