From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Phil Sainty Newsgroups: gmane.emacs.devel Subject: Questions about XDG_RUNTIME_DIR and server-socket-dir Date: Sun, 3 Feb 2019 18:21:37 +1300 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="65276"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 To: "emacs-devel@gnu.org" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Feb 03 06:22:28 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gqAEd-000Grh-Bo for ged-emacs-devel@m.gmane.org; Sun, 03 Feb 2019 06:22:27 +0100 Original-Received: from localhost ([127.0.0.1]:51598 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqAEc-0006nt-7d for ged-emacs-devel@m.gmane.org; Sun, 03 Feb 2019 00:22:26 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:47821) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqADz-0006nb-LE for emacs-devel@gnu.org; Sun, 03 Feb 2019 00:21:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqADy-0004Y5-V1 for emacs-devel@gnu.org; Sun, 03 Feb 2019 00:21:47 -0500 Original-Received: from smtp-2.orcon.net.nz ([60.234.4.43]:37412) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gqADx-0004Pa-Fi for emacs-devel@gnu.org; Sun, 03 Feb 2019 00:21:46 -0500 Original-Received: from [150.107.172.32] (port=29392 helo=[192.168.20.103]) by smtp-2.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from ) id 1gqADq-0003aZ-3X for emacs-devel@gnu.org; Sun, 03 Feb 2019 18:21:38 +1300 Content-Language: en-GB X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 60.234.4.43 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:232922 Archived-At: 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