unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Questions about XDG_RUNTIME_DIR and server-socket-dir
@ 2019-02-03  5:21 Phil Sainty
  2019-02-03  6:01 ` Eli Zaretskii
  2019-02-03  6:10 ` Paul Eggert
  0 siblings, 2 replies; 12+ messages in thread
From: Phil Sainty @ 2019-02-03  5:21 UTC (permalink / raw)
  To: emacs-devel@gnu.org

The recent change to server-socket-dir to use the XDG_RUNTIME_DIR
environment variable is breaking some of my tooling, so I want to
understand the matter better.

The essence of my issue is that, via my wrapper script, a user can
run multiple independent Emacs instances, including running multiple
Emacs servers, and it's necessary that I'm not depending on
--daemon=NAME to differentiate the server sockets in this situation,
because the user should be able to specify any arbitrary options,
and should be able to have a non-server instance call (server-start)
to create a new non-conflicting server with the default server-name.

At present I automatically establish a distinct TMPDIR for each
instance, and until Emacs 27 this has worked well: server-socket-dir
was relative to TMPDIR, and so it didn't matter whether multiple
servers had a common server-name, as the sockets themselves were in
different directories.

With the new behaviour, the socket filenames are all in a common
directory, and so unless a distinct server-name is specified,
conflicts occur.

XDG_RUNTIME_DIR is completely new to me, so I'm uncertain how I should
fix this.

I can, of course, create a temporary XDG_RUNTIME_DIR the same way that
I create a temporary TMPDIR (the new dir is a sub-dir of the original
dir), which would deal with the conflicts; but as such a change is
reflected in process-environment inside Emacs, any processes that
Emacs creates will see the modified XDG_RUNTIME_DIR too, and maybe
that's not ok?  I'm relatively comfortable with this being the case
for TMPDIR, but I don't know about XDG_RUNTIME_DIR.  Does that get
used in ways that rely upon its path never changing?

If it's not safe to change it, then I think I need a way to specify
the server-socket-dir via some new environment variable?

NEWS says that:

> *** Emacs and emacsclient now default to $XDG_RUNTIME_DIR/emacs
> as the directory for client/server sockets, if Emacs is running
> under an X Window System desktop that sets the XDG_RUNTIME_DIR
> environment variable to indicate where session sockets should go.
> To get the old, less-secure behavior, you can set the
> EMACS_SOCKET_NAME environment variable to an appropriate value.

It appears to me that *only* emacsclient respects the EMACS_SOCKET_NAME
environment variable.  Emacs itself ignores it when establishing the
socket, as far as I can see.  (This is a current bug?)

I think EMACS_SOCKET_NAME is, in any case, not suited for my purposes,
as it represents a combination of server-socket-dir and server-name,
and the emacsclient option --socket-name overrides it such that
--socket-name=foo would be looking for foo in the default location,
even if EMACS_SOCKET_NAME specified a directory.

Can we perhaps introduce an EMACS_SOCKET_DIR environment variable
which is respected by both emacs and emacsclient?


-Phil




^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-02-04 12:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-03  5:21 Questions about XDG_RUNTIME_DIR and server-socket-dir Phil Sainty
2019-02-03  6:01 ` Eli Zaretskii
2019-02-03  9:18   ` Phil Sainty
2019-02-03 11:21     ` Eli Zaretskii
2019-02-03 21:12       ` Phil Sainty
2019-02-04  3:30         ` Eli Zaretskii
2019-02-04  4:10           ` Stefan Monnier
2019-02-04  5:06           ` Phil Sainty
2019-02-03  6:10 ` Paul Eggert
2019-02-03  8:41   ` Phil Sainty
2019-02-03 16:42     ` Paul Eggert
2019-02-04 12:49   ` Ulrich Mueller

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).