* Copyright (C) 2003 CodeFactory AB
* Copyright (C) 2003 Red Hat, Inc.
* Copyright (C) 2004 Imendio HB
+ * Copyright (C) 2013 Samsung Electronics
*
* Licensed under the Academic Free License version 2.1
*
struct BusPendingActivationEntry
{
+ /* Normally a method call, but if connection is NULL, this is a signal
+ * instead.
+ */
DBusMessage *activation_message;
+ /* NULL if this activation entry is for the dbus-daemon itself,
+ * waiting for systemd to start. In this case, auto_activation is always
+ * TRUE.
+ */
DBusConnection *connection;
dbus_bool_t auto_activation;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
+ retval = FALSE;
name = NULL;
exec = NULL;
user = NULL;
if (_dbus_hash_table_lookup_string (activation->entries, name))
{
- _dbus_verbose ("The new service name \"%s\" of service file \"%s\" already in cache, ignoring\n",
+ _dbus_verbose ("The new service name \"%s\" of service file \"%s\" is already in cache, ignoring\n",
name, _dbus_string_get_const_data (&file_path));
+ dbus_set_error (error, DBUS_ERROR_FAILED,
+ "The new service name \"%s\" of service file \"%s\" is already in cache, ignoring\n",
+ name, _dbus_string_get_const_data (&file_path));
goto out;
}
* the entries hash table */
_dbus_hash_table_remove_string (entry->s_dir->entries,
entry->filename);
- bus_activation_entry_unref (entry);
- return FALSE;
+ goto out;
}
}
if (entry)
bus_activation_entry_unref (entry);
- return FALSE;
+ return retval;
}
static dbus_bool_t
DBusError *error)
{
BusActivation *activation;
- DBusList *link;
- char *dir;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
BusPendingActivationEntry *entry = link->data;
DBusList *next = _dbus_list_get_next_link (&pending_activation->entries, link);
- if (dbus_connection_get_is_connected (entry->connection))
+ /* entry->connection is NULL for activating systemd */
+ if (entry->connection && dbus_connection_get_is_connected (entry->connection))
{
/* Only send activation replies to regular activation requests. */
if (!entry->auto_activation)
BusPendingActivationEntry *entry = link->data;
DBusList *next = _dbus_list_get_next_link (&pending_activation->entries, link);
- if (entry->auto_activation && dbus_connection_get_is_connected (entry->connection))
+ if (entry->auto_activation && (entry->connection == NULL || dbus_connection_get_is_connected (entry->connection)))
{
DBusConnection *addressed_recipient;
- addressed_recipient = bus_service_get_primary_owners_connection (service);
+#ifdef ENABLE_KDBUS_TRANSPORT
+ /* kdbus change - we can not send anything using phantom connections
+ * (DBusConnection structures for services other than daemon)
+ * so we have to use daemon connection
+ */
+ if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
+ addressed_recipient = entry->connection;
+ else
+#endif
+ addressed_recipient = bus_service_get_primary_owners_connection (service);
/* Resume dispatching where we left off in bus_dispatch() */
if (!bus_dispatch_matches (transaction,
BusPendingActivationEntry *entry = link->data;
DBusList *next = _dbus_list_get_next_link (&pending_activation->entries, link);
- if (dbus_connection_get_is_connected (entry->connection))
+ if (entry->connection && dbus_connection_get_is_connected (entry->connection))
{
if (!bus_transaction_send_error_reply (transaction,
entry->connection,
watch);
}
+static void
+toggle_babysitter_watch (DBusWatch *watch,
+ void *data)
+{
+ BusPendingActivation *pending_activation = data;
+
+ _dbus_loop_toggle_watch (bus_context_get_loop (pending_activation->activation->context),
+ watch);
+}
+
static dbus_bool_t
pending_activation_timed_out (void *data)
{
char **envp = NULL;
int argc;
dbus_bool_t retval;
- DBusHashIter iter;
dbus_bool_t was_pending_activation;
DBusString command;
pending_activation_entry->activation_message = activation_message;
dbus_message_ref (activation_message);
pending_activation_entry->connection = connection;
- dbus_connection_ref (connection);
+ if (connection)
+ dbus_connection_ref (connection);
/* Check if the service is being activated */
pending_activation = _dbus_hash_table_lookup_string (activation->pending_activations, service_name);
service_name,
entry->systemd_service);
/* systemd is not around, let's "activate" it. */
- retval = bus_activation_activate_service (activation, connection, activation_transaction, TRUE,
+ retval = bus_activation_activate_service (activation, NULL, activation_transaction, TRUE,
message, "org.freedesktop.systemd1", error);
}
if (!_dbus_babysitter_set_watch_functions (pending_activation->babysitter,
add_babysitter_watch,
remove_babysitter_watch,
- NULL,
+ toggle_babysitter_watch,
pending_activation,
NULL))
{
error:
for (j = 0; j < i; j++)
- dbus_free (retval[i]);
+ dbus_free (retval[j]);
dbus_free (retval);
return FALSE;
return TRUE;
}
-#ifdef DBUS_BUILD_TESTS
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
#include <stdio.h>
bus_activation_service_reload_test (const DBusString *test_data_dir)
{
DBusString directory;
+ const char *tmp;
if (!_dbus_string_init (&directory))
return FALSE;
- if (!_dbus_string_append (&directory, _dbus_get_tmpdir()))
+ tmp = _dbus_get_tmpdir ();
+
+ if (tmp == NULL)
+ return FALSE;
+
+ if (!_dbus_string_append (&directory, tmp))
return FALSE;
if (!_dbus_string_append (&directory, "/dbus-reload-test-") ||
_dbus_assert_not_reached ("could not initiate service reload test");
if (!do_service_reload_test (&directory, FALSE))
- ; /* Do nothing? */
+ {
+ /* Do nothing? */
+ }
/* Do OOM tests */
if (!init_service_reload_test (&directory))
_dbus_assert_not_reached ("could not initiate service reload test");
if (!do_service_reload_test (&directory, TRUE))
- ; /* Do nothing? */
+ {
+ /* Do nothing? */
+ }
/* Cleanup test directory */
if (!cleanup_service_reload_test (&directory))
return TRUE;
}
-#endif /* DBUS_BUILD_TESTS */
+#endif /* DBUS_ENABLE_EMBEDDED_TESTS */