auth-source.el (auth-source-token-passphrase-callback-function): Simplify and remove EPA dependency.

This commit is contained in:
Daiki Ueno 2011-07-01 14:05:59 +00:00 committed by Katsumi Yamaoka
parent 26bde865f6
commit e9cb4479f5
2 changed files with 130 additions and 133 deletions

View file

@ -1,3 +1,8 @@
2011-07-01 Daiki Ueno <ueno@unixuser.org>
* auth-source.el (auth-source-token-passphrase-callback-function):
Simplify and remove EPA dependency.
2011-07-01 Andrew Cohen <cohen@andy.bu.edu> 2011-07-01 Andrew Cohen <cohen@andy.bu.edu>
* nnir.el (nnir-request-article): Fix error message text. * nnir.el (nnir-request-article): Fix error message text.

View file

@ -45,7 +45,17 @@
(require 'assoc) (require 'assoc)
(eval-when-compile (require 'cl)) (eval-when-compile (require 'cl))
(require 'eieio) (eval-and-compile
(or (ignore-errors (require 'eieio))
;; gnus-fallback-lib/ from gnus/lisp/gnus-fallback-lib
(ignore-errors
(let ((load-path (cons (expand-file-name
"gnus-fallback-lib/eieio"
(file-name-directory (locate-library "gnus")))
load-path)))
(require 'eieio)))
(error
"eieio not found in `load-path' or gnus-fallback-lib/ directory.")))
(autoload 'secrets-create-item "secrets") (autoload 'secrets-create-item "secrets")
(autoload 'secrets-delete-item "secrets") (autoload 'secrets-delete-item "secrets")
@ -64,8 +74,6 @@
(autoload 'plstore-save "plstore") (autoload 'plstore-save "plstore")
(autoload 'plstore-get-file "plstore") (autoload 'plstore-get-file "plstore")
(autoload 'epa-passphrase-callback-function "epa")
(autoload 'epg-context-operation "epg") (autoload 'epg-context-operation "epg")
(autoload 'epg-make-context "epg") (autoload 'epg-make-context "epg")
(autoload 'epg-context-set-passphrase-callback "epg") (autoload 'epg-context-set-passphrase-callback "epg")
@ -92,6 +100,9 @@ let-binding."
(const :tag "30 Minutes" 1800) (const :tag "30 Minutes" 1800)
(integer :tag "Seconds"))) (integer :tag "Seconds")))
;;; The slots below correspond with the `auth-source-search' spec,
;;; so a backend with :host set, for instance, would match only
;;; searches for that host. Normally they are nil.
(defclass auth-source-backend () (defclass auth-source-backend ()
((type :initarg :type ((type :initarg :type
:initform 'netrc :initform 'netrc
@ -993,25 +1004,7 @@ Note that the MAX parameter is used so we can exit the parse early."
(defvar auth-source-passphrase-alist nil) (defvar auth-source-passphrase-alist nil)
(defun auth-source-passphrase-callback-function (context key-id handback
&optional sym-detail)
"Exactly like `epa-passphrase-callback-function' but takes an
extra SYM-DETAIL parameter which will be printed at the end of
the symmetric passphrase prompt, and assumes symmetric
encryption."
(read-passwd
(format "Passphrase for symmetric encryption%s%s: "
;; Add the file name to the prompt, if any.
(if (stringp handback)
(format " for %s" handback)
"")
(if (stringp sym-detail)
sym-detail
""))
(eq (epg-context-operation context) 'encrypt)))
(defun auth-source-token-passphrase-callback-function (context key-id file) (defun auth-source-token-passphrase-callback-function (context key-id file)
(if (eq key-id 'SYM)
(let* ((file (file-truename file)) (let* ((file (file-truename file))
(entry (assoc file auth-source-passphrase-alist)) (entry (assoc file auth-source-passphrase-alist))
passphrase) passphrase)
@ -1023,14 +1016,13 @@ encryption."
(unless entry (unless entry
(setq entry (list file)) (setq entry (list file))
(push entry auth-source-passphrase-alist)) (push entry auth-source-passphrase-alist))
(setq passphrase (auth-source-passphrase-callback-function context (setq passphrase
key-id (read-passwd
file (format "Passphrase for %s tokens: " file)
" tokens")) t))
(setcdr entry (lexical-let ((p (copy-sequence passphrase))) (setcdr entry (lexical-let ((p (copy-sequence passphrase)))
(lambda () p))) (lambda () p)))
passphrase))) passphrase))))
(epa-passphrase-callback-function context key-id file)))
;; (auth-source-epa-extract-gpg-token "gpg:LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tClZlcnNpb246IEdudVBHIHYxLjQuMTEgKEdOVS9MaW51eCkKCmpBMEVBd01DT25qMjB1ak9rZnRneVI3K21iNm9aZWhuLzRad3cySkdlbnVaKzRpeEswWDY5di9icDI1U1dsQT0KPS9yc2wKLS0tLS1FTkQgUEdQIE1FU1NBR0UtLS0tLQo=" "~/.netrc") ;; (auth-source-epa-extract-gpg-token "gpg:LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tClZlcnNpb246IEdudVBHIHYxLjQuMTEgKEdOVS9MaW51eCkKCmpBMEVBd01DT25qMjB1ak9rZnRneVI3K21iNm9aZWhuLzRad3cySkdlbnVaKzRpeEswWDY5di9icDI1U1dsQT0KPS9yc2wKLS0tLS1FTkQgUEdQIE1FU1NBR0UtLS0tLQo=" "~/.netrc")
(defun auth-source-epa-extract-gpg-token (secret file) (defun auth-source-epa-extract-gpg-token (secret file)