From: Katsumi Yamaoka <yamaoka@jpl.org>
To: Ted Zlatanov <tzz@lifelogs.com>
Cc: ding@gnus.org, emacs-devel@gnu.org
Subject: Re: smtpmail and starttls improvement when starttls program is missing
Date: Tue, 04 Nov 2008 09:53:17 +0900 [thread overview]
Message-ID: <b4mzlkgfh1e.fsf@jpl.org> (raw)
In-Reply-To: 86wsfrayh9.fsf@lifelogs.com
>>>>> Ted Zlatanov <tzz@lifelogs.com> wrote:
> 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
I think `with-no-warnings' and `(require 'starttls)' are unnecessary.
For `with-no-warnings', it binds `byte-compile-warnings' to nil
when compiling. It is for making the byte compiler silent on any
form, however there seems nothing to be warned when compiling.
In addition, `with-no-warnings' is not available in Emacs 21 and
XEmacs that Gnus supports, so the warning like the following is
issued when compiling Gnus:
While compiling the end of the data in file gnus/lisp/starttls.el:
** The function `with-no-warnings' is not known to be defined.
It is not serious since the function will not be used with those
versions of Emacsen, though.
For `(require 'starttls)', the reason I say it is unnecessary is
that the function is defined in starttls.el that provides the
`starttls' feature. ;-) Therefore the function can be rewritten
like the following, isn't it?
--8<---------------cut here---------------start------------->8---
(defun starttls-any-program-available ()
(let ((program (if starttls-use-gnutls
starttls-gnutls-program
starttls-program)))
(condition-case ()
(progn
(call-process program)
program)
(error (progn
(message "No STARTTLS program was available (tried '%s')"
program)
nil)))))
--8<---------------cut here---------------end--------------->8---
> 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))
Regards,
next prev parent reply other threads:[~2008-11-04 0:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2008-11-04 16:50 ` Ted Zlatanov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b4mzlkgfh1e.fsf@jpl.org \
--to=yamaoka@jpl.org \
--cc=ding@gnus.org \
--cc=emacs-devel@gnu.org \
--cc=tzz@lifelogs.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.