Changeset 3108 for trunk/gsdl


Ignore:
Timestamp:
2002-04-29T13:11:51+12:00 (22 years ago)
Author:
jrm21
Message:

Don't recursive into directories if they are symbolic links and point to
a parent directory. Doesn't seem to work with windows shortcuts and
activeperl, but works on unix.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/plugins/RecPlug.pm

    r2925 r3108  
    245245    next if ($subfile =~ /^\.\.?$/);
    246246    next if ($read_metadata_files && $subfile =~ /metadata\.xml$/);
     247
     248    # check for a symlink pointing back to a leading directory
     249    if (-d "$dirname/$subfile" && -l "$dirname/$subfile") {
     250        # readlink gives a "fatal error" on systems that don't implement
     251        # symlinks. This assumes the the -l test above would fail on those.
     252        my $linkdest=readlink "$dirname/$subfile";
     253        if (!defined ($linkdest)) {
     254        # system error - file not found?
     255        warn "RecPlug: symlink problem - $!";
     256        } else {
     257        # see if link points to current or a parent directory
     258        if ($linkdest =~ m@^[\./\\]+$@ ||
     259            index($dirname, $linkdest) != -1) {
     260            warn "RecPlug: Ignoring recursive symlink ($dirname/$subfile -> $linkdest)\n";
     261            next;
     262            ;
     263        }
     264        }
     265    }
     266
    247267    print $outhandle "RecPlug: preparing metadata for $subfile\n" if ($verbosity > 2);
    248268
Note: See TracChangeset for help on using the changeset viewer.