#include <stdio.h>
#include <errno.h>
#include <limits.h>
+#include <stdlib.h>
#endif
static DBusConnection *
else
#endif
{
-
if (!bus_registry_list_services (registry, &services, &len))
{
dbus_message_unref (reply);
struct nameInfo info;
inter_ret = kdbus_NameQuery(name, dbus_connection_get_transport(connection), &info);
- if((inter_ret == 0) || (inter_ret == -ENOENT))
+ if((inter_ret == 0) || (inter_ret == -ENOENT) || (inter_ret == -ENXIO))
service_exists = (inter_ret == 0) ? TRUE : FALSE;
else
{
BusRegistry *registry;
BusService *service;
DBusMessage *reply;
+#ifdef ENABLE_KDBUS_TRANSPORT
+ char unique_name[(unsigned int)(snprintf((char*)base_name, 0, "%llu", ULLONG_MAX) + sizeof(":1."))];
+#endif
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
#ifdef ENABLE_KDBUS_TRANSPORT
if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
- {
- int ret;
- struct nameInfo info;
- char unique_name[(unsigned int)(snprintf((char*)base_name, 0, "%llu", ULLONG_MAX) + sizeof(":1."))];
+ {
+ int ret;
- ret = kdbus_NameQuery(text, dbus_connection_get_transport(connection), &info);
- if(ret == 0) //unique id of the name
- {
- sprintf(unique_name, ":1.%llu", (unsigned long long int)info.uniqueId);
- _dbus_verbose("Unique name discovered:%s\n", unique_name);
- base_name = unique_name;
- }
- else if(ret == -ENOENT) //name has no owner
- {
- dbus_set_error (error, DBUS_ERROR_NAME_HAS_NO_OWNER,
- "Could not get owner of name '%s': no such name", text);
- goto failed;
- }
- else
- {
- _dbus_verbose("kdbus error sending name query: err %d (%m)\n", errno);
- dbus_set_error (error, DBUS_ERROR_FAILED,
- "Could not determine unique name for '%s'", text);
- goto failed;
- }
- }
+ ret = kdbus_get_name_owner(connection, text, unique_name);
+ if(ret == 0)
+ base_name = unique_name;
+ else if((ret == -ENOENT) || (ret == -ENXIO)) //name has no owner
+ {
+ dbus_set_error (error, DBUS_ERROR_NAME_HAS_NO_OWNER,
+ "Could not get owner of name '%s': no such name", text);
+ goto failed;
+ }
+ else
+ {
+ dbus_set_error (error, DBUS_ERROR_FAILED,
+ "Could not determine unique name for '%s'", text);
+ goto failed;
+ }
+ }
else
#endif
{
if (! _dbus_list_append (&base_names, dbus_service_name))
goto oom;
}
+#ifdef ENABLE_KDBUS_TRANSPORT
+ else if (!bus_context_is_kdbus(bus_transaction_get_context (transaction)) && (service == NULL))
+#else
else if (service == NULL)
+#endif
{
dbus_set_error (error,
DBUS_ERROR_NAME_HAS_NO_OWNER,
}
else
{
- if (!bus_service_list_queued_owners (service,
- &base_names,
- error))
- goto failed;
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
+ {
+ if(!kdbus_list_queued (connection, &base_names, text ,error))
+ goto failed;
+ }
+ else
+#endif
+ {
+ if (!bus_service_list_queued_owners (service,
+ &base_names,
+ error))
+ goto failed;
+ }
}
_dbus_assert (base_names != NULL);
dbus_message_unref (reply);
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
+ {
+ link = _dbus_list_get_first_link (&base_names);
+ while (link != NULL)
+ {
+ DBusList *next = _dbus_list_get_next_link (&base_names, link);
+
+ if(link->data != NULL)
+ free(link->data);
+
+ _dbus_list_free_link (link);
+ link = next;
+ }
+ }
+#endif
+
return TRUE;
oom:
_DBUS_ASSERT_ERROR_IS_SET (error);
if (reply)
dbus_message_unref (reply);
-
if (base_names)
_dbus_list_clear (&base_names);
-
return FALSE;
}
#ifdef ENABLE_KDBUS_TRANSPORT
if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
{
- if(!kdbus_get_connection_unix_user(connection, message, &uid, error))
+ const char* name;
+
+ if(!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID))
+ goto failed;
+ if(!kdbus_get_unix_user(connection, name, &uid, error))
goto failed;
}
else
reply = dbus_message_new_method_return (message);
if (reply == NULL)
goto oom;
-
#ifdef ENABLE_KDBUS_TRANSPORT
if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
- {
- if(!kdbus_get_connection_unix_process_id(connection, message, &pid, error))
- goto failed;
- }
- else
+ {
+ const char* name;
+
+ if(!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID))
+ goto failed;
+ if(!kdbus_get_connection_unix_process_id(connection, name, &pid, error))
+ goto failed;
+ }
+ else
#endif
{
- conn = bus_driver_get_conn_helper (connection, message, "PID", &service,
- error);
-
- if (conn == NULL)
- goto failed;
-
-
+ conn = bus_driver_get_conn_helper (connection, message, "PID", &service,
+ error);
+ if (conn == NULL)
+ goto failed;
- if (!dbus_connection_get_unix_process_id (conn, &pid))
- {
- dbus_set_error (error,
- DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN,
- "Could not determine PID for '%s'", service);
- goto failed;
- }
+ if (!dbus_connection_get_unix_process_id (conn, &pid))
+ {
+ dbus_set_error (error,
+ DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN,
+ "Could not determine PID for '%s'", service);
+ goto failed;
+ }
}
pid32 = pid;
}
else
{
- if(kdbus_get_connection_unix_process_id(connection, message, &ulong_val, error))
+ const char* name;
+
+ if(!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID))
+ goto failed;
+ if(kdbus_get_connection_unix_process_id(connection, name, &ulong_val, error))
{
if (!_dbus_asv_add_uint32 (&array_iter, "ProcessID", ulong_val))
goto oom;
else
goto failed;
- if(kdbus_get_connection_unix_user(connection, message, &ulong_val, error))
+ if(kdbus_get_unix_user(connection, name, &ulong_val, error))
{
if (!_dbus_asv_add_uint32 (&array_iter, "UnixUserID", ulong_val))
goto oom;