From: Devin Hussey <husseydevin@gmail.com>
To: Mikael Magnusson <mikachu@gmail.com>
Cc: zsh-workers@zsh.org
Subject: Re: [PATCH] Ignore EACCES when doing non-pure globbing
Date: Tue, 12 Jan 2021 21:14:25 -0500 [thread overview]
Message-ID: <CAEtFKsvgYYGcNxqwERE+Lr-dJwvyvnP45vqtjnp6WnBOaeWwMA@mail.gmail.com> (raw)
In-Reply-To: <CAEtFKsuDqhu3USSVCcrt-8rkvA_yAkHt=eU+FY6=pNu+gVogMw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2010 bytes --]
Actually replied to the mailing list this time...
>Have you considered just not unsetting caseglob?
Brilliant solution.
"Doctor, it hurts when I do this."
"Then don't do that."
As for the compliant version, here is a much more "polite" version which
also avoids the awkward checks if lock != NULL (at the cost of reformatting
O.o).
/* Check for search permissions. If we don't have them, get out. */
if (access(fn, X_OK) != 0) {
return;
}
/* Check for read permissions. If we have them, try to open the directory.
*/
if (access(fn, R_OK) == 0) {
DIR *lock = diropen(fn);
if (lock == NULL)
return;
while (...) { ... }
closedir(lock);
}
if (subdirs) { ... }
% chmod 111 ..
% echo $PWD/*
/tmp/inaccessible/a/a /tmp/inaccessible/a/b /tmp/inaccessible/a/c
% chmod 000 ..
% echo $PWD/*
zsh: no matches found: /tmp/inaccessible/a/*
This matches the POSIX behavior of requiring parent directories to be
searchable, and is a little more respectful to filesystem permissions.
On Tue, Jan 12, 2021, 8:58 PM Devin Hussey <husseydevin@gmail.com> wrote:
> >Have you considered just not unsetting caseglob?
>
> Brilliant solution.
> "Doctor, it hurts when I do this."
> "Then don't do that."
>
> As for the compliant version, here is a much more "polite" version.
>
> This matches the behavior of the POSIX globs: with a non searchable
> directory, it returns no match, but doesn't require read access for parent
> directories.
>
> DIR *lock = NULL;
>
> /* Check for search permissions. If we don't have them, get out. */
> if (access(fn, X_OK) != 0) {
> return;
> }
> /* Check for read permissions. If we have them, try to open the directory.
> */
> if (access(fn, R_OK) == 0) {
> lock = diropen(fn);
> /* Error */
> if (lock == NULL)
> return;
> }
> while (lock != NULL &&...
>
> % chmod 111 ..
> % echo $PWD/*
> /tmp/inaccessible/a/a /tmp/inaccessible/a/b /tmp/inaccessible/a/c
> % chmod 000 ..
> % echo $PWD/*
> zsh: no matches found: /tmp/inaccessible/a/*
>
[-- Attachment #2: Type: text/html, Size: 4410 bytes --]
next prev parent reply other threads:[~2021-01-13 2:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-12 22:42 Devin Hussey
2021-01-12 22:48 ` Devin Hussey
2021-01-12 23:47 ` Lawrence Velázquez
2021-01-13 0:53 ` Devin Hussey
2021-01-13 1:12 ` Devin Hussey
2021-01-13 1:28 ` Bart Schaefer
2021-01-13 1:26 ` Mikael Magnusson
[not found] ` <CAEtFKsuDqhu3USSVCcrt-8rkvA_yAkHt=eU+FY6=pNu+gVogMw@mail.gmail.com>
2021-01-13 2:14 ` Devin Hussey [this message]
2021-01-13 3:01 ` Devin Hussey
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=CAEtFKsvgYYGcNxqwERE+Lr-dJwvyvnP45vqtjnp6WnBOaeWwMA@mail.gmail.com \
--to=husseydevin@gmail.com \
--cc=mikachu@gmail.com \
--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).