all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* smtpmail on Windows native Emacs with gnutls-cli from Cygwin freeze.
@ 2011-10-23 21:53 Oleksandr Gavenko
  2011-10-23 22:40 ` Oleksandr Gavenko
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Oleksandr Gavenko @ 2011-10-23 21:53 UTC (permalink / raw)
  To: emacs-devel

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




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

end of thread, other threads:[~2013-06-09  0:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-23 21:53 smtpmail on Windows native Emacs with gnutls-cli from Cygwin freeze Oleksandr Gavenko
2011-10-23 22:40 ` Oleksandr Gavenko
2013-06-09  0:15   ` l1dge
2011-10-23 23:56 ` Lars Magne Ingebrigtsen
2011-10-24  6:57   ` Eli Zaretskii
2011-10-24  7:15 ` Eli Zaretskii
2011-10-24 20:21   ` Oleksandr Gavenko
2011-10-24 21:45     ` Eli Zaretskii

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.