diff options
| author | Richard M. Stallman | 1994-12-07 07:39:23 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-12-07 07:39:23 +0000 |
| commit | b135a7cf0b1607ae7f1085c3e0ed69d69f7d7fd6 (patch) | |
| tree | 22ed2bfffe1799ceeb5040e950c195448778e4da /lib-src | |
| parent | 021eac48bf914e3f1995c6170d8a15b38d000972 (diff) | |
| download | emacs-b135a7cf0b1607ae7f1085c3e0ed69d69f7d7fd6.tar.gz emacs-b135a7cf0b1607ae7f1085c3e0ed69d69f7d7fd6.zip | |
[HAVE_SYSVIPC]: Include sys/utsname.h.
(main): If socket/mqueue name is in home dir, add in the host name.
Rename .emacs_server to .emacs-server-....
[!HAVE_SYSVIPC] (main): Fix error message diction.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/emacsclient.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 303ad654030..2a48a5022d1 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c | |||
| @@ -27,7 +27,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |||
| 27 | #undef signal | 27 | #undef signal |
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | #if !defined(HAVE_SOCKETS) && !defined(HAVE_SYSVIPC) | 30 | #if !defined (HAVE_SOCKETS) && !defined (HAVE_SYSVIPC) |
| 31 | #include <stdio.h> | 31 | #include <stdio.h> |
| 32 | 32 | ||
| 33 | main (argc, argv) | 33 | main (argc, argv) |
| @@ -103,9 +103,9 @@ main (argc, argv) | |||
| 103 | perror ("stat"); | 103 | perror ("stat"); |
| 104 | exit (1); | 104 | exit (1); |
| 105 | } | 105 | } |
| 106 | if (statbfr.st_uid != geteuid()) | 106 | if (statbfr.st_uid != geteuid ()) |
| 107 | { | 107 | { |
| 108 | fprintf (stderr, "Illegal socket owner\n"); | 108 | fprintf (stderr, "Invalid socket owner\n"); |
| 109 | exit (1); | 109 | exit (1); |
| 110 | } | 110 | } |
| 111 | } | 111 | } |
| @@ -116,7 +116,9 @@ main (argc, argv) | |||
| 116 | exit (1); | 116 | exit (1); |
| 117 | } | 117 | } |
| 118 | strcpy (server.sun_path, homedir); | 118 | strcpy (server.sun_path, homedir); |
| 119 | strcat (server.sun_path, "/.emacs_server"); | 119 | strcat (server.sun_path, "/.emacs-server-"); |
| 120 | gethostname (system_name, sizeof (system_name)); | ||
| 121 | strcat (server.sun_path, system_name); | ||
| 120 | #endif | 122 | #endif |
| 121 | 123 | ||
| 122 | if (connect (s, (struct sockaddr *) &server, strlen (server.sun_path) + 2) | 124 | if (connect (s, (struct sockaddr *) &server, strlen (server.sun_path) + 2) |
| @@ -176,9 +178,11 @@ main (argc, argv) | |||
| 176 | #include <sys/types.h> | 178 | #include <sys/types.h> |
| 177 | #include <sys/ipc.h> | 179 | #include <sys/ipc.h> |
| 178 | #include <sys/msg.h> | 180 | #include <sys/msg.h> |
| 181 | #include <sys/utsname.h> | ||
| 179 | #include <stdio.h> | 182 | #include <stdio.h> |
| 180 | 183 | ||
| 181 | char *getwd (), *getcwd (), *getenv (); | 184 | char *getwd (), *getcwd (), *getenv (); |
| 185 | struct utsname system_name; | ||
| 182 | 186 | ||
| 183 | main (argc, argv) | 187 | main (argc, argv) |
| 184 | int argc; | 188 | int argc; |
| @@ -206,7 +210,7 @@ main (argc, argv) | |||
| 206 | } | 210 | } |
| 207 | 211 | ||
| 208 | /* | 212 | /* |
| 209 | * Create a message queue using ~/.emacs_server as the path for ftok | 213 | * Create a message queue using ~/.emacs-server as the path for ftok |
| 210 | */ | 214 | */ |
| 211 | if ((homedir = getenv ("HOME")) == NULL) | 215 | if ((homedir = getenv ("HOME")) == NULL) |
| 212 | { | 216 | { |
| @@ -214,7 +218,14 @@ main (argc, argv) | |||
| 214 | exit (1); | 218 | exit (1); |
| 215 | } | 219 | } |
| 216 | strcpy (buf, homedir); | 220 | strcpy (buf, homedir); |
| 217 | strcat (buf, "/.emacs_server"); | 221 | #ifndef HAVE_LONG_FILE_NAMES |
| 222 | /* If file names are short, we can't fit the host name. */ | ||
| 223 | strcat (buf, "/.emacs-server"); | ||
| 224 | #else | ||
| 225 | strcat (buf, "/.emacs-server-"); | ||
| 226 | uname (&system_name); | ||
| 227 | strcat (buf, system_name.nodename); | ||
| 228 | #endif | ||
| 218 | creat (buf, 0600); | 229 | creat (buf, 0600); |
| 219 | key = ftok (buf, 1); /* unlikely to be anyone else using it */ | 230 | key = ftok (buf, 1); /* unlikely to be anyone else using it */ |
| 220 | s = msgget (key, 0600 | IPC_CREAT); | 231 | s = msgget (key, 0600 | IPC_CREAT); |