mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-06-14 12:31:25 +00:00
Decrypt plstore when needed in 'plstore-delete'
When a plstore has entries with secret keys, processing the plstore file would require decryption first. However, unlike other functions like 'plstore-get', 'plstore-put', etc., 'plstore-delete' does not check for secret keys and decrypt the file, which would corrupt the file when deleting any entries with secret keys. This patch adds checking for secret keys and decrypt the file when needed before removing the entry with name. * lisp/plstore.el (plstore--has-secret-keys): New. * lisp/plstore.el (plstore-delete): Check for secret keys of the entry and decrypt plstore before performing the deletion. (Bug#81061)
This commit is contained in:
parent
c9dfe2abe6
commit
d852d36c77
1 changed files with 28 additions and 15 deletions
|
|
@ -550,23 +550,36 @@ SECRET-KEYS is a plist containing secret data."
|
||||||
(cons (cons name secret-plist) (plstore--get-secret-alist plstore)))))
|
(cons (cons name secret-plist) (plstore--get-secret-alist plstore)))))
|
||||||
(plstore--merge-secret plstore)))
|
(plstore--merge-secret plstore)))
|
||||||
|
|
||||||
|
(defun plstore--has-secret-keys (plist)
|
||||||
|
"Return t if PLIST of a plstore entry has secret keys."
|
||||||
|
(string-match-p "\\`:secret-" (symbol-name (car plist))))
|
||||||
|
|
||||||
(defun plstore-delete (plstore name)
|
(defun plstore-delete (plstore name)
|
||||||
"Delete the first entry named NAME from PLSTORE."
|
"Delete the first entry named NAME from PLSTORE."
|
||||||
(let ((entry (assoc name (plstore--get-alist plstore))))
|
(when-let* ((entry (assoc name (plstore--get-alist plstore)))
|
||||||
(if entry
|
(plist (cdr entry)))
|
||||||
(plstore--set-alist
|
(when (plstore--has-secret-keys plist)
|
||||||
plstore
|
(plstore--decrypt plstore)
|
||||||
(delq entry (plstore--get-alist plstore))))
|
(setq entry (assoc name (plstore--get-alist plstore))))
|
||||||
(setq entry (assoc name (plstore--get-secret-alist plstore)))
|
(plstore--set-alist
|
||||||
(if entry
|
plstore
|
||||||
(plstore--set-secret-alist
|
(delq entry (plstore--get-alist plstore))))
|
||||||
plstore
|
(when-let* ((entry (assoc name (plstore--get-secret-alist plstore)))
|
||||||
(delq entry (plstore--get-secret-alist plstore))))
|
(plist (cdr entry)))
|
||||||
(setq entry (assoc name (plstore--get-merged-alist plstore)))
|
(when (plstore--has-secret-keys plist)
|
||||||
(if entry
|
(plstore--decrypt plstore)
|
||||||
(plstore--set-merged-alist
|
(setq entry (assoc name (plstore--get-secret-alist plstore))))
|
||||||
plstore
|
(plstore--set-secret-alist
|
||||||
(delq entry (plstore--get-merged-alist plstore))))))
|
plstore
|
||||||
|
(delq entry (plstore--get-secret-alist plstore))))
|
||||||
|
(when-let* ((entry (assoc name (plstore--get-merged-alist plstore)))
|
||||||
|
(plist (cdr entry)))
|
||||||
|
(when (plstore--has-secret-keys plist)
|
||||||
|
(plstore--decrypt plstore)
|
||||||
|
(setq entry (assoc name (plstore--get-merged-alist plstore))))
|
||||||
|
(plstore--set-merged-alist
|
||||||
|
plstore
|
||||||
|
(delq entry (plstore--get-merged-alist plstore)))))
|
||||||
|
|
||||||
(defvar pp-escape-newlines)
|
(defvar pp-escape-newlines)
|
||||||
(defun plstore--insert-buffer (plstore)
|
(defun plstore--insert-buffer (plstore)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue