Bug 13980 - directory scan gets caught in a recursive symlink loop
: directory scan gets caught in a recursive symlink loop
Status: NEW
Product: Logitech Media Server
Classification: Unclassified
Component: Scanner
: 7.4.0
: Macintosh MacOS X 10.5
: P5 normal (vote)
: 7.7.x
Assigned To: Andy Grundman
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-09-11 12:30 UTC by dan cohn
Modified: 2011-09-19 06:46 UTC (History)
2 users (show)

See Also:
Category: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dan cohn 2009-09-11 12:30:23 UTC
a symlink to the local directory causes an infinitely recursive directory scan loop.

suggested fix: do not follow symlinks to targets within the music root, as this will not discover new content and will likely cause recursion.
Comment 1 dan cohn 2009-09-11 12:54:11 UTC
i see there is protection in Scanner::findFilesMatching() as:

                elsif (my $file = Slim::Utils::Misc::pathFromMacAlias($file)) {
                        if (dir($file)->subsumes($topDir)) {

                                logWarning("Found an infinite loop! Breaking out: $file -> $topDir");
                                next;
                        }

but this doesn't seem to work properly. ktrace showed after 45 minutes directory scan was deeply recursed, although it did break out eventually. i'll try to get more diagnosis info from subsumes() to see why it is broken, or if this conditional is being missed somehow.
Comment 2 dan cohn 2009-09-11 13:59:30 UTC
problem is that this is actually not a mac alias, but a recursive unix symlink. therefore, its File::Next that needs to understand the situation. digging further.
Comment 3 dan cohn 2009-09-11 14:18:39 UTC
*** /Users/dan/slimdev/slim/7.4/trunk/server/Slim/Utils/Scanner.pm      2009-09-09 20:18:44.000000000 -0700
--- Scanner.pm  2009-09-11 14:15:22.000000000 -0700
***************
*** 131,136 ****
--- 131,137 ----
                'descend_filter'  => $descend_filter,
                'sort_files'      => 1,
                'error_handler'   => sub { errorMsg("$_\n") },
+               'follow_symlinks' => 0
        }, $topDir);
  
        my $found = $args->{'foundItems'} || [];


does the trick, although its not perfect. best would be a limit on following recursive symlinks only. enhancement request filed against File::Next maintainer.
Comment 4 James Richardson 2009-09-11 14:36:49 UTC
Andy: is this one yours to look at?
Comment 5 Chris Owens 2010-03-15 18:06:49 UTC
7.4.x milestone is in the past