GNU bug report logs -
#33847
27.0.50; emacsclient does not find server socket
Previous Next
Reported by: Ulrich Mueller <ulm <at> gentoo.org>
Date: Sun, 23 Dec 2018 09:49:01 UTC
Severity: normal
Tags: patch
Merged with 41707
Found in version 27.0.50
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #59 received at 33847 <at> debbugs.gnu.org (full text, mbox):
>>>>> On Sun, 30 Dec 2018, Paul Eggert wrote:
> Because we're not absolutists. On older systems that do not have
> adequate provisions for security, Emacs does the best it can: that's
> better than not doing anything, and people who run older, less-secure
> systems are likely to not care all that much about security anyway so
> this is OK. On newer systems that are more secure, though, Emacs can
> be more secure.
Since there doesn't seem to be any progress here, please find below
the patch that I am using since some time.
From f8d87a0a89b91c120935bd5be802604b2c749767 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ulrich=20M=C3=BCller?= <ulm <at> gentoo.org>
Date: Sun, 20 Jan 2019 18:48:45 +0100
Subject: [PATCH] Add a fallback for the socket location in emacsclient
(bug#33847)
* lib-src/emacsclient.c (set_local_socket): Fall back to TMPDIR
if the socket is not found under XDG_RUNTIME_DIR.
---
lib-src/emacsclient.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index f476840898..27b945133e 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -1356,6 +1356,7 @@ set_local_socket (char const *server_name)
enum { socknamesize = sizeof server.un.sun_path };
int tmpdirlen = -1;
int socknamelen = -1;
+ int sock_status = -1;
uid_t uid = geteuid ();
if (strchr (server_name, '/')
@@ -1366,9 +1367,15 @@ set_local_socket (char const *server_name)
/* socket_name is a file name component. */
char const *xdg_runtime_dir = egetenv ("XDG_RUNTIME_DIR");
if (xdg_runtime_dir)
- socknamelen = snprintf (sockname, socknamesize, "%s/emacs/%s",
- xdg_runtime_dir, server_name);
- else
+ {
+ socknamelen = snprintf (sockname, socknamesize, "%s/emacs/%s",
+ xdg_runtime_dir, server_name);
+ /* Check if sockname is valid and if the socket exists. */
+ if (0 <= socknamelen && socknamelen < socknamesize)
+ sock_status = socket_status (sockname, uid);
+ }
+
+ if (sock_status)
{
char const *tmpdir = egetenv ("TMPDIR");
if (tmpdir)
@@ -1399,7 +1406,9 @@ set_local_socket (char const *server_name)
}
/* See if the socket exists, and if it's owned by us. */
- int sock_status = socket_status (sockname, uid);
+ if (sock_status)
+ sock_status = socket_status (sockname, uid);
+
if (sock_status)
{
/* Failing that, see if LOGNAME or USER exist and differ from
--
2.19.1
This bug report was last modified 3 years and 225 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.