From cd3028abd00b5d6cf9ae7ce2d5aa1decdace424e Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Wed, 3 Apr 2019 18:05:27 +0200 Subject: [PATCH] system-helper: Don't use the system user when running on the session bus This makes it possible to test the revokefs codepaths with make check as non-root. Closes: #2657 Approved by: alexlarsson --- system-helper/flatpak-system-helper.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/system-helper/flatpak-system-helper.c b/system-helper/flatpak-system-helper.c index d56c94ea..516645df 100644 --- a/system-helper/flatpak-system-helper.c +++ b/system-helper/flatpak-system-helper.c @@ -1640,7 +1640,7 @@ handle_get_revokefs_fd (FlatpakSystemHelper *object, g_autofree gchar *flatpak_dir = NULL; g_autofree gchar *repo_tmp = NULL; g_autofree gchar *passwd_buf = NULL; - struct passwd passwd; + struct passwd passwd = { NULL }; OngoingPull *new_pull; uid_t uid; int fd_index = -1; @@ -1661,7 +1661,12 @@ handle_get_revokefs_fd (FlatpakSystemHelper *object, return TRUE; } - if (!check_for_system_helper_user (&passwd, &passwd_buf, &error)) + if (on_session_bus) + { + passwd.pw_uid = getuid(); + passwd.pw_gid = getgid(); + } + else if (!check_for_system_helper_user (&passwd, &passwd_buf, &error)) { g_dbus_method_invocation_return_gerror (invocation, error); return TRUE;