dbus/bus dispatch.c,1.66,1.67 services.c,1.29,1.30

Havoc Pennington hp@freedesktop.org
Thu Jan 20 19:44:12 PST 2005


Update of /cvs/dbus/dbus/bus
In directory gabe:/tmp/cvs-serv882/bus

Modified Files:
	dispatch.c services.c 
Log Message:
2005-01-20  Havoc Pennington  <hp@redhat.com>

	* doc/dbus-tutorial.xml: replace > with &gt;

	* bus/services.c (bus_registry_acquire_service): validate the name
	and return a better error if it's no good.

	* doc/dbus-specification.xml: note NO_AUTO_START change

	* dbus/dbus-protocol.h (DBUS_HEADER_FLAG_NO_AUTO_START): change
	from AUTO_START, we're toggling the default

	* bus/dispatch.c: adapt the tests to change of auto-start default



Index: dispatch.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/dispatch.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- dispatch.c	18 Jan 2005 20:42:15 -0000	1.66
+++ dispatch.c	21 Jan 2005 03:44:10 -0000	1.67
@@ -983,7 +983,7 @@
 
   if (message == NULL)
     return TRUE;
-
+  
   if (!dbus_connection_send (connection, message, &serial))
     {
       dbus_message_unref (message);
@@ -1524,8 +1524,8 @@
  * but the correct thing may include OOM errors.
  */
 static dbus_bool_t
-check_nonexistent_service_activation (BusContext     *context,
-                                      DBusConnection *connection)
+check_nonexistent_service_no_auto_start (BusContext     *context,
+                                         DBusConnection *connection)
 {
   DBusMessage *message;
   dbus_uint32_t serial;
@@ -1541,6 +1541,8 @@
   if (message == NULL)
     return TRUE;
 
+  dbus_message_set_auto_start (message, FALSE);
+  
   flags = 0;
   if (!dbus_message_append_args (message,
                                  DBUS_TYPE_STRING, &nonexistent,
@@ -1628,8 +1630,8 @@
  * but the correct thing may include OOM errors.
  */
 static dbus_bool_t
-check_nonexistent_service_auto_activation (BusContext     *context,
-					   DBusConnection *connection)
+check_nonexistent_service_auto_start (BusContext     *context,
+                                      DBusConnection *connection)
 {
   DBusMessage *message;
   dbus_uint32_t serial;
@@ -1642,8 +1644,6 @@
   
   if (message == NULL)
     return TRUE;
-
-  dbus_message_set_auto_start (message, TRUE);
  
   if (!dbus_connection_send (connection, message, &serial))
     {
@@ -2387,8 +2387,8 @@
  * but the correct thing may include OOM errors.
  */
 static dbus_bool_t
-check_existent_service_activation (BusContext     *context,
-                                   DBusConnection *connection)
+check_existent_service_no_auto_start (BusContext     *context,
+                                      DBusConnection *connection)
 {
   DBusMessage *message;
   DBusMessage *base_service_message;
@@ -2408,6 +2408,8 @@
   if (message == NULL)
     return TRUE;
 
+  dbus_message_set_auto_start (message, FALSE);
+  
   flags = 0;
   if (!dbus_message_append_args (message,
                                  DBUS_TYPE_STRING, &existent,
@@ -2611,8 +2613,8 @@
  * but the correct thing may include OOM errors.
  */
 static dbus_bool_t
-check_segfault_service_activation (BusContext     *context,
-                                   DBusConnection *connection)
+check_segfault_service_no_auto_start (BusContext     *context,
+                                      DBusConnection *connection)
 {
   DBusMessage *message;
   dbus_uint32_t serial;
@@ -2628,6 +2630,8 @@
   if (message == NULL)
     return TRUE;
 
+  dbus_message_set_auto_start (message, FALSE);
+  
   segv_service = "org.freedesktop.DBus.TestSuiteSegfaultService";
   flags = 0;
   if (!dbus_message_append_args (message,
@@ -2717,8 +2721,8 @@
  * but the correct thing may include OOM errors.
  */
 static dbus_bool_t
-check_segfault_service_auto_activation (BusContext     *context,
-					DBusConnection *connection)
+check_segfault_service_auto_start (BusContext     *context,
+                                   DBusConnection *connection)
 {
   DBusMessage *message;
   dbus_uint32_t serial;
@@ -2731,8 +2735,6 @@
   
   if (message == NULL)
     return TRUE;
-
-  dbus_message_set_auto_start (message, TRUE);
   
   if (!dbus_connection_send (connection, message, &serial))
     {
@@ -2813,8 +2815,8 @@
  * but the correct thing may include OOM errors.
  */
 static dbus_bool_t
-check_existent_service_auto_activation (BusContext     *context,
-					DBusConnection *connection)
+check_existent_service_auto_start (BusContext     *context,
+                                   DBusConnection *connection)
 {
   DBusMessage *message;
   DBusMessage *base_service_message;
@@ -2833,8 +2835,6 @@
   if (message == NULL)
     return TRUE;
 
-  dbus_message_set_auto_start (message, TRUE);
-
   text = TEST_ECHO_MESSAGE;
   if (!dbus_message_append_args (message,
                                  DBUS_TYPE_STRING, &text,
@@ -3164,32 +3164,32 @@
   check1_try_iterations (context, "create_and_hello",
                          check_hello_connection);
   
-  check2_try_iterations (context, foo, "nonexistent_service_activation",
-                         check_nonexistent_service_activation);
+  check2_try_iterations (context, foo, "nonexistent_service_no_auto_start",
+                         check_nonexistent_service_no_auto_start);
 
-  check2_try_iterations (context, foo, "segfault_service_activation",
-                         check_segfault_service_activation);
+  check2_try_iterations (context, foo, "segfault_service_no_auto_start",
+                         check_segfault_service_no_auto_start);
   
-  check2_try_iterations (context, foo, "existent_service_activation",
-                         check_existent_service_activation);
+  check2_try_iterations (context, foo, "existent_service_no_auto_start",
+                         check_existent_service_no_auto_start);
   
-  check2_try_iterations (context, foo, "nonexistent_service_auto_activation",
-			 check_nonexistent_service_auto_activation);
+  check2_try_iterations (context, foo, "nonexistent_service_auto_start",
+			 check_nonexistent_service_auto_start);
   
-  check2_try_iterations (context, foo, "segfault_service_auto_activation",
-			 check_segfault_service_auto_activation);
+  check2_try_iterations (context, foo, "segfault_service_auto_start",
+			 check_segfault_service_auto_start);
 
 #if 0
   /* Note: need to resolve some issues with the testing code in order to run
    * this in oom (handle that we sometimes don't get replies back from the bus
    * when oom happens, without blocking the test).
    */
-  check2_try_iterations (context, foo, "existent_service_auto_activation",
-			 check_existent_service_auto_activation);
+  check2_try_iterations (context, foo, "existent_service_auto_auto_start",
+			 check_existent_service_auto_start);
 #endif
   
-  if (!check_existent_service_auto_activation (context, foo))
-    _dbus_assert_not_reached ("existent service auto activation failed");
+  if (!check_existent_service_auto_start (context, foo))
+    _dbus_assert_not_reached ("existent service auto start failed");
 
   _dbus_verbose ("Disconnecting foo, bar, and baz\n");
 

Index: services.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/services.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- services.c	18 Jan 2005 20:42:15 -0000	1.29
+++ services.c	21 Jan 2005 03:44:10 -0000	1.30
@@ -24,6 +24,7 @@
 #include <dbus/dbus-hash.h>
 #include <dbus/dbus-list.h>
 #include <dbus/dbus-mempool.h>
+#include <dbus/dbus-marshal-validate.h>
 
 #include "driver.h"
 #include "services.h"
@@ -283,12 +284,14 @@
   
   retval = FALSE;
 
-  if (_dbus_string_get_length (service_name) == 0)
+  if (!_dbus_validate_bus_name (service_name, 0,
+                                _dbus_string_get_length (service_name)))
     {
-      dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
-                      "Zero-length service name is not allowed");
+      dbus_set_error (error, DBUS_ERROR_INVALID_ARGS,
+                      "Requested bus name \"%s\" is not valid",
+                      _dbus_string_get_const_data (service_name));
       
-      _dbus_verbose ("Attempt to acquire zero-length service name\n");
+      _dbus_verbose ("Attempt to acquire invalid service name\n");
       
       goto out;
     }
@@ -296,7 +299,7 @@
   if (_dbus_string_get_byte (service_name, 0) == ':')
     {
       /* Not allowed; only base services can start with ':' */
-      dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
+      dbus_set_error (error, DBUS_ERROR_INVALID_ARGS,
                       "Cannot acquire a service starting with ':' such as \"%s\"",
                       _dbus_string_get_const_data (service_name));
       



More information about the dbus-commit mailing list