From unknown Mon Jun 23 02:26:37 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7438: 23.2; [PATCH] lisp/gnus/pop3.el fix STLS command ordering Resent-From: Yuri Karaban Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 18 Nov 2010 23:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 7438 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 7438@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.129012163529960 (code B ref -1); Thu, 18 Nov 2010 23:08:01 +0000 Received: (at submit) by debbugs.gnu.org; 18 Nov 2010 23:07:15 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PJDZS-0007nA-9O for submit@debbugs.gnu.org; Thu, 18 Nov 2010 18:07:14 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PJDNY-0007hy-JS for submit@debbugs.gnu.org; Thu, 18 Nov 2010 17:54:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PJDST-0002P7-EX for submit@debbugs.gnu.org; Thu, 18 Nov 2010 18:00:02 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:47524) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PJDST-0002P3-CT for submit@debbugs.gnu.org; Thu, 18 Nov 2010 18:00:01 -0500 Received: from [140.186.70.92] (port=40723 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJDSS-0008HR-AM for bug-gnu-emacs@gnu.org; Thu, 18 Nov 2010 18:00:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PJDSQ-0002Oh-S7 for bug-gnu-emacs@gnu.org; Thu, 18 Nov 2010 18:00:00 -0500 Received: from askold.net ([173.203.215.26]:56436) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PJDSQ-0002OW-Oq for bug-gnu-emacs@gnu.org; Thu, 18 Nov 2010 17:59:58 -0500 Received: from [93.73.241.34] (helo=sun) by askold.net with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1PJDSP-0000bI-2V for bug-gnu-emacs@gnu.org; Thu, 18 Nov 2010 22:59:57 +0000 From: Yuri Karaban Date: Fri, 19 Nov 2010 00:59:54 +0200 Message-ID: <874obe44r9.fsf@askold.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Spam-Score: -6.6 (------) X-Mailman-Approved-At: Thu, 18 Nov 2010 18:07:13 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.6 (------) --=-=-= Hi Starttls (STLS) is not working with pop3. There is a bug in current implementation. Current implementation sends STLS just after opening connection. As result connection hangs (pop3.el tries to read a greeting message after STLS, but all POP3 servers I tried does not send anything after successful negotiation). On other hand, ignoring server greeting leads to mistreating server greeting (+OK ) as successful response to STLS command. In this case negotiation starts too early (before reading real response to STLS). I've attached a patch which fixes the problem. The server greeting got read first (as with plain POP3) and only after receiving greeting STLS issued and TLS negotiation starts. I hope much this would be fixed in next minor release of emacs. Thanks! --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=pop3.el-stls-order.patch --- pop3.el.orig 2010-04-04 01:26:09.000000000 +0300 +++ pop3.el 2010-11-19 00:21:53.106967116 +0200 @@ -261,12 +261,6 @@ (setq port 110)) (let ((process (starttls-open-stream "POP" (current-buffer) mailhost (or port 110)))) - (pop3-send-command process "STLS") - (let ((response (pop3-read-response process t))) - (if (and response (string-match "+OK" response)) - (starttls-negotiate process) - (pop3-quit process) - (error "POP server doesn't support starttls"))) process)) (t (open-network-stream "POP" (current-buffer) mailhost port)))) @@ -274,6 +268,13 @@ (setq pop3-timestamp (substring response (or (string-match "<" response) 0) (+ 1 (or (string-match ">" response) -1))))) + (when (eq pop3-stream-type 'starttls) + (pop3-send-command process "STLS") + (let ((response (pop3-read-response process t))) + (if (and response (string-match "+OK" response)) + (starttls-negotiate process) + (pop3-quit process) + (error "POP server doesn't support starttls")))) process))) ;; Support functions --=-=-= -- Citius Altius Fortius --=-=-=-- From unknown Mon Jun 23 02:26:37 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7438: 23.2; [PATCH] lisp/gnus/pop3.el fix STLS command ordering Resent-From: Chong Yidong Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org, bugs@gnus.org Resent-Date: Fri, 19 Nov 2010 16:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7438 X-GNU-PR-Package: emacs,gnus X-GNU-PR-Keywords: patch To: Yuri Karaban Cc: 7438@debbugs.gnu.org Received: via spool by 7438-submit@debbugs.gnu.org id=B7438.129018362532012 (code B ref 7438); Fri, 19 Nov 2010 16:21:02 +0000 Received: (at 7438) by debbugs.gnu.org; 19 Nov 2010 16:20:25 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PJThI-0008KG-5u for submit@debbugs.gnu.org; Fri, 19 Nov 2010 11:20:24 -0500 Received: from pantheon-po42.its.yale.edu ([130.132.50.101]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PJThG-0008KB-61 for 7438@debbugs.gnu.org; Fri, 19 Nov 2010 11:20:22 -0500 Received: from furball (dhcp128036014113.central.yale.edu [128.36.14.113]) (authenticated bits=0) by pantheon-po42.its.yale.edu (8.12.11.20060308/8.12.11) with ESMTP id oAJGPR4g021106 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 19 Nov 2010 11:25:27 -0500 Received: by furball (Postfix, from userid 1000) id 18AEF160854; Fri, 19 Nov 2010 11:25:28 -0500 (EST) From: Chong Yidong References: <874obe44r9.fsf@askold.net> Date: Fri, 19 Nov 2010 11:25:27 -0500 In-Reply-To: <874obe44r9.fsf@askold.net> (Yuri Karaban's message of "Fri, 19 Nov 2010 00:59:54 +0200") Message-ID: <87ipztp9fs.fsf@stupidchicken.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-YaleITSMailFilter: Version 1.2c (attachment(s) not renamed) X-Spam-Score: -2.7 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) Yuri Karaban writes: > Starttls (STLS) is not working with pop3. > > There is a bug in current implementation. > > Current implementation sends STLS just after opening connection. > > As result connection hangs (pop3.el tries to read a greeting message > after STLS, but all POP3 servers I tried does not send anything after > successful negotiation). On other hand, ignoring server greeting leads > to mistreating server greeting (+OK ) as successful response > to STLS command. In this case negotiation starts too early (before > reading real response to STLS). > > I've attached a patch which fixes the problem. The server greeting got > read first (as with plain POP3) and only after receiving greeting STLS > issued and TLS negotiation starts. > > I hope much this would be fixed in next minor release of emacs. Looks reasonable. I've checked your patch into the emacs-23 branch. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 19 11:20:37 2010 Received: (at control) by debbugs.gnu.org; 19 Nov 2010 16:20:37 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PJThV-0008KS-1s for submit@debbugs.gnu.org; Fri, 19 Nov 2010 11:20:37 -0500 Received: from pantheon-po16.its.yale.edu ([130.132.50.72]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PJThS-0008KN-Ki for control@debbugs.gnu.org; Fri, 19 Nov 2010 11:20:34 -0500 Received: from furball (dhcp128036014113.central.yale.edu [128.36.14.113]) (authenticated bits=0) by pantheon-po16.its.yale.edu (8.12.11.20060308/8.12.11) with ESMTP id oAJGPg2W022222 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Fri, 19 Nov 2010 11:25:42 -0500 Received: by furball (Postfix, from userid 1000) id D28E6160854; Fri, 19 Nov 2010 11:25:42 -0500 (EST) From: Chong Yidong To: control@debbugs.gnu.org Subject: close 7438 Date: Fri, 19 Nov 2010 11:25:42 -0500 Message-ID: <87lj4pz3eh.fsf@stupidchicken.com> MIME-Version: 1.0 Content-Type: text/plain X-YaleITSMailFilter: Version 1.2c (attachment(s) not renamed) X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) close 7438 thanks