From: Michal Nazarewicz <mnazarewicz@google.com>
To: emacs-devel@gnu.org
Cc: Michal Nazarewicz <mina86@mina86.com>
Subject: [PATCH] lisp/server.el: Introduction of server-auth-key variable
Date: Tue, 22 Feb 2011 14:55:00 +0100 [thread overview]
Message-ID: <835b9d42b15c18e5adf7381138f347061fbc17e8.1298381336.git.mina86@mina86.com> (raw)
From: Michal Nazarewicz <mina86@mina86.com>
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@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
next reply other threads:[~2011-02-22 13:55 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-22 13:55 Michal Nazarewicz [this message]
2011-04-29 11:30 ` [PATCH] lisp/server.el: Introduction of server-auth-key variable Juanma Barranquero
2011-04-29 11:42 ` Michal Nazarewicz
2011-04-29 12:02 ` Juanma Barranquero
2011-04-29 12:43 ` Michal Nazarewicz
2011-04-29 14:34 ` Michal Nazarewicz
2011-04-30 6:39 ` Eli Zaretskii
2011-04-30 21:03 ` Richard Stallman
2011-04-30 22:24 ` Michal Nazarewicz
2011-04-29 16:22 ` Stefan Monnier
2011-04-29 16:35 ` Michal Nazarewicz
2011-04-29 17:09 ` Stefan Monnier
2011-04-30 14:31 ` Juanma Barranquero
2011-04-30 22:55 ` Michal Nazarewicz
2011-04-30 23:59 ` Juanma Barranquero
2011-05-01 0:44 ` Michal Nazarewicz
2011-05-01 0:58 ` Juanma Barranquero
2011-05-01 1:22 ` Michal Nazarewicz
2011-05-02 15:28 ` [PATCHv2] " Michal Nazarewicz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=835b9d42b15c18e5adf7381138f347061fbc17e8.1298381336.git.mina86@mina86.com \
--to=mnazarewicz@google.com \
--cc=emacs-devel@gnu.org \
--cc=mina86@mina86.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.