Mercurial > emacs
changeset 53734:132739917566
(main): Don't use the hostname in the socket name.
Look for relative socket names in the /tmp dir rather than in cwd.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Tue, 27 Jan 2004 23:04:52 +0000 |
parents | d5f680b60b41 |
children | f8ced39adaf1 |
files | lib-src/emacsclient.c |
diffstat | 1 files changed, 14 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/lib-src/emacsclient.c Tue Jan 27 22:54:45 2004 +0000 +++ b/lib-src/emacsclient.c Tue Jan 27 23:04:52 2004 +0000 @@ -299,8 +299,6 @@ int argc; char **argv; { - char *system_name; - int system_name_length; int s, i, needlf = 0; FILE *out, *in; struct sockaddr_un server; @@ -333,39 +331,23 @@ 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 @@ 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);