summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2005-01-21 03:44:10 +0000
committerHavoc Pennington <hp@redhat.com>2005-01-21 03:44:10 +0000
commitf5cf675641e63cefc36c8a9a7a5872cc8600abcd (patch)
treef8762e202abb21da860b9af677ead55d5150dfa9
parent2abdb13ebe737e39653b79fecd93477e156b9db1 (diff)
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
-rw-r--r--ChangeLog14
-rw-r--r--bus/dispatch.c66
-rw-r--r--bus/services.c13
-rw-r--r--dbus/dbus-message.c8
-rw-r--r--dbus/dbus-protocol.h2
-rw-r--r--doc/dbus-specification.xml10
-rw-r--r--doc/dbus-tutorial.xml6
7 files changed, 68 insertions, 51 deletions
diff --git a/ChangeLog b/ChangeLog
index 1a9bcfcf..2d0dd6ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+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
+
2005-01-18 Havoc Pennington <hp@redhat.com>
* rename dbus-daemon-1 to dbus-daemon throughout
diff --git a/bus/dispatch.c b/bus/dispatch.c
index 120c9037..96115b1c 100644
--- a/bus/dispatch.c
+++ b/bus/dispatch.c
@@ -983,7 +983,7 @@ check_double_hello_message (BusContext *context,
if (message == NULL)
return TRUE;
-
+
if (!dbus_connection_send (connection, message, &serial))
{
dbus_message_unref (message);
@@ -1524,8 +1524,8 @@ check_hello_connection (BusContext *context)
* 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 @@ check_nonexistent_service_activation (BusContext *context,
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 @@ check_nonexistent_service_activation (BusContext *context,
* 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 @@ check_nonexistent_service_auto_activation (BusContext *context,
if (message == NULL)
return TRUE;
-
- dbus_message_set_auto_start (message, TRUE);
if (!dbus_connection_send (connection, message, &serial))
{
@@ -2387,8 +2387,8 @@ check_got_service_info (DBusMessage *message)
* 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 @@ check_existent_service_activation (BusContext *context,
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 @@ check_existent_service_activation (BusContext *context,
* 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 @@ check_segfault_service_activation (BusContext *context,
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 @@ check_segfault_service_activation (BusContext *context,
* 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 @@ check_segfault_service_auto_activation (BusContext *context,
if (message == NULL)
return TRUE;
-
- dbus_message_set_auto_start (message, TRUE);
if (!dbus_connection_send (connection, message, &serial))
{
@@ -2813,8 +2815,8 @@ check_segfault_service_auto_activation (BusContext *context,
* 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 @@ check_existent_service_auto_activation (BusContext *context,
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 @@ bus_dispatch_test (const DBusString *test_data_dir)
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");
diff --git a/bus/services.c b/bus/services.c
index 90c8d1d8..4392daa2 100644
--- a/bus/services.c
+++ b/bus/services.c
@@ -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 @@ bus_registry_acquire_service (BusRegistry *registry,
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 @@ bus_registry_acquire_service (BusRegistry *registry,
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));
diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c
index e4c761c2..4ddfa37a 100644
--- a/dbus/dbus-message.c
+++ b/dbus/dbus-message.c
@@ -2207,8 +2207,8 @@ dbus_message_set_auto_start (DBusMessage *message,
_dbus_return_if_fail (!message->locked);
_dbus_header_toggle_flag (&message->header,
- DBUS_HEADER_FLAG_AUTO_START,
- auto_start);
+ DBUS_HEADER_FLAG_NO_AUTO_START,
+ !auto_start);
}
/**
@@ -2223,8 +2223,8 @@ dbus_message_get_auto_start (DBusMessage *message)
{
_dbus_return_val_if_fail (message != NULL, FALSE);
- return _dbus_header_get_flag (&message->header,
- DBUS_HEADER_FLAG_AUTO_START);
+ return !_dbus_header_get_flag (&message->header,
+ DBUS_HEADER_FLAG_NO_AUTO_START);
}
diff --git a/dbus/dbus-protocol.h b/dbus/dbus-protocol.h
index fec94d8c..385c5ebc 100644
--- a/dbus/dbus-protocol.h
+++ b/dbus/dbus-protocol.h
@@ -142,7 +142,7 @@ extern "C" {
/* Header flags */
#define DBUS_HEADER_FLAG_NO_REPLY_EXPECTED 0x1
-#define DBUS_HEADER_FLAG_AUTO_START 0x2
+#define DBUS_HEADER_FLAG_NO_AUTO_START 0x2
/* Header fields */
#define DBUS_HEADER_FIELD_INVALID 0
diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml
index 821c6011..c0be80fb 100644
--- a/doc/dbus-specification.xml
+++ b/doc/dbus-specification.xml
@@ -757,10 +757,10 @@
to return the reply despite this flag.</entry>
</row>
<row>
- <entry><literal>AUTO_START</literal></entry>
+ <entry><literal>NO_AUTO_START</literal></entry>
<entry>0x2</entry>
- <entry>This message automatically launches an owner
- for the destination name before the message is delivered.
+ <entry>This message should not automatically launch an owner
+ for the destination name.
</entry>
</row>
</tbody>
@@ -1027,8 +1027,8 @@
flag and reply anyway.
</para>
<para>
- If a message has the flag <literal>AUTO_START</literal> and the
- destination name does not exist, then a program to own the destination
+ Unless a message has the flag <literal>NO_AUTO_START</literal>, if the
+ destination name does not exist then a program to own the destination
name will be started before the message is delivered. The message
will be held until the new program is successfully started or has
failed to start; in case of failure, an error will be returned. This
diff --git a/doc/dbus-tutorial.xml b/doc/dbus-tutorial.xml
index 44f2f7ca..ccb12d4c 100644
--- a/doc/dbus-tutorial.xml
+++ b/doc/dbus-tutorial.xml
@@ -408,7 +408,7 @@
method call on a particular object instance, a number of
nested components have to be named:
<programlisting>
- Address -> [Bus Name] -> Path -> Interface -> Method
+ Address -&gt; [Bus Name] -&gt; Path -&gt; Interface -&gt; Method
</programlisting>
The bus name is in brackets to indicate that it's optional -- you only
provide a name to route the method call to the right application
@@ -467,7 +467,7 @@ main (int argc, char **argv)
if (connection == NULL)
{
g_printerr ("Failed to open connection to bus: %s\n",
- error->message);
+ error-&gt;message);
g_error_free (error);
exit (1);
}
@@ -490,7 +490,7 @@ main (int argc, char **argv)
DBUS_TYPE_INVALID))
{
g_printerr ("Failed to complete ListNames call: %s\n",
- error->message);
+ error-&gt;message);
g_error_free (error);
exit (1);
}