]> code.delx.au - gnu-emacs/blobdiff - lisp/server.el
Merge from emacs-24; up to 2012-12-06T01:39:03Z!monnier@iro.umontreal.ca
[gnu-emacs] / lisp / server.el
index 32cecd508b58b8726bbf5194cd47b8ec79d60ab2..03d4bfc33df3ae0105f469c583e8030a344ea0ea 100644 (file)
@@ -1,6 +1,7 @@
 ;;; server.el --- Lisp code for GNU Emacs running as server process -*- lexical-binding: t -*-
 
-;; Copyright (C) 1986-1987, 1992, 1994-2012  Free Software Foundation, Inc.
+;; Copyright (C) 1986-1987, 1992, 1994-2013 Free Software Foundation,
+;; Inc.
 
 ;; Author: William Sommerfeld <wesommer@athena.mit.edu>
 ;; Maintainer: FSF
 
 (defcustom server-host nil
   "The name or IP address to use as host address of the server process.
-If set, the server accepts remote connections; otherwise it is local."
+If set, the server accepts remote connections; otherwise it is local.
+
+DO NOT give this a non-nil value unless you know what you are
+doing!  On unsecured networks, accepting remote connections is
+very dangerous, because server-client communication (including
+session authentication) is not encrypted."
   :group 'server
   :type '(choice
           (string :tag "Name or IP address")
@@ -140,12 +146,12 @@ directory residing in a NTFS partition instead."
 
 (defcustom server-auth-key nil
   "Server authentication key.
+This is only used if `server-use-tcp' is non-nil.
 
 Normally, the authentication key is randomly generated when the
-server starts, which guarantees some level of security.  It is
-recommended to leave it that way.  Using a long-lived shared key
-will decrease security (especially since the key is transmitted as
-plain text).
+server starts.  It is recommended to leave it that way.  Using a
+long-lived shared key will decrease security (especially since
+the key is transmitted as plain-text).
 
 In some situations however, it can be difficult to share randomly
 generated passwords with remote hosts (eg. no shared directory),
@@ -153,11 +159,13 @@ so you can set the key with this variable and then copy the
 server file to the remote host (with possible changes to IP
 address and/or port if that applies).
 
-The key must consist of 64 ASCII printable characters except for
-space (this means characters from ! to ~; or from code 33 to 126).
+Note that the usual security risks of using the server over
+remote TCP, arising from the fact that client-server
+communications are unencrypted, still apply.
 
-You can use \\[server-generate-key] to get a random authentication
-key."
+The key must consist of 64 ASCII printable characters except for
+space (this means characters from ! to ~; or from code 33 to
+126).  You can use \\[server-generate-key] to get a random key."
   :group 'server
   :type '(choice
          (const :tag "Random" nil)
@@ -835,6 +843,15 @@ This handles splitting the command if it would be bigger than
     (unless (assq w window-system-initialization-alist)
       (setq w nil))
 
+    ;; Special case for ns.  This is because DISPLAY may not be set at all
+    ;; which in the ns case isn't an error.  The variable display then becomes
+    ;; the fully qualified hostname, which make-frame-on-display below
+    ;; does not understand and throws an error.
+    ;; It may also be a valid X display, but if Emacs is compiled for ns, it
+    ;; can not make X frames.
+    (if (featurep 'ns-win)
+       (setq w 'ns display "ns"))
+
     (cond (w
            ;; Flag frame as client-created, but use a dummy client.
            ;; This will prevent the frame from being deleted when
@@ -1240,12 +1257,17 @@ The following commands are accepted by the client:
           (mapc 'funcall (nreverse commands))
 
          ;; If we were told only to open a new client, obey
-         ;; `initial-buffer-choice' if it specifies a file.
-         (unless (or files commands)
-           (if (stringp initial-buffer-choice)
-               (find-file initial-buffer-choice)
-             (switch-to-buffer (get-buffer-create "*scratch*")
-                               'norecord)))
+         ;; `initial-buffer-choice' if it specifies a file
+          ;; or a function.
+          (unless (or files commands)
+            (let ((buf
+                   (cond ((stringp initial-buffer-choice)
+                         (find-file-noselect initial-buffer-choice))
+                        ((functionp initial-buffer-choice)
+                         (funcall initial-buffer-choice)))))
+             (switch-to-buffer
+              (if (buffer-live-p buf) buf (get-buffer-create "*scratch*"))
+              'norecord)))
 
           ;; Delete the client if necessary.
           (cond