[gvfs/wip/oholy/admin-fixes: 7/9] admin: Pass also XDG_RUNTIME_DIR to pkexec environment
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/wip/oholy/admin-fixes: 7/9] admin: Pass also XDG_RUNTIME_DIR to pkexec environment
- Date: Thu, 15 Apr 2021 07:12:33 +0000 (UTC)
commit 034ca8bd921919e4543481cd22c420258c0a54cd
Author: Ondrej Holy <oholy redhat com>
Date: Tue Mar 30 10:44:06 2021 +0200
admin: Pass also XDG_RUNTIME_DIR to pkexec environment
Recently, GVfs switched from abstract sockets to named sockets. The
sockets are created in the `XDG_RUNTIME_DIR` directory. This directory
is not unfortunatelly set for `gvfsd-admin` and thus the root's cache
dir is used instead, which is wrong. Let's pass the `XDG_RUNTIME_DIR`
environment variable to the `pkexec` environment similarly to
`DBUS_SESSION_BUS_ADDRESS`.
Fixes: https://gitlab.gnome.org/GNOME/gvfs/-/issues/552
daemon/admin.mount.in | 2 +-
daemon/gvfsbackendadmin.c | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/daemon/admin.mount.in b/daemon/admin.mount.in
index 4fb97701..09f3b6f8 100644
--- a/daemon/admin.mount.in
+++ b/daemon/admin.mount.in
@@ -1,7 +1,7 @@
[Mount]
Type=admin
# Add a dummy argument after pkexec, or '/bin/sh -c' will eat the first argument in '$@'
-Exec=/bin/sh -c 'pkexec @libexecdir@/gvfsd-admin "$@" --address $DBUS_SESSION_BUS_ADDRESS' gvfsd-admin
+Exec=/bin/sh -c 'pkexec @libexecdir@/gvfsd-admin "$@" --address $DBUS_SESSION_BUS_ADDRESS --dir
$XDG_RUNTIME_DIR' gvfsd-admin
AutoMount=false
DBusName=org.gtk.vfs.mountpoint_admin
MountPerClient=true
diff --git a/daemon/gvfsbackendadmin.c b/daemon/gvfsbackendadmin.c
index a56e2bd3..d6168520 100644
--- a/daemon/gvfsbackendadmin.c
+++ b/daemon/gvfsbackendadmin.c
@@ -1094,8 +1094,10 @@ acquire_caps (uid_t uid)
}
static char *session_address = NULL;
+static char *runtime_dir = NULL;
static GOptionEntry entries[] = {
{ "address", 0, 0, G_OPTION_ARG_STRING, &session_address, "DBus session address", NULL },
+ { "dir", 0, 0, G_OPTION_ARG_STRING, &runtime_dir, "Runtime dir", NULL },
{ NULL }
};
@@ -1134,4 +1136,7 @@ g_vfs_backend_admin_pre_setup (int *argc,
acquire_caps (uid);
g_setenv ("DBUS_SESSION_BUS_ADDRESS", session_address, TRUE);
+
+ if (runtime_dir)
+ g_setenv ("XDG_RUNTIME_DIR", runtime_dir, TRUE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]