List Info

Thread: find does not report symlink loop when trying to follow symlinks




find does not report symlink loop when trying to follow symlinks
user name
2007-04-16 05:25:27
URL:
  <http://savann
ah.gnu.org/bugs/?19605>

                 Summary: find does not report symlink loop
when trying to
follow symlinks
                 Project: findutils
            Submitted by: geoffclare
            Submitted on: Monday 16/04/07 at 10:25
                Category: find
                Severity: 3 - Normal
              Item Group: Wrong result
                  Status: None
                 Privacy: Public
             Assigned to: None
         Originator Name: Geoff Clare
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.3.3
           Fixed Release: None

    _______________________________________________________

Details:

This is effectively the same problem as bug 11148 (fixed
long ago) but now in
the fts version of the code.

$ ln -s a b
$ ln -s b a
$ find --version
GNU find version 4.3.3
Built using GNU gnulib version 2007-04-14
Features enabled: D_TYPE O_NOFOLLOW(enabled)
LEAF_OPTIMISATION FTS(FTS_CWDFD)
CBO(level=0) 
$ find -L a
a

It should report an error when it gets ELOOP, as with the
non-fts version of
find:

$ find-4.2.28 -L a     
find-4.2.28: a: Too many levels of symbolic links

The original fts code also did not have the problem.  It has
come in since
the last time I tried the fts version (from CVS in August
2005).





    _______________________________________________________

Reply to this item at:

  <http://savann
ah.gnu.org/bugs/?19605>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




_______________________________________________
Bug-findutils mailing list
Bug-findutilsgnu.org
h
ttp://lists.gnu.org/mailman/listinfo/bug-findutils

find does not report symlink loop when trying to follow symlinks
user name
2007-04-16 15:23:47
Follow-up Comment #1, bug #19605 (project findutils):

Ouch.   Fixed by the attached patch.   The patch also fixes
a problem with
the test suite (not detecting some cases whetre a test
should fail) and a
problem in oldfind which relates to using out-of-date stat
information.   

I have not yet committed this to CVS.


(file #12505)
    _______________________________________________________

Additional Item Attachment:

File name: loop.patch                     Size:9 KB


    _______________________________________________________

Reply to this item at:

  <http://savann
ah.gnu.org/bugs/?19605>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




_______________________________________________
Bug-findutils mailing list
Bug-findutilsgnu.org
h
ttp://lists.gnu.org/mailman/listinfo/bug-findutils

find does not report symlink loop when trying to follow symlinks
user name
2007-04-17 05:27:12
Update of bug #19605 (project findutils):

             Assigned to:                    None => jay 
                  

    _______________________________________________________

Follow-up Comment #7:

Executive summary: I agree that a diagnostic should be
issued when -L is in
effect, but not for the reason you originally stated.  

I would regard the "find -L a/foo" problem (which
also affects -P and -H) to
be a separate (and catastrophic) bug.   I've logged a
sepaarte bug for it.

When -L is in effect, if an attempt to stat("x")
fails with ELOOP for some
directory entry x,  find will not try to recurse into x.  

If find does not descend into "x", is it required
to issue a diagnostic under
the infinite loop rule?  My reading of
http://www.opengroup.org/onlinepubs/009695399/u
tilities/find.html is that the
diagnostic is only required for directories find actually
enters (or tries to
enter) and which are ancestors.

In this example I can see two reasons why a diagnostic would
not be
required:
1. x (or in our earlier example a and b) does not point to
an ancestor of any
directory actually visited.
2. x is not entered.

I think either of reasons (1) and (2) should be sufficient
to avoid a
diagnostic required by the statement:

<< The find utility shall detect infinite loops; that
is, entering a
previously visited directory that is an ancestor of the last
file
encountered. >>

You write:

<<
With the -L option find follows symlinks, so all the
pathnames it writes to
stdout should be files that exist when symlinks are
followed. If "a" is a
symlink loop it effectively does not exist when symlinks are
followed,
because the pathname does not resolve successfully. 
>>

This, I believe, is a very good reason to omit printing
names corresponding
to symlink loops.   I'm not completely convinced that a
diagnostic should be
issued in this case.  However, I can understand that the
user might want to
be able to control this.  Control over this sort of thing is
essentially
already provided though, via -L, -P and -H.  

If the user does not care about symbolic link destinations,
they will be in
-P mode.    Hence I would interpret use of -L as indicating
that the user
cares about where symbolic links point, and so I believe
that find should be
modified to issue a diagnostic in this case.  

I believe at this stage that "find -H a" should
behave similarly to "find -P
a" when a is a symlink loop, since the "referenced
file does not exist" (that
is, no file is referenced).   Therefore for that case, no
diagnostic.


    _______________________________________________________

Reply to this item at:

  <http://savann
ah.gnu.org/bugs/?19605>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




_______________________________________________
Bug-findutils mailing list
Bug-findutilsgnu.org
h
ttp://lists.gnu.org/mailman/listinfo/bug-findutils

find does not report symlink loop when trying to follow symlinks
user name
2007-04-17 06:23:35
Follow-up Comment #8, bug #19605 (project findutils):

You are still trying to bring the POSIX requirements for
directory loop
detection into this, which I have already pointed out are a
completely
different thing and not relevant.  The requirements for a
diagnostic in the
symlink loop case come from XCU section 1.11 Utility
Description Defaults,
under the heading "CONSEQUENCES OF ERRORS":

"If the requested action cannot be performed on an
operand representing a
file, directory, user, process, and so on, the utility shall
issue a
diagnostic message to standard error and continue processing
the next operand
in sequence, but the final exit status shall be returned as
non-zero.

For a utility that recursively traverses a file hierarchy
(such as find or
chown -R), if the requested action cannot be performed on a
file or directory
encountered in the hierarchy, the utility shall issue a
diagnostic message to
standard error and continue processing the remaining files
in the hierarchy,
but the final exit status shall be returned as
non-zero."

Part of the "requested action", when the -L option
is used, is to determine
whether symlinks point to a directory or not, and to descend
into the
directory if they do.

As regards -H, I believe the "referenced file does not
exist" part is related
to dangling links (i.e. stat() fails with ENOENT) and should
not be applied in
the ELOOP case.  AIX, HP-UX and Solaris all report an error
for a path operand
that is a symlink loop with both -L and -H.

    _______________________________________________________

Reply to this item at:

  <http://savann
ah.gnu.org/bugs/?19605>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




_______________________________________________
Bug-findutils mailing list
Bug-findutilsgnu.org
h
ttp://lists.gnu.org/mailman/listinfo/bug-findutils

find does not report symlink loop when trying to follow symlinks
user name
2007-04-17 17:50:27
Update of bug #19605 (project findutils):

                  Status:                    None =>
Fixed                  


    _______________________________________________________

Reply to this item at:

  <http://savann
ah.gnu.org/bugs/?19605>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




_______________________________________________
Bug-findutils mailing list
Bug-findutilsgnu.org
h
ttp://lists.gnu.org/mailman/listinfo/bug-findutils

find does not report symlink loop when trying to follow symlinks
user name
2007-04-21 08:50:52
Update of bug #19605 (project findutils):

             Open/Closed:                    Open =>
Closed                 
           Fixed Release:                    None =>
4.3.4                  


    _______________________________________________________

Reply to this item at:

  <http://savann
ah.gnu.org/bugs/?19605>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




_______________________________________________
Bug-findutils mailing list
Bug-findutilsgnu.org
h
ttp://lists.gnu.org/mailman/listinfo/bug-findutils

[1-6]

about | contact  Other archives ( Real Estate discussion Medical topics )