Commit 66c15a41 authored by Simon McVittie's avatar Simon McVittie

Merge branch 'dbus-1.10'

parents db2af882 50fb0102
......@@ -20,10 +20,54 @@ Fixes:
<includedir>, apply the same relocation as for the Exec paths
in .service files (fd.o #92028, Simon McVittie)
• On Unix when running tests as root, don't assert that root and
the dbus-daemon user can still call UpdateActivationEnvironment;
assert that those privileged users can call BecomeMonitor instead
(fd.o #93036, Simon McVittie)
• On Windows, fix a memory leak in the autolaunch transport (fd.o #92899,
Simon McVittie)
• On Windows Autotools builds, don't run tests that rely on
dbus-run-session and other Unix-specifics (fd.o #92899, Simon McVittie)
D-Bus 1.10.4 (2015-11-17)
==
The “Frostburn Canyon” release.
Enhancements:
• GetConnectionCredentials, GetConnectionUnixUser and
GetConnectionUnixProcessID with argument "org.freedesktop.DBus"
will now return details of the dbus-daemon itself. This is required
to be able to call SetEnvironment on systemd.
(fd.o #92857, Jan Alexander Steffens)
Fixes:
• Make UpdateActivationEnvironment always fail with AccessDenied on the
system bus. Previously, it was possible to configure it so root could
call it, but the environment variables were not actually used,
because the launch helper would discard them.
(fd.o #92857, Jan Alexander Steffens)
• On Unix with --systemd-activation on a user bus, make
UpdateActivationEnvironment pass on its arguments to systemd's
SetEnvironment method, solving inconsistency between the environments
used for traditional activation and systemd user-service activation.
(fd.o #92857, Jan Alexander Steffens)
• On Windows, don't crash if <syslog/> or --syslog is used
(fd.o #92538, Ralf Habacker)
• On Windows, fix various failing tests:
• On Windows, fix a memory leak when setting a DBusError from a Windows
error (fd.o #92721, Ralf Habacker)
• On Windows, don't go into infinite recursion if we abort the process
with backtraces enabled (fd.o #92721, Ralf Habacker)
• Fix various failing tests, variously on Windows and cross-platform:
· don't test system.conf features (users, groups) that only make sense
on the system bus, which is not supported on Windows
· don't call _dbus_warn() when we skip a test, since it is fatal
......@@ -33,7 +77,8 @@ Fixes:
· don't stress-test refcounting under Wine, where it's really slow
· stop assuming that a message looped-back to the test will be received
immediately
(fd.o #83539, #92538, fd.o #92721; Ralf Habacker, Simon McVittie)
· skip some system bus tests on Windows since they make no sense there
(fd.o #92538, fd.o #92721; Ralf Habacker, Simon McVittie)
D-Bus 1.10.2 (2015-10-26)
==
......
This diff is collapsed.
......@@ -38,7 +38,7 @@ LT_CURRENT=17
## increment any time the source changes; set to
## 0 if you increment CURRENT
LT_REVISION=3
LT_REVISION=5
## increment if any interfaces have been added; set to 0
## if any interfaces have been changed or removed. removal has
......
......@@ -138,7 +138,6 @@ dbus_bool_t _dbus_group_info_fill_gid (DBusGroupInfo *info,
DBusError *error);
void _dbus_group_info_free (DBusGroupInfo *info);
dbus_uid_t _dbus_getuid (void);
DBUS_PRIVATE_EXPORT
dbus_uid_t _dbus_geteuid (void);
......
......@@ -2138,6 +2138,15 @@ _dbus_getpid (void)
return GetCurrentProcessId ();
}
/** Gets our Unix UID
* @returns on Windows, just DBUS_UID_UNSET
*/
dbus_uid_t
_dbus_getuid (void)
{
return DBUS_UID_UNSET;
}
/** nanoseconds in a second */
#define NANOSECONDS_PER_SECOND 1000000000
/** microseconds in a second */
......@@ -3188,6 +3197,7 @@ out:
_DBUS_ASSERT_ERROR_IS_SET (error);
_dbus_global_unlock (mutex);
_dbus_string_free (&shm_name);
return retval;
}
......
......@@ -643,6 +643,9 @@ unsigned long _dbus_pid_for_log (void);
DBUS_PRIVATE_EXPORT
dbus_pid_t _dbus_getpid (void);
DBUS_PRIVATE_EXPORT
dbus_uid_t _dbus_getuid (void);
dbus_bool_t _dbus_change_to_daemon_user (const char *user,
DBusError *error);
......
......@@ -15,7 +15,10 @@ SH_LOG_COMPILER = $(SHELL)
## note that TESTS has special meaning (stuff to use in make check)
## so if adding tests not to be run in make check, don't add them to
## TESTS
TESTS =
if DBUS_ENABLE_EMBEDDED_TESTS
if DBUS_UNIX
AM_TESTS_ENVIRONMENT = \
export DBUS_TOP_BUILDDIR=@abs_top_builddir@; \
export DBUS_TOP_SRCDIR=@abs_top_srcdir@; \
......@@ -25,9 +28,11 @@ AM_TESTS_ENVIRONMENT = \
export XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR; \
$(NULL)
TESTS=run-test.sh run-test-systemserver.sh
else
TESTS=
TESTS += \
run-test.sh \
run-test-systemserver.sh \
$(NULL)
endif
endif
EXTRA_DIST=run-test.sh run-test-systemserver.sh test-wait-for-echo.py test-activation-forking.py
......
......@@ -65,6 +65,35 @@ do { \
g_assert_cmpint (dbus_message_get_reply_serial (m), ==, 0); \
} while (0)
#define assert_method_call(m, sender, \
destination, path, iface, method, signature) \
do { \
g_assert_cmpstr (dbus_message_type_to_string (dbus_message_get_type (m)), \
==, dbus_message_type_to_string (DBUS_MESSAGE_TYPE_METHOD_CALL)); \
g_assert_cmpstr (dbus_message_get_sender (m), ==, sender); \
g_assert_cmpstr (dbus_message_get_destination (m), ==, destination); \
g_assert_cmpstr (dbus_message_get_path (m), ==, path); \
g_assert_cmpstr (dbus_message_get_interface (m), ==, iface); \
g_assert_cmpstr (dbus_message_get_member (m), ==, method); \
g_assert_cmpstr (dbus_message_get_signature (m), ==, signature); \
g_assert_cmpint (dbus_message_get_serial (m), !=, 0); \
g_assert_cmpint (dbus_message_get_reply_serial (m), ==, 0); \
} while (0)
#define assert_method_reply(m, sender, destination, signature) \
do { \
g_assert_cmpstr (dbus_message_type_to_string (dbus_message_get_type (m)), \
==, dbus_message_type_to_string (DBUS_MESSAGE_TYPE_METHOD_RETURN)); \
g_assert_cmpstr (dbus_message_get_sender (m), ==, sender); \
g_assert_cmpstr (dbus_message_get_destination (m), ==, destination); \
g_assert_cmpstr (dbus_message_get_path (m), ==, NULL); \
g_assert_cmpstr (dbus_message_get_interface (m), ==, NULL); \
g_assert_cmpstr (dbus_message_get_member (m), ==, NULL); \
g_assert_cmpstr (dbus_message_get_signature (m), ==, signature); \
g_assert_cmpint (dbus_message_get_serial (m), !=, 0); \
g_assert_cmpint (dbus_message_get_reply_serial (m), !=, 0); \
} while (0)
static DBusHandlerResult
systemd_filter (DBusConnection *connection,
DBusMessage *message,
......@@ -80,9 +109,23 @@ systemd_filter (DBusConnection *connection,
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
g_test_message("sender %s iface %s member %s",
dbus_message_get_sender (message),
dbus_message_get_interface (message),
dbus_message_get_member (message));
g_assert (f->systemd_message == NULL);
f->systemd_message = dbus_message_ref (message);
if (dbus_message_is_method_call (message, "org.freedesktop.systemd1.Manager",
"SetEnvironment"))
{
g_assert (dbus_message_get_no_reply (message));
g_test_message("got call");
return DBUS_HANDLER_RESULT_HANDLED;
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
......@@ -300,6 +343,171 @@ test_activation (Fixture *f,
dbus_message_unref (m);
}
static void
test_uae (Fixture *f,
gconstpointer context)
{
DBusMessage *m;
DBusPendingCall *pc;
DBusMessageIter args_iter, arr_iter, entry_iter;
const char *s;
if (f->address == NULL)
return;
m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS, "UpdateActivationEnvironment");
if (m == NULL)
g_error ("OOM");
dbus_message_iter_init_append (m, &args_iter);
/* Append an empty a{ss} (string => string dictionary). */
if (!dbus_message_iter_open_container (&args_iter, DBUS_TYPE_ARRAY,
"{ss}", &arr_iter) ||
!dbus_message_iter_close_container (&args_iter, &arr_iter))
g_error ("OOM");
if (!dbus_connection_send_with_reply (f->caller, m, &pc,
DBUS_TIMEOUT_USE_DEFAULT) || pc == NULL)
g_error ("OOM");
dbus_message_unref (m);
m = NULL;
if (dbus_pending_call_get_completed (pc))
test_pending_call_store_reply (pc, &m);
else if (!dbus_pending_call_set_notify (pc, test_pending_call_store_reply,
&m, NULL))
g_error ("OOM");
while (m == NULL)
test_main_context_iterate (f->ctx, TRUE);
assert_method_reply (m, DBUS_SERVICE_DBUS, f->caller_name, "");
dbus_message_unref (m);
/* The fake systemd connects to the bus. */
f->systemd = test_connect_to_bus (f->ctx, f->address);
if (!dbus_connection_add_filter (f->systemd, systemd_filter, f, NULL))
g_error ("OOM");
f->systemd_name = dbus_bus_get_unique_name (f->systemd);
take_well_known_name (f, f->systemd, "org.freedesktop.systemd1");
/* It gets the SetEnvironment */
while (f->systemd_message == NULL)
test_main_context_iterate (f->ctx, TRUE);
m = f->systemd_message;
f->systemd_message = NULL;
/* With activation, the destination is the well-known name */
assert_method_call (m, DBUS_SERVICE_DBUS, "org.freedesktop.systemd1",
"/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager",
"SetEnvironment", "as");
dbus_message_iter_init (m, &args_iter);
g_assert_cmpuint (dbus_message_iter_get_arg_type (&args_iter), ==,
DBUS_TYPE_ARRAY);
g_assert_cmpuint (dbus_message_iter_get_element_type (&args_iter), ==,
DBUS_TYPE_STRING);
dbus_message_iter_recurse (&args_iter, &arr_iter);
g_assert_cmpuint (dbus_message_iter_get_arg_type (&arr_iter), ==,
DBUS_TYPE_INVALID);
dbus_message_iter_next (&args_iter);
g_assert_cmpuint (dbus_message_iter_get_arg_type (&args_iter), ==,
DBUS_TYPE_INVALID);
dbus_message_unref (m);
m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS, "UpdateActivationEnvironment");
if (m == NULL)
g_error ("OOM");
dbus_message_iter_init_append (m, &args_iter);
{
const char *k1 = "Key1", *v1 = "Value1",
*k2 = "Key2", *v2 = "Value2";
/* Append a filled a{ss} (string => string dictionary). */
if (!dbus_message_iter_open_container (&args_iter, DBUS_TYPE_ARRAY,
"{ss}", &arr_iter) ||
!dbus_message_iter_open_container (&arr_iter, DBUS_TYPE_DICT_ENTRY,
NULL, &entry_iter) ||
!dbus_message_iter_append_basic (&entry_iter, DBUS_TYPE_STRING,
&k1) ||
!dbus_message_iter_append_basic (&entry_iter, DBUS_TYPE_STRING,
&v1) ||
!dbus_message_iter_close_container (&arr_iter, &entry_iter) ||
!dbus_message_iter_open_container (&arr_iter, DBUS_TYPE_DICT_ENTRY,
NULL, &entry_iter) ||
!dbus_message_iter_append_basic (&entry_iter, DBUS_TYPE_STRING,
&k2) ||
!dbus_message_iter_append_basic (&entry_iter, DBUS_TYPE_STRING,
&v2) ||
!dbus_message_iter_close_container (&arr_iter, &entry_iter) ||
!dbus_message_iter_close_container (&args_iter, &arr_iter))
g_error ("OOM");
}
if (!dbus_connection_send_with_reply (f->caller, m, &pc,
DBUS_TIMEOUT_USE_DEFAULT) || pc == NULL)
g_error ("OOM");
dbus_message_unref (m);
m = NULL;
if (dbus_pending_call_get_completed (pc))
test_pending_call_store_reply (pc, &m);
else if (!dbus_pending_call_set_notify (pc, test_pending_call_store_reply,
&m, NULL))
g_error ("OOM");
while (m == NULL)
test_main_context_iterate (f->ctx, TRUE);
assert_method_reply (m, DBUS_SERVICE_DBUS, f->caller_name, "");
dbus_message_unref (m);
while (f->systemd_message == NULL)
test_main_context_iterate (f->ctx, TRUE);
m = f->systemd_message;
f->systemd_message = NULL;
/* Without activation, the destination is the unique name */
assert_method_call (m, DBUS_SERVICE_DBUS, f->systemd_name,
"/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager",
"SetEnvironment", "as");
dbus_message_iter_init (m, &args_iter);
g_assert_cmpuint (dbus_message_iter_get_arg_type (&args_iter), ==,
DBUS_TYPE_ARRAY);
g_assert_cmpuint (dbus_message_iter_get_element_type (&args_iter), ==,
DBUS_TYPE_STRING);
dbus_message_iter_recurse (&args_iter, &arr_iter);
g_assert_cmpuint (dbus_message_iter_get_arg_type (&arr_iter), ==,
DBUS_TYPE_STRING);
dbus_message_iter_get_basic (&arr_iter, &s);
g_assert_cmpstr (s, ==, "Key1=Value1");
dbus_message_iter_next (&arr_iter);
g_assert_cmpuint (dbus_message_iter_get_arg_type (&arr_iter), ==,
DBUS_TYPE_STRING);
dbus_message_iter_get_basic (&arr_iter, &s);
g_assert_cmpstr (s, ==, "Key2=Value2");
dbus_message_iter_next (&arr_iter);
g_assert_cmpuint (dbus_message_iter_get_arg_type (&arr_iter), ==,
DBUS_TYPE_INVALID);
dbus_message_iter_next (&args_iter);
g_assert_cmpuint (dbus_message_iter_get_arg_type (&args_iter), ==,
DBUS_TYPE_INVALID);
dbus_message_unref (m);
}
static void
teardown (Fixture *f,
gconstpointer context G_GNUC_UNUSED)
......@@ -342,8 +550,10 @@ main (int argc,
{
test_init (&argc, &argv);
g_test_add ("/sd-activation", Fixture, NULL,
g_test_add ("/sd-activation/activation", Fixture, NULL,
setup, test_activation, teardown);
g_test_add ("/sd-activation/uae", Fixture, NULL,
setup, test_uae, teardown);
return g_test_run ();
}
......@@ -140,6 +140,71 @@ test_uae (Fixture *f,
dbus_message_unref (m);
}
static void
test_monitor (Fixture *f,
gconstpointer context)
{
const Config *config = context;
DBusMessage *m;
DBusPendingCall *pc;
DBusMessageIter args_iter;
DBusMessageIter arr_iter;
dbus_uint32_t no_flags = 0;
if (f->skip)
return;
m = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS, DBUS_INTERFACE_MONITORING, "BecomeMonitor");
if (m == NULL)
g_error ("OOM");
dbus_message_iter_init_append (m, &args_iter);
/* Append an empty as (string array). */
if (!dbus_message_iter_open_container (&args_iter, DBUS_TYPE_ARRAY,
"s", &arr_iter) ||
!dbus_message_iter_close_container (&args_iter, &arr_iter) ||
!dbus_message_iter_append_basic (&args_iter,
DBUS_TYPE_UINT32, &no_flags))
g_error ("OOM");
if (!dbus_connection_send_with_reply (f->conn, m, &pc,
DBUS_TIMEOUT_USE_DEFAULT) ||
pc == NULL)
g_error ("OOM");
dbus_message_unref (m);
m = NULL;
if (dbus_pending_call_get_completed (pc))
test_pending_call_store_reply (pc, &m);
else if (!dbus_pending_call_set_notify (pc, test_pending_call_store_reply,
&m, NULL))
g_error ("OOM");
while (m == NULL)
test_main_context_iterate (f->ctx, TRUE);
if (config->expect_success)
{
/* it succeeds */
g_assert_cmpint (dbus_message_get_type (m), ==,
DBUS_MESSAGE_TYPE_METHOD_RETURN);
}
else
{
/* it fails, yielding an error message with one string argument */
g_assert_cmpint (dbus_message_get_type (m), ==, DBUS_MESSAGE_TYPE_ERROR);
g_assert_cmpstr (dbus_message_get_error_name (m), ==,
DBUS_ERROR_ACCESS_DENIED);
g_assert_cmpstr (dbus_message_get_signature (m), ==, "s");
}
dbus_message_unref (m);
}
static void
teardown (Fixture *f,
gconstpointer context G_GNUC_UNUSED)
......@@ -188,12 +253,22 @@ main (int argc,
{
test_init (&argc, &argv);
g_test_add ("/uid-permissions/uae/root", Fixture, &root_ok_config,
setup, test_uae, teardown);
g_test_add ("/uid-permissions/uae/messagebus", Fixture, &messagebus_ok_config,
setup, test_uae, teardown);
/* UpdateActivationEnvironment used to be allowed by dbus-daemon for root
* and messagebus but not for other users (although system.conf forbids it
* for everyone, and it's useless). It is now hard-coded to fail on a
* system bus for everyone, so don't assert that root and messagebus
* may call it; continue to assert that it is denied for unprivileged
* users though. */
g_test_add ("/uid-permissions/uae/other", Fixture, &other_fail_config,
setup, test_uae, teardown);
/* BecomeMonitor has the behaviour that UAE used to have. */
g_test_add ("/uid-permissions/monitor/root", Fixture, &root_ok_config,
setup, test_monitor, teardown);
g_test_add ("/uid-permissions/monitor/messagebus", Fixture, &messagebus_ok_config,
setup, test_monitor, teardown);
g_test_add ("/uid-permissions/monitor/other", Fixture, &other_fail_config,
setup, test_monitor, teardown);
return g_test_run ();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment