From: Magnus H. <leg...@us...> - 2012-05-19 14:03:03
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "emacs-jabber". The branch, master has been updated via 1dca591d17cf084e6d870f55898e9343926f8bb8 (commit) via 5c7c52b066aa92d809b8f9b259f63fe79aed051c (commit) from f54c1b54b308f38caac66ae567e5f64f6adc631c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 1dca591d17cf084e6d870f55898e9343926f8bb8 Author: Magnus Henoch <mag...@gm...> Date: Sat May 19 15:01:05 2012 +0100 Fix reporting of STARTTLS negotiation errors jabber-starttls-process-input now signals an error on negotiation failure, as gnutls-negotiate already does. Catch errors in jabber-core, and put them as disconnection reason in the state data, to get fewer and less confusing messages in the echo area. diff --git a/jabber-conn.el b/jabber-conn.el index 5b4b89f..fba32bf 100644 --- a/jabber-conn.el +++ b/jabber-conn.el @@ -252,7 +252,7 @@ connection fails." (defun jabber-starttls-process-input (fsm xml-data) "Process result of starttls request. -Return non-nil on success, nil on failure." +On failure, signal error." (cond ((eq (car xml-data) 'proceed) (let* ((state-data (fsm-get-state-data fsm)) @@ -263,6 +263,8 @@ Return non-nil on success, nil on failure." (network (let* ((hostname (plist-get state-data :server)) (verifyp (not (member hostname jabber-invalid-certificate-servers)))) + ;; gnutls-negotiate might signal an error, which is caught + ;; by our caller (gnutls-negotiate :process connection ;; This is the hostname that the certificate should be valid for: @@ -270,9 +272,11 @@ Return non-nil on success, nil on failure." :verify-hostname-error verifyp :verify-error verifyp))) (real - (starttls-negotiate connection))))) + (or + (starttls-negotiate connection) + (error "Negotiation failure")))))) ((eq (car xml-data) 'failure) - nil))) + (error "Command rejected by server")))) (defvar *jabber-virtual-server-function* nil "Function to use for sending stanzas on a virtual connection. diff --git a/jabber-core.el b/jabber-core.el index eae787b..58b233d 100644 --- a/jabber-core.el +++ b/jabber-core.el @@ -483,11 +483,16 @@ With double prefix argument, specify more connection details." (jabber-fsm-handle-sentinel state-data event)) (:stanza - (if (jabber-starttls-process-input fsm (cadr event)) - ;; Connection is encrypted. Send a stream tag again. - (list :connected (plist-put state-data :encrypted t)) - (message "STARTTLS negotiation failed") - (list nil state-data))) + (condition-case e + (progn + (jabber-starttls-process-input fsm (cadr event)) + ;; Connection is encrypted. Send a stream tag again. + (list :connected (plist-put state-data :encrypted t))) + (error + (let* ((msg (concat "STARTTLS negotiation failed: " + (error-message-string e))) + (new-state-data (plist-put state-data :disconnection-reason msg))) + (list nil new-state-data))))) (:do-disconnect (jabber-send-string fsm "</stream:stream>") commit 5c7c52b066aa92d809b8f9b259f63fe79aed051c Author: mag...@gm... <mag...@gm...> Date: Sun Feb 5 13:15:43 2012 +0100 Fix error handling for old-style SSL/TLS connections When connecting to a Jabber server over SSL/TLS without STARTTLS (the legacy "port 5223" method), any connection error would cause the state machine to be stuck in the :connecting state, unable to go back or forward. Fix this by catching and reporting errors in jabber-ssl-connect. diff --git a/jabber-conn.el b/jabber-conn.el index 531d3a0..5b4b89f 100644 --- a/jabber-conn.el +++ b/jabber-conn.el @@ -181,14 +181,19 @@ connection fails." (error "Neither TLS nor SSL connect functions available"))))) (let ((process-buffer (generate-new-buffer jabber-process-buffer)) connection) - (unwind-protect + (setq network-server (or network-server server)) + (setq port (or port 5223)) + (condition-case e (setq connection (funcall connect-function "jabber" process-buffer - (or network-server server) - (or port 5223))) - (unless (or connection jabber-debug-keep-process-buffers) - (kill-buffer process-buffer))) + network-server + port)) + (error + (message "Couldn't connect to %s:%d: %s" network-server port + (error-message-string e)))) + (unless (or connection jabber-debug-keep-process-buffers) + (kill-buffer process-buffer)) (if connection (fsm-send fsm (list :connected connection)) (fsm-send fsm :connection-failed))))) ----------------------------------------------------------------------- Summary of changes: jabber-conn.el | 25 +++++++++++++++++-------- jabber-core.el | 15 ++++++++++----- 2 files changed, 27 insertions(+), 13 deletions(-) hooks/post-receive -- emacs-jabber |