unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* smtpmail and starttls improvement when starttls program is missing
@ 2008-10-29 21:21 Ted Zlatanov
  2008-10-31 17:40 ` Ted Zlatanov
  2008-11-04  0:53 ` Katsumi Yamaoka
  0 siblings, 2 replies; 5+ messages in thread
From: Ted Zlatanov @ 2008-10-29 21:21 UTC (permalink / raw)
  To: emacs-devel

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))





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-11-04 16:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-29 21:21 smtpmail and starttls improvement when starttls program is missing Ted Zlatanov
2008-10-31 17:40 ` Ted Zlatanov
2008-11-04 16:59   ` Ted Zlatanov
2008-11-04  0:53 ` Katsumi Yamaoka
2008-11-04 16:50   ` Ted Zlatanov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).