[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
smtpmail on Windows native Emacs with gnutls-cli from Cygwin freeze.
From: |
Oleksandr Gavenko |
Subject: |
smtpmail on Windows native Emacs with gnutls-cli from Cygwin freeze. |
Date: |
Mon, 24 Oct 2011 00:53:12 +0300 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.1) Gecko/20110830 Thunderbird/6.0.1 |
I like use native Emacs with Cygwin toolset. It does not
hard to friend then. But from time to time I discover some issues.
Now time I finally try setup Emacs to work with mail.
GMail SMTP require TLS connection. As usual this done by
'gnus/starttls.el'.
After configuring smtpmail (send-mail-function==smtpmail-send-it)
I try compose mail:
C-x m bla-bla-bla C-c C-c
Emacs freeze! Try same in Cygwin Emacs and all OK!
After debug I found root of evil:
(defun starttls-open-stream-gnutls (name buffer host port)
...
(process (apply #'start-process name buffer
starttls-gnutls-program "-s" host
"-p" (if (integerp port)
(int-to-string port)
port)
starttls-extra-arguments))
...)))))
(defun starttls-negotiate-gnutls (process)
...
;; XXX How to remove/extract the TLS negotiation junk?
(signal-process (process-id process) 'SIGALRM)
...
(save-excursion
(setq old-max (goto-char (point-max)))
(signal-process (process-id process) 'SIGALRM)
(while (and (processp process)
(eq (process-status process) 'run)
(save-excursion
(goto-char old-max)
(not (or (setq done-ok (re-search-forward
starttls-success nil t))
(setq done-bad (re-search-forward
starttls-failure nil t))))))
(accept-process-output process 1 100)
(sit-for 0.1))
...
So 'gnutls-cli' called with '-s' option. From man page:
-s, --starttls
Connect, establish a plain session and start TLS
when EOF or a SIGALRM is received.
and 'signal-process' call do nothing for SIGALRM. More correctly
return error. Look to 'src/w32proc.c':
int
sys_kill (int pid, int sig)
{
...
/* Only handle signals that will result in the process dying */
if (sig != SIGINT && sig != SIGKILL && sig != SIGQUIT && sig != SIGHUP)
{
errno = EINVAL;
return -1;
}
So 'gnutls-cli' don't send anything and 'while' loop can not match
'starttls-failure', 'starttls-success', etc...
I easy make workaround. Just replace 'signal-process' with Cygwin
'kill.exe':
(shell-command (format "kill.exe -s SIGALRM %d" (process-id process)))
Conclusion from this story: check return codes... and don't use
unsupported configuration!
But I think Emacs 'gnus/starttls.el' code can be rewritten to be able
work with Cygwin gnutls-cli without signals...
As emacs-jabber package work fine with Cygwin! I successfully use
it for 2 years with Google GTalk over TLS...
- smtpmail on Windows native Emacs with gnutls-cli from Cygwin freeze.,
Oleksandr Gavenko <=