dbus/dbus dbus-string.h, 1.27, 1.28 dbus-string.c, 1.50, 1.51 dbus-message.h, 1.55, 1.56 dbus-message.c, 1.138, 1.139

Colin Walters walters at freedesktop.org
Mon Nov 8 22:11:35 PST 2004


Update of /cvs/dbus/dbus/dbus
In directory gabe:/tmp/cvs-serv31095/dbus

Modified Files:
	dbus-string.h dbus-string.c dbus-message.h dbus-message.c 
Log Message:
2004-11-09  Colin Walters  <walters at verbum.org>

	* 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.


Index: dbus-string.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-string.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- dbus-string.h	9 Sep 2004 10:20:17 -0000	1.27
+++ dbus-string.h	9 Nov 2004 06:11:33 -0000	1.28
@@ -88,6 +88,9 @@
                                                   char             **data_return,
                                                   int                start,
                                                   int                len);
+void          _dbus_string_copy_to_buffer        (const DBusString  *str,
+                                                  char              *buffer,
+						  int                len);
 int           _dbus_string_get_length            (const DBusString  *str);
 dbus_bool_t   _dbus_string_lengthen              (DBusString        *str,
                                                   int                additional_length);

Index: dbus-string.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-string.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- dbus-string.c	10 Aug 2004 03:07:00 -0000	1.50
+++ dbus-string.c	9 Nov 2004 06:11:33 -0000	1.51
@@ -757,6 +757,30 @@
 }
 
 /**
+ * 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).
  *
  * @returns the length.

Index: dbus-message.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-message.h,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- dbus-message.h	9 Sep 2004 10:20:17 -0000	1.55
+++ dbus-message.h	9 Nov 2004 06:11:33 -0000	1.56
@@ -295,6 +295,7 @@
                                              dbus_int32_t      slot);
 
 int dbus_message_type_from_string (const char *type_str);
+const char * dbus_message_type_to_string (int type);
 
 DBUS_END_DECLS
 

Index: dbus-message.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-message.c,v
retrieving revision 1.138
retrieving revision 1.139
diff -u -d -r1.138 -r1.139
--- dbus-message.c	10 Aug 2004 21:32:25 -0000	1.138
+++ dbus-message.c	9 Nov 2004 06:11:33 -0000	1.139
@@ -5778,6 +5778,37 @@
     return DBUS_MESSAGE_TYPE_INVALID;
 }
 
+/**
+ * Utility function to convert a D-BUS message type into a
+ * machine-readable string (not translated).
+ *
+ * @code
+ *   DBUS_MESSAGE_TYPE_METHOD_CALL    -> "method_call"
+ *   DBUS_MESSAGE_TYPE_METHOD_RETURN  -> "method_return"
+ *   DBUS_MESSAGE_TYPE_SIGNAL         -> "signal"
+ *   DBUS_MESSAGE_TYPE_ERROR          -> "error"
+ *   DBUS_MESSAGE_TYPE_INVALID        -> "invalid"
+ * @endcode
+ * 
+ */
+const char *
+dbus_message_type_to_string (int type)
+{
+  switch (type)
+    {
+    case DBUS_MESSAGE_TYPE_METHOD_CALL:
+      return "method_call";
+    case DBUS_MESSAGE_TYPE_METHOD_RETURN:
+      return "method_return";
+    case DBUS_MESSAGE_TYPE_SIGNAL:
+      return "signal";
+    case DBUS_MESSAGE_TYPE_ERROR:
+      return "error";
+    default:
+      return "invalid";
+    }
+}
+
 /** @} */
 #ifdef DBUS_BUILD_TESTS
 #include "dbus-test.h"



More information about the dbus-commit mailing list