Subject: 29.1; plstore.el failed when save using EasyPG

From: LdBeth <[email-masked]>
Date: Tue, 13 Feb 2024 23:37:23 -0600

It seems to be the residue of bug #63256, with GnuPG 2.4.4 and set epg
to use loopback pinentry the plstore.el still failed to encrypt file.
The result below is produced without using init file on macOS.

$ gpg2 --version
gpg (GnuPG) 2.4.4
libgcrypt 1.10.3
Copyright (C) 2024 g10 Code GmbH
License GNU GPL-3.0-or-later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /Users/ldbeth/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2

$ cat .gnupg/gpg-agent.conf 
allow-loopback-pinentry
default-cache-ttl 34560000
max-cache-ttl 34560000

(setq epg-pinentry-mode 'loopback)
(require 'plstore)
(setq store (plstore-open (expand-file-name "~/foo")))

(plstore-put store "as" '(:host "bar.example.kk") '(:user "ba"))
(plstore-save store)

Debugger entered--Lisp error: (error "Process epg not running: exited abnormally with co...")
  process-send-string(#<process epg> "abcdef\n")
 context context))) (aref context 16)))))
 ith-new-line)) (if encoded-passphrase-with-new-line (clear-string encoded-passphrase-with-new-line)))
  (if (and symbol (fboundp symbol)) (funcall symbol epg-context string))
  (if (eq (progn (or (progn (and (memq (type-of epg-context) cl-struct-epg-context-tags) t)) (signal 'wrong-type-argument (list 'epg-context epg-context))) (aref epg-context 19)) 'edit-key) (funcall (car (progn (or (progn (and (memq ... cl-struct-epg-context-tags) t)) (signal 'wrong-type-argument (list 'epg-context epg-context))) (aref epg-context 12))) epg-context status string (cdr (progn (or (progn (and (memq ... cl-struct-epg-context-tags) t)) (signal 'wrong-type-argument (list 'epg-context epg-context))) (aref epg-context 12)))) (setq symbol (intern-soft (concat "epg--status-" status))) (if (and symbol (fboundp symbol)) (funcall symbol epg-context string)))
  (let ((status (match-string 1)) (string (match-string 2)) symbol) (if (member status epg-pending-status-list) (setq epg-pending-status-list nil)) (if (eq (progn (or (progn (and (memq ... cl-struct-epg-context-tags) t)) (signal 'wrong-type-argument (list 'epg-context epg-context))) (aref epg-context 19)) 'edit-key) (funcall (car (progn (or (progn (and ... t)) (signal 'wrong-type-argument (list ... epg-context))) (aref epg-context 12))) epg-context status string (cdr (progn (or (progn (and ... t)) (signal 'wrong-type-argument (list ... epg-context))) (aref epg-context 12)))) (setq symbol (intern-soft (concat "epg--status-" status))) (if (and symbol (fboundp symbol)) (funcall symbol epg-context string))) (setq epg-last-status (cons status string)))
  (if (looking-at "\\[GNUPG:] \\([A-Z_]+\\) ?\\(.*\\)") (let ((status (match-string 1)) (string (match-string 2)) symbol) (if (member status epg-pending-status-list) (setq epg-pending-status-list nil)) (if (eq (progn (or (progn (and ... t)) (signal 'wrong-type-argument (list ... epg-context))) (aref epg-context 19)) 'edit-key) (funcall (car (progn (or (progn ...) (signal ... ...)) (aref epg-context 12))) epg-context status string (cdr (progn (or (progn ...) (signal ... ...)) (aref epg-context 12)))) (setq symbol (intern-soft (concat "epg--status-" status))) (if (and symbol (fboundp symbol)) (funcall symbol epg-context string))) (setq epg-last-status (cons status string))))
  (while (looking-at ".*\n") (if (looking-at "\\[GNUPG:] \\([A-Z_]+\\) ?\\(.*\\)") (let ((status (match-string 1)) (string (match-string 2)) symbol) (if (member status epg-pending-status-list) (setq epg-pending-status-list nil)) (if (eq (progn (or (progn ...) (signal ... ...)) (aref epg-context 19)) 'edit-key) (funcall (car (progn (or ... ...) (aref epg-context 12))) epg-context status string (cdr (progn (or ... ...) (aref epg-context 12)))) (setq symbol (intern-soft (concat "epg--status-" status))) (if (and symbol (fboundp symbol)) (funcall symbol epg-context string))) (setq epg-last-status (cons status string)))) (forward-line) (setq epg-read-point (point)))
  (let ((epg-process-filter-running t)) (goto-char epg-read-point) (beginning-of-line) (while (looking-at ".*\n") (if (looking-at "\\[GNUPG:] \\([A-Z_]+\\) ?\\(.*\\)") (let ((status (match-string 1)) (string (match-string 2)) symbol) (if (member status epg-pending-status-list) (setq epg-pending-status-list nil)) (if (eq (progn (or ... ...) (aref epg-context 19)) 'edit-key) (funcall (car (progn ... ...)) epg-context status string (cdr (progn ... ...))) (setq symbol (intern-soft (concat "epg--status-" status))) (if (and symbol (fboundp symbol)) (funcall symbol epg-context string))) (setq epg-last-status (cons status string)))) (forward-line) (setq epg-read-point (point))))
  (if epg-process-filter-running nil (let ((epg-process-filter-running t)) (goto-char epg-read-point) (beginning-of-line) (while (looking-at ".*\n") (if (looking-at "\\[GNUPG:] \\([A-Z_]+\\) ?\\(.*\\)") (let ((status (match-string 1)) (string (match-string 2)) symbol) (if (member status epg-pending-status-list) (setq epg-pending-status-list nil)) (if (eq (progn ... ...) 'edit-key) (funcall (car ...) epg-context status string (cdr ...)) (setq symbol (intern-soft ...)) (if (and symbol ...) (funcall symbol epg-context string))) (setq epg-last-status (cons status string)))) (forward-line) (setq epg-read-point (point)))))
  (save-excursion (goto-char (point-max)) (insert input) (if epg-process-filter-running nil (let ((epg-process-filter-running t)) (goto-char epg-read-point) (beginning-of-line) (while (looking-at ".*\n") (if (looking-at "\\[GNUPG:] \\([A-Z_]+\\) ?\\(.*\\)") (let ((status ...) (string ...) symbol) (if (member status epg-pending-status-list) (setq epg-pending-status-list nil)) (if (eq ... ...) (funcall ... epg-context status string ...) (setq symbol ...) (if ... ...)) (setq epg-last-status (cons status string)))) (forward-line) (setq epg-read-point (point))))))
  (save-current-buffer (set-buffer (process-buffer process)) (save-excursion (goto-char (point-max)) (insert input) (if epg-process-filter-running nil (let ((epg-process-filter-running t)) (goto-char epg-read-point) (beginning-of-line) (while (looking-at ".*\n") (if (looking-at "\\[GNUPG:] \\([A-Z_]+\\) ?\\(.*\\)") (let (... ... symbol) (if ... ...) (if ... ... ... ...) (setq epg-last-status ...))) (forward-line) (setq epg-read-point (point)))))))
  (if (buffer-live-p (process-buffer process)) (save-current-buffer (set-buffer (process-buffer process)) (save-excursion (goto-char (point-max)) (insert input) (if epg-process-filter-running nil (let ((epg-process-filter-running t)) (goto-char epg-read-point) (beginning-of-line) (while (looking-at ".*\n") (if (looking-at "\\[GNUPG:] \\([A-Z_]+\\) ?\\(.*\\)") (let ... ... ... ...)) (forward-line) (setq epg-read-point (point))))))))
  epg--process-filter(#<process epg> "[GNUPG:] NEED_PASSPHRASE_SYM 9 3 8\n[GNUPG:] INQUIR...")
  accept-process-output(#<process epg> 1)
  (while (eq (process-status (progn (or (progn (and (memq ... cl-struct-epg-context-tags) t)) (signal 'wrong-type-argument (list 'epg-context context))) (aref context 16))) 'run) (accept-process-output (progn (or (progn (and (memq (type-of context) cl-struct-epg-context-tags) t)) (signal 'wrong-type-argument (list 'epg-context context))) (aref context 16)) 1))
  (progn (progn (or (progn (and (memq (type-of context) cl-struct-epg-context-tags) t)) (signal 'wrong-type-argument (list 'epg-context context))) (let* ((v context)) (aset v 17 (make-temp-file "epg-output")))) (write-region plain nil input-file nil 'quiet) (epg-start-encrypt context (record 'epg-data input-file nil) recipients sign always-trust) (epg-wait-for-completion context) (let ((errors (epg-context-result-for context 'error))) (if (and sign (not (epg-context-result-for context 'sign))) (signal 'epg-error (list "Sign failed" (epg-errors-to-string errors)))) (if errors (signal 'epg-error (list "Encrypt failed" (epg-errors-to-string errors))))) (epg-read-output context))
  (unwind-protect (progn (progn (or (progn (and (memq (type-of context) cl-struct-epg-context-tags) t)) (signal 'wrong-type-argument (list 'epg-context context))) (let* ((v context)) (aset v 17 (make-temp-file "epg-output")))) (write-region plain nil input-file nil 'quiet) (epg-start-encrypt context (record 'epg-data input-file nil) recipients sign always-trust) (epg-wait-for-completion context) (let ((errors (epg-context-result-for context 'error))) (if (and sign (not (epg-context-result-for context 'sign))) (signal 'epg-error (list "Sign failed" (epg-errors-to-string errors)))) (if errors (signal 'epg-error (list "Encrypt failed" (epg-errors-to-string errors))))) (epg-read-output context)) (epg-delete-output-file context) (delete-file input-file) (epg-reset context))
  (setq cipher (epg-encrypt-string context (pp-to-string (plstore--get-secret-alist plstore)) (if (or (eq plstore-select-keys t) (and (null plstore-select-keys) (not (local-variable-p 'plstore-encrypt-to (current-buffer))))) (epa-select-keys context "Select recipients for encryption.\nIf no one is sel..." recipients) (if plstore-encrypt-to (epg-list-keys context recipients)))))
  plstore--insert-buffer([#<buffer  plstore /Users/ldbeth/foo> (("as" :secret-user t :host "bar.example.kk")) nil (("as" :user "ba")) (("as" :user "ba" :host "bar.example.kk"))])
  (save-current-buffer (set-buffer (plstore--get-buffer plstore)) (erase-buffer) (plstore--insert-buffer plstore) (save-buffer))
  plstore-save([#<buffer  plstore /Users/ldbeth/foo> (("as" :secret-user t :host "bar.example.kk")) nil (("as" :user "ba")) (("as" :user "ba" :host "bar.example.kk"))])
  eval((plstore-save store) nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)