From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 17618 invoked from network); 14 Apr 2022 17:35:16 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 14 Apr 2022 17:35:16 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1649957716; b=r1IJuicndZBWsSLW44Pk04rU60B/b8bd/TY7O9h3yBUCmOuSseIAmDv3dwqHBZGIbyMiTJGvRy GEnFiWz7Nk+UTHAzxnrrdMgWbG091CpdQBLdV3t0MTEkvDqWGysu1rFti6pCquCYq72xOGc2ai q70cLDq+1H0gTJxMjWiDU7QcxzXgQYVBw4nuuEbQJuWkKErU8dzbxhq85n5DyZWLc1FiA8em80 hQIL5uUnnbpl7DFY4dz7qXG3p8MtgaEGoPMlPx5rn40lp1+4i1hdasEAYwZuAaHCxzSxfVRgJz aV6Y3XgF/RTdEYkmizIHnBhkn35gelp1iHgK5BcyORY+Gw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-pg1-f176.google.com) smtp.remote-ip=209.85.215.176; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1649957716; bh=3q1zH5n9k02+8ATBGnnarobQVUAMqWaqsOC/tqbT1Uw=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:References: In-Reply-To:MIME-Version:DKIM-Signature:DKIM-Signature; b=Pl/rKGkgbk0BQvzAdlbYAx7I5xat15/UvDzCQjIugxJHlZ9csLRdxq4daYYJ1W1Z1SeMeiSJ1E CRgvIEF9+q3rB0xMx3nSFk6TyyxPy6lbUnBcHzWWJhZaUvnr7wtUu//kouJjZhbdxbfYExz5fL jPcH/9WFV6osqsLFRx4ppEZoFTgtGTOS7AEzz0v96oAAK0Xh2uRL7ls1PhMpdENG30Wm8VDnd6 Oqkm+dTVd2BQxH2LOUVh27Hgzs+VXaCDDYzUAWzrCsl0DSvCk0sn1ohHvDWp1EFdYRnqr7niMm Ysf9YZmRQNgtWNrjOKiFQDViowkzthISCFZvBwGPhIGgOg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:To:Subject:Message-ID: Date:From:References:In-Reply-To:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=Lq+z1gfgJrC8Czstg/QTJ0uYe83hyx68CY1eCob8lZI=; b=esLMbyB0EXaLJB4tm0zS0z/2SF QFWaZymKHEcQn8IrqumDcL5zPX59QlK5Erwq2xK1zkp4MeznTaEk9TL9MA2fgezzQ8CfqN9/hK4Md rQUUIfJ4v25tqzaUA4cIQhghx+LbHSlWJRV6N0pr5T0xYXlGHxeHBmy3PG5/zkP5ecjHjH6e0IQMX xE9mgMbDvezKPAAfW6kbV1KLMZQRoEkMns2iR05s7labAqADsSEexjkZwIfSpqwPY4jHkf0V9LYSL HrjQuUK7FZU06hlgvMonlwQZHtTfZIRuxE+9iRsWdnKroLuOxCajNUJLAvK75fUKPNOJyp78+3aVT 96QMqAMA==; Received: from authenticated user by zero.zsh.org with local id 1nf3ND-000HIf-Sq; Thu, 14 Apr 2022 17:35:15 +0000 Authentication-Results: zsh.org; iprev=pass (mail-pg1-f176.google.com) smtp.remote-ip=209.85.215.176; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-pg1-f176.google.com ([209.85.215.176]:34391) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1nf3Mz-000GyL-Av; Thu, 14 Apr 2022 17:35:01 +0000 Received: by mail-pg1-f176.google.com with SMTP id t4so5371992pgc.1 for ; Thu, 14 Apr 2022 10:35:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=Lq+z1gfgJrC8Czstg/QTJ0uYe83hyx68CY1eCob8lZI=; b=gJ8WULSm7TKOzuQuy7qUnv06WGSfyWhwjQEkdVp7o1EZzGvDsZBQPDloIdHdBnknxw cJrPqQS1ddziW7x4zu4dNA9F1VzRlDQCB2OYfY6drPGe2pgsDZpFcomrkLLFBdMTWnY6 6tmDWlGI7S4jBC+saOGYWriVvZ35snp4efBqj0ashV0i8kYms8kVfIyrN360DgY/Vmqo sO+v/EtgztglA6pq+JlXp19kCKLMVJQjbGZFxR1n/QoF30EfXvZJhSp8wXYQNBSK+2Af 0R2qygQSqBHyVpc/JaP1AzR2myqyXQAWuEseppjdZRq9X4kLpUWTwNemcBBG6mbFcXgF AJKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=Lq+z1gfgJrC8Czstg/QTJ0uYe83hyx68CY1eCob8lZI=; b=O1Wm1h0tfwLzGqwnO1xYoOH92lIlPTYygSKWnQbSfljMUQgCO8k7HvTefw0e7Pxusg zLiuUBIw467iqBoTQVgZ7H8LXQem8DrkJU8MkUPxlbV7fG3TFKgw7HJJV/2eJgNw5xuK Qc496GqXmd5GDRMVCdVz3Cc4kwC7skjIr6w14GEToJUZYZ39G4KW9CriGs3E8TmNmTSb KJWCymuMdLIWcIFef6HEFU2hk00PdU7jRSUH73KDPDUlfWYAyJqh/t09AlB2xP1gNKXn eaz+6IUKxwIKa3nzCVg2OWj889GUkGP6xxUV1t466p2sqYq6EEeU/2ooecvhxvRIRL9u HzhA== X-Gm-Message-State: AOAM532obVgV7vqL950EW9ZQe2hG/diT3kMDop6XOnD7Y2JXpwrZv3hS XXmj1i381PsWIG8FM+lZUlPIjfxskwKWT3u62bcR25X+ X-Google-Smtp-Source: ABdhPJwyaz9YZVKS5uHDbChD8bTR2lpEghWHKDXnEndRpHsNsI+HbxocKH27Qr75Lgy29DiJNke/15adelISDETJ8pI= X-Received: by 2002:a63:5847:0:b0:399:3452:ffe4 with SMTP id i7-20020a635847000000b003993452ffe4mr3141294pgm.406.1649957700055; Thu, 14 Apr 2022 10:35:00 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:6a10:d5a5:0:0:0:0 with HTTP; Thu, 14 Apr 2022 10:34:59 -0700 (PDT) In-Reply-To: <20220414172717.nfjrqfa7ebm5xloo@sym.noone.org> References: <20220414161814.k5jtyuzyony2axz5@sym.noone.org> <20220414172717.nfjrqfa7ebm5xloo@sym.noone.org> From: Mikael Magnusson Date: Thu, 14 Apr 2022 19:34:59 +0200 Message-ID: Subject: Re: OpenSSH scp completion reminder To: zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" X-Seq: 50066 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On 4/14/22, Axel Beckert wrote: > Hi, > > On Thu, Apr 14, 2022 at 10:04:42AM -0700, Bart Schaefer wrote: >> On Thu, Apr 14, 2022 at 9:43 AM Axel Beckert wrote: >> > On Thu, Apr 14, 2022 at 11:20:34AM -0400, Phil Pennock wrote: >> > > This change impacts quoting of things like whitespace. >> > > Which I have assumed will impact zsh completion. >> > >> > I thought so as well, but I so far couldn't find anything which didn't >> > work with zsh remote file completion with OpenSSH 9.0 on the client >> > side. >> >> Completion itself doesn't use scp to do the remote file name >> generation, it uses plain ssh. Of course once the file names are >> returned, getting the quoting right for the actual scp invocation is >> down to what appears on the command line, so the only way completion >> could be implicated in messing this up is if it somehow automatically >> inserted the wrong quoting. > > Yep, and that's the point: In theory, the amount of quoting (e.g. > three backslashes vs one backslash) is expected to be different with > the different scp backends. But for some reason the variant with three > backslashes still worked for me with OpenSSH 9.0 on the client side > which defaults to use the SFTP backend which does no shell globbing or > escaping on the server side. > > To copy a file named "tmp/foo bar" from remotehost to my local > directory "tmp/", I did: > > % scp -p remotehost:tmp/foo tmp/ > > It expanded to: > > % scp -p remotehost:tmp/foo\\\ bar tmp/ > > Accoding to the docs, this does no more work with OpenSSH 9.0's > default settings, but it did. Running "scp" with "-vvvv" confirms that > the new default (SFTP backend) is used: > > scp -pvvvv remotehost:tmp/foo\\\ bar tmp/ |& fgrep tmp/foo > scp: debug3: sink_sftp: copying remote tmp/foo\\ bar to local tmp/ > scp: debug1: Fetching tmp/foo bar to tmp/foo bar > scp: debug2: do_download: download remote "tmp/foo bar" to local "tmp/foo > bar" > scp: debug2: Sending SSH2_FXP_STAT "tmp/foo bar" > scp: debug2: Sending SSH2_FXP_OPEN "tmp/foo bar" > scp: debug3: Sent remote message SSH2_FXP_OPEN I:4 P:tmp/foo bar > M:0x0001 > > It seems as if scp has some capability to recognize of there's too > much shell quoting in a file name and reducres it, since there are > still two backslashes in the first line with "debug3:" which vanish > after that line. > > And this even seems to go wrong if I want to copy a file created with > "touch 'foo\ bar'", i.e. with an backslash in there. I would have had > expected that OpenSSH 9.0 would fetch that file with "scp -p > remotehost:tmp/foo\\\ bar tmp/" but it actually stripped the file name > down and I needed five backslashes: > > scp -pvvvv remotehost:tmp/foo\\\\\ bar tmp/ |& fgrep tmp/foo > scp: debug3: sink_sftp: copying remote tmp/foo\\\\ bar to local tmp/ > scp: debug1: Fetching tmp/foo\\ bar to tmp/foo\\ bar > scp: debug2: do_download: download remote "tmp/foo\\ bar" to local > "tmp/foo\\ bar" > scp: debug2: Sending SSH2_FXP_STAT "tmp/foo\\ bar" > scp: debug2: Sending SSH2_FXP_OPEN "tmp/foo\\ bar" > scp: debug3: Sent remote message SSH2_FXP_OPEN I:4 P:tmp/foo\\ bar > M:0x0001 > > Looks like either a bug in OpenSSH 9.0 or an undocumented > compatibility feature to me. It's definitely a bug (I'm using 8.9 though): % touch '\;\[' % scp -s localhost:\\\;\\\[ . scp: \\;\\[: No such file or directory % scp -s localhost:\;\[ . scp: ;[: No such file or directory It doesn't seem possible to copy files with backslashes in the name at all using -s. -- Mikael Magnusson