+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.
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. */
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))
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);
(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)