mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-24 07:20:37 +00:00
Fix loss of encrypted data in plstore.el
* lisp/plstore.el (plstore--insert-buffer): Fix loss of encrypted data when a plstore gets opened and saved without being decrypted between these steps. (Bug#63627)
This commit is contained in:
parent
d9a1175a61
commit
89fa204b70
@ -570,18 +570,23 @@ SECRET-KEYS is a plist containing secret data."
|
||||
|
||||
(defvar pp-escape-newlines)
|
||||
(defun plstore--insert-buffer (plstore)
|
||||
"Insert the file representation of PLSTORE at point.
|
||||
Assumes that PLSTORE has been decrypted."
|
||||
"Insert the file representation of PLSTORE at point."
|
||||
(insert ";;; public entries -*- mode: plstore -*- \n"
|
||||
(pp-to-string (plstore--get-alist plstore)))
|
||||
(if (plstore--get-secret-alist plstore)
|
||||
(let ((pp-escape-newlines nil)
|
||||
(cipher nil))
|
||||
(cond
|
||||
;; Reuse the encrypted data as cipher text if this store has not
|
||||
;; been decrypted yet.
|
||||
((plstore--get-encrypted-data plstore)
|
||||
(setq cipher (plstore--get-encrypted-data plstore)))
|
||||
;; Encrypt the secret alist to generate the cipher text.
|
||||
((plstore--get-secret-alist plstore)
|
||||
(let ((context (epg-make-context 'OpenPGP))
|
||||
(pp-escape-newlines nil)
|
||||
(recipients
|
||||
(cond
|
||||
((listp plstore-encrypt-to) plstore-encrypt-to)
|
||||
((stringp plstore-encrypt-to) (list plstore-encrypt-to))))
|
||||
cipher)
|
||||
((stringp plstore-encrypt-to) (list plstore-encrypt-to)))))
|
||||
(setf (epg-context-armor context) t)
|
||||
(epg-context-set-passphrase-callback
|
||||
context
|
||||
@ -601,9 +606,10 @@ Assumes that PLSTORE has been decrypted."
|
||||
If no one is selected, symmetric encryption will be performed. "
|
||||
recipients)
|
||||
(if plstore-encrypt-to
|
||||
(epg-list-keys context recipients)))))
|
||||
(goto-char (point-max))
|
||||
(insert ";;; secret entries\n" (pp-to-string cipher)))))
|
||||
(epg-list-keys context recipients))))))))
|
||||
(when cipher
|
||||
(goto-char (point-max))
|
||||
(insert ";;; secret entries\n" (pp-to-string cipher)))))
|
||||
|
||||
(defun plstore-save (plstore)
|
||||
"Save PLSTORE to its associated file.
|
||||
|
Loading…
Reference in New Issue
Block a user