Mercurial > pkg
annotate 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 |
rev | line source |
---|---|
rlm@25 | 1 #!/usr/bin/perl |
rlm@28 | 2 use File::stat; |
rlm@25 | 3 |
rlm@35 | 4 $print0 = 0; |
rlm@35 | 5 |
rlm@25 | 6 if ($ARGV[0] eq "--help"){ |
rlm@25 | 7 print <<"HERE"; |
rlm@25 | 8 |
rlm@25 | 9 pkg-examine -- print package contents. |
rlm@25 | 10 |
rlm@35 | 11 usage: |
rlm@35 | 12 pkg-examine -0 <package> |
rlm@35 | 13 |
rlm@35 | 14 Prints the files which belong to the package user |
rlm@35 | 15 <package>. |
rlm@35 | 16 |
rlm@35 | 17 If the -0 option is given, prints all files belonging |
rlm@35 | 18 to <package> separated by null characters, as in the |
rlm@35 | 19 "-print0" option of find. |
rlm@35 | 20 |
rlm@25 | 21 Written by Robert McIntyre. This software is free |
rlm@25 | 22 software and is released to the public domain. |
rlm@25 | 23 |
rlm@25 | 24 HERE |
rlm@25 | 25 exit 0; |
rlm@25 | 26 } |
rlm@25 | 27 |
rlm@25 | 28 $" = " "; |
rlm@35 | 29 |
rlm@35 | 30 if ($ARGV[0] eq "-0"){ |
rlm@35 | 31 $print0 = 1; |
rlm@35 | 32 $pkg_name = $ARGV[1]; |
rlm@35 | 33 } |
rlm@35 | 34 else { |
rlm@35 | 35 $pkg_name = $ARGV[0]; |
rlm@35 | 36 } |
rlm@35 | 37 |
rlm@35 | 38 |
rlm@35 | 39 |
rlm@25 | 40 |
rlm@25 | 41 `id -g $pkg_name 2>/dev/null`; |
rlm@29 | 42 if (($pkg_name eq "") || $?){ |
rlm@29 | 43 print "No group named $pkg_name.\n"; |
rlm@29 | 44 exit 0; |
rlm@29 | 45 } |
rlm@25 | 46 |
rlm@35 | 47 $file_str = `find /usr /opt /etc -group $pkg_name -print0`; |
rlm@35 | 48 if ($print0){ |
rlm@35 | 49 print $file_str; |
rlm@35 | 50 exit 0; |
rlm@35 | 51 } |
rlm@35 | 52 |
rlm@35 | 53 @files = split(/\0/, $file_str); |
rlm@25 | 54 |
rlm@28 | 55 |
rlm@28 | 56 print "All files owned by this package:\n"; |
rlm@28 | 57 foreach (@files){print " $_\n";} |
rlm@28 | 58 |
rlm@28 | 59 print "SetUID/SetGID files:\n"; |
rlm@28 | 60 foreach $file(@files){ |
rlm@28 | 61 |
rlm@28 | 62 $sb = stat($file); |
rlm@28 | 63 $mode = $sb->mode & 07777; |
rlm@28 | 64 if ($mode & 07000){ |
rlm@28 | 65 printf "%s, %04o\n", $file, $mode; |
rlm@28 | 66 } |
rlm@28 | 67 } |
rlm@28 | 68 |
rlm@28 | 69 |
rlm@28 | 70 |
rlm@28 | 71 |
rlm@28 | 72 |