From 19aa5de8e84c58bb8d9bf1f0ddcbeeb157de15d2 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Thu, 12 Nov 2015 00:22:14 +0100 Subject: [PATCH] Complete support for dbus-daemon driver methods GetConnectionUnixUser and GetConnectionUnixProcessID on windows. Let GetConnectionUnixUser method return a DBUS_ERROR_NOT_SUPPORTED error on windows, enable GetConnectionUnixProcessID and adapt related test-bus tests. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92721 --- bus/dispatch.c | 27 ++++++--------------------- bus/driver.c | 7 +++++++ 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/bus/dispatch.c b/bus/dispatch.c index 0a2342c..13e2adc 100644 --- a/bus/dispatch.c +++ b/bus/dispatch.c @@ -1277,6 +1277,12 @@ check_get_connection_unix_user (BusContext *context, { ; /* good, this is a valid response */ } +#ifdef DBUS_WIN + else if (dbus_message_is_error (message, DBUS_ERROR_NOT_SUPPORTED)) + { + /* good, this is a valid response */ + } +#endif else { warn_unexpected (connection, message, "not this error"); @@ -1346,9 +1352,7 @@ check_get_connection_unix_process_id (BusContext *context, dbus_bool_t retval; DBusError error; const char *base_service_name; -#ifdef DBUS_UNIX dbus_uint32_t pid; -#endif retval = FALSE; dbus_error_init (&error); @@ -1416,15 +1420,6 @@ check_get_connection_unix_process_id (BusContext *context, { ; /* good, this is a valid response */ } -#ifdef DBUS_WIN - else if (dbus_message_is_error (message, DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN)) - { - /* We are expecting this error, since we know in the test suite we aren't - * talking to a client running on UNIX - */ - _dbus_verbose ("Windows correctly does not support GetConnectionUnixProcessID\n"); - } -#endif else { #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ @@ -1445,10 +1440,6 @@ check_get_connection_unix_process_id (BusContext *context, } else { -#ifdef DBUS_WIN - warn_unexpected (connection, message, "GetConnectionUnixProcessID to fail on Windows"); - goto out; -#else if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_RETURN) { ; /* good, expected */ @@ -1497,7 +1488,6 @@ check_get_connection_unix_process_id (BusContext *context, goto out; } } -#endif /* !DBUS_WIN */ } if (!check_no_leftovers (context)) @@ -4837,16 +4827,11 @@ bus_dispatch_test_conf (const DBusString *test_data_dir, _dbus_assert_not_reached ("GetAllMatchRules message failed"); #endif -#ifdef DBUS_WIN - _dbus_verbose("Skipping deprecated test for GetConnectionUnixUser\n"); - _dbus_verbose("Skipping deprecated test for GetConnectionUnixProcessID\n"); -#else if (!check_get_connection_unix_user (context, baz)) _dbus_assert_not_reached ("GetConnectionUnixUser message failed"); if (!check_get_connection_unix_process_id (context, baz)) _dbus_assert_not_reached ("GetConnectionUnixProcessID message failed"); -#endif if (!check_list_services (context, baz)) _dbus_assert_not_reached ("ListActivatableNames message failed"); diff --git a/bus/driver.c b/bus/driver.c index 852ac53..a279258 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -1460,6 +1460,13 @@ bus_driver_handle_get_connection_unix_user (DBusConnection *connection, if (reply == NULL) goto oom; +#ifdef DBUS_WIN + dbus_set_error (error, + DBUS_ERROR_NOT_SUPPORTED, + "Not supported on windows platform"); + goto failed; +#endif + if (!dbus_connection_get_unix_user (conn, &uid)) { dbus_set_error (error, -- 1.8.4.5