tramp-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: file storage in IMAP (eventually for Tramp) working and needs testin


From: Daiki Ueno
Subject: Re: file storage in IMAP (eventually for Tramp) working and needs testing
Date: Fri, 24 Apr 2009 09:37:47 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux)

>>>>> In <address@hidden> 
>>>>>   Ted Zlatanov <address@hidden> wrote:
> - EPG asks for the passphrase.  It should try tramp-imap-passphrase as a
>   string first (I'll add the alist and function call support later).  As
>   an extra courtesy to the user, if the passphrase is nil, we should ask
>   interactively if encryption is wanted, and if yes, read the
>   passphrase.  Would you be willing to make that addition?

Yes, here is a patch to do that.

--- tramp-imap.el~      2009-04-24 08:59:11.000000000 +0900
+++ tramp-imap.el       2009-04-24 09:01:16.000000000 +0900
@@ -738,12 +738,17 @@
        (error "Could not find the body separator in the encoded message!")))
       (current-buffer)))
 
+(defun tramp-imap-passphrase-callback-function (context key-id handback)
+  (or tramp-imap-passphrase
+      (epa-passphrase-callback-function context key-id handback)))
+
 (defun tramp-imap-encode-buffer ()
   (let ((context (epg-make-context 'OpenPGP))
        cipher)
     (epg-context-set-armor context t)
-    (epg-context-set-passphrase-callback context
-                                        #'epa-passphrase-callback-function)
+    (epg-context-set-passphrase-callback
+     context
+     #'tramp-imap-passphrase-callback-function)
     (epg-context-set-progress-callback context
                                       (cons #'epa-progress-callback-function
                                             "Encrypting..."))
@@ -758,8 +763,9 @@
 (defun tramp-imap-decode-buffer ()
   (let ((context (epg-make-context 'OpenPGP))
        plain)
-    (epg-context-set-passphrase-callback context
-                                        #'epa-passphrase-callback-function)
+    (epg-context-set-passphrase-callback
+     context
+     #'tramp-imap-passphrase-callback-function)
     (epg-context-set-progress-callback context
                                       (cons #'epa-progress-callback-function
                                             "Decrypting..."))
> - I had to clean ^M characters from the buffer before; EPG seems to
>   handle them automatically so I removed this code

>       ;; TODO: do this better, removes all ^M in the buffer
>       (goto-char (point-min))
>        (while (re-search-forward "^M" nil t) ;; this was the literal ^M
>       (replace-match "" nil nil))

>   from tramp-imap-get-file.  Is that OK?

I think so - if data do not roundtrip before/after encryption, it seems
a bug...

Regards,
-- 
Daiki Ueno

reply via email to

[Prev in Thread] Current Thread [Next in Thread]