From d65c95210da2e583a60b43804b49399242c34e01 Mon Sep 17 00:00:00 2001 From: Leo Liu Date: Sat, 14 Apr 2012 14:28:57 +0800 Subject: [PATCH 1/5] * lisp/vc/diff-mode.el (diff-file-prev/next): Fix typo. --- lisp/ChangeLog | 4 ++++ lisp/vc/diff-mode.el | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c25fab9b619..416a365179f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2012-04-14 Leo Liu + + * vc/diff-mode.el (diff-file-prev/next): Fix typo. + 2012-04-14 Paul Eggert Spelling fixes. diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 16e33889c31..8b6b85dd22e 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -545,7 +545,7 @@ but in the file header instead, in which case move forward to the first hunk." (condition-case-unless-debug nil (diff-refine-hunk) (error nil)))) (easy-mmode-define-navigation - diff-file diff-file-header-re "file" diff-end-of-hunk) + diff-file diff-file-header-re "file" diff-end-of-file) (defun diff-restrict-view (&optional arg) "Restrict the view to the current hunk. From 29734c215668ccd0c5d9affb71a7290b0ea9dbe4 Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Sat, 14 Apr 2012 13:16:17 +0200 Subject: [PATCH 2/5] Allow using `server-auth-key' to set a permanent shared key * server.el (server-auth-key): New variable. (server-generate-key): New function. (server-get-auth-key): New function. (server-start): Use the new variable and functions to allow setting a permanent server key. Fixes: debbugs:9423 --- etc/NEWS | 5 ++++- lisp/ChangeLog | 8 +++++++ lisp/server.el | 61 ++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 66 insertions(+), 8 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 4ec33eae625..186dca19495 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -53,8 +53,11 @@ character when doing minibuffer filename prompts. ** which-function-mode now applies to all applicable major modes by default. ** erc will look up server/channel names via auth-source and use the - channel keys found, if any. +channel keys found, if any. +** The `server-auth-key' variable can be used to set a permanent +shared key for Emacs Server. + ** Obsolete packages: *** mailpost.el diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 416a365179f..0222d51f8bc 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2012-04-14 Michal Nazarewicz + + * server.el (server-auth-key): New variable. + (server-generate-key): New function. + (server-get-auth-key): New function. + (server-start): Use the new variable and functions to allow + setting a permanent server key (bug#9423). + 2012-04-14 Leo Liu * vc/diff-mode.el (diff-file-prev/next): Fix typo. diff --git a/lisp/server.el b/lisp/server.el index 404bebc4747..dd40199ad1c 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -139,6 +139,33 @@ directory residing in a NTFS partition instead." ;;;###autoload (put 'server-auth-dir 'risky-local-variable t) +(defcustom server-auth-key nil + "Server authentication key. + +Normally, authentication key is generated on random when server +starts, which guarantees some level of security. It is +recommended to leave it that way. Using a long-lived shared key +may decrease security (especially since the key is transmitted as +plain text). + +In some situations however, it can be difficult to share randomly +generated password with remote hosts (eg. no shared directory), +so you can set the key with this variable and then copy server +file to remote host (with possible changes to IP address and/or +port if that applies). + +The key must consist of 64 US-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 authentication +key." + :group 'server + :type '(choice + (const :tag "Random" nil) + (string :tag "Password")) + :version "24.2") + (defcustom server-raise-frame t "If non-nil, raise frame when switching to a buffer." :group 'server @@ -522,6 +549,32 @@ See variable `server-auth-dir' for details." (unless safe (error "The directory `%s' is unsafe" dir))))) +(defun server-generate-key () + "Generates and returns a random 64-byte strings of random chars +in the range `!'..`~'. If called interactively, also inserts it +into current buffer." + (interactive) + (let ((auth-key + (loop repeat 64 + collect (+ 33 (random 94)) into auth + finally return (concat auth)))) + (if (called-interactively-p) + (insert auth-key)) + auth-key)) + +(defun server-get-auth-key () + "Returns server's authentication key. + +If `server-auth-key' is nil this function will just call +`server-generate-key'. Otherwise, if `server-auth-key' is +a valid authentication it will return it. Otherwise, it will +signal an error." + (if server-auth-key + (if (string-match "^[!-~]\\{64\\}$" server-auth-key) + server-auth-key + (error "The key '%s' is invalid" server-auth-key)) + (server-generate-key))) + ;;;###autoload (defun server-start (&optional leave-dead inhibit-prompt) "Allow this Emacs process to be a server for client processes. @@ -615,13 +668,7 @@ server or call `M-x server-force-delete' to forcibly disconnect it.") (unless server-process (error "Could not start server process")) (process-put server-process :server-file server-file) (when server-use-tcp - (let ((auth-key - (loop - ;; The auth key is a 64-byte string of random chars in the - ;; range `!'..`~'. - repeat 64 - collect (+ 33 (random 94)) into auth - finally return (concat auth)))) + (let ((auth-key (server-get-auth-key))) (process-put server-process :auth-key auth-key) (with-temp-file server-file (set-buffer-multibyte nil) From e6de100c5eafc96bf4429700e28ebdac9bc2ad8d Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sat, 14 Apr 2012 13:36:26 +0200 Subject: [PATCH 3/5] (server-generate-key): `called-interactively-p' requires a parameter. --- lisp/ChangeLog | 5 +++++ lisp/server.el | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0222d51f8bc..b8b00ab4f04 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-04-14 Lars Ingebrigtsen + + * server.el (server-generate-key): `called-interactively-p' + requires a parameter. + 2012-04-14 Michal Nazarewicz * server.el (server-auth-key): New variable. diff --git a/lisp/server.el b/lisp/server.el index dd40199ad1c..97e9510b8f2 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -558,7 +558,7 @@ into current buffer." (loop repeat 64 collect (+ 33 (random 94)) into auth finally return (concat auth)))) - (if (called-interactively-p) + (if (called-interactively-p 'interactive) (insert auth-key)) auth-key)) From 3603c3b1c5a0870a46e3fa2878cdd29ac1f890d9 Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Sat, 14 Apr 2012 14:58:29 +0200 Subject: [PATCH 4/5] * lisp/server.el: Doc fixes. (server-auth-key, server-generate-key): Doc fixes. (server-get-auth-key): Doc fix. Use `string-match-p'. (server-start): Reflow docstring. --- lisp/ChangeLog | 6 ++++++ lisp/server.el | 44 +++++++++++++++++++++----------------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b8b00ab4f04..5b16d78f1ca 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2012-04-14 Juanma Barranquero + + * server.el (server-auth-key, server-generate-key): Doc fixes. + (server-get-auth-key): Doc fix. Use `string-match-p'. + (server-start): Reflow docstring. + 2012-04-14 Lars Ingebrigtsen * server.el (server-generate-key): `called-interactively-p' diff --git a/lisp/server.el b/lisp/server.el index 97e9510b8f2..058bc55d87d 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -142,21 +142,20 @@ directory residing in a NTFS partition instead." (defcustom server-auth-key nil "Server authentication key. -Normally, authentication key is generated on random when server -starts, which guarantees some level of security. It is +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 -may decrease security (especially since the key is transmitted as +will decrease security (especially since the key is transmitted as plain text). In some situations however, it can be difficult to share randomly -generated password with remote hosts (eg. no shared directory), -so you can set the key with this variable and then copy server -file to remote host (with possible changes to IP address and/or -port if that applies). +generated passwords with remote hosts (eg. no shared directory), +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 US-ASCII printable characters except -for space (this means characters from ! to ~; or from code 33 -to 126). +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 authentication key." @@ -550,9 +549,9 @@ See variable `server-auth-dir' for details." (error "The directory `%s' is unsafe" dir))))) (defun server-generate-key () - "Generates and returns a random 64-byte strings of random chars -in the range `!'..`~'. If called interactively, also inserts it -into current buffer." + "Generate and return a random authentication key. +The key is a 64-byte string of random chars in the range `!'..`~'. +If called interactively, also inserts it into current buffer." (interactive) (let ((auth-key (loop repeat 64 @@ -563,14 +562,13 @@ into current buffer." auth-key)) (defun server-get-auth-key () - "Returns server's authentication key. + "Return server's authentication key. -If `server-auth-key' is nil this function will just call -`server-generate-key'. Otherwise, if `server-auth-key' is -a valid authentication it will return it. Otherwise, it will -signal an error." +If `server-auth-key' is nil, just call `server-generate-key'. +Otherwise, if `server-auth-key' is a valid key, return it. +If the key is not valid, signal an error." (if server-auth-key - (if (string-match "^[!-~]\\{64\\}$" server-auth-key) + (if (string-match-p "^[!-~]\\{64\\}$" server-auth-key) server-auth-key (error "The key '%s' is invalid" server-auth-key)) (server-generate-key))) @@ -578,10 +576,10 @@ signal an error." ;;;###autoload (defun server-start (&optional leave-dead inhibit-prompt) "Allow this Emacs process to be a server for client processes. -This starts a server communications subprocess through which -client \"editors\" can send your editing commands to this Emacs -job. To use the server, set up the program `emacsclient' in the -Emacs distribution as your standard \"editor\". +This starts a server communications subprocess through which client +\"editors\" can send your editing commands to this Emacs job. +To use the server, set up the program `emacsclient' in the Emacs +distribution as your standard \"editor\". Optional argument LEAVE-DEAD (interactively, a prefix arg) means just kill any existing server communications subprocess. From 3c80ae807c532597ba07ff028efc8add447f962e Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Sat, 14 Apr 2012 10:53:52 -0700 Subject: [PATCH 5/5] Comment. --- lisp/progmodes/which-func.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el index bacc542a388..c8435c14ea2 100644 --- a/lisp/progmodes/which-func.el +++ b/lisp/progmodes/which-func.el @@ -80,7 +80,7 @@ For other modes it is disabled. If this is equal to t, then Which Function mode is enabled in any major mode that supports it." :group 'which-func - :version "24.2" ; added objc-mode + :version "24.2" ; explicit list -> t :type '(choice (const :tag "All modes" t) (repeat (symbol :tag "Major mode"))))