view src/pkg-examine.pl @ 28:dd480255bd82

completed basic draft of pkg-examine script.
author Robert McIntyre <rlm@mit.edu>
date Thu, 10 Jan 2013 16:28:18 +0000
parents d956ace7380e
children 819e950ac8cc
line wrap: on
line source
1 #!/usr/bin/perl
2 use File::stat;
4 if ($ARGV[0] eq "--help"){
5 print <<"HERE";
7 pkg-examine -- print package contents.
9 Written by Robert McIntyre. This software is free
10 software and is released to the public domain.
12 HERE
13 exit 0;
14 }
16 $" = " ";
17 $pkg_name = $ARGV[0];
19 `id -g $pkg_name 2>/dev/null`;
20 if ($?){
21 print "No group named $pkg_name.";
22 exit 0;}
24 @files = split(/\0/, `find /usr /opt /etc -group $pkg_name -print0`);
27 print "All files owned by this package:\n";
28 foreach (@files){print " $_\n";}
30 print "SetUID/SetGID files:\n";
31 foreach $file(@files){
33 $sb = stat($file);
34 $mode = $sb->mode & 07777;
35 if ($mode & 07000){
36 printf "%s, %04o\n", $file, $mode;
37 }
38 }