GNU bug report logs - #8198
[PATCH] lisp/server.el: Introduction of server-auth-key variable

Previous Next

Package: emacs;

Reported by: Michal Nazarewicz <mnazarewicz <at> google.com>

Date: Mon, 7 Mar 2011 21:48:01 UTC

Severity: wishlist

Tags: fixed, patch

Merged with 9423

Fixed in version 24.2

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8198 in the body.
You can then email your comments to 8198 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Acknowledgement sent to Michal Nazarewicz <mnazarewicz <at> google.com>:
New bug report received and filed, but not forwarded. (Mon, 07 Mar 2011 21:48:01 GMT) Full text and rfc822 format available.

Message #3 received at quiet <at> debbugs.gnu.org (full text, mbox):

From: Michal Nazarewicz <mnazarewicz <at> google.com>
To: quiet <at> debbugs.gnu.org
Subject: [PATCH] lisp/server.el: Introduction of server-auth-key variable
Date: Tue, 22 Feb 2011 14:55:00 +0100
Package: emacs
Severity: wishlist


This commit adds a server-auth-key variable which allows
user to specify a default authentication key used by the
server process.
---
 lisp/server.el |   42 +++++++++++++++++++++++++++++++++++-------
 1 files changed, 35 insertions(+), 7 deletions(-)

Hello, attached is a patch that adds a `server-auth-key' variable,
which I use to easily allow a host to connect to Emacs daemon
listening on TCP port without the need of synchronising the server
file each time server starts.

The etc/CONTRIBUTE mentions ChangeLog entry.  I'm unsure whether
you need anything more then the commit message above but in case
you do, here's ChangeLog entry:

2011-02-21  Michal Nazarewicz  <mina86 <at> mina86.com>  (tiny change)

	* lisp/server.el: Introduce server-auth-key variable which
	allows user to specify a default authentication key used by
	the server process.

Hope you guys don't mind git style patch mail.

diff --git a/lisp/server.el b/lisp/server.el
index df8cae0..3963e86 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -134,6 +134,27 @@ 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 a certain level of security.  It is
+recommended to leave it that way.
+
+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).
+
+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.0")
+
 (defcustom server-raise-frame t
   "If non-nil, raise frame when switching to a buffer."
   :group 'server
@@ -495,6 +516,19 @@ 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))
+
 ;;;###autoload
 (defun server-start (&optional leave-dead inhibit-prompt)
   "Allow this Emacs process to be a server for client processes.
@@ -588,13 +622,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 (or server-auth-key (server-generate-key))))
 	      (process-put server-process :auth-key auth-key)
 	      (with-temp-file server-file
 		(set-buffer-multibyte nil)
-- 
1.7.3.1




Merged 8198 9423. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 02 Sep 2011 06:53:02 GMT) Full text and rfc822 format available.

Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 14 Apr 2012 11:19:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 24.2, send any further explanations to 9423 <at> debbugs.gnu.org and Stefan Monnier <monnier <at> iro.umontreal.ca> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 14 Apr 2012 11:19:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 13 May 2012 11:24:02 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 99 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.