[bug #60207] -prune returns false for files for which fstatat() fails with EACCESS

Stephane Chazelas <[email protected]>
Newsgroups gmane.comp.gnu.findutils.bugs
Message-ID <[email protected]>
URL:
  <https://savannah.gnu.org/bugs/?60207>

                 Summary: -prune returns false for files for which fstatat()
fails with EACCESS
                 Project: findutils
            Submitted by: stephanechazelas
            Submitted on: Wed 10 Mar 2021 12:17:47 PM UTC
                Category: find
                Severity: 3 - Normal
              Item Group: Wrong result
                  Status: None
                 Privacy: Public
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
                 Release: 4.7.0
         Discussion Lock: Any
           Fixed Release: None

    _______________________________________________________

Details:

(initially from
https://unix.stackexchange.com/questions/638372/why-does-find-still-try-to-access-gvfs-and-even-includes-it-in-the-output-de
by DJCrashdummy user there).

Reproduced with GNU find 4.8.0 and current git head (v4.8.0-5-gcaa03867) built
with default options on Debian GNU/Linux testing amd64.

Reproducer:


$ mkdir testdir; cd testdir
$ touch a1 a2 b1 b2
$ sudo bindfs --no-allow-other . a1
$ ls -l
ls: cannot access 'a1': Permission denied
total 0
-????????? ? ?        ?        ?            ? a1
-rw-r--r-- 1 stephane stephane 0 Mar 10 11:53 a2
-rw-r--r-- 1 stephane stephane 0 Mar 10 11:53 b1
-rw-r--r-- 1 stephane stephane 0 Mar 10 11:53 b2
$ find . -name 'a*' -prune -o -print
.
./b1
find: ‘./a1’: Permission denied
./a1
./b2


See how "./a1" was output even though it matches "a*".

Here using bindfs as a different user as a way to have a file (a1) that is not
lstat()able. The OP had the problem initially with a .gvfs directory (also a
fuse FS mount point).

It can also be reproduced with -L/-follow and symlinks to inaccessible areas:


$ mkdir testdir; cd testdir
$ touch a2 b1 b2
$ ln -s /var/spool/cron/crontabs/foo a1
$ ln -s /no/such/file a3
$ ln -s a4 a4
$ ln -s a2/foo a5
$ find -L . -name 'a*' -prune -o -print
.
./b1
find: ‘./a1’: Permission denied
./a1
./b2
find: ‘./a5’: Not a directory
find: ‘./a4’: Too many levels of symbolic links


See how a1 was reported (for which stat() fails with EACCESS), but not  a3
(ENOENT), a4 (ELOOP), a5 (ENOTDIR).





    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60207>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.