From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: smtpmail and starttls improvement when starttls program is missing Date: Wed, 29 Oct 2008 16:21:54 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <86wsfrayh9.fsf@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1225315357 395 80.91.229.12 (29 Oct 2008 21:22:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 29 Oct 2008 21:22:37 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 29 22:23:38 2008 connect(): Connection refused Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KvIVu-0001RX-FI for ged-emacs-devel@m.gmane.org; Wed, 29 Oct 2008 22:23:38 +0100 Original-Received: from localhost ([127.0.0.1]:57442 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KvIUo-0002mV-24 for ged-emacs-devel@m.gmane.org; Wed, 29 Oct 2008 17:22:30 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KvIUb-0002fh-LU for emacs-devel@gnu.org; Wed, 29 Oct 2008 17:22:17 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KvIUZ-0002cV-3D for emacs-devel@gnu.org; Wed, 29 Oct 2008 17:22:17 -0400 Original-Received: from [199.232.76.173] (port=51965 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KvIUY-0002c8-Nb for emacs-devel@gnu.org; Wed, 29 Oct 2008 17:22:14 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:37473 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KvIUY-0001MP-3c for emacs-devel@gnu.org; Wed, 29 Oct 2008 17:22:14 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1KvIUN-0003rJ-Ub for emacs-devel@gnu.org; Wed, 29 Oct 2008 21:22:03 +0000 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 29 Oct 2008 21:22:03 +0000 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 29 Oct 2008 21:22:03 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 79 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:9fuwLfIfeDJgQcmkyU41ci9nBjc= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:105158 Archived-At: 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))