changeset 99209:01e8c1513572

* server.el, emacsclient.c: Use TMPDIR (default /tmp) instead of hardcoded /tmp.
author Juanma Barranquero <lekktu@gmail.com>
date Wed, 29 Oct 2008 10:42:31 +0000
parents 45165d7f6e05
children ce3730476c2a
files lib-src/ChangeLog lib-src/emacsclient.c lisp/ChangeLog lisp/server.el
diffstat 4 files changed, 23 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/ChangeLog	Wed Oct 29 06:52:05 2008 +0000
+++ b/lib-src/ChangeLog	Wed Oct 29 10:42:31 2008 +0000
@@ -1,3 +1,8 @@
+2008-10-29  Ulrich Mueller  <ulm@gentoo.org>
+
+	* emacsclient.c (set_local_socket): Use TMPDIR (default /tmp)
+	instead of hardcoded /tmp.
+
 2008-10-13  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	* emacsclient.c (longopts, print_help_and_exit): Add -nw.
--- a/lib-src/emacsclient.c	Wed Oct 29 06:52:05 2008 +0000
+++ b/lib-src/emacsclient.c	Wed Oct 29 10:42:31 2008 +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 (32 + 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 (32 + 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);
--- a/lisp/ChangeLog	Wed Oct 29 06:52:05 2008 +0000
+++ b/lisp/ChangeLog	Wed Oct 29 10:42:31 2008 +0000
@@ -1,3 +1,8 @@
+2008-10-29  Ulrich Mueller  <ulm@gentoo.org>
+
+	* server.el (server-socket-dir): Use TMPDIR (default /tmp) instead
+	of hardcoded /tmp.
+
 2008-10-29  Glenn Morris  <rgm@gnu.org>
 
 	* net/xesam.el (dbus-get-unique-name, dbus-debug): Declare.
--- a/lisp/server.el	Wed Oct 29 06:52:05 2008 +0000
+++ b/lisp/server.el	Wed Oct 29 10:42:31 2008 +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)