Mercurial > pkg
view src/pkg-files.pl @ 36:d66d34065dd9 tip
better less.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 19 May 2013 14:40:32 -0400 |
parents | 4823f88ea3b6 |
children |
line wrap: on
line source
1 #!/usr/bin/perl2 use File::stat;4 $print0 = 0;6 if ($ARGV[0] eq "--help"){7 print <<"HERE";9 pkg-examine -- print package contents.11 usage:12 pkg-examine -0 <package>14 Prints the files which belong to the package user15 <package>.17 If the -0 option is given, prints all files belonging18 to <package> separated by null characters, as in the19 "-print0" option of find.21 Written by Robert McIntyre. This software is free22 software and is released to the public domain.24 HERE25 exit 0;26 }28 $" = " ";30 if ($ARGV[0] eq "-0"){31 $print0 = 1;32 $pkg_name = $ARGV[1];33 }34 else {35 $pkg_name = $ARGV[0];36 }41 `id -g $pkg_name 2>/dev/null`;42 if (($pkg_name eq "") || $?){43 print "No group named $pkg_name.\n";44 exit 0;45 }47 $file_str = `find /usr /opt /etc -group $pkg_name -print0`;48 if ($print0){49 print $file_str;50 exit 0;51 }53 @files = split(/\0/, $file_str);56 print "All files owned by this package:\n";57 foreach (@files){print " $_\n";}59 print "SetUID/SetGID files:\n";60 foreach $file(@files){62 $sb = stat($file);63 $mode = $sb->mode & 07777;64 if ($mode & 07000){65 printf "%s, %04o\n", $file, $mode;66 }67 }