auth-source.el (auth-source-token-passphrase-callback-function): Simplify and remove EPA dependency.
This commit is contained in:
parent
26bde865f6
commit
e9cb4479f5
2 changed files with 130 additions and 133 deletions
|
@ -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.
|
||||||
|
|
|
@ -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)
|
||||||
|
@ -1110,7 +1102,7 @@ FILE is the file from which we obtained this token."
|
||||||
&key backend require create delete
|
&key backend require create delete
|
||||||
type max host user port
|
type max host user port
|
||||||
&allow-other-keys)
|
&allow-other-keys)
|
||||||
"Given a property list SPEC, return search matches from the :backend.
|
"Given a property list SPEC, return search matches from the :backend.
|
||||||
See `auth-source-search' for details on SPEC."
|
See `auth-source-search' for details on SPEC."
|
||||||
;; just in case, check that the type is correct (null or same as the backend)
|
;; just in case, check that the type is correct (null or same as the backend)
|
||||||
(assert (or (null type) (eq type (oref backend type)))
|
(assert (or (null type) (eq type (oref backend type)))
|
||||||
|
@ -1246,8 +1238,8 @@ See `auth-source-search' for details on SPEC."
|
||||||
(cond
|
(cond
|
||||||
((and (null data) (eq r 'secret))
|
((and (null data) (eq r 'secret))
|
||||||
;; Special case prompt for passwords.
|
;; Special case prompt for passwords.
|
||||||
;; TODO: make the default (setq auth-source-netrc-use-gpg-tokens `((,(if (boundp 'epa-file-auto-mode-alist-entry) (car (symbol-value 'epa-file-auto-mode-alist-entry)) "\\.gpg\\'") nil) (t gpg)))
|
;; TODO: make the default (setq auth-source-netrc-use-gpg-tokens `((,(if (boundp 'epa-file-auto-mode-alist-entry) (car (symbol-value 'epa-file-auto-mode-alist-entry)) "\\.gpg\\'") nil) (t gpg)))
|
||||||
;; TODO: or maybe leave as (setq auth-source-netrc-use-gpg-tokens 'never)
|
;; TODO: or maybe leave as (setq auth-source-netrc-use-gpg-tokens 'never)
|
||||||
(let* ((ep (format "Use GPG password tokens in %s?" file))
|
(let* ((ep (format "Use GPG password tokens in %s?" file))
|
||||||
(gpg-encrypt
|
(gpg-encrypt
|
||||||
(cond
|
(cond
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue