equal
deleted
inserted
replaced
1 #!/bin/perl |
|
2 |
|
3 sub traverse { |
|
4 my ($dir, @callbacks) = @_; |
|
5 my $present; |
|
6 |
|
7 opendir $present, $dir or return(); |
|
8 |
|
9 for (grep { ! /^(\.|\.\.)$/ } readdir $present) { |
|
10 my $path = "$dir/$_"; |
|
11 |
|
12 foreach $validation (@callbacks) |
|
13 { |
|
14 &$validation($path); |
|
15 } |
|
16 traverse($path, @callbacks) if -d $path; |
|
17 } |
|
18 |
|
19 closedir $present; |
|
20 return(); |
|
21 } |
|
22 |
|
23 sub checkManpage { |
|
24 my $file = shift; |
|
25 if (-T $file) { |
|
26 if ($file =~ /\/man\//) { |
|
27 my $attribute_section = 0; |
|
28 open (FILE, $file); |
|
29 while (<FILE>) { |
|
30 if (/\.so /) { return; }#reference only manpage |
|
31 if (/.SH.*ATTRIBUTES/) { |
|
32 $attribute_section = 1; |
|
33 } |
|
34 } |
|
35 close (FILE); |
|
36 if ($attribute_section == 0) { |
|
37 print "MAN CHECK : Error in $file\n\tNo attribute section missing\n"; |
|
38 } |
|
39 } |
|
40 } |
|
41 return; |
|
42 } |
|
43 |
|
44 |
|
45 sub checkExecutableNotWritable { |
|
46 my $file = shift; |
|
47 if (not -d $file and -x $file and -w $file) |
|
48 { |
|
49 print "ATTRIBUTE CHECK : Error in $file\n\texecutable file should not be writable\n"; |
|
50 } |
|
51 return; |
|
52 } |
|
53 |
|
54 @validationFcts = (\&checkManpage, \&checkExecutableNoWritable); |
|
55 |
|
56 |
|
57 traverse($ARGV[0], @validationFcts); |
|
58 |
|