Fixed passphrase caching.
authorueno <ueno>
Mon, 17 Apr 2006 07:46:36 +0000 (07:46 +0000)
committerueno <ueno>
Mon, 17 Apr 2006 07:46:36 +0000 (07:46 +0000)
epa-file.el

index d0d194f..9232426 100644 (file)
   :type 'regexp
   :group 'epa-file)
   
-(defvar epa-passphrase-alist nil)
+(defvar epa-file-passphrase-alist nil)
 
-(defun epa-file-passphrase-callback-function (key-id buffer)
+(defun epa-file-passphrase-callback-function (key-id file)
   (if (eq key-id 'SYM)
-      (let ((entry (assoc buffer epa-passphrase-alist))
+      (let ((entry (assoc file epa-file-passphrase-alist))
            passphrase)
-       (or (cdr entry)
+       (or (copy-sequence (cdr entry))
            (progn
              (unless entry
-               (setq entry (list buffer)
-                     epa-passphrase-alist (cons entry
-                                                epa-passphrase-alist)))
+               (setq entry (list file)
+                     epa-file-passphrase-alist (cons entry
+                                                epa-file-passphrase-alist)))
              (setq passphrase (epg-passphrase-callback-function key-id nil))
              (setcdr entry (copy-sequence passphrase))
              passphrase)))
@@ -80,7 +80,7 @@
     (epg-context-set-passphrase-callback
      context
      (cons #'epa-file-passphrase-callback-function
-          (current-buffer)))
+          file))
     (unwind-protect
        (progn
          (if replace
     (epg-context-set-passphrase-callback
      context
      (cons #'epa-file-passphrase-callback-function
-          (current-buffer)))
+          file))
     (epa-file-run-real-handler
      #'write-region
      (list (epg-encrypt-string
            (encode-coding-string (buffer-string) coding-system)
            (mapcar (lambda (key)
                      (epg-sub-key-id (car (epg-key-sub-key-list key))))
-                   (unless (assoc (current-buffer) epa-passphrase-alist)
+                   (unless (assoc file epa-file-passphrase-alist)
                      (epa-select-keys
                       "Select recipents for encryption.
 If no one is selected, symmetric encryption will be performed.  "))))