[Github-comments] [geany/geany] prefer XDG_RUNTIME_DIR over /tmp for the socket (#2222)
Colomban Wendling
notifications at xxxxx
Sun Jul 28 19:38:07 UTC 2019
b4n approved this pull request.
Apart from the nitpicking below, LGTM
>
if (utils_is_file_writable(real_path) != 0)
{ /* if real_path is not writable for us, fall back to ~/.config/geany/geany_socket_*_* */
/* instead of creating a symlink and print a warning */
g_warning("Socket %s could not be written, using %s as fallback.", real_path, path);
SETPTR(real_path, g_strdup(path));
}
- /* create a symlink in e.g. ~/.config/geany/geany_socket_hostname__0 to /tmp/geany_socket.499602d2 */
+ /* create a symlink in e.g. ~/.config/geany/geany_socket_hostname__0 to
+ * /var/run/user/1000/geany/geany_socket_hostname__0 */
the filename in /var in this comment is not correct anymore
> - * 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.
+ * If that fails, we try to use /tmp as a fallback. The last resort
+ * is the configuration directory. But the other directories
+ * are preferred in case the configuration directory is located on
+ * a network file system or any other file system which doesn't
+ * support sockets (see #1888561). Append a random int to
+ * prevent clashes with other instances on the system. */
+ real_dir = g_build_filename(g_get_user_runtime_dir(), "geany", NULL);
+ val = utils_mkdir(real_dir, FALSE);
ideally you'd increase the cope of the `saved_errno` variables en use that as it's a better variable name.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/2222#pullrequestreview-267504513
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20190728/96609eb2/attachment.html>
More information about the Github-comments
mailing list