fts and unveil issue

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

fts and unveil issue

Kristaps Dzonsons
When I unveil(2), fts doesn't behave well.  But only in a subtle way.
Enclosed is a demonstration.  I found this with openrsync, which unveils
before using fts_open to scan for files.

When run with a directory with only empty subdirectories or just files,
this works fine.  But when run with a directory that contains other
non-empty directories, the fts_read fails in the nested directories.

This is on stock OpenBSD 6.4, syspatched, amd64.

For example, consider the following abridged output (to fit into this
e-mail window):

% find ~/tmp/test -ls
drwxr-xr-x    3  /home/kristaps/tmp/test
drwxr-xr-x    3  /home/kristaps/tmp/test/test2
-rw-r--r--    1  /home/kristaps/tmp/test/test2/test2
drwxr-xr-x    2  /home/kristaps/tmp/test/test2/test3
-rw-r--r--    1  /home/kristaps/tmp/test/test1
% gcc -W -Wall -Wextra -g foo.c
% ./a.out /home/kristaps/tmp/test/
a.out: /home/kristaps/tmp/test/
a.out: /home/kristaps/tmp/test/test2
a.out: /home/kristaps/tmp/test/test2/test2
a.out: /home/kristaps/tmp/test/test2/test3
a.out: /home/kristaps/tmp/test/test2/test3
a.out: /home/kristaps/tmp/test/test2
a.out: /home/kristaps/tmp/test/test1
a.out: /home/kristaps/tmp/test/
a.out: TRYING AGAIN.
a.out: /home/kristaps/tmp/test/
a.out: /home/kristaps/tmp/test/test2
a.out: /home/kristaps/tmp/test/test2/test2: no stat
a.out: ...but regular stat works

So the first nested child fails (regardless of whether it's a file or
directory, by the way).  But a regular stat still works.

The same happens if I use unveil("/", "r").
Reply | Threaded
Open this post in threaded view
|

Re: fts and unveil issue

Bob Beck-3
yes you are seeing the limitation of 6.4 unveil as mentioned at the bottom
of the man page.   this should be fixed in current

On Sun, Feb 3, 2019 at 03:29 Kristaps Dzonsons <[hidden email]> wrote:

> When I unveil(2), fts doesn't behave well.  But only in a subtle way.
> Enclosed is a demonstration.  I found this with openrsync, which unveils
> before using fts_open to scan for files.
>
> When run with a directory with only empty subdirectories or just files,
> this works fine.  But when run with a directory that contains other
> non-empty directories, the fts_read fails in the nested directories.
>
> This is on stock OpenBSD 6.4, syspatched, amd64.
>
> For example, consider the following abridged output (to fit into this
> e-mail window):
>
> % find ~/tmp/test -ls
> drwxr-xr-x    3  /home/kristaps/tmp/test
> drwxr-xr-x    3  /home/kristaps/tmp/test/test2
> -rw-r--r--    1  /home/kristaps/tmp/test/test2/test2
> drwxr-xr-x    2  /home/kristaps/tmp/test/test2/test3
> -rw-r--r--    1  /home/kristaps/tmp/test/test1
> % gcc -W -Wall -Wextra -g foo.c
> % ./a.out /home/kristaps/tmp/test/
> a.out: /home/kristaps/tmp/test/
> a.out: /home/kristaps/tmp/test/test2
> a.out: /home/kristaps/tmp/test/test2/test2
> a.out: /home/kristaps/tmp/test/test2/test3
> a.out: /home/kristaps/tmp/test/test2/test3
> a.out: /home/kristaps/tmp/test/test2
> a.out: /home/kristaps/tmp/test/test1
> a.out: /home/kristaps/tmp/test/
> a.out: TRYING AGAIN.
> a.out: /home/kristaps/tmp/test/
> a.out: /home/kristaps/tmp/test/test2
> a.out: /home/kristaps/tmp/test/test2/test2: no stat
> a.out: ...but regular stat works
>
> So the first nested child fails (regardless of whether it's a file or
> directory, by the way).  But a regular stat still works.
>
> The same happens if I use unveil("/", "r").
>