zsh-workers
 help / color / mirror / code / Atom feed
From: Devin Hussey <husseydevin@gmail.com>
To: "Lawrence Velázquez" <vq@larryv.me>
Cc: Bart Schaefer <schaefer@brasslantern.com>, zsh-workers@zsh.org
Subject: Re: [PATCH] Allow globbing with unreadable parent directories
Date: Wed, 13 Jan 2021 21:24:11 -0500	[thread overview]
Message-ID: <CAEtFKst3uJFQfGh7ChFtZrNGu7jVPBmsxJxibZWtZw8i3qJzsg@mail.gmail.com> (raw)
In-Reply-To: <CAEtFKssQ34pP7KyEU=TrWzxg8qLUo+FEVS5TeuBQg5J5bmkw-Q@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3172 bytes --]

Nevermind, I'm dumb on that last part, I forgot that the shell option
syntax is backwards.

On Wed, Jan 13, 2021, 9:22 PM Devin Hussey <husseydevin@gmail.com> wrote:

>
> On Wed, Jan 13, 2021, 8:33 PM Lawrence Velázquez <vq@larryv.me> wrote:
>
>> > On Jan 13, 2021, at 7:27 PM, Devin Hussey <husseydevin@gmail.com>
>> wrote:
>> >
>> >> On Wed, Jan 13, 2021, 5:28 PM Bart Schaefer <schaefer@brasslantern.com>
>> wrote:
>> >>
>> >> As far as I can tell, the patch
>> >> would only cause globbing to fail in more cases, not succeed where it
>> >> previously did not.
>> >
>> > No, that is definitely not the case.
>>
>> But your patch *does* cause globbing to fail in cases for which it
>> currently doesn't.
>>
>>         % mkdir -p notsearchable/{dir,DIR}
>>         % touch notsearchable/{dir,DIR}/file
>>         % chmod 600 notsearchable
>>         % zsh -fc 'echo notsearchable/*'
>>         notsearchable/DIR notsearchable/dir
>>         % ./zsh-patched -fc 'echo notsearchable/*'
>>         zsh:1: no matches found: notsearchable/*
>>
>
> Huh. Yeah, that is a bug.
>
> I don't yet understand enough of the logic.
>
> > opendir() would fail if either R_OK or X_OK was false, causing
>> unreadable folders to be a false negative.
>> >
>> > This is allowing certain combinations where opendir() would fail.
>>
>> If I'm understanding your intention correctly, you would like
>> "literal" segments (e.g., lacking special characters) of
>> case-insensitive glob patterns to match literally if the "parent"
>> lacks read permissions. This doesn't seem to work, though. Am I
>> missing something?
>>
>
> That is correct.
>
> To reiterate the problem:
>
>  - Case-sensitive (and POSIX) globs seemingly only fail if the parent
> directory is unsearchable or if the target directory is unreadable, as it
> only opens the globbed directory.
>
>  - The case-insensitive ("impure") glob will fail if ANY parent is
> unreadable or unsearchable. This is because unlike the normal glob, the
> impure glob will try to recursively opendir() from "/".
>
>  - If I ignore EACCES entirely like in my first patch, case-insensitive
> globs would succeed if the parent is unsearchable, causing the opposite bug
> where case-sensitive globs fail.
>
>  - The current patch does not handle the target directory being readable
> but not searchable.
>
> I admit that I know very little about the Zsh source tree, so I have
> tunnel vision when it comes to the program logic. It is likely I who is
> missing something obvious.
>
> The only reason that I found the cause of this bug was via strace.
>
>         % mkdir -p notreadable/dir
>>         % touch notreadable/dir/file
>>         % chmod 300 notreadable
>>         % zsh -f +o CASE_GLOB -c 'echo notreadable/dir/*'
>>         zsh:1: no matches found: notreadable/dir/*
>>         % ./zsh-patched -f +o CASE_GLOB -c 'echo notreadable/dir/*'
>>         zsh:1: no matches found: notreadable/dir/*
>
>
> I didn't do anything that would directly affect CASE_GLOB, as CASE_GLOB
> uses the "pure" codepath. It is expected that the behavior would not change.
>

[-- Attachment #2: Type: text/html, Size: 4996 bytes --]

  reply	other threads:[~2021-01-14  2:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-13  3:04 Devin Hussey
2021-01-13 22:27 ` Bart Schaefer
2021-01-14  0:27   ` Devin Hussey
2021-01-14  1:32     ` Lawrence Velázquez
2021-01-14  2:22       ` Devin Hussey
2021-01-14  2:24         ` Devin Hussey [this message]
2021-01-17 17:22       ` Daniel Shahaf
2021-01-17 18:02         ` Bart Schaefer
2021-01-17 18:23           ` Bart Schaefer
2021-01-14  4:04     ` Bart Schaefer
2021-01-14  5:57       ` NO_CASE_GLOB and unreadable directories (Episode VI: A New Hope) Bart Schaefer
2021-01-14 18:56         ` Bart Schaefer
2021-01-25  0:52         ` Bart Schaefer
2021-01-25 14:05           ` Peter Stephenson
2021-02-05  5:53             ` Bart Schaefer
2021-02-06 12:31               ` Daniel Shahaf
2021-03-27 17:31           ` Lawrence Velázquez
2021-04-10 20:56             ` Lawrence Velázquez
2021-04-10 21:22               ` Bart Schaefer
2021-04-13 11:46                 ` Daniel Shahaf
2021-04-13 21:33                   ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAEtFKst3uJFQfGh7ChFtZrNGu7jVPBmsxJxibZWtZw8i3qJzsg@mail.gmail.com \
    --to=husseydevin@gmail.com \
    --cc=schaefer@brasslantern.com \
    --cc=vq@larryv.me \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).