+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.
int argc;
char **argv;
{
- char *system_name;
- int system_name_length;
int s, i, needlf = 0;
FILE *out, *in;
struct sockaddr_un server;
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))
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);