diff options
| author | Stefan Monnier | 2004-01-20 23:25:33 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2004-01-20 23:25:33 +0000 |
| commit | 5c9659d3f6a8d29925bec34376f3e21f4a2deade (patch) | |
| tree | 2fa6f33ac1d0940bc0602bd154a3b8286ac7682a /lib-src | |
| parent | 9adcb5f2c83b756efe7c12ddaae03a9fcd678eea (diff) | |
| download | emacs-5c9659d3f6a8d29925bec34376f3e21f4a2deade.tar.gz emacs-5c9659d3f6a8d29925bec34376f3e21f4a2deade.zip | |
(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.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/emacsclient.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 9f8eb04011a..49ebada768f 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Client process that communicates with GNU Emacs acting as server. | 1 | /* Client process that communicates with GNU Emacs acting as server. |
| 2 | Copyright (C) 1986, 1987, 1994, 1999, 2000, 2001, 2003 | 2 | Copyright (C) 1986, 1987, 1994, 1999, 2000, 2001, 2003, 2004 |
| 3 | Free Software Foundation, Inc. | 3 | Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| @@ -358,9 +358,10 @@ main (argc, argv) | |||
| 358 | 358 | ||
| 359 | { | 359 | { |
| 360 | int sock_status = 0; | 360 | int sock_status = 0; |
| 361 | int default_sock = !socket_name; | ||
| 361 | int saved_errno; | 362 | int saved_errno; |
| 362 | 363 | ||
| 363 | if (! socket_name) | 364 | if (default_sock) |
| 364 | { | 365 | { |
| 365 | socket_name = alloca (system_name_length + 100); | 366 | socket_name = alloca (system_name_length + 100); |
| 366 | sprintf (socket_name, "/tmp/emacs%d-%s/server", | 367 | sprintf (socket_name, "/tmp/emacs%d-%s/server", |
| @@ -370,13 +371,16 @@ main (argc, argv) | |||
| 370 | if (strlen (socket_name) < sizeof (server.sun_path)) | 371 | if (strlen (socket_name) < sizeof (server.sun_path)) |
| 371 | strcpy (server.sun_path, socket_name); | 372 | strcpy (server.sun_path, socket_name); |
| 372 | else | 373 | else |
| 373 | fprintf (stderr, "%s: socket-name %s too long", | 374 | { |
| 374 | argv[0], socket_name); | 375 | fprintf (stderr, "%s: socket-name %s too long", |
| 376 | argv[0], socket_name); | ||
| 377 | exit (1); | ||
| 378 | } | ||
| 375 | 379 | ||
| 376 | /* See if the socket exists, and if it's owned by us. */ | 380 | /* See if the socket exists, and if it's owned by us. */ |
| 377 | sock_status = socket_status (server.sun_path); | 381 | sock_status = socket_status (server.sun_path); |
| 378 | saved_errno = errno; | 382 | saved_errno = errno; |
| 379 | if (sock_status) | 383 | if (sock_status && default_sock) |
| 380 | { | 384 | { |
| 381 | /* Failing that, see if LOGNAME or USER exist and differ from | 385 | /* Failing that, see if LOGNAME or USER exist and differ from |
| 382 | our euid. If so, look for a socket based on the UID | 386 | our euid. If so, look for a socket based on the UID |
| @@ -393,8 +397,18 @@ main (argc, argv) | |||
| 393 | if (pw && (pw->pw_uid != geteuid ())) | 397 | if (pw && (pw->pw_uid != geteuid ())) |
| 394 | { | 398 | { |
| 395 | /* We're running under su, apparently. */ | 399 | /* We're running under su, apparently. */ |
| 396 | sprintf (server.sun_path, "/tmp/emacs%d-%s/server", | 400 | sprintf (socket_name, "/tmp/emacs%d-%s/server", |
| 397 | (int) pw->pw_uid, system_name); | 401 | (int) pw->pw_uid, system_name); |
| 402 | |||
| 403 | if (strlen (socket_name) < sizeof (server.sun_path)) | ||
| 404 | strcpy (server.sun_path, socket_name); | ||
| 405 | else | ||
| 406 | { | ||
| 407 | fprintf (stderr, "%s: socket-name %s too long", | ||
| 408 | argv[0], socket_name); | ||
| 409 | exit (1); | ||
| 410 | } | ||
| 411 | |||
| 398 | sock_status = socket_status (server.sun_path); | 412 | sock_status = socket_status (server.sun_path); |
| 399 | saved_errno = errno; | 413 | saved_errno = errno; |
| 400 | } | 414 | } |