From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.devel Subject: Re: bug#40248: 27.0.90; Failure open .authinfo.gpg from Gnus Date: Tue, 31 Mar 2020 11:20:17 +0200 Message-ID: References: <86bloi1zrj.fsf@csic.es> <83lfnm8b30.fsf@gnu.org> <83ftdt9b1d.fsf@gnu.org> <86sght3h1s.fsf@csic.es> <834ku89anf.fsf@gnu.org> <87a740ub2r.fsf@gnus.org> <83tv287s9j.fsf@gnu.org> <874ku7txho.fsf@gnus.org> <83imin5l0w.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="85152"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Mar 31 11:21:40 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jJD5Y-000M0v-AU for ged-emacs-devel@m.gmane-mx.org; Tue, 31 Mar 2020 11:21:40 +0200 Original-Received: from localhost ([::1]:34486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJD5W-00086R-OC for ged-emacs-devel@m.gmane-mx.org; Tue, 31 Mar 2020 05:21:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36229) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJD4L-000775-HR for emacs-devel@gnu.org; Tue, 31 Mar 2020 05:20:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJD4J-0000oY-UG for emacs-devel@gnu.org; Tue, 31 Mar 2020 05:20:25 -0400 Original-Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:53568) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jJD4J-0000n1-MT; Tue, 31 Mar 2020 05:20:23 -0400 Original-Received: by mail-wm1-x329.google.com with SMTP id b12so1635189wmj.3; Tue, 31 Mar 2020 02:20:21 -0700 (PDT) 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; bh=yBTZORQnHa2h09a06UZt/WhyKrZ5/VN1oml14RdKub0=; b=udV3S97QvsHm0b29Gn2rKgQDcAz/EewoDwBTHf7d1h/DFEBupG27a6c+D2j9xxIKlG tb2Q9BIvLDh21YMRLN3o7snSpE2SZB/fuMaAy3yhESPpTy6NrB9SvHe2xY4jYQrRx7qg nT6+jUuU3yMJhWi76JVA/Aj1RT1IiysfX8T7BIApPhxS8dTiB/UT7NlBJFtye6dz3EsG 1dQpVefVrFvuMxIViwF+CLXSQjvw5JwP9rl8dbYz+U2u5AUHGXm3bBW+63p1m7Xi7nSA B38gSv3K1le7zrVurDLIUfLjzaoCnHYPFhai+sdBAWbztu7s8gbcZVRkIXx15ROduRhC nSUQ== 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; bh=yBTZORQnHa2h09a06UZt/WhyKrZ5/VN1oml14RdKub0=; b=FJlkRqg42+Uk8CegCvkKIj76cNqd17u++ykK513b0lgzNViv5Kyg4MCLC2c1gbKPwg Dy79NZOX5ulEk/LcTyX5UVNA7KfGEjgVb1c+fao4+xOiOUMgMeeKq5YNibrE+F2A2jgi tr1exjznwMvRFnAMlytB19H11VsH3JjA/WCjiQ562iSAdjMvuOjt4RjHbeiW/zDS+vZN ibbtIs50fC++0QwbVARrGf+tOJrXuusb91kOMrOCpb2/JT4CEn9D0FPviuKfO7ZApW4B iEgZVWabeOvWkQq2a03nElN8+6uFq4RSc7+ZP6v8jIBnDaD80htGe7Jr5WoucQtjDdA0 w38Q== X-Gm-Message-State: ANhLgQ2fNMp8/E09fRTjxrUP3ZStf6WUfVL0tbP9f2Tw37jbjzWB9afQ MEUWrzNSKEEbvHSwaj4Og+J1tXWz X-Google-Smtp-Source: ADFU+vuXO2cAr4FkXOsvnjXaPhuwJNZxjFBUFIuOAtTq7CqKOVQw6+LTUkkiPS2S/KmvtpwO3cGRTg== X-Received: by 2002:a1c:f409:: with SMTP id z9mr2554205wma.51.1585646419716; Tue, 31 Mar 2020 02:20:19 -0700 (PDT) Original-Received: from rpluim-mac ([2a01:e34:ecfc:a860:65f2:9a92:2c96:9204]) by smtp.gmail.com with ESMTPSA id b15sm25513498wru.70.2020.03.31.02.20.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2020 02:20:18 -0700 (PDT) In-Reply-To: <83imin5l0w.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 29 Mar 2020 16:49:03 +0300") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::329 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:246079 Archived-At: (dropping the bug, redirecting to emacs-devel) >>>>> On Sun, 29 Mar 2020 16:49:03 +0300, Eli Zaretskii said: >> Yes, that's unfortunate -- the "bind variables as a way of passing in >> parameters" thing that Emacs does a lot is a really bad one. I think >> the fix here would be to change open-network-stream, at least, to have a >> :coding parameter (and pass it on). Eli> Yes, let's do that on master. Having resisted the strong urge to rip out the gnutls-cli support in open-network-stream, this turned out to be surprisingly invasive. It works for nnimap with Gnus for me when passing :coding 'binary instead of binding coding-system-for-{read-write}, but more testing is definitely required. diff --git c/doc/lispref/processes.texi i/doc/lispref/processes.texi index 4a4f51474c..7d9ca46d94 100644 --- c/doc/lispref/processes.texi +++ i/doc/lispref/processes.texi @@ -2462,6 +2462,12 @@ Network @item :nowait @var{boolean} If non-@code{nil}, try to make an asynchronous connection. +@item :coding @var{coding} +Use this to set the coding systems used by the network process, in +preference to binding @code{coding-system-for-read} or +@code{coding-system-for-write}. @xref{Network Processes} for +details. + @item :type @var{type} The type of connection. Options are: diff --git c/etc/NEWS i/etc/NEWS index 8bbe2aee0b..14bdae3ea7 100644 --- c/etc/NEWS +++ i/etc/NEWS @@ -274,6 +274,11 @@ optional argument specifying whether to follow symbolic links. ** 'parse-time-string' can now parse ISO 8601 format strings, such as "2020-01-15T16:12:21-08:00". +** 'open-network-stream' now accepts a :coding argument. +This allows specifying the coding systems used by a network process +for encoding and decoding without having to bind +coding-system-for-{read,write} or call 'set-process-coding-system'. + * Changes in Emacs 28.1 on Non-Free Operating Systems diff --git c/lisp/net/gnutls.el i/lisp/net/gnutls.el index 459156e6d2..171a829f5b 100644 --- c/lisp/net/gnutls.el +++ i/lisp/net/gnutls.el @@ -169,8 +169,9 @@ open-gnutls-stream Fourth arg SERVICE is the name of the service desired, or an integer specifying a port number to connect to. Fifth arg PARAMETERS is an optional list of keyword/value pairs. -Only :client-certificate and :nowait keywords are recognized, and -have the same meaning as for `open-network-stream'. +Only :client-certificate, :nowait, and :coding keywords are +recognized, and have the same meaning as for +`open-network-stream'. For historical reasons PARAMETERS can also be a symbol, which is interpreted the same as passing a list containing :nowait and the value of that symbol. @@ -199,16 +200,19 @@ open-gnutls-stream (cert (network-stream-certificate host service parameters)) (keylist (and cert (list cert))) (nowait (plist-get parameters :nowait)) - (process (open-network-stream - name buffer host service - :nowait nowait - :tls-parameters - (and nowait - (cons 'gnutls-x509pki - (gnutls-boot-parameters - :type 'gnutls-x509pki - :keylist keylist - :hostname (puny-encode-domain host))))))) + (coding-p (plist-member parameters :coding)) + (coding-val (plist-get parameters :coding)) + (args (append (list name buffer host service + :nowait nowait + :tls-parameters + (and nowait + (cons 'gnutls-x509pki + (gnutls-boot-parameters + :type 'gnutls-x509pki + :keylist keylist + :hostname (puny-encode-domain host))))) + (when coding-p (list :coding coding-val)))) + (process (apply #'open-network-stream args))) (if nowait process (gnutls-negotiate :process process diff --git c/lisp/net/network-stream.el i/lisp/net/network-stream.el index e99d7a372c..d7d0aedada 100644 --- c/lisp/net/network-stream.el +++ i/lisp/net/network-stream.el @@ -113,6 +113,10 @@ open-network-stream `ssl' -- Equivalent to `tls'. `shell' -- A shell connection. +:coding is a symbol or a cons used to specify the coding systems +used to decode and encode the data which the process reads and +writes. See `make-network-process' for details. + :return-list specifies this function's return value. If omitted or nil, return a process object. A non-nil means to return (PROC . PROPS), where PROC is a process object and PROPS @@ -178,18 +182,21 @@ 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)) + (coding-p (plist-member parameters :coding))) (if (and (not return-list) (or (eq type 'plain) (and (memq type '(nil network)) (not (and (plist-get parameters :success) (plist-get parameters :capability-command)))))) ;; The simplest case: wrapper around `make-network-process'. - (make-network-process :name name :buffer buffer - :host (puny-encode-domain host) :service service - :nowait (plist-get parameters :nowait) - :tls-parameters - (plist-get parameters :tls-parameters)) + (let ((args (append (list :name name :buffer buffer + :host (puny-encode-domain host) :service service + :nowait (plist-get parameters :nowait) + :tls-parameters + (plist-get parameters :tls-parameters)) + (when coding-p (list :coding (plist-get parameters :coding)))))) + (apply #'make-network-process args)) (let ((work-buffer (or buffer (generate-new-buffer " *stream buffer*"))) (fun (cond ((and (eq type 'plain) @@ -245,11 +252,15 @@ 'open-protocol-stream "26.1") (defun network-stream-open-plain (name buffer host service parameters) - (let ((start (with-current-buffer buffer (point))) - (stream (make-network-process :name name :buffer buffer - :host (puny-encode-domain host) - :service service - :nowait (plist-get parameters :nowait)))) + (let* ((start (with-current-buffer buffer (point))) + (coding-p (plist-member parameters :coding)) + (coding-val (plist-get parameters :coding)) + (args (append (list :name name :buffer buffer + :host (puny-encode-domain host) + :service service + :nowait (plist-get parameters :nowait)) + (when coding-p (list :coding coding-val)))) + (stream (apply #'make-network-process args))) (when (plist-get parameters :warn-unless-encrypted) (setq stream (nsm-verify-connection stream host service nil t))) (list stream @@ -267,10 +278,14 @@ network-stream-open-starttls (eoc (plist-get parameters :end-of-command)) (eo-capa (or (plist-get parameters :end-of-capability) eoc)) + (coding-p (plist-member parameters :coding)) + (coding-val (plist-get parameters :coding)) + (args (append (list :name name :buffer buffer + :host (puny-encode-domain host) + :service service) + (when coding-p (list :coding coding-val)))) ;; Return (STREAM GREETING CAPABILITIES RESULTING-TYPE) - (stream (make-network-process :name name :buffer buffer - :host (puny-encode-domain host) - :service service)) + (stream (apply #'make-network-process args)) (greeting (and (not (plist-get parameters :nogreeting)) (network-stream-get-response stream start eoc))) (capabilities (network-stream-command stream capability-command @@ -348,9 +363,7 @@ network-stream-open-starttls ;; isn't demanded, reopen an unencrypted connection. (unless require-tls (setq stream - (make-network-process :name name :buffer buffer - :host (puny-encode-domain host) - :service service)) + (apply #'make-network-process args)) (network-stream-get-response stream start eoc))) (unless (process-live-p stream) (error "Unable to negotiate a TLS connection with %s/%s" @@ -453,6 +466,8 @@ network-stream-open-shell (let* ((capability-command (plist-get parameters :capability-command)) (eoc (plist-get parameters :end-of-command)) (start (with-current-buffer buffer (point))) + (coding-p (plist-member parameters :coding)) + (coding-val (plist-get parameters :coding)) (stream (let ((process-connection-type nil)) (start-process name buffer shell-file-name shell-command-switch @@ -461,6 +476,13 @@ network-stream-open-shell (format-spec-make ?s host ?p service)))))) + (when coding-p (if (consp coding-val) + (set-process-coding-system stream + (car coding-val) + (cdr coding-val)) + (set-process-coding-system stream + coding-val + coding-val))) (list stream (network-stream-get-response stream start eoc) (network-stream-command stream capability-command