summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <pwithnall@endlessos.org>2021-01-14 18:03:35 +0000
committerPhilip Withnall <pwithnall@endlessos.org>2021-02-11 16:12:40 +0000
commit2f91caf77e7e13222373f0c5e8aec617b8e1cffa (patch)
treef932bc8d8592cf7082a48f8556f95f7264050e3c
parent5d0ffe73b76288bd43f01ea2b20416d646c5dca3 (diff)
downloadglib-2f91caf77e7e13222373f0c5e8aec617b8e1cffa.tar.gz
tests: Add a basic test for require-same-user D-Bus auth flag
It’s not feasible to test that the require-same-user flag can cause authentication to fail, as that would require the build environment to have two users available. We can, however, test that it passes when authenticating a client and server running under the same user account. I have manually tested that the new flag works, by running the following as user A: ``` `$prefix/gdbus-daemon --print-env &` gdbus call --session --dest org.freedesktop.DBus --object-path /org/freedesktop/DBus --method org.freedesktop.DBus.ListNames ``` And then running the `gdbus call` command again as user B (with the same value for `DBUS_SESSION_BUS_ADDRESS` in the environment), which produces: ``` Error connecting: Unexpected lack of content trying to read a line ``` (an authentication rejection) Commenting out the use of `G_DBUS_SERVER_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER` from `gdbusdaemon.c`, the `gdbus call` command succeeds for both users. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
-rw-r--r--gio/tests/gdbus-server-auth.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gio/tests/gdbus-server-auth.c b/gio/tests/gdbus-server-auth.c
index b3ee8aab2..bd1443eb1 100644
--- a/gio/tests/gdbus-server-auth.c
+++ b/gio/tests/gdbus-server-auth.c
@@ -37,6 +37,7 @@ typedef enum
INTEROP_FLAGS_TCP = (1 << 3),
INTEROP_FLAGS_LIBDBUS = (1 << 4),
INTEROP_FLAGS_ABSTRACT = (1 << 5),
+ INTEROP_FLAGS_REQUIRE_SAME_USER = (1 << 6),
INTEROP_FLAGS_NONE = 0
} InteropFlags;
@@ -325,6 +326,8 @@ do_test_server_auth (InteropFlags flags)
if (flags & INTEROP_FLAGS_ANONYMOUS)
server_flags |= G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS;
+ if (flags & INTEROP_FLAGS_REQUIRE_SAME_USER)
+ server_flags |= G_DBUS_SERVER_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER;
observer = g_dbus_auth_observer_new ();
@@ -514,6 +517,12 @@ test_server_auth_external (void)
}
static void
+test_server_auth_external_require_same_user (void)
+{
+ do_test_server_auth (INTEROP_FLAGS_EXTERNAL | INTEROP_FLAGS_REQUIRE_SAME_USER);
+}
+
+static void
test_server_auth_sha1 (void)
{
do_test_server_auth (INTEROP_FLAGS_SHA1);
@@ -537,6 +546,7 @@ main (int argc,
g_test_add_func ("/gdbus/server-auth/anonymous", test_server_auth_anonymous);
g_test_add_func ("/gdbus/server-auth/anonymous/tcp", test_server_auth_anonymous_tcp);
g_test_add_func ("/gdbus/server-auth/external", test_server_auth_external);
+ g_test_add_func ("/gdbus/server-auth/external/require-same-user", test_server_auth_external_require_same_user);
g_test_add_func ("/gdbus/server-auth/sha1", test_server_auth_sha1);
g_test_add_func ("/gdbus/server-auth/sha1/tcp", test_server_auth_sha1_tcp);