summaryrefslogtreecommitdiff
path: root/lib-src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-04-20 09:31:47 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2019-04-20 09:40:10 -0700
commitb3a12c62c9085171866256f00dada4326a4a3084 (patch)
treef16ec0bf97b7cd85313dd1576e7ec176def06303 /lib-src
parenta85befa4aa52033bd6d9927144b358529ec2b360 (diff)
downloademacs-b3a12c62c9085171866256f00dada4326a4a3084.tar.gz
Improve XDG_RUNTIME_DIR diagnostic
* lib-src/emacsclient.c (set_local_socket): If there appears to be an XDG runtime directory for the user but XDG_RUNTIME_DIR is unset, suggest setting it while warning about potential security issues (Bug#35300).
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/emacsclient.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index f4768408980..5871a18ce69 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -1357,6 +1357,7 @@ set_local_socket (char const *server_name)
int tmpdirlen = -1;
int socknamelen = -1;
uid_t uid = geteuid ();
+ bool tmpdir_used = false;
if (strchr (server_name, '/')
|| (ISSLASH ('\\') && strchr (server_name, '\\')))
@@ -1389,6 +1390,7 @@ set_local_socket (char const *server_name)
}
socknamelen = local_sockname (sockname, socknamesize, tmpdirlen,
uid, server_name);
+ tmpdir_used = true;
}
}
@@ -1462,11 +1464,27 @@ set_local_socket (char const *server_name)
if (sock_status < 0)
message (true, "%s: Invalid socket owner\n", progname);
else if (sock_status == ENOENT)
- message (true,
- ("%s: can't find socket; have you started the server?\n"
- "%s: To start the server in Emacs,"
- " type \"M-x server-start\".\n"),
- progname, progname);
+ {
+ if (tmpdir_used)
+ {
+ uintmax_t id = uid;
+ char sockdirname[socknamesize];
+ int sockdirnamelen = snprintf (sockdirname, sizeof sockdirname,
+ "/run/user/%"PRIuMAX, id);
+ if (0 <= sockdirnamelen && sockdirnamelen < sizeof sockdirname
+ && euidaccess (sockdirname, X_OK) == 0)
+ message
+ (true,
+ ("%s: Should XDG_RUNTIME_DIR='%s' be in the environment?\n"
+ "%s: (Be careful: XDG_RUNTIME_DIR is security-related.)\n"),
+ progname, sockdirname, progname);
+ }
+ message (true,
+ ("%s: can't find socket; have you started the server?\n"
+ "%s: To start the server in Emacs,"
+ " type \"M-x server-start\".\n"),
+ progname, progname);
+ }
else
message (true, "%s: can't stat %s: %s\n",
progname, sockname, strerror (sock_status));