@b4n requested changes on this pull request.

I like the idea, but I'm a little worried about what the spec says on lifetime of files in that directory:
Files in this directory MAY be subjected to periodic clean-up. To ensure that your files are not removed, they should have their access time timestamp modified at least once every 6 hours of monotonic time or the 'sticky' bit should be set on the file.

This suggests our socket link could disappear on us after 6 hours if we're not careful, doesn't it? That could be a problem and the source of weird bugs.


In src/socket.c:

> @@ -439,20 +441,35 @@ static gint socket_fd_open_unix(const gchar *path)
 		return -1;
 	}
 
-	/* fix for #1888561:
-	 * in case the configuration directory is located on a network file system or any other
-	 * file system which doesn't support sockets, we just link the socket there and create the
-	 * real socket in the system's tmp directory assuming it supports sockets */
-	real_path = g_strdup_printf("%s%cgeany_socket.%08x",
-		g_get_tmp_dir(), G_DIR_SEPARATOR, g_random_int());
+	/* Try to place the socket in XDG_RUNTIME_DIR, according to XDG Base
+	 * Directory Specification, see
+	 * https://specifications.freedesktop.org/basedir-spec/latest */
+	real_dir = g_build_filename(g_get_user_runtime_dir(), "geany", NULL);
+	if (g_mkdir_with_parents(real_dir, 0755) == 0)

The spec says that The directory MUST be owned by the user, and he MUST be the only one having read and write access to it. Its Unix access mode MUST be 0700. The lifetime of the directory MUST be bound to the user being logged in. It MUST be created when the user first logs in […]. This tells us first that we don't need the with_parents() part as the runtime dir must already exist, and then even if it didn't have to it must be created with mode 0700, not 0755.
I suggest we use g_mkdir(real_dir, 0700), so we only create it when it's "safe".
Also note that g_get_user_runtime_dir() is slightly annoying in that it returns $XDG_CACHE_HOME if $XDG_RUNTIME_DIR isn't set, and that directory does not have cleanup semantics similar to /tmp or $XDG_RUNTIME_DIR.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.