comparison 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
comparison
equal deleted inserted replaced
27:738745bfa17b 28:dd480255bd82
1 #!/usr/bin/perl 1 #!/usr/bin/perl
2 2 use File::stat;
3 3
4 if ($ARGV[0] eq "--help"){ 4 if ($ARGV[0] eq "--help"){
5 print <<"HERE"; 5 print <<"HERE";
6 6
7 pkg-examine -- print package contents. 7 pkg-examine -- print package contents.
11 11
12 HERE 12 HERE
13 exit 0; 13 exit 0;
14 } 14 }
15 15
16
17
18 $" = " "; 16 $" = " ";
19 $pkg_name = $ARGV[0]; 17 $pkg_name = $ARGV[0];
20 18
21 `id -g $pkg_name 2>/dev/null`; 19 `id -g $pkg_name 2>/dev/null`;
22 if ($?){ 20 if ($?){
23 print "No group named $pkg_name."; 21 print "No group named $pkg_name.";
24 exit 0;} 22 exit 0;}
25 23
26 @files = split(/\0/, `find /usr /opt /etc -group $pkg_name -print0`); 24 @files = split(/\0/, `find /usr /opt /etc -group $pkg_name -print0`);
27 25
28 print "@files\n"; 26
27 print "All files owned by this package:\n";
28 foreach (@files){print " $_\n";}
29
30 print "SetUID/SetGID files:\n";
31 foreach $file(@files){
32
33 $sb = stat($file);
34 $mode = $sb->mode & 07777;
35 if ($mode & 07000){
36 printf "%s, %04o\n", $file, $mode;
37 }
38 }
39
40
41
42
43