From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15598 invoked by alias); 2 Jun 2018 18:17:27 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42917 Received: (qmail 363 invoked by uid 1010); 2 Jun 2018 18:17:26 -0000 X-Qmail-Scanner-Diagnostics: from mail-wm0-f65.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(74.125.82.65):SA:0(-1.9/5.0):. Processed in 1.15771 secs); 02 Jun 2018 18:17:26 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: tamelingdaniel@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=IZosRzYwRH0MBM6omNEq0/vQk3keqUJ/D0MGWneLlGk=; b=OOaPc3mwIe4yF3C8shu7DjnSecMXtDad1TpaqMwuQks84Rc5PUp1zUPmXI5lIxN7Vq qZ3T9DuBYe4DIST+whF1dvv0C8i/mV59dLpYMCoP/8SSI2yfk0e3Q5mwxQLaEAISLNmm Mma4F407u/0B+ou4SJ40NWfywvhoFEawxK1YpFIn65YvgA/x6hPIGRFoxyKBWn8jxN89 rciEf8xt/hZQtHcod2lRemVDA09fAQrgHRhuALzHmLfve97AGkAl/ctN/WnebdNwYptG C36lEchHsKr3UNbpeysvxDEMGYmgK3/Q21X4PEawU/t7rs5XACfLlP/f2sBYCncj/idd S8tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to; bh=IZosRzYwRH0MBM6omNEq0/vQk3keqUJ/D0MGWneLlGk=; b=BqqriMwlfsJjGJSStK0inyNy+L2hs31EfRcoNAWqvWC51XUldhDYjMiLBopkkE3aw7 vpidjBKpB6ssaxQU6fCf0nLgQ5pfdOv2pxb1n1zCyThlItr9mHJS0zsxQ5oxsxYYMs5A wIBq4TzbLPeoWBjlI8WlmiCIdsnmyYbp72Ox4cnwqKMaKCDdYREYEWW0trIfegjqZJWb DER/qUf3uSsI9k/g2STL2D/2Z0nyHQhDr7fUb+7uhtKbCM2VSUY2Za3KBoqGcjwMOW9p wAsdCEayg8jioJ9toMEIrOrMeCthFHxUM3UFUybOagupoyrUEbEh4RkbkzjijT6w6os4 N6Ug== X-Gm-Message-State: APt69E2ixT5Hf8rKrQfuw2VDd/bo53TKGIEY3wRpzEPQIKpBUFjA9yjP ZRLdIgj5iTYQNBsMRzlymGEmyQ== X-Google-Smtp-Source: ADUXVKIKh9XvXsSIjNaMx2VsWcMjfb/5m7sOUHT7I9Q6PsKkR6+3o/4AUyLjQcDMUgoKMecn3n7T8Q== X-Received: by 2002:a1c:3505:: with SMTP id c5-v6mr3779062wma.80.1527963441887; Sat, 02 Jun 2018 11:17:21 -0700 (PDT) Date: Sat, 2 Jun 2018 20:17:19 +0200 From: Daniel Tameling To: zsh-workers@zsh.org Subject: Re: [Bug] Strange Globing Behaviour when used with sudo Message-ID: <20180602181719.vzcnij3fvx7eueuk@Daniels-MacBook-Air.local> Mail-Followup-To: zsh-workers@zsh.org References: <20180530202349.GA10754@osmium.lan> <20180531094403.05b62bee@camnpupstephen.cam.scsc.local> <20180531084938eucas1p19a854d9e9ea17428cd6549f56a283356~zroN76sl33019130191eucas1p1K@eucas1p1.samsung.com> <3977A049-90E6-4EDD-9E4C-8D2FF38593A3@kba.biglobe.ne.jp> <20180531152941eucas1p2c45927fa47f727224e2da98b4f6a7604~zxFgS-BM50307003070eucas1p2G@eucas1p2.samsung.com> <20180531181546.osffv3ysjzaxjfid@Daniels-MacBook-Air.local> <01B9BB58-DDAE-4056-AD9A-2367DC3AC20D@kba.biglobe.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <01B9BB58-DDAE-4056-AD9A-2367DC3AC20D@kba.biglobe.ne.jp> On Fri, Jun 01, 2018 at 11:08:30PM +0900, Jun T. wrote: > > > 2018/06/01 03:15, Daniel Tameling wrote: > > > > As s is NULL and buf is in the example ./file/, statfullpath adds to > > buf a . so that it's "./file/.". > (snip) > > So one possibility to fix this is to > > call stat before adding the . to ./file/, and the return non-zero if > > it is not a directory. > > Yes, but users can add '.' by themselves, for example > sudo zsh -c 'echo */.'. And of course you can not just > "return !S_ISDIR(st->st_mode)", and st may be NULL. > > I've also fond that stat("file/..") is similarly broken. > > In the patch below, I enclosed everything within "#ifdef __APPLE__" > to minimize the side effects. It is difficult to detect the bug > by configure since it requires sudo. > Your patch works, but it didn't solve everything. So while $ sudo zsh -c 'echo */.. results in "no matches found", but already adding a slash and you get again output: $ sudo zsh -c 'echo */../ file/../ This is not so easy to fix because you can continue the path after .. : $ sudo zsh -c 'echo */../.././directory/' file/../.././directory/ So fixing this would probably mean, you need to iterate over the path, and whenever encountering "." or ".." checking whether everything before is really a directory. But note that fixing the problem would also lead to a behavior that some might find counter-intuitive: $ sudo zsh -c 'ls file/..' file $ sudo zsh -c 'ls */..' zsh:1: no matches found: */.. Btw: I noticed bash manages to trigger the ls error message when zsh outputs "no matches found" $ bash -c 'ls */..' ls: cannot access '*/..': No such file or directory -- Best, Daniel