line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of Config-Model-OpenSsh |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2008-2022 by Dominique Dumont. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The GNU Lesser General Public License, Version 2.1, February 1999 |
9
|
|
|
|
|
|
|
# |
10
|
4
|
|
|
4
|
|
2227
|
use strict; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
129
|
|
11
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
239
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Config::Model::Backend::OpenSsh::Role::MatchBlock ; |
14
|
|
|
|
|
|
|
$Config::Model::Backend::OpenSsh::Role::MatchBlock::VERSION = '2.9.4.1'; |
15
|
4
|
|
|
4
|
|
24
|
use Mouse::Role ; |
|
4
|
|
|
|
|
23
|
|
|
4
|
|
|
|
|
29
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
requires qw(current_node write_node_content write_line); |
18
|
|
|
|
|
|
|
|
19
|
4
|
|
|
4
|
|
1688
|
use Carp ; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
274
|
|
20
|
4
|
|
|
4
|
|
28
|
use IO::File ; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
655
|
|
21
|
4
|
|
|
4
|
|
29
|
use Log::Log4perl; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
35
|
|
22
|
4
|
|
|
4
|
|
187
|
use File::Copy ; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
235
|
|
23
|
4
|
|
|
4
|
|
35
|
use File::Path ; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
2273
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $logger = Log::Log4perl::get_logger("Backend::OpenSsh"); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub match { |
28
|
8
|
|
|
8
|
0
|
32
|
my ($self, $root, $key, $pairs, $comment, $check) = @_ ; |
29
|
8
|
|
|
|
|
59
|
$logger->debug("match: @$pairs # $comment"); |
30
|
8
|
|
|
|
|
80
|
my $list_obj = $root->fetch_element('Match'); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# create new match block |
33
|
8
|
|
|
|
|
37384
|
my $nb_of_elt = $list_obj->fetch_size; |
34
|
8
|
|
|
|
|
85
|
my $block_obj = $list_obj->fetch_with_id($nb_of_elt) ; |
35
|
8
|
|
|
|
|
10022
|
$block_obj->annotation($comment) ; |
36
|
|
|
|
|
|
|
|
37
|
8
|
|
|
|
|
276
|
while (@$pairs) { |
38
|
15
|
|
|
|
|
15588
|
my $criteria = shift @$pairs; |
39
|
15
|
|
|
|
|
41
|
my $pattern = shift @$pairs; |
40
|
15
|
|
|
|
|
90
|
$block_obj->load( |
41
|
|
|
|
|
|
|
steps => qq!Condition $criteria="$pattern"!, |
42
|
|
|
|
|
|
|
check => $check, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
8
|
|
|
|
|
24282
|
$self->current_node( $block_obj->fetch_element('Settings') ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub write_all_match_block { |
51
|
13
|
|
|
13
|
0
|
50
|
my $self = shift ; |
52
|
13
|
|
|
|
|
41
|
my $match_elt = shift ; |
53
|
13
|
|
100
|
|
|
77
|
my $mode = shift || ''; |
54
|
|
|
|
|
|
|
|
55
|
13
|
|
|
|
|
37
|
my $result = ''; |
56
|
13
|
|
|
|
|
82
|
foreach my $elt ($match_elt->fetch_all($mode) ) { |
57
|
4
|
|
|
|
|
341
|
$result .= $self->write_match_block($elt,$mode) ; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
13
|
|
|
|
|
597
|
return $result ; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub write_match_block { |
64
|
4
|
|
|
4
|
0
|
11
|
my $self = shift ; |
65
|
4
|
|
|
|
|
8
|
my $match_elt = shift ; |
66
|
4
|
|
50
|
|
|
31
|
my $mode = shift || ''; |
67
|
|
|
|
|
|
|
|
68
|
4
|
|
|
|
|
14
|
my $match_line ; |
69
|
|
|
|
|
|
|
my $match_body ; |
70
|
|
|
|
|
|
|
|
71
|
4
|
|
|
|
|
19
|
foreach my $name ($match_elt->get_element_name() ) { |
72
|
8
|
|
|
|
|
455
|
my $elt = $match_elt->fetch_element($name) ; |
73
|
|
|
|
|
|
|
|
74
|
8
|
100
|
|
|
|
614
|
if ($name eq 'Settings') { |
|
|
50
|
|
|
|
|
|
75
|
4
|
|
|
|
|
50
|
$match_body .= $self->write_node_content($elt,$mode)."\n" ; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
elsif ($name eq 'Condition') { |
78
|
4
|
|
|
|
|
16
|
$match_line = $self->write_line( |
79
|
|
|
|
|
|
|
Match => $self->write_match_condition($elt,$mode) , |
80
|
|
|
|
|
|
|
$match_elt -> annotation |
81
|
|
|
|
|
|
|
) ; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
else { |
84
|
0
|
|
|
|
|
0
|
die "write_match_block: unexpected element: $name"; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
4
|
|
|
|
|
29
|
return $match_line.$match_body ; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub write_match_condition { |
92
|
4
|
|
|
4
|
0
|
10
|
my $self = shift ; |
93
|
4
|
|
|
|
|
8
|
my $cond_elt = shift ; |
94
|
4
|
|
50
|
|
|
20
|
my $mode = shift || ''; |
95
|
|
|
|
|
|
|
|
96
|
4
|
|
|
|
|
9
|
my $result = '' ; |
97
|
|
|
|
|
|
|
|
98
|
4
|
|
|
|
|
15
|
foreach my $name ($cond_elt->get_element_name() ) { |
99
|
16
|
|
|
|
|
492
|
my $elt = $cond_elt->fetch_element($name) ; |
100
|
16
|
|
|
|
|
1241
|
my $v = $elt->fetch($mode) ; |
101
|
16
|
100
|
|
|
|
3710
|
$result .= " $name $v" if defined $v; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
4
|
|
|
|
|
36
|
return $result ; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
4
|
|
|
4
|
|
31
|
no Mouse; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
31
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# ABSTRACT: Backend role for Ssh Match blocks |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
__END__ |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=pod |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=encoding UTF-8 |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 NAME |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Config::Model::Backend::OpenSsh::Role::MatchBlock - Backend role for Ssh Match blocks |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 VERSION |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
version 2.9.4.1 |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 SYNOPSIS |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
None |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 DESCRIPTION |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This class provides a backend role to read and write C<Match> blocks |
134
|
|
|
|
|
|
|
in OpenSsh configuration files. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 SEE ALSO |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
L<Config::Model::Backend::OpenSsh>, |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 AUTHOR |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Dominique Dumont |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This software is Copyright (c) 2008-2022 by Dominique Dumont. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This is free software, licensed under: |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
The GNU Lesser General Public License, Version 2.1, February 1999 |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=cut |