mirror of
https://github.com/masscollaborationlabs/emacs.git
synced 2025-07-03 19:03:24 +00:00
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).
This commit is contained in:
parent
a85befa4aa
commit
b3a12c62c9
1 changed files with 23 additions and 5 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue