summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2021-03-30 10:03:28 +0200
committerOndrej Holy <oholy@redhat.com>2021-04-15 07:12:32 +0000
commit06f90d2800048c5d52cf46adc882a49fe0707bcd (patch)
tree2fce2168bda66a4923145b7f9cbd8f835eff3846 /daemon
parent4bb8a42f90e681aa07ed9942d5dafd69d0307f0a (diff)
downloadgvfs-06f90d2800048c5d52cf46adc882a49fe0707bcd.tar.gz
daemon: Create socket dir from gvfsd daemon
Recently, GVfs switched from abstract sockets to named sockets. The socket dir is currently created by the individual daemons immediately before starting DBus server. If gvfsd-admin is started at first, the socket dir is owned by root user and thus it isn't accesible for other daemons and clients. Let's create the socket dir early from the gvfsd daemon to ensure correct ownership. https://gitlab.gnome.org/GNOME/gvfs/-/issues/552
Diffstat (limited to 'daemon')
-rw-r--r--daemon/gvfsdaemon.c3
-rw-r--r--daemon/main.c6
2 files changed, 7 insertions, 2 deletions
diff --git a/daemon/gvfsdaemon.c b/daemon/gvfsdaemon.c
index 8e4fb868..b29bba13 100644
--- a/daemon/gvfsdaemon.c
+++ b/daemon/gvfsdaemon.c
@@ -745,8 +745,7 @@ generate_address (gchar **address, gchar **socket_path)
gvfs_randomize_string (tmp + 7, 8);
tmp[15] = '\0';
- socket_dir = g_build_filename (g_get_user_runtime_dir (), "gvfsd", NULL);
- g_mkdir (socket_dir, 0700);
+ socket_dir = gvfs_get_socket_dir ();
*socket_path = g_build_filename (socket_dir, tmp, NULL);
*address = g_strdup_printf ("unix:path=%s", *socket_path);
diff --git a/daemon/main.c b/daemon/main.c
index d145c5f8..ff1c522b 100644
--- a/daemon/main.c
+++ b/daemon/main.c
@@ -143,6 +143,7 @@ main (int argc, char *argv[])
guint name_owner_id;
GBusNameOwnerFlags flags;
GOptionContext *context;
+ gchar *socket_dir;
const GOptionEntry options[] = {
{ "replace", 'r', 0, G_OPTION_ARG_NONE, &replace, N_("Replace old daemon."), NULL },
{ "no-fuse", 0, 0, G_OPTION_ARG_NONE, &no_fuse, N_("Don’t start fuse."), NULL },
@@ -212,6 +213,11 @@ main (int argc, char *argv[])
if (daemon == NULL)
return 1;
+ /* This is needed for gvfsd-admin to ensure correct ownership. */
+ socket_dir = gvfs_get_socket_dir ();
+ g_mkdir (socket_dir, 0700);
+ g_free (socket_dir);
+
g_signal_connect (daemon, "shutdown",
G_CALLBACK (daemon_shutdown), loop);