From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs Subject: bug#38066: 26.1; X-Message-SMTP-Method header does not affect smtpmail-stream-type Date: Tue, 05 Nov 2019 18:24:16 +0100 Message-ID: References: <87ftj3j5hb.fsf@disp2634> <87o8xqcn8v.fsf@disp2634> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="221639"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 38066@debbugs.gnu.org To: Ryan Tate Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 05 18:25:21 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iS2a0-000vUC-Dz for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Nov 2019 18:25:20 +0100 Original-Received: from localhost ([::1]:46826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iS2Zy-0003K5-L6 for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Nov 2019 12:25:18 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41798) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iS2Zk-0003HS-NL for bug-gnu-emacs@gnu.org; Tue, 05 Nov 2019 12:25:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iS2Zj-0003uW-7P for bug-gnu-emacs@gnu.org; Tue, 05 Nov 2019 12:25:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58435) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iS2Zj-0003uS-3N for bug-gnu-emacs@gnu.org; Tue, 05 Nov 2019 12:25:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iS2Zi-0003pS-Gq for bug-gnu-emacs@gnu.org; Tue, 05 Nov 2019 12:25:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Nov 2019 17:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38066 X-GNU-PR-Package: emacs Original-Received: via spool by 38066-submit@debbugs.gnu.org id=B38066.157297466714664 (code B ref 38066); Tue, 05 Nov 2019 17:25:02 +0000 Original-Received: (at 38066) by debbugs.gnu.org; 5 Nov 2019 17:24:27 +0000 Original-Received: from localhost ([127.0.0.1]:39023 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iS2Z8-0003oQ-O9 for submit@debbugs.gnu.org; Tue, 05 Nov 2019 12:24:27 -0500 Original-Received: from mail-wr1-f46.google.com ([209.85.221.46]:41282) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iS2Z7-0003oC-A0 for 38066@debbugs.gnu.org; Tue, 05 Nov 2019 12:24:25 -0500 Original-Received: by mail-wr1-f46.google.com with SMTP id p4so22360160wrm.8 for <38066@debbugs.gnu.org>; Tue, 05 Nov 2019 09:24:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-transfer-encoding; bh=rMJD/lqq+E2N6U2pE4CbG2mdnVVsV/6CXnK7FDjcthY=; b=bCk7VBHlfnyYfpr3TUPIYUI2tx4Rcs2jEJumsAakom7L+enVxibRRmX58BpG0Woeu/ Uz9K9Zmy7VYw6DImfG9p3FEOt2lGUubYHtcQ9kt7PUO4/vPRpNGzlXOY3Cpy6NVicNl/ cKlw93KQo0V4rJKWPkawMug+wRx7yuYoAufOikfnrFBcj2wRwYAk2jvUghCCBft9fQnb 7KCYRUJIbbxNcXz3bMUqUk81MS0nL9oYsSXsqV+tXJ0sYZk8RrPugDZDrvxAT1v0VYmM Aa1p/H2d2b7hz8R8w1m5Ionk26fFPD4L8TOQFB3lsT6A9F1pJs5XQ6Idj8vPuffyXvlu RRVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:mime-version:content-transfer-encoding; bh=rMJD/lqq+E2N6U2pE4CbG2mdnVVsV/6CXnK7FDjcthY=; b=GDPDHyhHRZcYfkC/qfhQxCvLgqyAinjjkq2Bmlilu0/huzahBecz9bD96805djD7bn ILyqPI517VSvxUtMqgoI0Nj7ZK4OQx57KOXJw1Rb5Dl5tdqJOzELUFzqexzR/q+nC+F9 F879CfMX017btcU0gv6Rf2wj83vO8uoyRN5pk2f3Hp2zPwb4AEpNaeZPPC09wR+Fi8tL XzNysaOZLweUml9bi3vMkLPAIZZxeIYeSV/GIGtYUScMBFq5ZObzXrnER571zbbVm0vL rjkLOxvIVJVnNm/b3Vb3E1MkyRysfDud439koLBYPWjnwDNEYPoEP79eIVXW/6UH3elX Kr6g== X-Gm-Message-State: APjAAAXvTgeaDY1nJTydxuE3hYlE5SV09wiqlLv3QHqPomm7S++Xuf0x dhcBh9qpxP0i8N7s/IrumYcN+vin X-Google-Smtp-Source: APXvYqz4psm+RLv9SlhfBvV6vfiGTMCMRXcD08ISUxf++GiW3obRgmdIdYGRlH+vuBPLgaHRkjqkvg== X-Received: by 2002:adf:9506:: with SMTP id 6mr12521451wrs.274.1572974658560; Tue, 05 Nov 2019 09:24:18 -0800 (PST) Original-Received: from rpluim-mac ([2a01:e34:ecfc:a860:c514:c07d:445b:e553]) by smtp.gmail.com with ESMTPSA id b17sm106911wrr.37.2019.11.05.09.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 09:24:17 -0800 (PST) In-Reply-To: <87o8xqcn8v.fsf@disp2634> (Ryan Tate's message of "Tue, 05 Nov 2019 11:16:16 -0500") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:170980 Archived-At: (please keep 38066@debbugs.gnu.org in the CC) >>>>> On Tue, 05 Nov 2019 11:16:16 -0500, Ryan Tate = said: >> Alternatively we could put this kind of code in open-network-stream, >> to allow other protocols to benefit from the same kind of detection. Ryan> I don't know enough about the open-network-stream corner of emacs= so won't argue either Ryan> way. At the very least, I think it certainly makes sense with reg= ard to the X-Message-SMTP-Method Ryan> header because this is a convenience feature (so some small amoun= t "magic" Ryan> seems permissable) and there is no existing way to set the stream= type Ryan> here. I imagine it could be useful elsewhere in emacs though. If we do it in the lower layers, then everyone gets to use it, not just people using X-Message-SMTP-Method or smtpmail-stream-type. Ryan> Your patches look good, thank you for writing them! (Do I need to= submit Ryan> them formally as a patch on this list?) No, if they gain traction I can commit them. I took a look at open-network-stream, and it=CA=BCs not too hard to do the equivalent there, although it probably needs to be conditioned on the specified :type being nil rather than unconditionally overriding it. diff --git i/lisp/net/gnutls.el w/lisp/net/gnutls.el index 9b13adaefe..a083e9df6c 100644 --- i/lisp/net/gnutls.el +++ w/lisp/net/gnutls.el @@ -202,6 +202,7 @@ open-gnutls-stream (process (open-network-stream name buffer host service :nowait nowait + :auto-tls (plist-get parameters :auto-tls) :tls-parameters (and nowait (cons 'gnutls-x509pki diff --git i/lisp/net/network-stream.el w/lisp/net/network-stream.el index 4050c83eb0..8b4bd66ef4 100644 --- i/lisp/net/network-stream.el +++ w/lisp/net/network-stream.el @@ -73,6 +73,35 @@ network-stream-use-client-certificates :type 'boolean :version "27.1") =20 +(defcustom network-stream-auto-tls nil + "Whether to automatically try with TLS for certain port +numbers. See `network-stream-auto-tls-alist' for the default +settings." + :group 'network + :type 'boolean + :version "27.1") + +(defcustom network-stream-auto-tls-alist + '((465 . tls) + (587 . starttls) + (993 . tls)) + "Alist used for mapping ports to TLS usage. +Specifies which port number to map to which TLS behaviour. See +`open-network-stream' for a full explanation of the possible +behaviours." + :group 'network + :type '(alist :key-type integer + :value-type (choice + (const :tag "Possibly upgrade to STARTTLS" ni= l) + (const :tag "Always use STARTTLS" starttls) + (const :tag "Never use STARTTLS" plain) + (const :tag "Use TLS/SSL" tls))) + :version "27.1") + ;;;###autoload (defun open-network-stream (name buffer host service &rest parameters) "Open a TCP connection to HOST, optionally with encryption. @@ -175,7 +204,19 @@ open-network-stream (unless (featurep 'make-network-process) (error "Emacs was compiled without networking support")) (let ((type (plist-get parameters :type)) - (return-list (plist-get parameters :return-list))) + (return-list (plist-get parameters :return-list)) + mapped-type) + (when (and network-stream-auto-tls (not (plist-get parameters :auto-tl= s))) + (setq mapped-type (assoc (if (integerp service) + service + (string-to-number service)) + network-stream-auto-tls-alist)) + (when mapped-type + (setq type (cdr mapped-type) + parameters (plist-put + (plist-put parameters :auto-tls t) + :type (cdr mapped-type))))) + (message "Auto-TLS %s %s" type mapped-type) (if (and (not return-list) (or (eq type 'plain) (and (memq type '(nil network))