Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [Bug] Strange Globing Behaviour when used with sudo
- X-seq: zsh-workers 42917
- From: Daniel Tameling <tamelingdaniel@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [Bug] Strange Globing Behaviour when used with sudo
- Date: Sat, 2 Jun 2018 20:17:19 +0200
- 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==
- In-reply-to: <01B9BB58-DDAE-4056-AD9A-2367DC3AC20D@kba.biglobe.ne.jp>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mail-followup-to: zsh-workers@xxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20180530202349.GA10754@osmium.lan> <CAMaoPXzzuRvAn1FFF3BJ0fnJTiaGgeg2TJKAZgL4RLwV5t5RBw@mail.gmail.com> <CGME20180530205013epcas1p21e3a53e151d3696ad475913d56ced3db@epcas1p2.samsung.com> <CAMaoPXwFdVPszgra5busqtLNqAKsJxDV56LPW9ZrtUbg=tbSMQ@mail.gmail.com> <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>
On Fri, Jun 01, 2018 at 11:08:30PM +0900, Jun T. wrote:
>
> > 2018/06/01 03:15, Daniel Tameling <tamelingdaniel@xxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author