zsh-workers
 help / color / mirror / Atom feed
* Issue with permissions and case-insensitive globbing
@ 2021-01-12 18:54 Devin Hussey
  2021-01-12 21:38 ` Mikael Magnusson
  0 siblings, 1 reply; 3+ messages in thread
From: Devin Hussey @ 2021-01-12 18:54 UTC (permalink / raw)
  To: zsh-workers

Case insensitive globbing will not work at all if any of the parent
directories of the target folder are inaccessible.

This bug makes zsh very unstable on Termux (a Linux environment for
Android), as scripts which use "~/..." will immediately show no
results.

Android's directory structure makes it so apps can only access their
/data/data subfolder, blocking access to /data/data itself (it will
return EACCES).

Termux's $HOME is /data/data/com.termux/files/home.

The simplified folder setup is this:

root    root    0700 /
root    root    0700 /data
root    root    0700 /data/data
termux termux 0700 /data/data/com.termux

A (possible) fix for this issue would be to start in the "base"
directory before any opendir() calls instead of starting from the root
directory, and checking for errno.

See:

 - https://github.com/sorin-ionescu/prezto/issues/1560
- https://github.com/termux/termux-packages/issues/1894


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Issue with permissions and case-insensitive globbing
  2021-01-12 18:54 Issue with permissions and case-insensitive globbing Devin Hussey
@ 2021-01-12 21:38 ` Mikael Magnusson
  2021-01-12 22:22   ` Devin Hussey
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael Magnusson @ 2021-01-12 21:38 UTC (permalink / raw)
  To: Devin Hussey; +Cc: zsh-workers

On 1/12/21, Devin Hussey <husseydevin@gmail.com> wrote:
> Case insensitive globbing will not work at all if any of the parent
> directories of the target folder are inaccessible.
>
> This bug makes zsh very unstable on Termux (a Linux environment for
> Android), as scripts which use "~/..." will immediately show no
> results.
>
> Android's directory structure makes it so apps can only access their
> /data/data subfolder, blocking access to /data/data itself (it will
> return EACCES).
>
> Termux's $HOME is /data/data/com.termux/files/home.
>
> The simplified folder setup is this:
>
> root    root    0700 /
> root    root    0700 /data
> root    root    0700 /data/data
> termux termux 0700 /data/data/com.termux
>
> A (possible) fix for this issue would be to start in the "base"
> directory before any opendir() calls instead of starting from the root
> directory, and checking for errno.
>
> See:
>
>  - https://github.com/sorin-ionescu/prezto/issues/1560
> - https://github.com/termux/termux-packages/issues/1894

I can only reproduce this with absolute paths, which will obviously
not work (there's no way it ever could, as the kernel will not let you
open the directory). It seems to be completely independent of case
sensitivity as well. Using a relative path should work fine.

To expound a bit,
% mkdir inaccessible; cd inaccessible
% mkdir a; cd a
% chmod 000 .. # make inaccessible inaccessible
% touch a b c; echo *
a b c
% echo $PWD/*
zsh: no matches found: /tmp/inaccessible/a/*

(you will get the same result in any other shell (some may echo the
path with the * unexpanded)).

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Issue with permissions and case-insensitive globbing
  2021-01-12 21:38 ` Mikael Magnusson
@ 2021-01-12 22:22   ` Devin Hussey
  0 siblings, 0 replies; 3+ messages in thread
From: Devin Hussey @ 2021-01-12 22:22 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: zsh-workers

Actually, I think I found the fix. We can simply continue recursing
(skipping the readdir() loop) if we hit EACCES. EACCES seems to have
lower priority than ENOENT/ENOTDIR, so it won't end up in an infinite
loop or any of that.

I have a patch to change this, although it has only gone through
preliminary testing.

On 1/12/21, Mikael Magnusson <mikachu@gmail.com> wrote:
> On 1/12/21, Devin Hussey <husseydevin@gmail.com> wrote:
>> Case insensitive globbing will not work at all if any of the parent
>> directories of the target folder are inaccessible.
>>
>> This bug makes zsh very unstable on Termux (a Linux environment for
>> Android), as scripts which use "~/..." will immediately show no
>> results.
>>
>> Android's directory structure makes it so apps can only access their
>> /data/data subfolder, blocking access to /data/data itself (it will
>> return EACCES).
>>
>> Termux's $HOME is /data/data/com.termux/files/home.
>>
>> The simplified folder setup is this:
>>
>> root    root    0700 /
>> root    root    0700 /data
>> root    root    0700 /data/data
>> termux termux 0700 /data/data/com.termux
>>
>> A (possible) fix for this issue would be to start in the "base"
>> directory before any opendir() calls instead of starting from the root
>> directory, and checking for errno.
>>
>> See:
>>
>>  - https://github.com/sorin-ionescu/prezto/issues/1560
>> - https://github.com/termux/termux-packages/issues/1894
>
> I can only reproduce this with absolute paths, which will obviously
> not work (there's no way it ever could, as the kernel will not let you
> open the directory). It seems to be completely independent of case
> sensitivity as well. Using a relative path should work fine.
>
> To expound a bit,
> % mkdir inaccessible; cd inaccessible
> % mkdir a; cd a
> % chmod 000 .. # make inaccessible inaccessible
> % touch a b c; echo *
> a b c
> % echo $PWD/*
> zsh: no matches found: /tmp/inaccessible/a/*
>
> (you will get the same result in any other shell (some may echo the
> path with the * unexpanded)).
>
> --
> Mikael Magnusson
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-12 22:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-12 18:54 Issue with permissions and case-insensitive globbing Devin Hussey
2021-01-12 21:38 ` Mikael Magnusson
2021-01-12 22:22   ` Devin Hussey

zsh-workers

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/zsh-workers

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-workers zsh-workers/ http://inbox.vuxu.org/zsh-workers \
		zsh-workers@zsh.org
	public-inbox-index zsh-workers

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


code repositories for the project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git