line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id$ |
2
|
|
|
|
|
|
|
# $Source$ |
3
|
|
|
|
|
|
|
# $Author$ |
4
|
|
|
|
|
|
|
# $HeadURL$ |
5
|
|
|
|
|
|
|
# $Revision$ |
6
|
|
|
|
|
|
|
# $Date$ |
7
|
|
|
|
|
|
|
package Config::PlConfig::Host::Base; |
8
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
57
|
|
9
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
58
|
|
10
|
2
|
|
|
2
|
|
34
|
use 5.006001; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
137
|
|
11
|
2
|
|
|
2
|
|
11
|
use Carp qw(croak); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
90
|
|
12
|
2
|
|
|
2
|
|
16
|
use version; our $VERSION = qv('0.1_02'); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
10
|
|
13
|
2
|
|
|
2
|
|
2471
|
use utf8; |
|
2
|
|
|
|
|
24
|
|
|
2
|
|
|
|
|
10
|
|
14
|
|
|
|
|
|
|
{ |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
2
|
|
93
|
use Class::Dot qw(property isa_String); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
16
|
|
17
|
2
|
|
|
2
|
|
416
|
use File::Path qw(mkpath); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
160
|
|
18
|
2
|
|
|
2
|
|
11
|
use File::Spec; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
57
|
|
19
|
2
|
|
|
2
|
|
11
|
use Config::PlConfig::Constants; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
3247
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
property confdir => isa_String; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $RE_UNTAINT_DOMAIN = qr/ |
24
|
|
|
|
|
|
|
\A # beginning of string. |
25
|
|
|
|
|
|
|
( # capture: |
26
|
|
|
|
|
|
|
[\w\d\.\+\-\_]+? # any letter, digit, dot, plus-sign, |
27
|
|
|
|
|
|
|
# minus-sign or underscore. |
28
|
|
|
|
|
|
|
) |
29
|
|
|
|
|
|
|
\z # end of string. |
30
|
|
|
|
|
|
|
/xms; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new { |
33
|
5
|
|
|
5
|
0
|
355
|
my ($class, $options_ref) = @_; |
34
|
5
|
|
|
|
|
51
|
my $self = { }; |
35
|
5
|
|
|
|
|
15
|
bless $self, $class; |
36
|
|
|
|
|
|
|
|
37
|
5
|
|
|
|
|
25
|
my $CONF_DIRNAME = Config::PlConfig::Constants->get('CONF_DIRNAME'); |
38
|
|
|
|
|
|
|
|
39
|
5
|
|
|
|
|
26
|
my $confdir_parent = $self->locate_confdir_parent; |
40
|
5
|
|
|
|
|
224
|
my $confdir = File::Spec->catdir($confdir_parent, $CONF_DIRNAME); |
41
|
5
|
|
|
|
|
37
|
$self->set_confdir( $confdir ); |
42
|
5
|
|
|
|
|
73
|
$self->init_confdir( ); |
43
|
|
|
|
|
|
|
|
44
|
5
|
|
|
|
|
17
|
return $self; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub file_for_domain { |
48
|
30
|
|
|
30
|
0
|
4523
|
my ($self, $domain) = @_; |
49
|
|
|
|
|
|
|
|
50
|
30
|
|
100
|
|
|
81
|
$domain = $self->check_domain($domain) || return; |
51
|
22
|
|
|
|
|
161
|
my $DOMAINFILE_SUFFIX = Config::PlConfig::Constants->get( |
52
|
|
|
|
|
|
|
'DOMAINFILE_SUFFIX' |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
22
|
|
|
|
|
64
|
my $configfile = File::Spec->catfile( |
56
|
|
|
|
|
|
|
$self->confdir, |
57
|
|
|
|
|
|
|
$domain, |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
22
|
|
|
|
|
368
|
$configfile = join q{.}, $configfile, $DOMAINFILE_SUFFIX; |
61
|
|
|
|
|
|
|
|
62
|
22
|
|
|
|
|
68
|
return $configfile; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub locate_confdir { |
66
|
0
|
|
|
0
|
0
|
0
|
croak 'Cannot use '. __PACKAGE__ . 'directly!'; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub check_domain { |
70
|
52
|
|
|
52
|
0
|
1774
|
my ($self, $domain) = @_; |
71
|
|
|
|
|
|
|
|
72
|
52
|
100
|
|
|
|
455
|
if ($domain =~ $RE_UNTAINT_DOMAIN) { |
73
|
36
|
|
|
|
|
93
|
$domain = $1; |
74
|
36
|
|
|
|
|
134
|
return $domain; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
#carp "Illegal domain name."; # TODO Error handling!. |
78
|
|
|
|
|
|
|
|
79
|
16
|
|
|
|
|
86
|
return; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub init_confdir { |
83
|
5
|
|
|
5
|
0
|
8
|
my ($self) = @_; |
84
|
5
|
|
|
|
|
32
|
my $confdir = $self->confdir; |
85
|
|
|
|
|
|
|
|
86
|
5
|
50
|
|
|
|
132
|
if (! -d $confdir) { |
87
|
0
|
0
|
|
|
|
0
|
mkpath($confdir) or return; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
5
|
|
|
|
|
10
|
return 1; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# Module implementation here |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
98
|
|
|
|
|
|
|
__END__ |