- context = bus_connection_get_selinux_id (conn);
- if (!context)
- {
- dbus_set_error (error,
- DBUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN,
- "Could not determine security context for '%s'", service);
- goto failed;
- }
-
- if (! bus_selinux_append_context (reply, context, error))
- goto failed;
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(!bus_context_is_kdbus(bus_transaction_get_context (transaction)))
+ {
+#endif
+ conn = bus_driver_get_conn_helper (connection, message, "credentials",
+ &service, error);
+
+ if (conn == NULL)
+ goto failed;
+
+ /* we can't represent > 32-bit pids; if your system needs them, please
+ * add ProcessID64 to the spec or something */
+ if (dbus_connection_get_unix_process_id (conn, &ulong_val) &&
+ ulong_val <= _DBUS_UINT32_MAX)
+ {
+ if (!_dbus_asv_add_uint32 (&array_iter, "ProcessID", ulong_val))
+ goto oom;
+ }
+
+ /* we can't represent > 32-bit uids; if your system needs them, please
+ * add UnixUserID64 to the spec or something */
+ if (dbus_connection_get_unix_user (conn, &ulong_val) &&
+ ulong_val <= _DBUS_UINT32_MAX)
+ {
+ if (!_dbus_asv_add_uint32 (&array_iter, "UnixUserID", ulong_val))
+ goto oom;
+ }
+#ifdef ENABLE_KDBUS_TRANSPORT
+ }
+ else
+ {
+ if(kdbus_get_connection_unix_process_id(connection, message, &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 (!_dbus_asv_add_uint32 (&array_iter, "UnixUserID", ulong_val))
+ goto oom;
+ }
+ else
+ goto failed;
+ }
+#endif