unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ulrich Mueller <ulm@gentoo.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs@gentoo.org, Ulrich Mueller <ulm@gentoo.org>,
	Diego Petteno <flameeyes@gmail.com>,
	emacs-devel@gnu.org
Subject: Re: emacs client/server mode hardcodes /tmp path
Date: Wed, 29 Oct 2008 08:51:57 +0100	[thread overview]
Message-ID: <18696.5661.523071.167994@a1ihome1.kph.uni-mainz.de> (raw)
In-Reply-To: <jwvskqg23q9.fsf-monnier+emacs@gnu.org>

>>>>> On Tue, 28 Oct 2008, Stefan Monnier wrote:

> Yes, I think we should obey TMPDIR (of course consistently between
> emacsclient.c and server.el).

A patch is included below.

Ulrich


2008-10-29  Ulrich Mueller  <ulm@gentoo.org>

	* emacsclient.c (set_local_socket): Use TMPDIR (default /tmp)
	instead of hardcoded /tmp.

2008-10-29  Ulrich Mueller  <ulm@gentoo.org>

	* server.el (server-socket-dir): Use TMPDIR (default /tmp) instead
	of hardcoded /tmp.

--- lib-src/emacsclient.c	13 Oct 2008 02:32:51 -0000	1.133
+++ lib-src/emacsclient.c	29 Oct 2008 07:42:54 -0000
@@ -1128,6 +1128,7 @@
     int default_sock = !socket_name;
     int saved_errno = 0;
     char *server_name = "server";
+    char *tmpdir;
 
     if (socket_name && !index (socket_name, '/') && !index (socket_name, '\\'))
       { /* socket_name is a file name component.  */
@@ -1138,9 +1139,12 @@
 
     if (default_sock)
       {
- 	socket_name = alloca (100 + strlen (server_name));
- 	sprintf (socket_name, "/tmp/emacs%d/%s",
- 		 (int) geteuid (), server_name);
+	tmpdir = egetenv ("TMPDIR");
+	if (!tmpdir)
+	  tmpdir = "/tmp";
+	socket_name = alloca (96 + strlen (tmpdir) + strlen (server_name));
+	sprintf (socket_name, "%s/emacs%d/%s",
+		 tmpdir, (int) geteuid (), server_name);
       }
 
     if (strlen (socket_name) < sizeof (server.sun_path))
@@ -1174,9 +1178,10 @@
 	    if (pw && (pw->pw_uid != geteuid ()))
 	      {
 		/* We're running under su, apparently. */
-		socket_name = alloca (100 + strlen (server_name));
-		sprintf (socket_name, "/tmp/emacs%d/%s",
-			 (int) pw->pw_uid, server_name);
+		socket_name = alloca (96 + strlen (tmpdir)
+				      + strlen (server_name));
+		sprintf (socket_name, "%s/emacs%d/%s",
+			 tmpdir, (int) pw->pw_uid, server_name);
 
 		if (strlen (socket_name) < sizeof (server.sun_path))
 		  strcpy (server.sun_path, socket_name);
--- lisp/server.el	24 Oct 2008 09:39:32 -0000	1.169
+++ lisp/server.el	29 Oct 2008 07:42:56 -0000
@@ -202,7 +202,8 @@
 
 (defvar server-name "server")
 
-(defvar server-socket-dir (format "/tmp/emacs%d" (user-uid))
+(defvar server-socket-dir
+  (format "%s/emacs%d" (or (getenv "TMPDIR") "/tmp") (user-uid))
   "The directory in which to place the server socket.")
 
 (defun server-clients-with (property value)




  reply	other threads:[~2008-10-29  7:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-06 15:43 emacs client/server mode hardcodes /tmp path Diego 'Flameeyes' Pettenò
2008-03-06 17:48 ` Stefan Monnier
2008-03-06 17:58   ` Diego 'Flameeyes' Pettenò
2008-10-28 13:38   ` Ulrich Mueller
2008-10-28 14:29     ` Stefan Monnier
2008-10-29  7:51       ` Ulrich Mueller [this message]
2008-10-29  9:15         ` Juanma Barranquero
2008-10-29  9:28           ` Ulrich Mueller
2008-10-29  9:37             ` Juanma Barranquero
2008-10-29 14:41               ` Stefan Monnier
2008-10-29 14:55                 ` Juanma Barranquero
2008-10-29 15:03                   ` Stefan Monnier
2008-10-29 15:12                     ` Juanma Barranquero

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18696.5661.523071.167994@a1ihome1.kph.uni-mainz.de \
    --to=ulm@gentoo.org \
    --cc=emacs-devel@gnu.org \
    --cc=emacs@gentoo.org \
    --cc=flameeyes@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).