Date: Fri, 25 Aug 2000 11:50:12 +0200 (CEST) From: Roman Shterenzon <roman@harmonic.co.il> To: freebsd-stable@freebsd.org Subject: pkg_check Message-ID: <Pine.BSF.4.21.0008251145190.25998-200000@excalibur.oven.org>
index | next in thread | raw e-mail
[-- Attachment #1 --]
Hello,
I didn't find the functionality to check package integrity in the standard
freebsd pkg_* utilities. (Perhaps I'm missing something?)
So, I wrote this small perl script which does it for me.
With this tool, one may use tripwire only on /var/db/pkg and skip
/usr/local.
What do you think about it?
--Roman Shterenzon, UNIX System Administrator and Consultant
[ Xpert UNIX Systems Ltd., Herzlia, Israel. Tel: +972-9-9522361 ]
[-- Attachment #2 --]
#!/usr/bin/perl -w
# Roman Shterenzon <roman@xpert.com> 24/08/2000
$Version='0.01';
$DB='/var/db/pkg';
# PrintHelp
#
# Print usage information
sub PrintHelp {
print <<"EOF";
pkg_check $Version
Roman Shterenzon <roman\@xpert.com>
Usage: pkg_check [-a] pkgname
-a Check MD5 sums of all installed packages
EOF
exit 1;
}
$pkg=shift || &PrintHelp;
die "Package $pkg isn't installed\n" unless( -d "$DB/$pkg" || $pkg eq "-a" );
if ( $pkg eq "-a" ) {
opendir(DH, $DB) || die "Cannot read database directory\n";
@pkg=grep { -d "$DB/$_" && /^[^.]/ } readdir(DH);
closedir(DH);
}
else { @pkg = ( $pkg ); }
foreach $pkg ( @pkg ) {
open(FH, "$DB/$pkg/+CONTENTS") || die "Cannot open package contents\n";
while (<FH>) {
chomp;
if ( $_=~s/\@cwd // ) {
$cwd = $_;
}
elsif ( /^[^@]/ ) {
$file = $_;
}
elsif ( $_=~ s/^\@comment MD5:// ) {
$md5_pkg=$_;
if ( ! $file ) {
die "Unusual pkg listing, expected md5 after filename, got only md5\n";
}
$filename="$cwd/$file";
if ( -r "$filename" ) {
chomp( $md5_fs=`/sbin/md5 -q $filename` );
if ( $md5_fs ne $md5_pkg ) {
print "WARNING: $pkg: $filename md5 sum differs from the one in pkg db\n";
}
undef($file);
}
else {
print "Cannot access $filename (insufficient access or inexistent)\n";
}
}
}
close(FH);
} # of the outer foreach loop
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0008251145190.25998-200000>
