summaryrefslogtreecommitdiff
path: root/lisp/epg.el
diff options
context:
space:
mode:
authorNoam Postavsky <npostavs@gmail.com>2018-04-30 08:49:11 -0400
committerNoam Postavsky <npostavs@gmail.com>2018-05-23 07:53:57 -0400
commit21ab346a07eff8ba43cb2738dc6752f012b77670 (patch)
tree649652b71d097f51d0273dff34acba4e98e392e2 /lisp/epg.el
parentbab73230d1be1fe394b7269c1365ef6fb1a5d9b3 (diff)
downloademacs-21ab346a07eff8ba43cb2738dc6752f012b77670.tar.gz
Drop some epg/epa backwards compat code for ancient Emacs versions
* lisp/epa.el (epa--select-safe-coding-system): Remove, `select-safe-coding-system' has been present since Emacs 20.3. (epa--encode-coding-string, epa--decode-coding-string): * lisp/epg.el (epg--decode-coding-string, epg--encode-coding-string) (epg--clear-string): Remove, the corresponding Emacs functions are so old they don't show up in NEWS. Furthermore, the fallback for the *-coding-string functions was `identity' which wouldn't have worked anyway, since it only takes a single argument. (epg--make-temp-file): Remove, `make-temp-file' has been present since Emacs 21.1. * lisp/epg-config.el (epg-gpg-program, epg-gpgsm-program) (epg-gpgconf-program, epg-gpg-home-directory) (epg-passphrase-coding-system, epg-debug): Remove unneeded :group parameter.
Diffstat (limited to 'lisp/epg.el')
-rw-r--r--lisp/epg.el118
1 files changed, 23 insertions, 95 deletions
diff --git a/lisp/epg.el b/lisp/epg.el
index 091021936ad..e6b4af2b36e 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -760,18 +760,13 @@ callback data (if any)."
(file-exists-p (epg-context-output-file context)))
(delete-file (epg-context-output-file context))))
-(eval-and-compile
- (if (fboundp 'decode-coding-string)
- (defalias 'epg--decode-coding-string 'decode-coding-string)
- (defalias 'epg--decode-coding-string 'identity)))
-
(defun epg--status-USERID_HINT (_context string)
(if (string-match "\\`\\([^ ]+\\) \\(.*\\)" string)
(let* ((key-id (match-string 1 string))
(user-id (match-string 2 string))
(entry (assoc key-id epg-user-id-alist)))
(condition-case nil
- (setq user-id (epg--decode-coding-string
+ (setq user-id (decode-coding-string
(epg--decode-percent-escape user-id)
'utf-8))
(error))
@@ -790,17 +785,6 @@ callback data (if any)."
(defun epg--status-NEED_PASSPHRASE_PIN (_context _string)
(setq epg-key-id 'PIN))
-(eval-and-compile
- (if (fboundp 'clear-string)
- (defalias 'epg--clear-string 'clear-string)
- (defun epg--clear-string (string)
- (fillarray string 0))))
-
-(eval-and-compile
- (if (fboundp 'encode-coding-string)
- (defalias 'epg--encode-coding-string 'encode-coding-string)
- (defalias 'epg--encode-coding-string 'identity)))
-
(defun epg--status-GET_HIDDEN (context string)
(when (and epg-key-id
(string-match "\\`passphrase\\." string))
@@ -821,16 +805,16 @@ callback data (if any)."
(cdr (epg-context-passphrase-callback context))))
(when passphrase
(setq passphrase-with-new-line (concat passphrase "\n"))
- (epg--clear-string passphrase)
+ (clear-string passphrase)
(setq passphrase nil)
(if epg-passphrase-coding-system
(progn
(setq encoded-passphrase-with-new-line
- (epg--encode-coding-string
+ (encode-coding-string
passphrase-with-new-line
(coding-system-change-eol-conversion
epg-passphrase-coding-system 'unix)))
- (epg--clear-string passphrase-with-new-line)
+ (clear-string passphrase-with-new-line)
(setq passphrase-with-new-line nil))
(setq encoded-passphrase-with-new-line
passphrase-with-new-line
@@ -844,11 +828,11 @@ callback data (if any)."
(epg-context-result-for context 'error)))
(delete-process (epg-context-process context))))
(if passphrase
- (epg--clear-string passphrase))
+ (clear-string passphrase))
(if passphrase-with-new-line
- (epg--clear-string passphrase-with-new-line))
+ (clear-string passphrase-with-new-line))
(if encoded-passphrase-with-new-line
- (epg--clear-string encoded-passphrase-with-new-line))))))
+ (clear-string encoded-passphrase-with-new-line))))))
(defun epg--prompt-GET_BOOL (_context string)
(let ((entry (assoc string epg-prompt-alist)))
@@ -911,7 +895,7 @@ callback data (if any)."
(condition-case nil
(if (eq (epg-context-protocol context) 'CMS)
(setq user-id (epg-dn-from-string user-id))
- (setq user-id (epg--decode-coding-string
+ (setq user-id (decode-coding-string
(epg--decode-percent-escape user-id)
'utf-8)))
(error))
@@ -1192,7 +1176,7 @@ callback data (if any)."
(user-id (match-string 2 string))
(entry (assoc key-id epg-user-id-alist)))
(condition-case nil
- (setq user-id (epg--decode-coding-string
+ (setq user-id (decode-coding-string
(epg--decode-percent-escape user-id)
'utf-8))
(error))
@@ -1349,7 +1333,7 @@ NAME is either a string or a list of strings."
(setq string (replace-match "\\\"" t t string)
index (1+ (match-end 0))))
(condition-case nil
- (setq string (epg--decode-coding-string
+ (setq string (decode-coding-string
(car (read-from-string (concat "\"" string "\"")))
'utf-8))
(error
@@ -1394,62 +1378,6 @@ NAME is either a string or a list of strings."
(setq pointer (cdr pointer)))
keys))
-(eval-and-compile
- (if (fboundp 'make-temp-file)
- (defalias 'epg--make-temp-file 'make-temp-file)
- (defvar temporary-file-directory)
- ;; stolen from poe.el.
- (defun epg--make-temp-file (prefix)
- "Create a temporary file.
-The returned file name (created by appending some random characters at the end
-of PREFIX, and expanding against `temporary-file-directory' if necessary),
-is guaranteed to point to a newly created empty file.
-You can then use `write-region' to write new data into the file."
- (let ((orig-modes (default-file-modes))
- tempdir tempfile)
- (setq prefix (expand-file-name prefix
- (if (featurep 'xemacs)
- (temp-directory)
- temporary-file-directory)))
- (unwind-protect
- (let (file)
- ;; First, create a temporary directory.
- (set-default-file-modes #o700)
- (while (condition-case ()
- (progn
- (setq tempdir (make-temp-name
- (concat
- (file-name-directory prefix)
- "DIR")))
- ;; return nil or signal an error.
- (make-directory tempdir))
- ;; let's try again.
- (file-already-exists t)))
- ;; Second, create a temporary file in the tempdir.
- ;; There *is* a race condition between `make-temp-name'
- ;; and `write-region', but we don't care it since we are
- ;; in a private directory now.
- (setq tempfile (make-temp-name (concat tempdir "/EMU")))
- (write-region "" nil tempfile nil 'silent)
- ;; Finally, make a hard-link from the tempfile.
- (while (condition-case ()
- (progn
- (setq file (make-temp-name prefix))
- ;; return nil or signal an error.
- (add-name-to-file tempfile file))
- ;; let's try again.
- (file-already-exists t)))
- file)
- (set-default-file-modes orig-modes)
- ;; Cleanup the tempfile.
- (and tempfile
- (file-exists-p tempfile)
- (delete-file tempfile))
- ;; Cleanup the tempdir.
- (and tempdir
- (file-directory-p tempdir)
- (delete-directory tempdir)))))))
-
(defun epg--args-from-sig-notations (notations)
(apply #'nconc
(mapcar
@@ -1513,7 +1441,7 @@ If PLAIN is nil, it returns the result as a string."
(unwind-protect
(progn
(setf (epg-context-output-file context)
- (or plain (epg--make-temp-file "epg-output")))
+ (or plain (make-temp-file "epg-output")))
(epg-start-decrypt context (epg-make-data-from-file cipher))
(epg-wait-for-completion context)
(epg--check-error-for-decrypt context)
@@ -1525,13 +1453,13 @@ If PLAIN is nil, it returns the result as a string."
(defun epg-decrypt-string (context cipher)
"Decrypt a string CIPHER and return the plain text."
- (let ((input-file (epg--make-temp-file "epg-input"))
+ (let ((input-file (make-temp-file "epg-input"))
(coding-system-for-write 'binary))
(unwind-protect
(progn
(write-region cipher nil input-file nil 'quiet)
(setf (epg-context-output-file context)
- (epg--make-temp-file "epg-output"))
+ (make-temp-file "epg-output"))
(epg-start-decrypt context (epg-make-data-from-file input-file))
(epg-wait-for-completion context)
(epg--check-error-for-decrypt context)
@@ -1602,7 +1530,7 @@ which will return a list of `epg-signature' object."
(unwind-protect
(progn
(setf (epg-context-output-file context)
- (or plain (epg--make-temp-file "epg-output")))
+ (or plain (make-temp-file "epg-output")))
(if signed-text
(epg-start-verify context
(epg-make-data-from-file signature)
@@ -1639,10 +1567,10 @@ which will return a list of `epg-signature' object."
(unwind-protect
(progn
(setf (epg-context-output-file context)
- (epg--make-temp-file "epg-output"))
+ (make-temp-file "epg-output"))
(if signed-text
(progn
- (setq input-file (epg--make-temp-file "epg-signature"))
+ (setq input-file (make-temp-file "epg-signature"))
(write-region signature nil input-file nil 'quiet)
(epg-start-verify context
(epg-make-data-from-file input-file)
@@ -1710,7 +1638,7 @@ Otherwise, it makes a cleartext signature."
(unwind-protect
(progn
(setf (epg-context-output-file context)
- (or signature (epg--make-temp-file "epg-output")))
+ (or signature (make-temp-file "epg-output")))
(epg-start-sign context (epg-make-data-from-file plain) mode)
(epg-wait-for-completion context)
(unless (epg-context-result-for context 'sign)
@@ -1730,12 +1658,12 @@ If it is nil or `normal', it makes a normal signature.
Otherwise, it makes a cleartext signature."
(let ((input-file
(unless (eq (epg-context-protocol context) 'CMS)
- (epg--make-temp-file "epg-input")))
+ (make-temp-file "epg-input")))
(coding-system-for-write 'binary))
(unwind-protect
(progn
(setf (epg-context-output-file context)
- (epg--make-temp-file "epg-output"))
+ (make-temp-file "epg-output"))
(if input-file
(write-region plain nil input-file nil 'quiet))
(epg-start-sign context
@@ -1812,7 +1740,7 @@ If RECIPIENTS is nil, it performs symmetric encryption."
(unwind-protect
(progn
(setf (epg-context-output-file context)
- (or cipher (epg--make-temp-file "epg-output")))
+ (or cipher (make-temp-file "epg-output")))
(epg-start-encrypt context (epg-make-data-from-file plain)
recipients sign always-trust)
(epg-wait-for-completion context)
@@ -1837,12 +1765,12 @@ If RECIPIENTS is nil, it performs symmetric encryption."
(let ((input-file
(unless (or (not sign)
(eq (epg-context-protocol context) 'CMS))
- (epg--make-temp-file "epg-input")))
+ (make-temp-file "epg-input")))
(coding-system-for-write 'binary))
(unwind-protect
(progn
(setf (epg-context-output-file context)
- (epg--make-temp-file "epg-output"))
+ (make-temp-file "epg-output"))
(if input-file
(write-region plain nil input-file nil 'quiet))
(epg-start-encrypt context
@@ -1887,7 +1815,7 @@ If you are unsure, use synchronous version of this function
(unwind-protect
(progn
(setf (epg-context-output-file context)
- (or file (epg--make-temp-file "epg-output")))
+ (or file (make-temp-file "epg-output")))
(epg-start-export-keys context keys)
(epg-wait-for-completion context)
(let ((errors (epg-context-result-for context 'error)))