From 2d15828444656460893973d00dffc8964eba6dba Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Sat, 21 Feb 2004 19:15:41 +0000 Subject: distinguish between unreadable directories and non packages. problem found by John L. Scarfone, who runs a paranoid root. --- usr.sbin/pkg_add/OpenBSD/PackageInfo.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm index ae99bf292bd..a62662b7632 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm @@ -1,4 +1,4 @@ -# $OpenBSD: PackageInfo.pm,v 1.5 2004/01/27 00:14:42 espie Exp $ +# $OpenBSD: PackageInfo.pm,v 1.6 2004/02/21 19:15:40 espie Exp $ # # Copyright (c) 2003 Marc Espie. # @@ -81,18 +81,26 @@ sub installed_packages() { if (!defined $list) { $list = {}; + my @bad=(); opendir(my $dir, $pkg_db) or die "Bad pkg_db: $!"; while (my $e = readdir($dir)) { next if $e eq '.' or $e eq '..'; next unless -d "$pkg_db/$e"; + if (! -r _) { + push(@bad, $e); + next; + } if (-f "$pkg_db/$e/+CONTENTS") { $list->{$e} = 1; } else { - print "Warning: $e is not really a package"; + print "Warning: $e is not really a package\n"; } } close($dir); + if (@bad > 0) { + print "Warning: can't access information for ", join(", ", @bad), "\n"; + } } return keys %$list; } -- cgit v1.2.3