Mercurial > pkg
annotate 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 |
rev | line source |
---|---|
rlm@25 | 1 #!/usr/bin/perl |
rlm@28 | 2 use File::stat; |
rlm@25 | 3 |
rlm@25 | 4 if ($ARGV[0] eq "--help"){ |
rlm@25 | 5 print <<"HERE"; |
rlm@25 | 6 |
rlm@25 | 7 pkg-examine -- print package contents. |
rlm@25 | 8 |
rlm@25 | 9 Written by Robert McIntyre. This software is free |
rlm@25 | 10 software and is released to the public domain. |
rlm@25 | 11 |
rlm@25 | 12 HERE |
rlm@25 | 13 exit 0; |
rlm@25 | 14 } |
rlm@25 | 15 |
rlm@25 | 16 $" = " "; |
rlm@25 | 17 $pkg_name = $ARGV[0]; |
rlm@25 | 18 |
rlm@25 | 19 `id -g $pkg_name 2>/dev/null`; |
rlm@25 | 20 if ($?){ |
rlm@25 | 21 print "No group named $pkg_name."; |
rlm@25 | 22 exit 0;} |
rlm@25 | 23 |
rlm@25 | 24 @files = split(/\0/, `find /usr /opt /etc -group $pkg_name -print0`); |
rlm@25 | 25 |
rlm@28 | 26 |
rlm@28 | 27 print "All files owned by this package:\n"; |
rlm@28 | 28 foreach (@files){print " $_\n";} |
rlm@28 | 29 |
rlm@28 | 30 print "SetUID/SetGID files:\n"; |
rlm@28 | 31 foreach $file(@files){ |
rlm@28 | 32 |
rlm@28 | 33 $sb = stat($file); |
rlm@28 | 34 $mode = $sb->mode & 07777; |
rlm@28 | 35 if ($mode & 07000){ |
rlm@28 | 36 printf "%s, %04o\n", $file, $mode; |
rlm@28 | 37 } |
rlm@28 | 38 } |
rlm@28 | 39 |
rlm@28 | 40 |
rlm@28 | 41 |
rlm@28 | 42 |
rlm@28 | 43 |