Commit 0734b0d0 authored by Stefan Monnier's avatar Stefan Monnier

(main): Don't use the hostname in the socket name.

Look for relative socket names in the /tmp dir rather than in cwd.
parent e8a12926
2004-01-27 Stefan Monnier <monnier@iro.umontreal.ca>
* emacsclient.c (main): Don't use the hostname in the socket name.
Look for relative socket names in the /tmp dir rather than in cwd.
2004-01-24 Richard M. Stallman <rms@gnu.org>
* emacsclient.c (main): Restore errno from saved_errno,
so the error message comes from socket_status.
2004-01-20 Stefan Monnier <monnier@iro.umontreal.ca>
* emacsclient.c (main): Stop if socket name too long.
Only try su-fallback if the socket name was not explicit.
Check socket name length in su-fallback case as well.
2004-01-08 Andreas Schwab <schwab@suse.de>
* emacsclient.c (main): Save errno from socket_status.
......
......@@ -299,8 +299,6 @@ main (argc, argv)
int argc;
char **argv;
{
char *system_name;
int system_name_length;
int s, i, needlf = 0;
FILE *out, *in;
struct sockaddr_un server;
......@@ -332,40 +330,24 @@ main (argc, argv)
server.sun_family = AF_UNIX;
{
char *dot;
system_name_length = 32;
while (1)
{
system_name = (char *) xmalloc (system_name_length + 1);
/* system_name must be null-terminated string. */
system_name[system_name_length] = '\0';
if (gethostname (system_name, system_name_length) == 0)
break;
free (system_name);
system_name_length *= 2;
}
/* We always use the non-dotted host name, for simplicity. */
dot = index (system_name, '.');
if (dot)
*dot = '\0';
}
{
int sock_status = 0;
int default_sock = !socket_name;
int saved_errno;
char *server_name = "server";
if (socket_name && !index (socket_name, '/') && !index (socket_name, '\\'))
{ /* socket_name is a file name component. */
server_name = socket_name;
socket_name = NULL;
default_sock = 1; /* Try both UIDs. */
}
if (default_sock)
{
socket_name = alloca (system_name_length + 100);
sprintf (socket_name, "/tmp/emacs%d-%s/server",
(int) geteuid (), system_name);
socket_name = alloca (100 + strlen (server_name));
sprintf (socket_name, "/tmp/emacs%d/%s",
(int) geteuid (), server_name);
}
if (strlen (socket_name) < sizeof (server.sun_path))
......@@ -399,8 +381,9 @@ main (argc, argv)
if (pw && (pw->pw_uid != geteuid ()))
{
/* We're running under su, apparently. */
sprintf (socket_name, "/tmp/emacs%d-%s/server",
(int) pw->pw_uid, system_name);
socket_name = alloca (100 + strlen (server_name));
sprintf (socket_name, "/tmp/emacs%d/%s",
(int) pw->pw_uid, server_name);
if (strlen (socket_name) < sizeof (server.sun_path))
strcpy (server.sun_path, socket_name);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment