summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2021-03-30 10:44:06 +0200
committerOndrej Holy <oholy@redhat.com>2021-03-31 15:56:31 +0200
commite5761b3315bcd0f786cb7901b07343606ca19acb (patch)
treed82264a1903eeb16c0661f8d287989bdcbe8f740
parent8af5e1ba9a63224f30a5dc9d91c9cce711dd16da (diff)
downloadgvfs-e5761b3315bcd0f786cb7901b07343606ca19acb.tar.gz
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
-rw-r--r--daemon/admin.mount.in2
-rw-r--r--daemon/gvfsbackendadmin.c5
2 files changed, 6 insertions, 1 deletions
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);
}