OpenPKG CVS Repository
  http://cvs.openpkg.org/
  ____________________________________________________________________________

  Server: cvs.openpkg.org                  Name:   Ralf S. Engelschall
  Root:   /e/openpkg/cvs                   Email:  [EMAIL PROTECTED]
  Module: openpkg-re                       Date:   09-Jul-2003 16:05:17
  Branch: HEAD                             Handle: 2003070915051600

  Modified files:
    openpkg-re              rpmlint.pl

  Log:
    add one more experimental check

  Summary:
    Revision    Changes     Path
    1.7         +48 -0      openpkg-re/rpmlint.pl
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-re/rpmlint.pl
  ============================================================================
  $ cvs diff -u -r1.6 -r1.7 rpmlint.pl
  --- openpkg-re/rpmlint.pl     8 Jul 2003 12:58:07 -0000       1.6
  +++ openpkg-re/rpmlint.pl     9 Jul 2003 14:05:16 -0000       1.7
  @@ -313,6 +313,50 @@
               }
           }
       }
  +
  +    #   check for symbolic link targets (absolute, dangling)
  +    foreach my $path (keys(%{$info->{ls}})) {
  +        my $symlink = $info->{ls}->{$path}->{'symlink'};
  +        if ($symlink ne '') {
  +            #   check 1: absolute target
  +            if ($symlink =~ m|^/.*|) {
  +                &lint_warning($rpm, "symbolic link \"$path\" points to absolute 
path \"$symlink\" (expected relative path)");
  +            }
  +            #   check 2: dangling target
  +            my $resolved = &resolve($info, $path);
  +            sub resolve {
  +                my ($info, $path) = @_;
  +                if (not defined($info->{ls}->{$path})) {
  +                    return $path;
  +                }
  +                my $symlink = $info->{ls}->{$path}->{'symlink'};
  +                if ($symlink eq '') {
  +                    return $path;
  +                }
  +                else {
  +                    my $resolved;
  +                    if ($symlink =~ m|^/|) {
  +                        $resolved = $symlink;
  +                    }
  +                    else {
  +                        $resolved = $path;
  +                        $resolved =~ s|/[^/]+$||s;
  +                        $resolved .= "/" . $symlink;
  +                        $resolved =~ s|/{2,}|/|sg;
  +                        $resolved =~ s|/\.(?=/)||sg;
  +                        $resolved =~ s|/\.$||sg;
  +                        1 while ($resolved =~ s|/[^/]+/\.\./|/|s);
  +                        $resolved =~ s|/[^/]+/\.\.$||s;
  +                        $resolved =~ s|(.)/$|$1|s;
  +                    }
  +                    return &resolve($info, $resolved);
  +                }
  +            }
  +            if (not defined($info->{ls}->{$resolved})) {
  +                &lint_error($rpm, "symbolic link \"$path\" points to not existing 
target path \"$resolved\" (expected existing target path)");
  +            }
  +        }
  +    }
   }
   
   ##  _________________________________________________________________
  @@ -341,5 +385,9 @@
   
       #   stripped (file)
       #   syslibs (ldd)
  +    #   hard-coded paths pointing outside instance
  +    #   sanity check for shebang-lines
  +    #   contained temporary path
  +    #   bad-files: .po
   }
   
  @@ .
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     [EMAIL PROTECTED]

Reply via email to