| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Apache::Yaalr; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
53249
|
use 5.008008; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
39
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
41
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
10
|
|
|
|
1
|
|
|
|
|
31
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use Carp qw(croak); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
932
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
11
|
|
|
|
|
|
|
our @EXPORT = qw( @potential_confs ); |
|
12
|
|
|
|
|
|
|
our $VERSION = '0.03.3 '; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my (@potential_confs, @dirs); |
|
15
|
|
|
|
|
|
|
my @mac = qw( /etc/apache /etc/apache2 /etc/httpd /usr/local/apache2 /Library/WebServer/ ); |
|
16
|
|
|
|
|
|
|
my @lin = qw( /etc/apache /etc/apache2/sites-avilable/ /etc/httpd /usr/local/apache2 /etc/apache-perl ); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
|
19
|
1
|
|
|
1
|
0
|
868
|
my $package = shift; |
|
20
|
1
|
|
|
|
|
3
|
return bless({}, $package); |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub os { # operating system best guess, we'll need this later |
|
24
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
25
|
0
|
|
|
|
|
|
my $uname = `which uname`; |
|
26
|
0
|
|
|
|
|
|
my @os; |
|
27
|
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
|
if ($uname) { |
|
|
|
0
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
push @os, `uname -a` or croak "Cannot execute uname -a"; |
|
30
|
|
|
|
|
|
|
} elsif ($^O) { |
|
31
|
0
|
|
|
|
|
|
push @os, "$^O unknown"; |
|
32
|
|
|
|
|
|
|
} else { |
|
33
|
0
|
|
|
|
|
|
push @os, "unknown unknown"; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
0
|
|
|
|
|
|
return @os; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# This is for getting info from a user supplied Apache2 config file |
|
40
|
|
|
|
|
|
|
sub apache2_conf { |
|
41
|
0
|
|
|
0
|
0
|
|
my ($self, $file) = @_; |
|
42
|
0
|
0
|
|
|
|
|
croak("$file does not exist.") unless (-e $file); |
|
43
|
0
|
0
|
|
|
|
|
croak("$file not readable.") unless (-r $file); |
|
44
|
0
|
|
|
|
|
|
my ($str, $line, $format); |
|
45
|
0
|
|
|
|
|
|
my (@formats, @format_string); |
|
46
|
0
|
0
|
|
|
|
|
open FH, $file or croak "Cannot open configuration file: $file"; |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
while () { |
|
49
|
0
|
0
|
|
|
|
|
if (/LogFormat/) { |
|
50
|
0
|
|
|
|
|
|
push @formats, $_; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
} |
|
53
|
0
|
|
|
|
|
|
close FH; |
|
54
|
|
|
|
|
|
|
# here we need to scoop up everything in sites-available |
|
55
|
0
|
0
|
|
|
|
|
croak("Format not found\n") unless (($#formats) >= 0) ; |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
for (@formats) { |
|
58
|
0
|
|
|
|
|
|
my @format_string = split / /, $_; |
|
59
|
0
|
|
|
|
|
|
$format = pop @format_string; |
|
60
|
0
|
|
|
|
|
|
$str = \@format_string; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
0
|
|
|
|
|
|
return ($file, \$format, $str); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub httpd_conf { # get LogFormat and type of log from user supplied httpd.conf file |
|
67
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
68
|
0
|
|
|
|
|
|
my $file = shift; |
|
69
|
0
|
0
|
|
|
|
|
croak("$file does not exist.") unless (-e $file); |
|
70
|
|
|
|
|
|
|
# check the basename here to make sure we have a httpd.conf file |
|
71
|
0
|
|
|
|
|
|
my ($str, $line, $log_type, $location, $format); |
|
72
|
0
|
|
|
|
|
|
my ( @formats, @custom, @format_string,); |
|
73
|
0
|
0
|
|
|
|
|
open FH, $file or croak "Cannot open configuration file: $file"; |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
while () { |
|
76
|
0
|
0
|
|
|
|
|
if (/LogFormat/) { |
|
77
|
0
|
|
|
|
|
|
push @formats, $_; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
0
|
0
|
|
|
|
|
if (/CustomLog/) { |
|
80
|
0
|
|
|
|
|
|
push @custom, $_; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
} |
|
83
|
0
|
|
|
|
|
|
close FH; |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
0
|
0
|
|
|
|
croak("Format not found\n") unless (($#formats) && ($#custom) >= 0) ; |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
for $line (@custom) { |
|
88
|
0
|
0
|
|
|
|
|
if ($line !~ /#/) { # this is a hack, it gets commented-out lines |
|
89
|
0
|
|
|
|
|
|
my ($CustomLog, $location, $log_type) = split / /, $line; |
|
90
|
0
|
|
|
|
|
|
$log_type =~ s/ //g; |
|
91
|
0
|
|
|
|
|
|
for (@formats) { |
|
92
|
0
|
|
|
|
|
|
my @format_string = split / /, $_; |
|
93
|
0
|
|
|
|
|
|
$format = pop @format_string; |
|
94
|
0
|
0
|
|
|
|
|
if ($format =~ /$log_type/) { |
|
95
|
0
|
|
|
|
|
|
shift @format_string; |
|
96
|
0
|
|
|
|
|
|
$str = \@format_string; |
|
97
|
0
|
|
|
|
|
|
last; # no need to check further |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
} |
|
100
|
0
|
|
|
|
|
|
chomp($log_type); |
|
101
|
0
|
|
|
|
|
|
return ($file, $log_type, $location, $str); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub find_conf { |
|
107
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
108
|
|
|
|
|
|
|
|
|
109
|
1
|
|
|
1
|
|
6
|
use File::Find qw(find); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
368
|
|
|
110
|
0
|
0
|
|
|
|
|
if ($^O =~ /darwin/) { |
|
|
|
0
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# grep for potential apache dirs on the system - note that apache2 does things differently!! |
|
113
|
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
@dirs = grep {-d} @mac; |
|
|
0
|
|
|
|
|
|
|
|
115
|
0
|
0
|
|
|
|
|
croak "no suitable directories" unless @dirs; |
|
116
|
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
find(\&httpd, @dirs); |
|
118
|
0
|
|
|
|
|
|
find(\&apache2, @dirs); |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# return an array of files |
|
121
|
0
|
|
|
|
|
|
return @potential_confs; |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
} elsif ($^O =~ /linux/) { |
|
124
|
0
|
|
|
|
|
|
@dirs = grep {-d} @lin; |
|
|
0
|
|
|
|
|
|
|
|
125
|
0
|
0
|
|
|
|
|
croak "no suitable directories" unless @dirs; |
|
126
|
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
find(\&httpd, @dirs); |
|
128
|
0
|
|
|
|
|
|
find(\&apache2, @dirs); |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# return an array of files |
|
131
|
0
|
|
|
|
|
|
return @potential_confs; |
|
132
|
|
|
|
|
|
|
} else { |
|
133
|
0
|
|
|
|
|
|
croak "Cannot determine operating system."; |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
sub httpd { |
|
137
|
0
|
0
|
0
|
0
|
0
|
|
/^httpd.conf$/ && |
|
138
|
|
|
|
|
|
|
-r && |
|
139
|
|
|
|
|
|
|
push @potential_confs, $File::Find::name; |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub apache2 { |
|
143
|
0
|
0
|
0
|
0
|
0
|
|
/^apache2.conf$/ && |
|
144
|
|
|
|
|
|
|
-r && |
|
145
|
|
|
|
|
|
|
push @potential_confs, $File::Find::name; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
1; |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
__END__ |