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-03-30 15:54:52 +0200
commit303675c98c399790560c80c792dd9a28bd6a4c69 (patch)
tree77b951a8ad55c8e9411ecf63552e8e0fd135c444 /daemon
parentd34ad86eb0181527c3141a8e4765742002b81a72 (diff)
downloadgvfs-303675c98c399790560c80c792dd9a28bd6a4c69.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);