emacs-devel
[Top][All Lists]
Advanced

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

smtpmail and starttls improvement when starttls program is missing


From: Ted Zlatanov
Subject: smtpmail and starttls improvement when starttls program is missing
Date: Wed, 29 Oct 2008 16:21:54 -0500
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux)

Currently, smtpmail-open-stream will quietly fail if the starttls /
gnutls program is not available.  The changes below (starttls diff is
against the Gnus trunk but it shouldn't matter) introduce the function
starttls-any-program-available which will return either starttls-program
or starttls-gnutls-program, whichever is usable.  It also shows a
message, so a user can see in *Messages* that no STARTTLS protocol
transport is available.  smtpmail-open-stream then uses the function,
simplifying the logic flow.

The message will only be shown when starttls-any-program-available is
called, but note that it is called by smtpmail-open-stream iff there is
a match for the server in smtpmail-starttls-credentials.  This means the
user won't see the message unless he has an entry for the server that
implies he wants STARTTLS.

Let me know what you think...  Thanks
Ted

Index: starttls.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/starttls.el,v
retrieving revision 7.19
diff -c -r7.19 starttls.el
*** starttls.el 19 May 2008 08:47:42 -0000      7.19
--- starttls.el 29 Oct 2008 21:15:29 -0000
***************
*** 295,300 ****
--- 295,314 ----
        (starttls-set-process-query-on-exit-flag process nil)
        process)))
  
+ (defun starttls-any-program-available ()
+   (let ((program (if starttls-use-gnutls
+                    starttls-gnutls-program
+                  starttls-program)))
+     (condition-case ()
+       (with-no-warnings
+         (require 'starttls)
+         (call-process program)
+         program)
+       (error (progn
+              (message "No STARTTLS program was available (tried '%s')" 
+                       program)
+              nil)))))
+ 
  (provide 'starttls)
  
  ;; arch-tag: 648b3bd8-63bd-47f5-904c-7c819aea2297

Index: lisp/mail/smtpmail.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/mail/smtpmail.el,v
retrieving revision 1.105
diff -c -r1.105 smtpmail.el
*** lisp/mail/smtpmail.el       7 Jun 2008 02:41:06 -0000       1.105
--- lisp/mail/smtpmail.el       29 Oct 2008 21:16:26 -0000
***************
*** 503,515 ****
  (defun smtpmail-open-stream (process-buffer host port)
    (let ((cred (smtpmail-find-credentials
               smtpmail-starttls-credentials host port)))
!     (if (null (and cred (condition-case ()
!                           (with-no-warnings
!                             (require 'starttls)
!                             (call-process (if starttls-use-gnutls
!                                               starttls-gnutls-program
!                                             starttls-program)))
!                         (error nil))))
        ;; The normal case.
        (open-network-stream "SMTP" process-buffer host port)
        (let* ((cred-key (smtpmail-cred-key cred))
--- 503,509 ----
  (defun smtpmail-open-stream (process-buffer host port)
    (let ((cred (smtpmail-find-credentials
               smtpmail-starttls-credentials host port)))
!     (if (null (and cred (starttls-any-program-available)))
        ;; The normal case.
        (open-network-stream "SMTP" process-buffer host port)
        (let* ((cred-key (smtpmail-cred-key cred))





reply via email to

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