OpenDNSSEC/Server.pm

filter: Statementstmt 1.5% 27 / 1798 Branchbran 0.0% 0 / 1084 Conditioncond 0.0% 0 / 154 MC/DCmcdc 0.0% 0 / 82 Subroutinesub 3.6% 8 / 219 Podpod 100% 61 / 61 totaltotal 2.8% 96 / 3398 CC 607 SCAR 56.3
CC
607
Cov
1%
Init
3422.0
__ANON__
210.0
__ANON__
210.0
CRAP 277.4
« OpenDNSSEC/CLI.pm ↑ Summary OpenDNSSEC.pm »
1 package Lim::Plugin::OpenDNSSEC::Server;
2  
3 1 ▶use common::sense;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Fcntl qw(:seek);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use IO::File ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Digest::SHA ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use Lim::Plugin::OpenDNSSEC ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use Lim::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use base qw(Lim::Component::Server);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 =encoding utf8
17  
18 =head1 NAME
19  
20 ...
21  
22 =head1 VERSION
23  
24 See L<Lim::Plugin::OpenDNSSEC> for version.
25  
26 =over 4
27  
28 =item OPENDNSSEC_VERSION_MIN
29  
30 =item OPENDNSSEC_VERSION_MAX
31  
32 =back
33  
34 =cut
35  
36 1 our $VERSION = $Lim::Plugin::OpenDNSSEC::VERSION;
37 1 our %ConfigFiles = (
38 'conf.xml' => [
39 '/etc/opendnssec/conf.xml',
40 'conf.xml'
41 ],
42 'kasp.xml' => [
43 '/etc/opendnssec/kasp.xml',
44 'kasp.xml'
45 ],
46 'zonelist.xml' => [
47 '/etc/opendnssec/zonelist.xml',
48 'zonelist.xml'
49 ],
50 'zonefetch.xml' => [
51 '/etc/opendnssec/zonefetch.xml',
52 'zonefetch.xml'
53 ],
54 'addns.xml' => [
55 '/etc/opendnssec/addns.xml',
56 'addns.xml'
57 ]
58 );
59  
60 sub OPENDNSSEC_VERSION_MIN (){ 1003000 }
61 sub OPENDNSSEC_VERSION_MAX (){ 1004000 }
62  
63 =head1 SYNOPSIS
64  
65 ...
66  
67 =head1 SUBROUTINES/METHODS
68  
69 =head2 Init
70  
71 =cut
72  
73 0 ▶sub Init {
Subroutine Init: not called CC=58 SCAR=81.4
Pod documented
74 0 my $self = shift;
75 0 my %args = ( @_ );
76  
77 $self->{bin} = {
78 0 control => 0,
79 enforcerd => 0,
80 ksmutil => 0,
81 signer => 0,
82 signerd => 0,
83 hsmutil => 0
84 };
85 0 $self->{bin_version} = {};
86
87 0 my ($stdout, $stderr);
88 0 my $cv = Lim::Util::run_cmd [ 'ods-control' ],
89 '<', '/dev/null',
90 '>', \$stdout,
91 '2>', \$stderr;
92 # ods-control exits with 1 when just running it
93 0 ▶ if ($cv->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cv->recv) 0 0 0
94 0 ▶ if ($stderr =~ /usage:\s+ods-control/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stderr =~ /usage:\s+ods-control/ou) { } 0 0 0
95 0 $self->{bin}->{control} = 1;
96 }
97 else {
98 0 $self->{logger}->warn('Unable to find "ods-control" executable, module functions limited');
99 }
100 }
101  
102 0 my $cv = Lim::Util::run_cmd [ 'ods-enforcerd', '-V' ],
103 '<', '/dev/null',
104 '>', \$stdout,
105 '2>', \$stderr;
106 0 ▶ if ($cv->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cv->recv) { } 0 0 0
107 0 $self->{logger}->warn('Unable to find "ods-enforcerd" executable, module functions limited');
108 }
109 else {
110 0 ▶ if ($stderr =~ /opendnssec\s+version\s+([0-9]+)\.([0-9]+)\.([0-9]+)/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stderr =~ /opendnssec\s+version\s+([0-9]+)\.([0-9]+)\.([0-9]+)/ou) { } 0 0 0
111 0 my ($major,$minor,$patch) = ($1, $2, $3);
112
113 0 ▶ if ($major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100) {
Branch: 1 branch
BranchTrueFalseTotal
if ($major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100) { } 0 0 0
Condition0%0/15
$major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100
!ll&&!rl&&r
000
$major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1
!ll&&!rl&&r
000
$major > 0 and $major < 10 and $minor > -1 and $minor < 10
!ll&&!rl&&r
000
$major > 0 and $major < 10 and $minor > -1
!ll&&!rl&&r
000
$major > 0 and $major < 10
!ll&&!rl&&r
000
MC/DC0%0/6
$major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100
$major > 0 $major < 10 $minor > -1 $minor < 10 $patch > -1 $patch < 100
Truth table0%0/7
A and B and C and D and E and F
A= $major > 0B= $major < 10C= $minor > -1D= $minor < 10E= $patch > -1F= $patch < 100
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
114 0 my $version = ($major * 1000000) + ($minor * 1000) + $patch;
115
116 0 ▶ unless ($version >= OPENDNSSEC_VERSION_MIN and $version <= OPENDNSSEC_VERSION_MAX) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version >= 1003000 and $version <= 1004000) { } 0 0 0
Condition0%0/3
$version >= 1003000 and $version <= 1004000
!ll&&!rl&&r
000
MC/DC0%0/2
$version >= 1003000 and $version <= 1004000
$version >= 1003000 $version <= 1004000
Truth table0%0/3
A and B
A= $version >= 1003000B= $version <= 1004000
ABresult
0X0
100
111
117 0 $self->{logger}->warn('Unsupported "ods-enforcerd" executable version, unable to continue');
118 }
119 else {
120 0 $self->{bin}->{enforcerd} = $version;
121 0 $self->{bin_version}->{enforcerd} = $major.'.'.$minor.'.'.$patch;
122 }
123 }
124 else {
125 0 $self->{logger}->warn('Invalid "ods-enforcerd" version, module functions limited');
126 }
127 }
128 else {
129 0 $self->{logger}->warn('Unable to get "ods-enforcerd" version, module functions limited');
130 }
131 }
132  
133 0 my $cv = Lim::Util::run_cmd [ 'ods-ksmutil', '--version' ],
134 '<', '/dev/null',
135 '>', \$stdout,
136 '2>', \$stderr;
137 0 ▶ if ($cv->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cv->recv) { } 0 0 0
138 0 $self->{logger}->warn('Unable to find "ods-ksmutil" executable, module functions limited');
139 }
140 else {
141 0 ▶ if ($stdout =~ /opendnssec\s+version\s+([0-9]+)\.([0-9]+)\.([0-9]+)/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stdout =~ /opendnssec\s+version\s+([0-9]+)\.([0-9]+)\.([0-9]+)/ou) { } 0 0 0
142 0 my ($major,$minor,$patch) = ($1, $2, $3);
143
144 0 ▶ if ($major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100) {
Branch: 1 branch
BranchTrueFalseTotal
if ($major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100) { } 0 0 0
Condition0%0/15
$major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100
!ll&&!rl&&r
000
$major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1
!ll&&!rl&&r
000
$major > 0 and $major < 10 and $minor > -1 and $minor < 10
!ll&&!rl&&r
000
$major > 0 and $major < 10 and $minor > -1
!ll&&!rl&&r
000
$major > 0 and $major < 10
!ll&&!rl&&r
000
MC/DC0%0/6
$major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100
$major > 0 $major < 10 $minor > -1 $minor < 10 $patch > -1 $patch < 100
Truth table0%0/7
A and B and C and D and E and F
A= $major > 0B= $major < 10C= $minor > -1D= $minor < 10E= $patch > -1F= $patch < 100
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
145 0 my $version = ($major * 1000000) + ($minor * 1000) + $patch;
146
147 0 ▶ unless ($version >= OPENDNSSEC_VERSION_MIN and $version <= OPENDNSSEC_VERSION_MAX) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version >= 1003000 and $version <= 1004000) { } 0 0 0
Condition0%0/3
$version >= 1003000 and $version <= 1004000
!ll&&!rl&&r
000
MC/DC0%0/2
$version >= 1003000 and $version <= 1004000
$version >= 1003000 $version <= 1004000
Truth table0%0/3
A and B
A= $version >= 1003000B= $version <= 1004000
ABresult
0X0
100
111
148 0 $self->{logger}->warn('Unsupported "ods-ksmutil" executable version, unable to continue');
149 }
150 else {
151 0 $self->{bin}->{ksmutil} = $version;
152 0 $self->{bin_version}->{ksmutil} = $major.'.'.$minor.'.'.$patch;
153 }
154 }
155 else {
156 0 $self->{logger}->warn('Invalid "ods-ksmutil" version, module functions limited');
157 }
158 }
159 else {
160 0 $self->{logger}->warn('Unable to get "ods-ksmutil" version, module functions limited');
161 }
162 }
163  
164 0 my $cv = Lim::Util::run_cmd [ 'ods-signer', '--help' ],
165 '<', '/dev/null',
166 '>', \$stdout,
167 '2>', \$stderr;
168 # ods-signer exits with 3 on --help
169 0 ▶ if ($cv->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cv->recv) 0 0 0
170 0 ▶ if ($stdout =~ /Version\s+([0-9]+)\.([0-9]+)\.([0-9]+)/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stdout =~ /Version\s+([0-9]+)\.([0-9]+)\.([0-9]+)/ou) { } 0 0 0
171 0 my ($major,$minor,$patch) = ($1, $2, $3);
172
173 0 ▶ if ($major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100) {
Branch: 1 branch
BranchTrueFalseTotal
if ($major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100) { } 0 0 0
Condition0%0/15
$major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100
!ll&&!rl&&r
000
$major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1
!ll&&!rl&&r
000
$major > 0 and $major < 10 and $minor > -1 and $minor < 10
!ll&&!rl&&r
000
$major > 0 and $major < 10 and $minor > -1
!ll&&!rl&&r
000
$major > 0 and $major < 10
!ll&&!rl&&r
000
MC/DC0%0/6
$major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100
$major > 0 $major < 10 $minor > -1 $minor < 10 $patch > -1 $patch < 100
Truth table0%0/7
A and B and C and D and E and F
A= $major > 0B= $major < 10C= $minor > -1D= $minor < 10E= $patch > -1F= $patch < 100
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
174 0 my $version = ($major * 1000000) + ($minor * 1000) + $patch;
175
176 0 ▶ unless ($version >= OPENDNSSEC_VERSION_MIN and $version <= OPENDNSSEC_VERSION_MAX) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version >= 1003000 and $version <= 1004000) { } 0 0 0
Condition0%0/3
$version >= 1003000 and $version <= 1004000
!ll&&!rl&&r
000
MC/DC0%0/2
$version >= 1003000 and $version <= 1004000
$version >= 1003000 $version <= 1004000
Truth table0%0/3
A and B
A= $version >= 1003000B= $version <= 1004000
ABresult
0X0
100
111
177 0 $self->{logger}->warn('Unsupported "ods-signer" executable version, unable to continue');
178 }
179 else {
180 0 $self->{bin}->{signer} = $version;
181 0 $self->{bin_version}->{signer} = $major.'.'.$minor.'.'.$patch;
182 }
183 }
184 else {
185 0 $self->{logger}->warn('Invalid "ods-signer" version, module functions limited');
186 }
187 }
188 else {
189 0 $self->{logger}->warn('Unable to get "ods-signer" version, module functions limited');
190 }
191 }
192  
193 0 my $cv = Lim::Util::run_cmd [ 'ods-signerd', '-V' ],
194 '<', '/dev/null',
195 '>', \$stdout,
196 '2>', \$stderr;
197 0 ▶ if ($cv->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cv->recv) { } 0 0 0
198 0 $self->{logger}->warn('Unable to find "ods-signerd" executable, module functions limited');
199 }
200 else {
201 0 ▶ if ($stdout =~ /opendnssec\s+version\s+([0-9]+)\.([0-9]+)\.([0-9]+)/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stdout =~ /opendnssec\s+version\s+([0-9]+)\.([0-9]+)\.([0-9]+)/ou) { } 0 0 0
202 0 my ($major,$minor,$patch) = ($1, $2, $3);
203
204 0 ▶ if ($major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100) {
Branch: 1 branch
BranchTrueFalseTotal
if ($major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100) { } 0 0 0
Condition0%0/15
$major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100
!ll&&!rl&&r
000
$major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1
!ll&&!rl&&r
000
$major > 0 and $major < 10 and $minor > -1 and $minor < 10
!ll&&!rl&&r
000
$major > 0 and $major < 10 and $minor > -1
!ll&&!rl&&r
000
$major > 0 and $major < 10
!ll&&!rl&&r
000
MC/DC0%0/6
$major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100
$major > 0 $major < 10 $minor > -1 $minor < 10 $patch > -1 $patch < 100
Truth table0%0/7
A and B and C and D and E and F
A= $major > 0B= $major < 10C= $minor > -1D= $minor < 10E= $patch > -1F= $patch < 100
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
205 0 my $version = ($major * 1000000) + ($minor * 1000) + $patch;
206
207 0 ▶ unless ($version >= OPENDNSSEC_VERSION_MIN and $version <= OPENDNSSEC_VERSION_MAX) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version >= 1003000 and $version <= 1004000) { } 0 0 0
Condition0%0/3
$version >= 1003000 and $version <= 1004000
!ll&&!rl&&r
000
MC/DC0%0/2
$version >= 1003000 and $version <= 1004000
$version >= 1003000 $version <= 1004000
Truth table0%0/3
A and B
A= $version >= 1003000B= $version <= 1004000
ABresult
0X0
100
111
208 0 $self->{logger}->warn('Unsupported "ods-signerd" executable version, unable to continue');
209 }
210 else {
211 0 $self->{bin}->{signerd} = $version;
212 0 $self->{bin_version}->{signerd} = $major.'.'.$minor.'.'.$patch;
213 }
214 }
215 else {
216 0 $self->{logger}->warn('Invalid "ods-signerd" version, module functions limited');
217 }
218 }
219 else {
220 0 $self->{logger}->warn('Unable to get "ods-signerd" version, module functions limited');
221 }
222 }
223
224 0 my $cv = Lim::Util::run_cmd [ 'ods-hsmutil', '-V' ],
225 '<', '/dev/null',
226 '>', \$stdout,
227 '2>', \$stderr;
228 0 ▶ if ($cv->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cv->recv) { } 0 0 0
229 0 $self->{logger}->warn('Unable to find "ods-hsmutil" executable, module functions limited');
230 }
231 else {
232 0 ▶ if ($stdout =~ /version\s+([0-9]+)\.([0-9]+)\.([0-9]+)/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stdout =~ /version\s+([0-9]+)\.([0-9]+)\.([0-9]+)/ou) { } 0 0 0
233 0 my ($major,$minor,$patch) = ($1, $2, $3);
234
235 0 ▶ if ($major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100) {
Branch: 1 branch
BranchTrueFalseTotal
if ($major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100) { } 0 0 0
Condition0%0/15
$major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100
!ll&&!rl&&r
000
$major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1
!ll&&!rl&&r
000
$major > 0 and $major < 10 and $minor > -1 and $minor < 10
!ll&&!rl&&r
000
$major > 0 and $major < 10 and $minor > -1
!ll&&!rl&&r
000
$major > 0 and $major < 10
!ll&&!rl&&r
000
MC/DC0%0/6
$major > 0 and $major < 10 and $minor > -1 and $minor < 10 and $patch > -1 and $patch < 100
$major > 0 $major < 10 $minor > -1 $minor < 10 $patch > -1 $patch < 100
Truth table0%0/7
A and B and C and D and E and F
A= $major > 0B= $major < 10C= $minor > -1D= $minor < 10E= $patch > -1F= $patch < 100
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
236 0 my $version = ($major * 1000000) + ($minor * 1000) + $patch;
237
238 0 ▶ unless ($version >= OPENDNSSEC_VERSION_MIN and $version <= OPENDNSSEC_VERSION_MAX) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version >= 1003000 and $version <= 1004000) { } 0 0 0
Condition0%0/3
$version >= 1003000 and $version <= 1004000
!ll&&!rl&&r
000
MC/DC0%0/2
$version >= 1003000 and $version <= 1004000
$version >= 1003000 $version <= 1004000
Truth table0%0/3
A and B
A= $version >= 1003000B= $version <= 1004000
ABresult
0X0
100
111
239 0 $self->{logger}->warn('Unsupported "ods-hsmutil" executable version, unable to continue');
240 }
241 else {
242 0 $self->{bin}->{hsmutil} = $version;
243 0 $self->{bin_version}->{hsmutil} = $major.'.'.$minor.'.'.$patch;
244 }
245 }
246 else {
247 0 $self->{logger}->warn('Invalid "ods-hsmutil" version, module functions limited');
248 }
249 }
250 else {
251 0 $self->{logger}->warn('Unable to get "ods-hsmutil" version, module functions limited');
252 }
253 }
254  
255 0 my $version = 0;
256 0 foreach my $program (keys %{$self->{bin}}) {
257 0 ▶ if ($program eq 'control') {
Branch: 1 branch
BranchTrueFalseTotal
if ($program eq "control") 0 0 0
258 0 next;
259 }
260 0 ▶ if ($self->{bin}->{$program}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"bin"}{$program}) 0 0 0
261 0 ▶ if ($version and $version != $self->{bin}->{$program}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version and $version != $self->{"bin"}{$program}) 0 0 0
Condition0%0/3
$version and $version != $self->{"bin"}{$program}
!ll&&!rl&&r
000
MC/DC0%0/2
$version and $version != $self->{"bin"}{$program}
$version $version != $self->{"bin"}{$program}
Truth table0%0/3
A and B
A= $versionB= $version != $self->{"bin"}{$program}
ABresult
0X0
100
111
262 0 die 'Missmatch version between Enforcer and Signer tools, disabling module';
263 }
264 0 $version = $self->{bin}->{$program};
265 }
266 }
267
268 0 $self->{version} = $version;
269 }
270  
271 =head2 Destroy
272  
273 =cut
274  
275 0 ▶sub Destroy {
Subroutine Destroy: not called CC=1 SCAR=0.0
Pod documented
276 }
277  
278 =head2 _ScanConfig
279  
280 =cut
281  
282 0 ▶sub _ScanConfig {
Subroutine _ScanConfig: not called CC=11 SCAR=48.8
283 0 my ($self) = @_;
284 0 my %file;
285
286 0 foreach my $config (keys %ConfigFiles) {
287
288 0 ▶ if ($config eq 'zonefetch.xml') {
Branch: 2 branches
BranchTrueFalseTotal
if ($config eq 'zonefetch.xml') { } 0 0 0
elsif ($config eq 'addns.xml') { } 0 0 0
289 0 ▶ if ($self->{version} >= 1004000) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"version"} >= 1004000) 0 0 0
290 # zonefetch.xml is only pre 1.4
291 0 next;
292 }
293 }
294 elsif ($config eq 'addns.xml') {
295 0 ▶ if ($self->{version} <= 1004000) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"version"} <= 1004000) 0 0 0
296 # addns.xml is only 1.4 and up
297 0 next;
298 }
299 }
300
301 0 foreach my $file (@{$ConfigFiles{$config}}) {
302 0 ▶ if (defined ($_ = Lim::Util::FileWritable($file))) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined($_ = Lim::Util::FileWritable($file))) { } 0 0 0
elsif (defined($_ = Lim::Util::FileReadable($file))) { } 0 0 0
303 0 ▶ if (exists $file{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $file{$_}) 0 0 0
304 0 $file{$_}->{write} = 1;
305 0 next;
306 }
307
308 0 $file{$_} = {
309 name => $_,
310 write => 1,
311 read => 1
312 };
313 }
314 elsif (defined ($_ = Lim::Util::FileReadable($file))) {
315 0 ▶ if (exists $file{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $file{$_}) 0 0 0
316 0 next;
317 }
318
319 0 $file{$_} = {
320 name => $_,
321 write => 0,
322 read => 1
323 };
324 }
325 }
326 }
327
328 0 return \%file;
329 }
330  
331 =head2 ReadVersion
332  
333 =cut
334  
335 0 ▶sub ReadVersion {
Subroutine ReadVersion: not called CC=3 SCAR=24.8
Pod documented
336 0 my ($self, $cb) = @_;
337 0 my @program;
338
339 0 foreach my $program (keys %{$self->{bin_version}}) {
340 0 push(@program, { name => 'ods-'.$program, version => $self->{bin_version}->{$program} });
341 }
342  
343 0 ▶ if (scalar @program) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @program) { } 0 0 0
344 0 $self->Successful($cb, { version => $VERSION, program => \@program });
345 }
346 else {
347 0 $self->Successful($cb, { version => $VERSION });
348 }
349 }
350  
351 =head2 ReadConfigs
352  
353 =cut
354  
355 0 ▶sub ReadConfigs {
Subroutine ReadConfigs: not called CC=1 SCAR=6.9
Pod documented
356 0 my ($self, $cb) = @_;
357 0 my $files = $self->_ScanConfig;
358
359 0 $self->Successful($cb, {
360 file => [ values %$files ]
361 });
362 }
363  
364 =head2 CreateConfig
365  
366 =cut
367  
368 0 ▶sub CreateConfig {
Subroutine CreateConfig: not called CC=1 SCAR=6.9
Pod documented
369 0 my ($self, $cb) = @_;
370
371 0 $self->Error($cb, 'Not Implemented');
372 }
373  
374 =head2 ReadConfig
375  
376 =cut
377  
378 0 ▶sub ReadConfig {
Subroutine ReadConfig: not called CC=9 SCAR=45.0
Pod documented
379 0 my ($self, $cb, $q) = @_;
380 0 my $files = $self->_ScanConfig;
381 0 my $result = {};
382  
383 0 ▶ foreach my $read (ref($q->{file}) eq 'ARRAY' ? @{$q->{file}} : $q->{file}) {
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'file'} eq 'ARRAY' ? : 0 0 0
384 0 ▶ if (exists $files->{$read->{name}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$files{$read->{'name'}}) { } 0 0 0
385 0 my $file = $files->{$read->{name}};
386
387 0 ▶ if ($file->{read} and defined (my $fh = IO::File->new($file->{name}))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file->{"read"} and defined(my $fh = "IO::File"->new($file->{"name"}))) 0 0 0
Condition0%0/3
$file->{"read"} and defined(my $fh = "IO::File"->new($file->{"name"}))
!ll&&!rl&&r
000
MC/DC0%0/2
$file->{"read"} and defined(my $fh = "IO::File"->new($file->{"name"}))
$file->{"read"} defined(my $fh = "IO::File"->new($file->{"name"}))
Truth table0%0/3
A and B
A= $file->{"read"}B= defined(my $fh = "IO::File"->new($file->{"name"}))
ABresult
0X0
100
111
388 0 my ($tell, $content);
389 0 $fh->seek(0, SEEK_END);
390 0 $tell = $fh->tell;
391 0 $fh->seek(0, SEEK_SET);
392 0 ▶ if ($fh->read($content, $tell) == $tell) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fh->read($content, $tell) == $tell) 0 0 0
393 0 ▶ if (exists $result->{file}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $result->{'file'}) { } 0 0 0
394 0 ▶ unless (ref($result->{file}) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $result->{"file"} eq "ARRAY") 0 0 0
395 0 $result->{file} = [ $result->{file} ];
396 }
397 0 push(@{$result->{file}}, {
398 name => $file->{name},
399 0 content => $content
400 });
401 }
402 else {
403 $result->{file} = {
404 name => $file->{name},
405 0 content => $content
406 };
407 }
408 }
409 }
410 }
411 else {
412 $self->Error($cb, Lim::Error->new(
413 code => 500,
414 0 message => 'File "'.$read->{name}.'" not found in configuration files'
415 ));
416 0 return;
417 }
418 }
419 0 $self->Successful($cb, $result);
420 }
421  
422 =head2 UpdateConfig
423  
424 =cut
425  
426 0 ▶sub UpdateConfig {
Subroutine UpdateConfig: not called CC=10 SCAR=47.0
Pod documented
427 0 my ($self, $cb, $q) = @_;
428 0 my $files = $self->_ScanConfig;
429 0 my $result = {};
430  
431 0 ▶ foreach my $read (ref($q->{file}) eq 'ARRAY' ? @{$q->{file}} : $q->{file}) {
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'file'} eq 'ARRAY' ? : 0 0 0
432 0 ▶ if (exists $files->{$read->{name}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$files{$read->{'name'}}) { } 0 0 0
433 0 my $file = $files->{$read->{name}};
434  
435 0 ▶ if ($file->{write} and defined (my $tmp = Lim::Util::TempFileLikeThis($file->{name}))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file->{"write"} and defined(my $tmp = Lim::Util::TempFileLikeThis($file->{"name"}))) 0 0 0
Condition0%0/3
$file->{"write"} and defined(my $tmp = Lim::Util::TempFileLikeThis($file->{"name"}))
!ll&&!rl&&r
000
MC/DC0%0/2
$file->{"write"} and defined(my $tmp = Lim::Util::TempFileLikeThis($file->{"name"}))
$file->{"write"} defined(my $tmp = Lim::Util::TempFileLikeThis($file->{"name"}))
Truth table0%0/3
A and B
A= $file->{"write"}B= defined(my $tmp = Lim::Util::TempFileLikeThis($file->{"name"}))
ABresult
0X0
100
111
436 0 print $tmp $read->{content};
437 0 $tmp->flush;
438 0 $tmp->close;
439
440 0 my $fh = IO::File->new;
441 0 ▶ if ($fh->open($tmp->filename)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fh->open($tmp->filename)) 0 0 0
442 0 my ($tell, $content);
443 0 $fh->seek(0, SEEK_END);
444 0 $tell = $fh->tell;
445 0 $fh->seek(0, SEEK_SET);
446 0 ▶ unless ($fh->read($content, $tell) == $tell) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fh->read($content, $tell) == $tell) 0 0 0
447 $self->Error($cb, Lim::Error->new(
448 code => 500,
449 0 message => 'Failed to write "'.$read->{name}.'" to temporary file'
450 ));
451 0 return;
452 }
453 0 ▶ unless (Digest::SHA::sha1_base64($read->{content}) eq Digest::SHA::sha1_base64($content)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&Digest::SHA::sha1_base64($read->{"content"}) eq &Digest::SHA::sha1_base64($content)) 0 0 0
454 $self->Error($cb, Lim::Error->new(
455 code => 500,
456 0 message => 'Checksum missmatch on "'.$read->{name}.'" after writing to temporary file'
457 ));
458 0 return;
459 }
460 0 ▶ unless (rename($tmp->filename, $file->{name}))
Branch: 1 branch
BranchTrueFalseTotal
unless (rename $tmp->filename, $file->{"name"}) 0 0 0
461 {
462 $self->Error($cb, Lim::Error->new(
463 code => 500,
464 0 message => 'Failed to rename "'.$read->{name}.'"'
465 ));
466 0 return;
467 }
468 }
469 }
470 }
471 else {
472 $self->Error($cb, Lim::Error->new(
473 code => 500,
474 0 message => 'File "'.$read->{name}.'" not found in configuration files'
475 ));
476 0 return;
477 }
478 }
479 0 $self->Successful($cb);
480 }
481  
482 =head2 DeleteConfig
483  
484 =cut
485  
486 0 ▶sub DeleteConfig {
Subroutine DeleteConfig: not called CC=1 SCAR=6.9
Pod documented
487 0 my ($self, $cb) = @_;
488
489 0 $self->Error($cb, 'Not Implemented');
490 }
491  
492 =head2 UpdateControl
493  
494 =cut
495  
496 0 ▶sub UpdateControl {
Subroutine UpdateControl: not called CC=1 SCAR=6.9
Pod documented
497 0 my ($self, $cb) = @_;
498  
499 0 $self->Successful($cb);
500 }
501  
502 =head2 UpdateControlStart
503  
504 =cut
505  
506 0 ▶sub UpdateControlStart {
Subroutine UpdateControlStart: not called CC=11 SCAR=48.8
Pod documented
507 0 my ($self, $cb, $q) = @_;
508
509 0 ▶ unless ($self->{bin}->{control}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"control"}) 0 0 0
510 0 $self->Error($cb, 'No "ods-control" executable found or unsupported version, unable to continue');
511 0 return;
512 }
513  
514 0 ▶ if (exists $q->{program}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $q->{'program'}) { } 0 0 0
515 0 my @programs;
516 0 ▶ foreach my $program (ref($q->{program}) eq 'ARRAY' ? @{$q->{program}} : $q->{program}) {
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'program'} eq 'ARRAY' ? : 0 0 0
517 0 ▶ if (exists $program->{name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $program->{"name"}) 0 0 0
518 0 my $name = lc($program->{name});
519 0 ▶ if ($name eq 'enforcer' and $self->{bin}->{enforcerd}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($name eq 'enforcer' and $self->{'bin'}{'enforcerd'}) { } 0 0 0
elsif ($name eq 'signer' and $self->{'bin'}{'signerd'}) { } 0 0 0
Condition0%0/3
$name eq "enforcer" and $self->{"bin"}{"enforcerd"}
!ll&&!rl&&r
000
MC/DC0%0/2
$name eq "enforcer" and $self->{"bin"}{"enforcerd"}
$name eq "enforcer" $self->{"bin"}{"enforcerd"}
Truth table0%0/3
A and B
A= $name eq "enforcer"B= $self->{"bin"}{"enforcerd"}
ABresult
0X0
100
111
520 0 push(@programs, $name);
521 }
522 ▶ elsif ($name eq 'signer' and $self->{bin}->{signerd}) {
Condition0%0/3
$name eq "signer" and $self->{"bin"}{"signerd"}
!ll&&!rl&&r
000
MC/DC0%0/2
$name eq "signer" and $self->{"bin"}{"signerd"}
$name eq "signer" $self->{"bin"}{"signerd"}
Truth table0%0/3
A and B
A= $name eq "signer"B= $self->{"bin"}{"signerd"}
ABresult
0X0
100
111
523 0 push(@programs, $name);
524 }
525 else {
526 0 $self->Error($cb, Lim::Error->new(
527 code => 500,
528 message => 'Unknown program "'.$name.'" specified'
529 ));
530 0 return;
531 }
532 }
533 }
534 0 ▶ if (scalar @programs) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @programs) 0 0 0
535 0 weaken($self);
536 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
537 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
538 0 undef($cmd_cb);
539 0 return;
540 }
541 0 ▶ if (my $program = shift(@programs)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $program = shift @programs) { } 0 0 0
542 Lim::Util::run_cmd
543 [ 'ods-control', $program, 'start' ],
544 '<', '/dev/null',
545 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
546 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
547 0 $cb->reset_timeout;
548 }
549 },
550 '2>', '/dev/null',
551 timeout => 30,
552 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
553 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
554 0 undef($cmd_cb);
555 0 return;
556 }
557 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
558 0 $self->Error($cb, 'Unable to start OpenDNSSEC '.$program);
559 0 undef($cmd_cb);
560 0 return;
561 }
562 0 $cmd_cb->();
563 0 };
564 }
565 else {
566 0 $self->Successful($cb);
567 0 undef($cmd_cb);
568 }
569 0 };
570 0 $cmd_cb->();
571 0 return;
572 }
573 }
574 else {
575 0 weaken($self);
576 Lim::Util::run_cmd
577 [ 'ods-control', 'start' ],
578 '<', '/dev/null',
579 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
580 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
581 0 $cb->reset_timeout;
582 }
583 },
584 '2>', '/dev/null',
585 timeout => 30,
586 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
587 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
588 0 return;
589 }
590 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
591 0 $self->Error($cb, 'Unable to start OpenDNSSEC');
592 0 return;
593 }
594 0 $self->Successful($cb);
595 0 };
596 0 return;
597 }
598 0 $self->Successful($cb);
599 }
600  
601 =head2 UpdateControlStop
602  
603 =cut
604  
605 0 ▶sub UpdateControlStop {
Subroutine UpdateControlStop: not called CC=11 SCAR=48.8
Pod documented
606 0 my ($self, $cb, $q) = @_;
607
608 0 ▶ unless ($self->{bin}->{control}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"control"}) 0 0 0
609 0 $self->Error($cb, 'No "ods-control" executable found or unsupported version, unable to continue');
610 0 return;
611 }
612  
613 0 ▶ if (exists $q->{program}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $q->{'program'}) { } 0 0 0
614 0 my @programs;
615 0 ▶ foreach my $program (ref($q->{program}) eq 'ARRAY' ? @{$q->{program}} : $q->{program}) {
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'program'} eq 'ARRAY' ? : 0 0 0
616 0 ▶ if (exists $program->{name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $program->{"name"}) 0 0 0
617 0 my $name = lc($program->{name});
618 0 ▶ if ($name eq 'enforcer' and $self->{bin}->{enforcerd}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($name eq 'enforcer' and $self->{'bin'}{'enforcerd'}) { } 0 0 0
elsif ($name eq 'signer' and $self->{'bin'}{'signerd'}) { } 0 0 0
Condition0%0/3
$name eq "enforcer" and $self->{"bin"}{"enforcerd"}
!ll&&!rl&&r
000
MC/DC0%0/2
$name eq "enforcer" and $self->{"bin"}{"enforcerd"}
$name eq "enforcer" $self->{"bin"}{"enforcerd"}
Truth table0%0/3
A and B
A= $name eq "enforcer"B= $self->{"bin"}{"enforcerd"}
ABresult
0X0
100
111
619 0 push(@programs, $name);
620 }
621 ▶ elsif ($name eq 'signer' and $self->{bin}->{signerd}) {
Condition0%0/3
$name eq "signer" and $self->{"bin"}{"signerd"}
!ll&&!rl&&r
000
MC/DC0%0/2
$name eq "signer" and $self->{"bin"}{"signerd"}
$name eq "signer" $self->{"bin"}{"signerd"}
Truth table0%0/3
A and B
A= $name eq "signer"B= $self->{"bin"}{"signerd"}
ABresult
0X0
100
111
622 0 push(@programs, $name);
623 }
624 else {
625 0 $self->Error($cb, Lim::Error->new(
626 code => 500,
627 message => 'Unknown program "'.$name.'" specified'
628 ));
629 0 return;
630 }
631 }
632 }
633 0 ▶ if (scalar @programs) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @programs) 0 0 0
634 0 weaken($self);
635 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
636 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
637 0 undef($cmd_cb);
638 0 return;
639 }
640 0 ▶ if (my $program = shift(@programs)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $program = shift @programs) { } 0 0 0
641 Lim::Util::run_cmd
642 [ 'ods-control', $program, 'stop' ],
643 '<', '/dev/null',
644 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
645 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
646 0 $cb->reset_timeout;
647 }
648 },
649 '2>', '/dev/null',
650 timeout => 30,
651 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
652 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
653 0 undef($cmd_cb);
654 0 return;
655 }
656 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
657 0 $self->Error($cb, 'Unable to stop OpenDNSSEC '.$program);
658 0 undef($cmd_cb);
659 0 return;
660 }
661 0 $cmd_cb->();
662 0 };
663 }
664 else {
665 0 $self->Successful($cb);
666 0 undef($cmd_cb);
667 }
668 0 };
669 0 $cmd_cb->();
670 0 return;
671 }
672 }
673 else {
674 0 weaken($self);
675 Lim::Util::run_cmd
676 [ 'ods-control', 'stop' ],
677 '<', '/dev/null',
678 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
679 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
680 0 $cb->reset_timeout;
681 }
682 },
683 '2>', '/dev/null',
684 timeout => 30,
685 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
686 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
687 0 return;
688 }
689 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
690 0 $self->Error($cb, 'Unable to stop OpenDNSSEC');
691 0 return;
692 }
693 0 $self->Successful($cb);
694 0 };
695 0 return;
696 }
697 0 $self->Successful($cb);
698 }
699  
700 =head2 CreateEnforcer
701  
702 =cut
703  
704 0 ▶sub CreateEnforcer {
Subroutine CreateEnforcer: not called CC=1 SCAR=6.9
Pod documented
705 0 my ($self, $cb) = @_;
706  
707 0 $self->Successful($cb);
708 }
709  
710 =head2 ReadEnforcer
711  
712 =cut
713  
714 0 ▶sub ReadEnforcer {
Subroutine ReadEnforcer: not called CC=1 SCAR=6.9
Pod documented
715 0 my ($self, $cb) = @_;
716  
717 0 $self->Successful($cb);
718 }
719  
720 =head2 UpdateEnforcer
721  
722 =cut
723  
724 0 ▶sub UpdateEnforcer {
Subroutine UpdateEnforcer: not called CC=1 SCAR=6.9
Pod documented
725 0 my ($self, $cb) = @_;
726  
727 0 $self->Successful($cb);
728 }
729  
730 =head2 DeleteEnforcer
731  
732 =cut
733  
734 0 ▶sub DeleteEnforcer {
Subroutine DeleteEnforcer: not called CC=1 SCAR=6.9
Pod documented
735 0 my ($self, $cb) = @_;
736  
737 0 $self->Successful($cb);
738 }
739  
740 =head2 CreateEnforcerSetup
741  
742 =cut
743  
744 0 ▶sub CreateEnforcerSetup {
Subroutine CreateEnforcerSetup: not called CC=2 SCAR=17.9
Pod documented
745 0 my ($self, $cb) = @_;
746
747 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
748 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
749 0 return;
750 }
751
752 # TODO confirm with user
753  
754 0 weaken($self);
755 0 my ($stdout, $stderr);
756 0 my $stdin = "Y\015";
757 Lim::Util::run_cmd [ 'ods-ksmutil', 'setup' ],
758 '<', \$stdin,
759 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
760 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
761 0 $cb->reset_timeout;
762 }
763 },
764 '2>', \$stderr,
765 timeout => 30,
766 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
767 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
768 0 return;
769 }
770 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
771 0 $self->Error($cb, 'Unable to setup OpenDNSSEC');
772 0 return;
773 }
774 0 $self->Successful($cb);
775 0 };
776 }
777  
778 =head2 UpdateEnforcerUpdate
779  
780 =cut
781  
782 0 ▶sub UpdateEnforcerUpdate {
Subroutine UpdateEnforcerUpdate: not called CC=7 SCAR=40.3
Pod documented
783 0 my ($self, $cb, $q) = @_;
784
785 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
786 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
787 0 return;
788 }
789
790 0 my %section = (
791 kasp => 1,
792 zonelist => 1,
793 conf => 1
794 );
795
796 0 ▶ if (exists $q->{update}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $q->{'update'}) { } 0 0 0
797 0 my @sections;
798 0 ▶ foreach my $section (ref($q->{update}) eq 'ARRAY' ? @{$q->{update}} : $q->{update}) {
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'update'} eq 'ARRAY' ? : 0 0 0
799 0 my $name = lc($section->{section});
800
801 0 ▶ if (exists $section{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $section{$name}) { } 0 0 0
802 0 push(@sections, $name);
803 }
804 else {
805 0 $self->Error($cb, Lim::Error->new(
806 code => 500,
807 message => 'Unknown Enforcer configuration section "'.$name.'" specified'
808 ));
809 0 return;
810 }
811 }
812 0 ▶ if (scalar @sections) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @sections) 0 0 0
813 0 weaken($self);
814 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
815 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
816 0 undef($cmd_cb);
817 0 return;
818 }
819 0 ▶ if (my $section = shift(@sections)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $section = shift @sections) { } 0 0 0
820 0 my ($stdout, $stderr);
821 Lim::Util::run_cmd
822 [ 'ods-ksmutil', 'update', $section ],
823 '<', '/dev/null',
824 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
825 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
826 0 $cb->reset_timeout;
827 0 $stdout .= $_[0];
828 }
829 },
830 '2>', \$stderr,
831 timeout => 30,
832 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
833 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
834 0 undef($cmd_cb);
835 0 return;
836 }
837 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
838 0 $self->Error($cb, 'Unable to update Enforcer configuration section '.$section);
839 0 undef($cmd_cb);
840 0 return;
841 }
842 0 $cmd_cb->();
843 0 };
844 }
845 else {
846 0 $self->Successful($cb);
847 0 undef($cmd_cb);
848 }
849 0 };
850 0 $cmd_cb->();
851 0 return;
852 }
853 }
854 else {
855 0 my ($stdout, $stderr);
856 0 weaken($self);
857 Lim::Util::run_cmd
858 [ 'ods-ksmutil', 'update', 'all' ],
859 '<', '/dev/null',
860 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
861 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
862 0 $cb->reset_timeout;
863 0 $stdout .= $_[0];
864 }
865 },
866 '2>', \$stderr,
867 timeout => 30,
868 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
869 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
870 0 return;
871 }
872 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
873 0 $self->Error($cb, 'Unable to update all Enforcer configuration sections');
874 0 return;
875 }
876 0 $self->Successful($cb);
877 0 };
878 0 return;
879 }
880 0 $self->Successful($cb);
881 }
882  
883 =head2 CreateEnforcerZone
884  
885 =cut
886  
887 0 ▶sub CreateEnforcerZone {
Subroutine CreateEnforcerZone: not called CC=4 SCAR=30.0
Pod documented
888 0 my ($self, $cb, $q) = @_;
889
890 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
891 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
892 0 return;
893 }
894
895 0 ▶ my @zones = ref($q->{zone}) eq 'ARRAY' ? @{$q->{zone}} : ($q->{zone});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'zone'} eq 'ARRAY' ? : 0 0 0
896 0 ▶ if (scalar @zones) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @zones) 0 0 0
897 0 weaken($self);
898 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
899 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
900 0 undef($cmd_cb);
901 0 return;
902 }
903 0 ▶ if (my $zone = shift(@zones)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $zone = shift @zones) { } 0 0 0
904 0 my ($stdout, $stderr);
905 Lim::Util::run_cmd
906 [
907 'ods-ksmutil', 'zone', 'add',
908 '--zone', $zone->{name},
909 '--policy', $zone->{policy},
910 '--signerconf', $zone->{signerconf},
911 '--input', $zone->{input},
912 '--output', $zone->{output},
913 (exists $zone->{no_xml} and $zone->{no_xml} ? '--no-xml' : ())
914 ],
915 '<', '/dev/null',
916 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
917 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
918 0 $cb->reset_timeout;
919 0 $stdout .= $_[0];
920 }
921 },
922 '2>', \$stderr,
923 timeout => 10,
924 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
925 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
926 0 undef($cmd_cb);
927 0 return;
928 }
929 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
930 0 $self->Error($cb, 'Unable to create zone ', $zone->{name});
931 0 undef($cmd_cb);
932 0 return;
933 }
934 0 $cmd_cb->();
935 0 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
$zone->{'no_xml'} ? : 0 0 0
Condition0%0/3
exists $zone->{'no_xml'} && ($zone->{'no_xml'} ? '--no-xml' : ())
!ll&&!rl&&r
000
MC/DC0%0/2
exists $zone->{'no_xml'} && ($zone->{'no_xml'} ? '--no-xml' : ())
exists $zone->{'no_xml'} ($zone->{'no_xml'} ? '--no-xml' : ())
Truth table0%0/3
A && B
A= exists $zone->{'no_xml'}B= ($zone->{'no_xml'} ? '--no-xml' : ())
ABresult
0X0
100
111
936 }
937 else {
938 0 $self->Successful($cb);
939 0 undef($cmd_cb);
940 }
941 0 };
942 0 $cmd_cb->();
943 0 return;
944 }
945 0 $self->Successful($cb);
946 }
947  
948 =head2 ReadEnforcerZoneList
949  
950 =cut
951  
952 0 ▶sub ReadEnforcerZoneList {
Subroutine ReadEnforcerZoneList: not called CC=2 SCAR=17.9
Pod documented
953 0 my ($self, $cb) = @_;
954
955 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
956 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
957 0 return;
958 }
959
960 0 weaken($self);
961 0 my ($data, $stderr, @zones);
962 Lim::Util::run_cmd [ 'ods-ksmutil', 'zone', 'list' ],
963 '<', '/dev/null',
964 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
965 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
966 0 $data .= $_[0];
967
968 0 $cb->reset_timeout;
969
970 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
971 0 my $line = $1;
972
973 0 ▶ if ($line =~ /^Found\s+Zone:\s+([^;]+);\s+on\s+policy\s+(.+)$/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^Found\s+Zone:\s+([^;]+);\s+on\s+policy\s+(.+)$/ou) 0 0 0
974 0 push(@zones, {
975 name => $1,
976 policy => $2
977 });
978 }
979 }
980 }
981 },
982 '2>', \$stderr,
983 timeout => 30,
984 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
985 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
986 0 return;
987 }
988 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
989 0 $self->Error($cb, 'Unable to get Enforcer zone list');
990 0 return;
991 }
992 0 ▶ if (scalar @zones == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @zones == 1) { } 0 0 0
elsif (scalar @zones) { } 0 0 0
993 0 $self->Successful($cb, { zone => $zones[0] });
994 }
995 elsif (scalar @zones) {
996 0 $self->Successful($cb, { zone => \@zones });
997 }
998 else {
999 0 $self->Successful($cb);
1000 }
1001 0 };
1002 }
1003  
1004 =head2 DeleteEnforcerZone
1005  
1006 =cut
1007  
1008 0 ▶sub DeleteEnforcerZone {
Subroutine DeleteEnforcerZone: not called CC=7 SCAR=40.3
Pod documented
1009 0 my ($self, $cb, $q) = @_;
1010
1011 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
1012 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
1013 0 return;
1014 }
1015
1016 0 ▶ my @zones = ref($q->{zone}) eq 'ARRAY' ? @{$q->{zone}} : ($q->{zone});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'zone'} eq 'ARRAY' ? : 0 0 0
1017 0 ▶ if (scalar @zones) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @zones) 0 0 0
1018 0 foreach (@zones) {
1019 0 ▶ if (exists $_->{all} and $_->{all}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $_->{"all"} and $_->{"all"}) 0 0 0
Condition0%0/3
exists $_->{"all"} and $_->{"all"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $_->{"all"} and $_->{"all"}
exists $_->{"all"} $_->{"all"}
Truth table0%0/3
A and B
A= exists $_->{"all"}B= $_->{"all"}
ABresult
0X0
100
111
1020 0 weaken($self);
1021 0 my ($stdout, $stderr);
1022 # TODO reset timer on stdout output
1023 Lim::Util::run_cmd
1024 [ 'ods-ksmutil', 'zone', 'delete', '--all' ],
1025 '<', '/dev/null',
1026 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1027 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
1028 0 $cb->reset_timeout;
1029 0 $stdout .= $_[0];
1030 }
1031 },
1032 '2>', \$stderr,
1033 timeout => 30,
1034 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1035 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1036 0 return;
1037 }
1038 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
1039 0 $self->Error($cb, 'Unable to delete all zones');
1040 0 return;
1041 }
1042 0 $self->Successful($cb);
1043 0 };
1044 0 return;
1045 }
1046 }
1047
1048 0 weaken($self);
1049 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=8 SCAR=42.8
1050 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1051 0 undef($cmd_cb);
1052 0 return;
1053 }
1054 0 ▶ if (my $zone = shift(@zones)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $zone = shift @zones) { } 0 0 0
1055 0 ▶ while (defined $zone and !exists $zone->{name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $zone and not exists $zone->{"name"}) 0 0 0
Condition0%0/3
defined $zone and not exists $zone->{"name"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $zone and not exists $zone->{"name"}
defined $zone not exists $zone->{"name"}
Truth table0%0/3
A and not(B)
A= defined $zoneB= not exists $zone->{"name"}
ABresult
0X0
100
111
1056 0 $zone = shift(@zones);
1057 }
1058 0 ▶ unless (defined $zone) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $zone) 0 0 0
1059 0 $self->Successful($cb);
1060 0 undef($cmd_cb);
1061 0 return;
1062 }
1063 0 my ($stdout, $stderr);
1064 Lim::Util::run_cmd
1065 [
1066 'ods-ksmutil', 'zone', 'delete',
1067 '--zone', $zone->{name},
1068 (exists $zone->{no_xml} and $zone->{no_xml} ? '--no-xml' : ())
1069 ],
1070 '<', '/dev/null',
1071 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1072 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
1073 0 $cb->reset_timeout;
1074 0 $stdout .= $_[0];
1075 }
1076 },
1077 '2>', \$stderr,
1078 timeout => 10,
1079 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1080 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1081 0 undef($cmd_cb);
1082 0 return;
1083 }
1084 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
1085 0 $self->Error($cb, 'Unable to delete zone ', $zone->{name});
1086 0 undef($cmd_cb);
1087 0 return;
1088 }
1089 0 $cmd_cb->();
1090 0 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
$zone->{'no_xml'} ? : 0 0 0
Condition0%0/3
exists $zone->{'no_xml'} && ($zone->{'no_xml'} ? '--no-xml' : ())
!ll&&!rl&&r
000
MC/DC0%0/2
exists $zone->{'no_xml'} && ($zone->{'no_xml'} ? '--no-xml' : ())
exists $zone->{'no_xml'} ($zone->{'no_xml'} ? '--no-xml' : ())
Truth table0%0/3
A && B
A= exists $zone->{'no_xml'}B= ($zone->{'no_xml'} ? '--no-xml' : ())
ABresult
0X0
100
111
1091 }
1092 else {
1093 0 $self->Successful($cb);
1094 0 undef($cmd_cb);
1095 }
1096 0 };
1097 0 $cmd_cb->();
1098 0 return;
1099 }
1100 0 $self->Successful($cb);
1101 }
1102  
1103 =head2 ReadEnforcerRepositoryList
1104  
1105 =cut
1106  
1107 0 ▶sub ReadEnforcerRepositoryList {
Subroutine ReadEnforcerRepositoryList: not called CC=2 SCAR=17.9
Pod documented
1108 0 my ($self, $cb) = @_;
1109
1110 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
1111 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
1112 0 return;
1113 }
1114
1115 0 weaken($self);
1116 0 my ($data, $stderr, @repositories);
1117 0 my $skip = 2;
1118 Lim::Util::run_cmd [ 'ods-ksmutil', 'repository', 'list' ],
1119 '<', '/dev/null',
1120 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
1121 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
1122 0 $data .= $_[0];
1123
1124 0 $cb->reset_timeout;
1125
1126 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
1127 0 my $line = $1;
1128
1129 0 ▶ if ($skip) {
Branch: 1 branch
BranchTrueFalseTotal
if ($skip) 0 0 0
1130 0 $skip--;
1131 0 next;
1132 }
1133
1134 # TODO spaces in name?
1135 0 ▶ if ($line =~ /^(\S+)\s+(\d+)\s+((?:Yes|No))$/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^(\S+)\s+(\d+)\s+((?:Yes|No))$/ou) 0 0 0
1136 0 ▶ push(@repositories, {
Branch: 1 branch
BranchTrueFalseTotal
$3 eq 'Yes' ? : 0 0 0
1137 name => $1,
1138 capacity => $2,
1139 require_backup => $3 eq 'Yes' ? 1 : 0
1140 });
1141 }
1142 }
1143 }
1144 },
1145 '2>', \$stderr,
1146 timeout => 30,
1147 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
1148 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1149 0 return;
1150 }
1151 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
1152 0 $self->Error($cb, 'Unable to get Enforcer repository list');
1153 0 return;
1154 }
1155 0 ▶ if (scalar @repositories == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @repositories == 1) { } 0 0 0
elsif (scalar @repositories) { } 0 0 0
1156 0 $self->Successful($cb, { repository => $repositories[0] });
1157 }
1158 elsif (scalar @repositories) {
1159 0 $self->Successful($cb, { repository => \@repositories });
1160 }
1161 else {
1162 0 $self->Successful($cb);
1163 }
1164 0 };
1165 }
1166  
1167 =head2 ReadEnforcerPolicyList
1168  
1169 =cut
1170  
1171 0 ▶sub ReadEnforcerPolicyList {
Subroutine ReadEnforcerPolicyList: not called CC=2 SCAR=17.9
Pod documented
1172 0 my ($self, $cb) = @_;
1173
1174 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
1175 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
1176 0 return;
1177 }
1178
1179 0 weaken($self);
1180 0 my ($data, $stderr, @policies);
1181 0 my $skip = 2;
1182 Lim::Util::run_cmd [ 'ods-ksmutil', 'policy', 'list' ],
1183 '<', '/dev/null',
1184 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
1185 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
1186 0 $data .= $_[0];
1187
1188 0 $cb->reset_timeout;
1189
1190 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
1191 0 my $line = $1;
1192
1193 0 ▶ if ($skip) {
Branch: 1 branch
BranchTrueFalseTotal
if ($skip) 0 0 0
1194 0 $skip--;
1195 0 next;
1196 }
1197
1198 # TODO spaces in name?
1199 0 ▶ if ($line =~ /^(\S+)\s+(.+)$/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^(\S+)\s+(.+)$/ou) 0 0 0
1200 0 push(@policies, {
1201 name => $1,
1202 description => $2
1203 });
1204 }
1205 }
1206 }
1207 },
1208 '2>', \$stderr,
1209 timeout => 30,
1210 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
1211 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1212 0 return;
1213 }
1214 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
1215 0 $self->Error($cb, 'Unable to get Enforcer policy list');
1216 0 return;
1217 }
1218 0 ▶ if (scalar @policies == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @policies == 1) { } 0 0 0
elsif (scalar @policies) { } 0 0 0
1219 0 $self->Successful($cb, { policy => $policies[0] });
1220 }
1221 elsif (scalar @policies) {
1222 0 $self->Successful($cb, { policy => \@policies });
1223 }
1224 else {
1225 0 $self->Successful($cb);
1226 }
1227 0 };
1228 }
1229  
1230 =head2 ReadEnforcerPolicyExport
1231  
1232 =cut
1233  
1234 0 ▶sub ReadEnforcerPolicyExport {
Subroutine ReadEnforcerPolicyExport: not called CC=4 SCAR=30.0
Pod documented
1235 0 my ($self, $cb, $q) = @_;
1236  
1237 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
1238 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
1239 0 return;
1240 }
1241  
1242 # TODO is there a way to send the database as base64 incrementaly to avoid hogning memory?
1243
1244 0 ▶ if (exists $q->{policy}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $q->{'policy'}) { } 0 0 0
1245 0 ▶ my @policies = ref($q->{policy}) eq 'ARRAY' ? @{$q->{policy}} : ($q->{policy});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'policy'} eq 'ARRAY' ? : 0 0 0
1246 0 my %policy;
1247 0 weaken($self);
1248 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
1249 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1250 0 undef($cmd_cb);
1251 0 return;
1252 }
1253 0 ▶ if (my $policy = shift(@policies)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $policy = shift @policies) { } 0 0 0
1254 0 my ($stdout, $stderr);
1255 Lim::Util::run_cmd
1256 [
1257 'ods-ksmutil', 'policy', 'export',
1258 '--policy', $policy->{name}
1259 ],
1260 '<', '/dev/null',
1261 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1262 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
1263 0 $cb->reset_timeout;
1264 0 $stdout .= $_[0];
1265 }
1266 },
1267 '2>', \$stderr,
1268 timeout => 30,
1269 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1270 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1271 0 undef($cmd_cb);
1272 0 return;
1273 }
1274 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
1275 0 $self->Error($cb, 'Unable to get Enforcer policy export for policy ', $policy->{name});
1276 0 undef($cmd_cb);
1277 0 return;
1278 }
1279 $policy{$policy->{name}} = {
1280 name => $policy->{name},
1281 0 kasp => $stdout
1282 };
1283 0 $cmd_cb->();
1284 0 };
1285 }
1286 else {
1287 0 ▶ if (scalar %policy) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar %policy) { } 0 0 0
1288 0 $self->Successful($cb, { policy => [ values %policy ] });
1289 }
1290 else {
1291 0 $self->Successful($cb);
1292 }
1293 0 undef($cmd_cb);
1294 }
1295 0 };
1296 0 $cmd_cb->();
1297 }
1298 else {
1299 0 weaken($self);
1300 0 my ($stdout, $stderr);
1301 Lim::Util::run_cmd [ 'ods-ksmutil', 'policy', 'export', '--all' ],
1302 '<', '/dev/null',
1303 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1304 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
1305 0 $cb->reset_timeout;
1306 0 $stdout .= $_[0];
1307 }
1308 },
1309 '2>', \$stderr,
1310 timeout => 30,
1311 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1312 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1313 0 return;
1314 }
1315 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
1316 0 $self->Error($cb, 'Unable to export policies');
1317 0 return;
1318 }
1319 0 $self->Successful($cb, { kasp => $stdout });
1320 0 };
1321 }
1322 }
1323  
1324 =head2 DeleteEnforcerPolicyPurge
1325  
1326 =cut
1327  
1328 0 ▶sub DeleteEnforcerPolicyPurge {
Subroutine DeleteEnforcerPolicyPurge: not called CC=1 SCAR=6.9
Pod documented
1329 0 my ($self, $cb) = @_;
1330  
1331 0 $self->Error($cb, 'Not Implemented: function experimental');
1332 }
1333  
1334 =head2 ReadEnforcerKeyList
1335  
1336 =cut
1337  
1338 0 ▶sub ReadEnforcerKeyList {
Subroutine ReadEnforcerKeyList: not called CC=6 SCAR=37.4
Pod documented
1339 0 my ($self, $cb, $q) = @_;
1340
1341 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
1342 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
1343 0 return;
1344 }
1345  
1346 0 ▶ if (exists $q->{zone}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $q->{'zone'}) { } 0 0 0
1347 0 ▶ my @zones = ref($q->{zone}) eq 'ARRAY' ? @{$q->{zone}} : ($q->{zone});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'zone'} eq 'ARRAY' ? : 0 0 0
1348 0 my %zone;
1349 0 weaken($self);
1350 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
1351 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1352 0 undef($cmd_cb);
1353 0 return;
1354 }
1355 0 ▶ if (my $zone = shift(@zones)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $zone = shift @zones) { } 0 0 0
1356 0 my ($data, $stderr);
1357 0 my $skip = 2;
1358 Lim::Util::run_cmd
1359 [
1360 'ods-ksmutil', 'key', 'list',
1361 '--zone', $zone->{name},
1362 (exists $q->{verbose} and $q->{verbose} ? '--verbose' : ())
1363 ],
1364 '<', '/dev/null',
1365 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=9 SCAR=45.0
1366 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
1367 0 $data .= $_[0];
1368
1369 0 $cb->reset_timeout;
1370
1371 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
1372 0 my $line = $1;
1373
1374 0 ▶ if ($skip) {
Branch: 1 branch
BranchTrueFalseTotal
if ($skip) 0 0 0
1375 0 $skip--;
1376 0 next;
1377 }
1378
1379 0 ▶ if ($line =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+(?:\s\S+)*)\s*(?:(\S+)\s+(\S+)\s+(\S+)){0,1}$/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+(?:\s\S+)*)\s*(?:(\S+)\s+(\S+)\s+(\S+)){0,1}$/ou) 0 0 0
1380 0 ▶ unless (exists $zone{$1}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $zone{$1}) 0 0 0
1381 0 $zone{$1} = {
1382 name => $1,
1383 key => []
1384 };
1385 }
1386 0 ▶ push(@{$zone{$1}->{key}}, {
Branch: 3 branches
BranchTrueFalseTotal
defined $5 ? : 0 0 0
defined $6 ? : 0 0 0
defined $7 ? : 0 0 0
1387 type => $2,
1388 state => $3,
1389 next_transaction => $4,
1390 (defined $5 ? (cka_id => $5) : ()),
1391 (defined $6 ? (repository => $6) : ()),
1392 (defined $7 ? (keytag => $7) : ())
1393 });
1394 }
1395 }
1396 }
1397 },
1398 '2>', \$stderr,
1399 timeout => 30,
1400 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1401 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1402 0 undef($cmd_cb);
1403 0 return;
1404 }
1405 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
1406 0 $self->Error($cb, 'Unable to get Enforcer key list for zone ', $zone->{name});
1407 0 undef($cmd_cb);
1408 0 return;
1409 }
1410 0 $cmd_cb->();
1411 0 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
$q->{'verbose'} ? : 0 0 0
Condition0%0/3
exists $q->{'verbose'} && ($q->{'verbose'} ? '--verbose' : ())
!ll&&!rl&&r
000
MC/DC0%0/2
exists $q->{'verbose'} && ($q->{'verbose'} ? '--verbose' : ())
exists $q->{'verbose'} ($q->{'verbose'} ? '--verbose' : ())
Truth table0%0/3
A && B
A= exists $q->{'verbose'}B= ($q->{'verbose'} ? '--verbose' : ())
ABresult
0X0
100
111
1412 }
1413 else {
1414 0 ▶ if (scalar %zone) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar %zone) { } 0 0 0
1415 0 $self->Successful($cb, { zone => [ values %zone ] });
1416 }
1417 else {
1418 0 $self->Successful($cb);
1419 }
1420 0 undef($cmd_cb);
1421 }
1422 0 };
1423 0 $cmd_cb->();
1424 }
1425 else {
1426 0 weaken($self);
1427 0 my ($data, $stderr, %zone);
1428 0 my $skip = 2;
1429 Lim::Util::run_cmd
1430 [
1431 'ods-ksmutil', 'key', 'list',
1432 (exists $q->{verbose} and $q->{verbose} ? '--verbose' : ())
1433 ],
1434 '<', '/dev/null',
1435 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=9 SCAR=45.0
1436 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
1437 0 $data .= $_[0];
1438
1439 0 $cb->reset_timeout;
1440
1441 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
1442 0 my $line = $1;
1443
1444 0 ▶ if ($skip) {
Branch: 1 branch
BranchTrueFalseTotal
if ($skip) 0 0 0
1445 0 $skip--;
1446 0 next;
1447 }
1448
1449 0 ▶ if ($line =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+(?:\s\S+)*)\s*(?:(\S+)\s+(\S+)\s+(\S+)){0,1}$/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+(?:\s\S+)*)\s*(?:(\S+)\s+(\S+)\s+(\S+)){0,1}$/ou) 0 0 0
1450 0 ▶ unless (exists $zone{$1}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $zone{$1}) 0 0 0
1451 0 $zone{$1} = {
1452 name => $1,
1453 key => []
1454 };
1455 }
1456 0 ▶ push(@{$zone{$1}->{key}}, {
Branch: 3 branches
BranchTrueFalseTotal
defined $5 ? : 0 0 0
defined $6 ? : 0 0 0
defined $7 ? : 0 0 0
1457 type => $2,
1458 state => $3,
1459 next_transaction => $4,
1460 (defined $5 ? (cka_id => $5) : ()),
1461 (defined $6 ? (repository => $6) : ()),
1462 (defined $7 ? (keytag => $7) : ())
1463 });
1464 }
1465 }
1466 }
1467 },
1468 '2>', \$stderr,
1469 timeout => 30,
1470 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
1471 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1472 0 return;
1473 }
1474 0 ▶ if (shift->recv) {
Branch: 2 branches
BranchTrueFalseTotal
if ((shift())->recv) { } 0 0 0
elsif (scalar %zone) { } 0 0 0
1475 0 $self->Error($cb, 'Unable to get Enforcer key list');
1476 0 return;
1477 }
1478 elsif (scalar %zone) {
1479 0 $self->Successful($cb, { zone => [ values %zone ] });
1480 }
1481 else {
1482 0 $self->Successful($cb);
1483 }
1484 0 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
$q->{'verbose'} ? : 0 0 0
Condition0%0/3
exists $q->{'verbose'} && ($q->{'verbose'} ? '--verbose' : ())
!ll&&!rl&&r
000
MC/DC0%0/2
exists $q->{'verbose'} && ($q->{'verbose'} ? '--verbose' : ())
exists $q->{'verbose'} ($q->{'verbose'} ? '--verbose' : ())
Truth table0%0/3
A && B
A= exists $q->{'verbose'}B= ($q->{'verbose'} ? '--verbose' : ())
ABresult
0X0
100
111
1485 }
1486 }
1487  
1488 =head2 ReadEnforcerKeyExport
1489  
1490 =cut
1491  
1492 0 ▶sub ReadEnforcerKeyExport {
Subroutine ReadEnforcerKeyExport: not called CC=10 SCAR=47.0
Pod documented
1493 0 my ($self, $cb, $q) = @_;
1494  
1495 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
1496 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
1497 0 return;
1498 }
1499  
1500 0 ▶ if (exists $q->{zone}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $q->{'zone'}) { } 0 0 0
1501 0 ▶ my @zones = ref($q->{zone}) eq 'ARRAY' ? @{$q->{zone}} : ($q->{zone});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'zone'} eq 'ARRAY' ? : 0 0 0
1502 0 my @rr;
1503 0 weaken($self);
1504 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=14 SCAR=53.5
1505 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1506 0 undef($cmd_cb);
1507 0 return;
1508 }
1509 0 ▶ if (my $zone = shift(@zones)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $zone = shift @zones) { } 0 0 0
1510 0 my ($data, $stderr);
1511 Lim::Util::run_cmd
1512 [
1513 'ods-ksmutil', 'key', 'export',
1514 '--zone', $zone->{name},
1515 (exists $zone->{keystate} ? ('--keystate' => $zone->{keystate}) : (exists $q->{keystate} and $q->{keystate} ? ('--keystate', $q->{keystate}) : ())),
1516 (exists $zone->{keytype} ? ('--keytype' => $zone->{keytype}) : (exists $q->{keytype} and $q->{keytype} ? ('--keytype', $q->{keytype}) : ())),
1517 (exists $zone->{ds} ? ('--ds' => $zone->{ds}) : (exists $q->{ds} and $q->{ds} ? ('--ds') : ()))
1518 ],
1519 '<', '/dev/null',
1520 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
1521 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
1522 0 $data .= $_[0];
1523
1524 0 $cb->reset_timeout;
1525
1526 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
1527 0 my $line = $1;
1528
1529 0 $line =~ s/;.*//o;
1530
1531 0 ▶ if ($line =~ /^(\S+)\s+(\d+)\s+(\S+)\s+(\S+)\s+(.+)$/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^(\S+)\s+(\d+)\s+(\S+)\s+(\S+)\s+(.+)$/ou) 0 0 0
1532 0 push(@rr, {
1533 name => $1,
1534 ttl => $2,
1535 class => $3,
1536 type => $4,
1537 rdata => $5
1538 });
1539 }
1540 }
1541 }
1542 },
1543 '2>', \$stderr,
1544 timeout => 30,
1545 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1546 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1547 0 undef($cmd_cb);
1548 0 return;
1549 }
1550 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
1551 0 $self->Error($cb, 'Unable to get Enforcer key export for zone ', $zone->{name});
1552 0 undef($cmd_cb);
1553 0 return;
1554 }
1555 0 $cmd_cb->();
1556 0 ▶ };
Branch: 6 branches
BranchTrueFalseTotal
exists $zone->{'keystate'} ? : 0 0 0
$q->{'keystate'} ? : 0 0 0
exists $zone->{'keytype'} ? : 0 0 0
$q->{'keytype'} ? : 0 0 0
exists $zone->{'ds'} ? : 0 0 0
$q->{'ds'} ? : 0 0 0
Condition0%0/9
exists $q->{"keystate"} and $q->{"keystate"} ? ("--keystate", $q->{"keystate"}) : ()
!ll&&!rl&&r
000
exists $q->{"keytype"} and $q->{"keytype"} ? ("--keytype", $q->{"keytype"}) : ()
!ll&&!rl&&r
000
exists $q->{"ds"} and $q->{"ds"} ? "--ds" : ()
!ll&&!rl&&r
000
MC/DC0%0/2
exists $q->{"keystate"} and $q->{"keystate"} ? ("--keystate", $q->{"keystate"}) : ()
exists $q->{"keystate"} $q->{"keystate"} ? ("--keystate", $q->{"keystate"}) : ()
MC/DC0%0/2
exists $q->{"keytype"} and $q->{"keytype"} ? ("--keytype", $q->{"keytype"}) : ()
exists $q->{"keytype"} $q->{"keytype"} ? ("--keytype", $q->{"keytype"}) : ()
MC/DC0%0/2
exists $q->{"ds"} and $q->{"ds"} ? "--ds" : ()
exists $q->{"ds"} $q->{"ds"} ? "--ds" : ()
Truth table0%0/3
A and B
A= exists $q->{"keystate"}B= $q->{"keystate"} ? ("--keystate", $q->{"keystate"}) : ()
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= exists $q->{"keytype"}B= $q->{"keytype"} ? ("--keytype", $q->{"keytype"}) : ()
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= exists $q->{"ds"}B= $q->{"ds"} ? "--ds" : ()
ABresult
0X0
100
111
1557 }
1558 else {
1559 0 ▶ if (scalar @rr == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @rr == 1) { } 0 0 0
elsif (scalar @rr) { } 0 0 0
1560 0 $self->Successful($cb, { rr => $rr[0] });
1561 }
1562 elsif (scalar @rr) {
1563 0 $self->Successful($cb, { rr => \@rr });
1564 }
1565 else {
1566 0 $self->Successful($cb);
1567 }
1568 0 undef($cmd_cb);
1569 }
1570 0 };
1571 0 $cmd_cb->();
1572 }
1573 else {
1574 0 weaken($self);
1575 0 my ($data, $stderr, @rr);
1576 Lim::Util::run_cmd
1577 [
1578 'ods-ksmutil', 'key', 'export', '--all',
1579 (exists $q->{keystate} and $q->{keystate} ? ('--keystate', $q->{keystate}) : ()),
1580 (exists $q->{keytype} and $q->{keytype} ? ('--keytype', $q->{keytype}) : ()),
1581 (exists $q->{ds} and $q->{ds} ? ('--ds') : ())
1582 ],
1583 '<', '/dev/null',
1584 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
1585 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
1586 0 $data .= $_[0];
1587
1588 0 $cb->reset_timeout;
1589
1590 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
1591 0 my $line = $1;
1592
1593 0 $line =~ s/;.*//o;
1594
1595 0 ▶ if ($line =~ /^(\S+)\s+(\d+)\s+(\S+)\s+(\S+)\s+(.+)$/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^(\S+)\s+(\d+)\s+(\S+)\s+(\S+)\s+(.+)$/ou) 0 0 0
1596 0 push(@rr, {
1597 name => $1,
1598 ttl => $2,
1599 class => $3,
1600 type => $4,
1601 rdata => $5
1602 });
1603 }
1604 }
1605 }
1606 },
1607 '2>', \$stderr,
1608 timeout => 30,
1609 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
1610 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1611 0 return;
1612 }
1613 0 ▶ if (shift->recv) {
Branch: 3 branches
BranchTrueFalseTotal
if ((shift())->recv) { } 0 0 0
elsif (scalar @rr == 1) { } 0 0 0
elsif (scalar @rr) { } 0 0 0
1614 0 $self->Error($cb, 'Unable to get Enforcer key export');
1615 0 return;
1616 }
1617 elsif (scalar @rr == 1) {
1618 0 $self->Successful($cb, { rr => $rr[0] });
1619 }
1620 elsif (scalar @rr) {
1621 0 $self->Successful($cb, { rr => \@rr });
1622 }
1623 else {
1624 0 $self->Successful($cb);
1625 }
1626 0 ▶ };
Branch: 3 branches
BranchTrueFalseTotal
$q->{'keystate'} ? : 0 0 0
$q->{'keytype'} ? : 0 0 0
$q->{'ds'} ? : 0 0 0
Condition0%0/9
exists $q->{'keystate'} && ($q->{'keystate'} ? ('--keystate', $q->{'keystate'}) : ())
!ll&&!rl&&r
000
exists $q->{'keytype'} && ($q->{'keytype'} ? ('--keytype', $q->{'keytype'}) : ())
!ll&&!rl&&r
000
exists $q->{'ds'} && ($q->{'ds'} ? '--ds' : ())
!ll&&!rl&&r
000
MC/DC0%0/2
exists $q->{'keystate'} && ($q->{'keystate'} ? ('--keystate', $q->{'keystate'}) : ())
exists $q->{'keystate'} ($q->{'keystate'} ? ('--keystate', $q->{'keystate'}) : ())
MC/DC0%0/2
exists $q->{'keytype'} && ($q->{'keytype'} ? ('--keytype', $q->{'keytype'}) : ())
exists $q->{'keytype'} ($q->{'keytype'} ? ('--keytype', $q->{'keytype'}) : ())
MC/DC0%0/2
exists $q->{'ds'} && ($q->{'ds'} ? '--ds' : ())
exists $q->{'ds'} ($q->{'ds'} ? '--ds' : ())
Truth table0%0/3
A && B
A= exists $q->{'keystate'}B= ($q->{'keystate'} ? ('--keystate', $q->{'keystate'}) : ())
ABresult
0X0
100
111
Truth table0%0/3
A && B
A= exists $q->{'keytype'}B= ($q->{'keytype'} ? ('--keytype', $q->{'keytype'}) : ())
ABresult
0X0
100
111
Truth table0%0/3
A && B
A= exists $q->{'ds'}B= ($q->{'ds'} ? '--ds' : ())
ABresult
0X0
100
111
1627 }
1628 }
1629  
1630 =head2 CreateEnforcerKeyImport
1631  
1632 =cut
1633  
1634 0 ▶sub CreateEnforcerKeyImport {
Subroutine CreateEnforcerKeyImport: not called CC=3 SCAR=24.8
Pod documented
1635 0 my ($self, $cb, $q) = @_;
1636  
1637 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
1638 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
1639 0 return;
1640 }
1641  
1642 0 ▶ my @keys = ref($q->{key}) eq 'ARRAY' ? @{$q->{key}} : ($q->{key});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'key'} eq 'ARRAY' ? : 0 0 0
1643  
1644 0 weaken($self);
1645 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
1646 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1647 0 undef($cmd_cb);
1648 0 return;
1649 }
1650 0 ▶ if (my $key = shift(@keys)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $key = shift @keys) { } 0 0 0
1651 0 my ($stdout, $stderr);
1652 Lim::Util::run_cmd
1653 [
1654 'ods-ksmutil', 'key', 'import',
1655 '--zone', $key->{zone},
1656 '--cka_id', $key->{cka_id},
1657 '--repository', $key->{repository},
1658 '--bits', $key->{bits},
1659 '--algorithm', $key->{algorithm},
1660 '--keystate', $key->{keystate},
1661 '--keytype', $key->{keytype},
1662 '--time', $key->{time},
1663 (exists $key->{retire} ? ('--retire', $key->{retire}) : ())
1664 ],
1665 '<', '/dev/null',
1666 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1667 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
1668 0 $cb->reset_timeout;
1669 0 $stdout .= $_[0];
1670 }
1671 },
1672 '2>', \$stderr,
1673 timeout => 30,
1674 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1675 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1676 0 undef($cmd_cb);
1677 0 return;
1678 }
1679 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
1680 0 $self->Error($cb, 'Unable to import key cka id ', $key->{cka_id}, ' to Enforcer for zone ', $key->{zone});
1681 0 undef($cmd_cb);
1682 0 return;
1683 }
1684 0 $cmd_cb->();
1685 0 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
exists $key->{'retire'} ? : 0 0 0
1686 }
1687 else {
1688 0 $self->Successful($cb);
1689 0 undef($cmd_cb);
1690 }
1691 0 };
1692 0 $cmd_cb->();
1693 }
1694  
1695 =head2 UpdateEnforcerKeyRollover
1696  
1697 =cut
1698  
1699 0 ▶sub UpdateEnforcerKeyRollover {
Subroutine UpdateEnforcerKeyRollover: not called CC=8 SCAR=42.8
Pod documented
1700 0 my ($self, $cb, $q) = @_;
1701  
1702 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
1703 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
1704 0 return;
1705 }
1706  
1707 0 my @zones;
1708 0 ▶ if (exists $q->{zone}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $q->{"zone"}) 0 0 0
1709 0 ▶ @zones = ref($q->{zone}) eq 'ARRAY' ? @{$q->{zone}} : ($q->{zone});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'zone'} eq 'ARRAY' ? : 0 0 0
1710 }
1711
1712 0 my @policies;
1713 0 ▶ if (exists $q->{policy}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $q->{"policy"}) 0 0 0
1714 0 ▶ @policies = ref($q->{policy}) eq 'ARRAY' ? @{$q->{policy}} : ($q->{policy});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'policy'} eq 'ARRAY' ? : 0 0 0
1715 }
1716  
1717 0 ▶ if (scalar @zones or scalar @policies) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @zones or scalar @policies) 0 0 0
Condition0%0/2
scalar @zones or scalar @policies
l!l
00
MC/DC0%0/1
scalar @zones or scalar @policies
scalar @zones
Truth table0%0/2
A
A= scalar @zones
Aresult
11
00
1718 0 weaken($self);
1719 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
1720 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1721 0 undef($cmd_cb);
1722 0 return;
1723 }
1724 0 ▶ if (my $zone = shift(@zones)) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $zone = shift @zones) { } 0 0 0
elsif (my $policy = shift @policies) { } 0 0 0
1725 0 my ($stdout, $stderr);
1726 Lim::Util::run_cmd
1727 [
1728 'ods-ksmutil', 'key', 'rollover',
1729 '--zone', $zone->{name},
1730 (exists $zone->{keytype} ? ('--keytype' => $zone->{keytype}) : ())
1731 ],
1732 '<', '/dev/null',
1733 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1734 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
1735 0 $cb->reset_timeout;
1736 0 $stdout .= $_[0];
1737 }
1738 },
1739 '2>', \$stderr,
1740 timeout => 30,
1741 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1742 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1743 0 undef($cmd_cb);
1744 0 return;
1745 }
1746 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
1747 0 $self->Error($cb, 'Unable to issue Enforcer key rollover for zone ', $zone->{name});
1748 0 undef($cmd_cb);
1749 0 return;
1750 }
1751 0 $cmd_cb->();
1752 0 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
exists $zone->{'keytype'} ? : 0 0 0
1753 }
1754 elsif (my $policy = shift(@policies)) {
1755 0 my ($stdout, $stderr, $stdin);
1756 0 $stdin = "Y\015";
1757 Lim::Util::run_cmd
1758 [
1759 'ods-ksmutil', 'key', 'rollover',
1760 '--policy', $policy->{name},
1761 (exists $policy->{keytype} ? ('--keytype' => $policy->{keytype}) : ())
1762 ],
1763 '<', \$stdin,
1764 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1765 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
1766 0 $cb->reset_timeout;
1767 0 $stdout .= $_[0];
1768 }
1769 },
1770 '2>', \$stderr,
1771 timeout => 30,
1772 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1773 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1774 0 undef($cmd_cb);
1775 0 return;
1776 }
1777 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
1778 0 $self->Error($cb, 'Unable to issue Enforcer key rollover for policy ', $policy->{name});
1779 0 undef($cmd_cb);
1780 0 return;
1781 }
1782 0 $cmd_cb->();
1783 0 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
exists $policy->{'keytype'} ? : 0 0 0
1784 }
1785 else {
1786 0 $self->Successful($cb);
1787 0 undef($cmd_cb);
1788 }
1789 0 };
1790 0 $cmd_cb->();
1791 0 return;
1792 }
1793 0 $self->Successful($cb);
1794 }
1795  
1796 =head2 DeleteEnforcerKeyPurge
1797  
1798 =cut
1799  
1800 0 ▶sub DeleteEnforcerKeyPurge {
Subroutine DeleteEnforcerKeyPurge: not called CC=8 SCAR=42.8
Pod documented
1801 0 my ($self, $cb, $q) = @_;
1802  
1803 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
1804 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
1805 0 return;
1806 }
1807  
1808 0 my @zones;
1809 0 ▶ if (exists $q->{zone}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $q->{"zone"}) 0 0 0
1810 0 ▶ @zones = ref($q->{zone}) eq 'ARRAY' ? @{$q->{zone}} : ($q->{zone});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'zone'} eq 'ARRAY' ? : 0 0 0
1811 }
1812
1813 0 my @policies;
1814 0 ▶ if (exists $q->{policy}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $q->{"policy"}) 0 0 0
1815 0 ▶ @policies = ref($q->{policy}) eq 'ARRAY' ? @{$q->{policy}} : ($q->{policy});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'policy'} eq 'ARRAY' ? : 0 0 0
1816 }
1817  
1818 # TODO test parsing of output
1819  
1820 0 ▶ if (scalar @zones or scalar @policies) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @zones or scalar @policies) 0 0 0
Condition0%0/2
scalar @zones or scalar @policies
l!l
00
MC/DC0%0/1
scalar @zones or scalar @policies
scalar @zones
Truth table0%0/2
A
A= scalar @zones
Aresult
11
00
1821 0 my @keys;
1822 0 weaken($self);
1823 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
1824 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1825 0 undef($cmd_cb);
1826 0 return;
1827 }
1828 0 ▶ if (my $zone = shift(@zones)) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $zone = shift @zones) { } 0 0 0
elsif (my $policy = shift @policies) { } 0 0 0
1829 0 my ($data, $stderr);
1830 Lim::Util::run_cmd
1831 [
1832 'ods-ksmutil', 'key', 'purge',
1833 '--zone', $zone->{name}
1834 ],
1835 '<', '/dev/null',
1836 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
1837 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
1838 0 $data .= $_[0];
1839
1840 0 $cb->reset_timeout;
1841
1842 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
1843 0 my $line = $1;
1844
1845 0 ▶ if ($line =~ /^Key\s+remove\s+successful:\s+(\S+)$/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^Key\s+remove\s+successful:\s+(\S+)$/ou) 0 0 0
1846 0 push(@keys, {
1847 cka_id => $1
1848 });
1849 }
1850 }
1851 }
1852 },
1853 '2>', \$stderr,
1854 timeout => 30,
1855 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1856 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1857 0 undef($cmd_cb);
1858 0 return;
1859 }
1860 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
1861 0 $self->Error($cb, 'Unable to issue Enforcer key rollover for zone ', $zone->{name});
1862 0 undef($cmd_cb);
1863 0 return;
1864 }
1865 0 $cmd_cb->();
1866 0 };
1867 }
1868 elsif (my $policy = shift(@policies)) {
1869 0 my ($data, $stderr);
1870 Lim::Util::run_cmd
1871 [
1872 'ods-ksmutil', 'key', 'purge',
1873 '--policy', $policy->{name}
1874 ],
1875 '<', '/dev/null',
1876 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
1877 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
1878 0 $data .= $_[0];
1879
1880 0 $cb->reset_timeout;
1881
1882 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
1883 0 my $line = $1;
1884
1885 0 ▶ if ($line =~ /^Key\s+remove\s+successful:\s+(\S+)$/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^Key\s+remove\s+successful:\s+(\S+)$/ou) 0 0 0
1886 0 push(@keys, {
1887 cka_id => $1
1888 });
1889 }
1890 }
1891 }
1892 },
1893 '2>', \$stderr,
1894 timeout => 30,
1895 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1896 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1897 0 undef($cmd_cb);
1898 0 return;
1899 }
1900 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
1901 0 $self->Error($cb, 'Unable to issue Enforcer key rollover for policy ', $policy->{name});
1902 0 undef($cmd_cb);
1903 0 return;
1904 }
1905 0 $cmd_cb->();
1906 0 };
1907 }
1908 else {
1909 0 ▶ if (scalar @keys == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @keys == 1) { } 0 0 0
elsif (scalar @keys) { } 0 0 0
1910 0 $self->Successful($cb, { key => $keys[0] });
1911 }
1912 elsif (scalar @keys) {
1913 0 $self->Successful($cb, { key => \@keys });
1914 }
1915 else {
1916 0 $self->Successful($cb);
1917 }
1918 0 undef($cmd_cb);
1919 }
1920 0 };
1921 0 $cmd_cb->();
1922 0 return;
1923 }
1924 0 $self->Successful($cb);
1925 }
1926  
1927 =head2 CreateEnforcerKeyGenerate
1928  
1929 =cut
1930  
1931 0 ▶sub CreateEnforcerKeyGenerate {
Subroutine CreateEnforcerKeyGenerate: not called CC=3 SCAR=24.8
Pod documented
1932 0 my ($self, $cb, $q) = @_;
1933  
1934 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
1935 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
1936 0 return;
1937 }
1938  
1939 0 ▶ my @policies = ref($q->{policy}) eq 'ARRAY' ? @{$q->{policy}} : ($q->{policy});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'policy'} eq 'ARRAY' ? : 0 0 0
1940 0 my @keys;
1941 0 weaken($self);
1942 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
1943 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1944 0 undef($cmd_cb);
1945 0 return;
1946 }
1947 0 ▶ if (my $policy = shift(@policies)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $policy = shift @policies) { } 0 0 0
1948 0 my ($data, $stderr);
1949 Lim::Util::run_cmd
1950 [
1951 'ods-ksmutil', 'key', 'generate',
1952 '--policy', $policy->{name},
1953 '--interval', $policy->{interval},
1954 ],
1955 '<', '/dev/null',
1956 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
1957 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
1958 0 $data .= $_[0];
1959
1960 0 $cb->reset_timeout;
1961
1962 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
1963 0 my $line = $1;
1964
1965 0 ▶ if ($line =~ /^Created\s+(\S+)\s+size:\s+(\d+),\s+alg:\s+(\d+)\s+with\s+id:\s+(\S+)\s+in\s+repository:\s+(.*)\s+and\s+database\.$/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^Created\s+(\S+)\s+size:\s+(\d+),\s+alg:\s+(\d+)\s+with\s+id:\s+(\S+)\s+in\s+repository:\s+(.*)\s+and\s+database\.$/ou) 0 0 0
1966 0 push(@keys, {
1967 keytype => $1,
1968 bits => $2,
1969 algorithm => $3,
1970 cka_id => $4,
1971 repository => $5
1972 });
1973 }
1974 }
1975 }
1976 },
1977 '2>', \$stderr,
1978 timeout => 30,
1979 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1980 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
1981 0 undef($cmd_cb);
1982 0 return;
1983 }
1984 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
1985 0 $self->Error($cb, 'Unable to generate keys for policy ', $policy->{name});
1986 0 undef($cmd_cb);
1987 0 return;
1988 }
1989 0 $cmd_cb->();
1990 0 };
1991 }
1992 else {
1993 0 ▶ if (scalar @keys == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @keys == 1) { } 0 0 0
elsif (scalar @keys) { } 0 0 0
1994 0 $self->Successful($cb, { key => $keys[0] });
1995 }
1996 elsif (scalar @keys) {
1997 0 $self->Successful($cb, { key => \@keys });
1998 }
1999 else {
2000 0 $self->Successful($cb);
2001 }
2002 0 undef($cmd_cb);
2003 }
2004 0 };
2005 0 $cmd_cb->();
2006 }
2007  
2008 =head2 UpdateEnforcerKeyKskRetire
2009  
2010 =cut
2011  
2012 0 ▶sub UpdateEnforcerKeyKskRetire {
Subroutine UpdateEnforcerKeyKskRetire: not called CC=3 SCAR=24.8
Pod documented
2013 0 my ($self, $cb, $q) = @_;
2014  
2015 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
2016 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
2017 0 return;
2018 }
2019  
2020 0 ▶ my @zones = ref($q->{zone}) eq 'ARRAY' ? @{$q->{zone}} : ($q->{zone});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'zone'} eq 'ARRAY' ? : 0 0 0
2021 0 weaken($self);
2022 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
2023 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2024 0 undef($cmd_cb);
2025 0 return;
2026 }
2027 0 ▶ if (my $zone = shift(@zones)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $zone = shift @zones) { } 0 0 0
2028 0 my ($stdout, $stderr, $stdin);
2029 0 $stdin = "Y\015";
2030 Lim::Util::run_cmd
2031 [
2032 'ods-ksmutil', 'key', 'ksk-retire',
2033 '--zone', $zone->{name},
2034 (exists $zone->{cka_id} ? ('--cka_id' => $zone->{cka_id}) : ()),
2035 (exists $zone->{keytag} ? ('--keytag' => $zone->{keytag}) : ())
2036 ],
2037 '<', \$stdin,
2038 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2039 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
2040 0 $cb->reset_timeout;
2041 0 $stdout .= $_[0];
2042 }
2043 },
2044 '2>', \$stderr,
2045 timeout => 30,
2046 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=7 SCAR=40.3
2047 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2048 0 undef($cmd_cb);
2049 0 return;
2050 }
2051 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
2052 0 my $error;
2053 0 ▶ if ($stdout =~ /((?:Error:|No keys in)[^,]+)/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stdout =~ /((?:Error:|No keys in)[^,]+)/ou) 0 0 0
2054 0 $error = $1;
2055 0 $error =~ s/^Error:\s+//o;
2056 }
2057 $self->Error($cb, 'Unable to retire KSK keys for zone ', $zone->{name},
2058 (exists $zone->{cka_id} ? ' cka_id '.$zone->{cka_id} : ''),
2059 0 ▶ (exists $zone->{keytag} ? ' keytag '.$zone->{keytag} : ''),
Branch: 3 branches
BranchTrueFalseTotal
exists $zone->{'cka_id'} ? : 0 0 0
exists $zone->{'keytag'} ? : 0 0 0
defined $error ? : 0 0 0
2060 ' error: ', (defined $error ? $error : 'unknown')
2061 );
2062 0 undef($cmd_cb);
2063 0 return;
2064 }
2065 0 $cmd_cb->();
2066 0 ▶ };
Branch: 2 branches
BranchTrueFalseTotal
exists $zone->{'cka_id'} ? : 0 0 0
exists $zone->{'keytag'} ? : 0 0 0
2067 }
2068 else {
2069 0 $self->Successful($cb);
2070 0 undef($cmd_cb);
2071 }
2072 0 };
2073 0 $cmd_cb->();
2074 }
2075  
2076 =head2 UpdateEnforcerKeyDsSeen
2077  
2078 =cut
2079  
2080 0 ▶sub UpdateEnforcerKeyDsSeen {
Subroutine UpdateEnforcerKeyDsSeen: not called CC=3 SCAR=24.8
Pod documented
2081 0 my ($self, $cb, $q) = @_;
2082  
2083 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
2084 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
2085 0 return;
2086 }
2087  
2088 0 ▶ my @zones = ref($q->{zone}) eq 'ARRAY' ? @{$q->{zone}} : ($q->{zone});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'zone'} eq 'ARRAY' ? : 0 0 0
2089  
2090 0 weaken($self);
2091 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=7 SCAR=40.3
2092 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2093 0 undef($cmd_cb);
2094 0 return;
2095 }
2096 0 ▶ if (my $zone = shift(@zones)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $zone = shift @zones) { } 0 0 0
2097 0 my ($stdout, $stderr);
2098 Lim::Util::run_cmd
2099 [
2100 'ods-ksmutil', 'key', 'ds-seen',
2101 '--zone', $zone->{name},
2102 (exists $zone->{cka_id} ? ('--cka_id', $zone->{cka_id}) : ()),
2103 (exists $zone->{keytag} ? ('--keytag', $zone->{keytag}) : ()),
2104 (exists $zone->{no_retire} and $zone->{no_retire} ? ('--no-retire') : ())
2105 ],
2106 '<', '/dev/null',
2107 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2108 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
2109 0 $cb->reset_timeout;
2110 0 $stdout .= $_[0];
2111 }
2112 },
2113 '2>', \$stderr,
2114 timeout => 30,
2115 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
2116 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2117 0 undef($cmd_cb);
2118 0 return;
2119 }
2120 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
2121 $self->Error($cb, 'Unable to set key as ds seen for zone ', $zone->{name},
2122 (exists $zone->{cka_id} ? ' cka_id '.$zone->{cka_id} : ''),
2123 0 ▶ (exists $zone->{keytag} ? ' keytag '.$zone->{keytag} : '')
Branch: 2 branches
BranchTrueFalseTotal
exists $zone->{'cka_id'} ? : 0 0 0
exists $zone->{'keytag'} ? : 0 0 0
2124 );
2125 0 undef($cmd_cb);
2126 0 return;
2127 }
2128 0 $cmd_cb->();
2129 0 ▶ };
Branch: 3 branches
BranchTrueFalseTotal
exists $zone->{'cka_id'} ? : 0 0 0
exists $zone->{'keytag'} ? : 0 0 0
$zone->{'no_retire'} ? : 0 0 0
Condition0%0/3
exists $zone->{'no_retire'} && ($zone->{'no_retire'} ? '--no-retire' : ())
!ll&&!rl&&r
000
MC/DC0%0/2
exists $zone->{'no_retire'} && ($zone->{'no_retire'} ? '--no-retire' : ())
exists $zone->{'no_retire'} ($zone->{'no_retire'} ? '--no-retire' : ())
Truth table0%0/3
A && B
A= exists $zone->{'no_retire'}B= ($zone->{'no_retire'} ? '--no-retire' : ())
ABresult
0X0
100
111
2130 }
2131 else {
2132 0 $self->Successful($cb);
2133 0 undef($cmd_cb);
2134 }
2135 0 };
2136 0 $cmd_cb->();
2137 }
2138  
2139 =head2 UpdateEnforcerBackupPrepare
2140  
2141 =cut
2142  
2143 0 ▶sub UpdateEnforcerBackupPrepare {
Subroutine UpdateEnforcerBackupPrepare: not called CC=4 SCAR=30.0
Pod documented
2144 0 my ($self, $cb, $q) = @_;
2145  
2146 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
2147 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
2148 0 return;
2149 }
2150  
2151 0 ▶ if (exists $q->{repository}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $q->{'repository'}) { } 0 0 0
2152 0 ▶ my @repositories = ref($q->{repository}) eq 'ARRAY' ? @{$q->{repository}} : ($q->{repository});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'repository'} eq 'ARRAY' ? : 0 0 0
2153 0 weaken($self);
2154 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2155 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2156 0 undef($cmd_cb);
2157 0 return;
2158 }
2159 0 ▶ if (my $repository = shift(@repositories)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $repository = shift @repositories) { } 0 0 0
2160 0 my ($stdout, $stderr);
2161 Lim::Util::run_cmd
2162 [
2163 'ods-ksmutil', 'backup', 'prepare',
2164 '--repository', $repository->{name}
2165 ],
2166 '<', '/dev/null',
2167 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2168 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
2169 0 $cb->reset_timeout;
2170 0 $stdout .= $_[0];
2171 }
2172 },
2173 '2>', \$stderr,
2174 timeout => 30,
2175 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2176 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2177 0 undef($cmd_cb);
2178 0 return;
2179 }
2180 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
2181 0 $self->Error($cb, 'Unable to prepare backup of repository ', $repository->{name});
2182 0 undef($cmd_cb);
2183 0 return;
2184 }
2185 0 $cmd_cb->();
2186 0 };
2187 }
2188 else {
2189 0 $self->Successful($cb);
2190 0 undef($cmd_cb);
2191 }
2192 0 };
2193 0 $cmd_cb->();
2194 }
2195 else {
2196 0 weaken($self);
2197 0 my ($stdout, $stderr);
2198 Lim::Util::run_cmd
2199 [
2200 'ods-ksmutil', 'backup', 'prepare'
2201 ],
2202 '<', '/dev/null',
2203 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2204 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
2205 0 $cb->reset_timeout;
2206 0 $stdout .= $_[0];
2207 }
2208 },
2209 '2>', \$stderr,
2210 timeout => 30,
2211 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2212 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2213 0 return;
2214 }
2215 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
2216 0 $self->Error($cb, 'Unable to prepare backup');
2217 0 return;
2218 }
2219 0 $self->Successful($cb);
2220 0 };
2221 }
2222 }
2223  
2224 =head2 UpdateEnforcerBackupCommit
2225  
2226 =cut
2227  
2228 0 ▶sub UpdateEnforcerBackupCommit {
Subroutine UpdateEnforcerBackupCommit: not called CC=4 SCAR=30.0
Pod documented
2229 0 my ($self, $cb, $q) = @_;
2230  
2231 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
2232 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
2233 0 return;
2234 }
2235  
2236 0 ▶ if (exists $q->{repository}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $q->{'repository'}) { } 0 0 0
2237 0 ▶ my @repositories = ref($q->{repository}) eq 'ARRAY' ? @{$q->{repository}} : ($q->{repository});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'repository'} eq 'ARRAY' ? : 0 0 0
2238 0 weaken($self);
2239 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2240 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2241 0 undef($cmd_cb);
2242 0 return;
2243 }
2244 0 ▶ if (my $repository = shift(@repositories)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $repository = shift @repositories) { } 0 0 0
2245 0 my ($stdout, $stderr);
2246 Lim::Util::run_cmd
2247 [
2248 'ods-ksmutil', 'backup', 'commit',
2249 '--repository', $repository->{name}
2250 ],
2251 '<', '/dev/null',
2252 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2253 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
2254 0 $cb->reset_timeout;
2255 0 $stdout .= $_[0];
2256 }
2257 },
2258 '2>', \$stderr,
2259 timeout => 30,
2260 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2261 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2262 0 undef($cmd_cb);
2263 0 return;
2264 }
2265 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
2266 0 $self->Error($cb, 'Unable to commit backup of repository ', $repository->{name});
2267 0 undef($cmd_cb);
2268 0 return;
2269 }
2270 0 $cmd_cb->();
2271 0 };
2272 }
2273 else {
2274 0 $self->Successful($cb);
2275 0 undef($cmd_cb);
2276 }
2277 0 };
2278 0 $cmd_cb->();
2279 }
2280 else {
2281 0 weaken($self);
2282 0 my ($stdout, $stderr);
2283 Lim::Util::run_cmd
2284 [
2285 'ods-ksmutil', 'backup', 'commit'
2286 ],
2287 '<', '/dev/null',
2288 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2289 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
2290 0 $cb->reset_timeout;
2291 0 $stdout .= $_[0];
2292 }
2293 },
2294 '2>', \$stderr,
2295 timeout => 30,
2296 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2297 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2298 0 return;
2299 }
2300 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
2301 0 $self->Error($cb, 'Unable to commit backup');
2302 0 return;
2303 }
2304 0 $self->Successful($cb);
2305 0 };
2306 }
2307 }
2308  
2309 =head2 UpdateEnforcerBackupRollback
2310  
2311 =cut
2312  
2313 0 ▶sub UpdateEnforcerBackupRollback {
Subroutine UpdateEnforcerBackupRollback: not called CC=4 SCAR=30.0
Pod documented
2314 0 my ($self, $cb, $q) = @_;
2315  
2316 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
2317 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
2318 0 return;
2319 }
2320  
2321 0 ▶ if (exists $q->{repository}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $q->{'repository'}) { } 0 0 0
2322 0 ▶ my @repositories = ref($q->{repository}) eq 'ARRAY' ? @{$q->{repository}} : ($q->{repository});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'repository'} eq 'ARRAY' ? : 0 0 0
2323 0 weaken($self);
2324 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2325 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2326 0 undef($cmd_cb);
2327 0 return;
2328 }
2329 0 ▶ if (my $repository = shift(@repositories)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $repository = shift @repositories) { } 0 0 0
2330 0 my ($stdout, $stderr);
2331 Lim::Util::run_cmd
2332 [
2333 'ods-ksmutil', 'backup', 'rollback',
2334 '--repository', $repository->{name}
2335 ],
2336 '<', '/dev/null',
2337 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2338 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
2339 0 $cb->reset_timeout;
2340 0 $stdout .= $_[0];
2341 }
2342 },
2343 '2>', \$stderr,
2344 timeout => 30,
2345 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2346 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2347 0 undef($cmd_cb);
2348 0 return;
2349 }
2350 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
2351 0 $self->Error($cb, 'Unable to rollback backup of repository ', $repository->{name});
2352 0 undef($cmd_cb);
2353 0 return;
2354 }
2355 0 $cmd_cb->();
2356 0 };
2357 }
2358 else {
2359 0 $self->Successful($cb);
2360 0 undef($cmd_cb);
2361 }
2362 0 };
2363 0 $cmd_cb->();
2364 }
2365 else {
2366 0 weaken($self);
2367 0 my ($stdout, $stderr);
2368 Lim::Util::run_cmd
2369 [
2370 'ods-ksmutil', 'backup', 'rollback'
2371 ],
2372 '<', '/dev/null',
2373 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2374 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
2375 0 $cb->reset_timeout;
2376 0 $stdout .= $_[0];
2377 }
2378 },
2379 '2>', \$stderr,
2380 timeout => 30,
2381 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2382 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2383 0 return;
2384 }
2385 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
2386 0 $self->Error($cb, 'Unable to rollback backup');
2387 0 return;
2388 }
2389 0 $self->Successful($cb);
2390 0 };
2391 }
2392 }
2393  
2394 =head2 UpdateEnforcerBackupDone
2395  
2396 =cut
2397  
2398 0 ▶sub UpdateEnforcerBackupDone {
Subroutine UpdateEnforcerBackupDone: not called CC=4 SCAR=30.0
Pod documented
2399 0 my ($self, $cb, $q) = @_;
2400  
2401 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
2402 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
2403 0 return;
2404 }
2405  
2406 0 ▶ if (exists $q->{repository}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $q->{'repository'}) { } 0 0 0
2407 0 ▶ my @repositories = ref($q->{repository}) eq 'ARRAY' ? @{$q->{repository}} : ($q->{repository});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'repository'} eq 'ARRAY' ? : 0 0 0
2408 0 weaken($self);
2409 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2410 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2411 0 undef($cmd_cb);
2412 0 return;
2413 }
2414 0 ▶ if (my $repository = shift(@repositories)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $repository = shift @repositories) { } 0 0 0
2415 0 my ($stdout, $stderr);
2416 Lim::Util::run_cmd
2417 [
2418 'ods-ksmutil', 'backup', 'done',
2419 '--repository', $repository->{name}
2420 ],
2421 '<', '/dev/null',
2422 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2423 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
2424 0 $cb->reset_timeout;
2425 0 $stdout .= $_[0];
2426 }
2427 },
2428 '2>', \$stderr,
2429 timeout => 30,
2430 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2431 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2432 0 undef($cmd_cb);
2433 0 return;
2434 }
2435 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
2436 0 $self->Error($cb, 'Unable to take backup of repository ', $repository->{name});
2437 0 undef($cmd_cb);
2438 0 return;
2439 }
2440 0 $cmd_cb->();
2441 0 };
2442 }
2443 else {
2444 0 $self->Successful($cb);
2445 0 undef($cmd_cb);
2446 }
2447 0 };
2448 0 $cmd_cb->();
2449 }
2450 else {
2451 0 weaken($self);
2452 0 my ($stdout, $stderr);
2453 Lim::Util::run_cmd
2454 [
2455 'ods-ksmutil', 'backup', 'done'
2456 ],
2457 '<', '/dev/null',
2458 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2459 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
2460 0 $cb->reset_timeout;
2461 0 $stdout .= $_[0];
2462 }
2463 },
2464 '2>', \$stderr,
2465 timeout => 30,
2466 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2467 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2468 0 return;
2469 }
2470 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
2471 0 $self->Error($cb, 'Unable to take backup');
2472 0 return;
2473 }
2474 0 $self->Successful($cb);
2475 0 };
2476 }
2477 }
2478  
2479 =head2 ReadEnforcerBackupList
2480  
2481 =cut
2482  
2483 0 ▶sub ReadEnforcerBackupList {
Subroutine ReadEnforcerBackupList: not called CC=4 SCAR=30.0
Pod documented
2484 0 my ($self, $cb, $q) = @_;
2485  
2486 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
2487 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
2488 0 return;
2489 }
2490  
2491 0 ▶ if (exists $q->{repository}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $q->{'repository'}) { } 0 0 0
2492 0 ▶ my @respositories = ref($q->{repository}) eq 'ARRAY' ? @{$q->{repository}} : ($q->{repository});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'repository'} eq 'ARRAY' ? : 0 0 0
2493 0 my %repository;
2494 0 weaken($self);
2495 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
2496 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2497 0 undef($cmd_cb);
2498 0 return;
2499 }
2500 0 ▶ if (my $repository = shift(@respositories)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $repository = shift @respositories) { } 0 0 0
2501 0 my ($data, $stderr);
2502 Lim::Util::run_cmd
2503 [
2504 'ods-ksmutil', 'backup', 'list',
2505 '--repository', $repository->{name}
2506 ],
2507 '<', '/dev/null',
2508 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=9 SCAR=45.0
2509 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
2510 0 $data .= $_[0];
2511
2512 0 $cb->reset_timeout;
2513
2514 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
2515 0 my $line = $1;
2516
2517 0 ▶ if ($line =~ /^Repository\s+(.+)\s+has\s+unbacked\s+up\s+keys/o) {
Branch: 3 branches
BranchTrueFalseTotal
if ($line =~ /^Repository\s+(.+)\s+has\s+unbacked\s+up\s+keys/ou) { } 0 0 0
elsif ($line =~ /^Repository\s+(.+)\s+has\s+keys\s+prepared/ou) { } 0 0 0
elsif ($line =~ /^(\S+\s+\S+)\s+(\S+)$/ou) { } 0 0 0
2518 0 ▶ unless (exists $repository{$1}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $repository{$1}) 0 0 0
2519 0 $repository{$1} = {
2520 name => $1
2521 };
2522 }
2523 0 $repository{$1}->{unbacked_up_keys} = 1;
2524 }
2525 elsif ($line =~ /^Repository\s+(.+)\s+has\s+keys\s+prepared/o) {
2526 0 ▶ unless (exists $repository{$1}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $repository{$1}) 0 0 0
2527 0 $repository{$1} = {
2528 name => $1
2529 };
2530 }
2531 0 $repository{$1}->{prepared_keys} = 1;
2532 }
2533 elsif ($line =~ /^(\S+\s+\S+)\s+(\S+)$/o) {
2534 0 ▶ unless (exists $repository{$2}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $repository{$2}) 0 0 0
2535 0 $repository{$2} = {
2536 name => $2
2537 };
2538 }
2539 0 push(@{$repository{$2}->{backup}}, {
2540 date => $1
2541 });
2542 }
2543 }
2544 }
2545 },
2546 '2>', \$stderr,
2547 timeout => 30,
2548 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2549 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2550 0 undef($cmd_cb);
2551 0 return;
2552 }
2553 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
2554 0 $self->Error($cb, 'Unable to get Enforcer backup list for repository ', $repository->{name});
2555 0 undef($cmd_cb);
2556 0 return;
2557 }
2558 0 $cmd_cb->();
2559 0 };
2560 }
2561 else {
2562 0 ▶ if (scalar %repository) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar %repository) { } 0 0 0
2563 0 $self->Successful($cb, { repository => [ values %repository ] });
2564 }
2565 else {
2566 0 $self->Successful($cb);
2567 }
2568 0 undef($cmd_cb);
2569 }
2570 0 };
2571 0 $cmd_cb->();
2572 }
2573 else {
2574 0 weaken($self);
2575 0 my ($data, $stderr, %repository);
2576 Lim::Util::run_cmd
2577 [
2578 'ods-ksmutil', 'backup', 'list'
2579 ],
2580 '<', '/dev/null',
2581 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=9 SCAR=45.0
2582 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
2583 0 $data .= $_[0];
2584
2585 0 $cb->reset_timeout;
2586
2587 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
2588 0 my $line = $1;
2589
2590 0 ▶ if ($line =~ /^Repository\s+(.+)\s+has\s+unbacked\s+up\s+keys/o) {
Branch: 3 branches
BranchTrueFalseTotal
if ($line =~ /^Repository\s+(.+)\s+has\s+unbacked\s+up\s+keys/ou) { } 0 0 0
elsif ($line =~ /^Repository\s+(.+)\s+has\s+keys\s+prepared/ou) { } 0 0 0
elsif ($line =~ /^(\S+\s+\S+)\s+(\S+)$/ou) { } 0 0 0
2591 0 ▶ unless (exists $repository{$1}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $repository{$1}) 0 0 0
2592 0 $repository{$1} = {
2593 name => $1
2594 };
2595 }
2596 0 $repository{$1}->{unbacked_up_keys} = 1;
2597 }
2598 elsif ($line =~ /^Repository\s+(.+)\s+has\s+keys\s+prepared/o) {
2599 0 ▶ unless (exists $repository{$1}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $repository{$1}) 0 0 0
2600 0 $repository{$1} = {
2601 name => $1
2602 };
2603 }
2604 0 $repository{$1}->{prepared_keys} = 1;
2605 }
2606 elsif ($line =~ /^(\S+\s+\S+)\s+(\S+)$/o) {
2607 0 ▶ unless (exists $repository{$2}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $repository{$2}) 0 0 0
2608 0 $repository{$2} = {
2609 name => $2
2610 };
2611 }
2612 0 push(@{$repository{$2}->{backup}}, {
2613 date => $1
2614 });
2615 }
2616 }
2617 }
2618 },
2619 '2>', \$stderr,
2620 timeout => 30,
2621 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
2622 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2623 0 return;
2624 }
2625 0 ▶ if (shift->recv) {
Branch: 2 branches
BranchTrueFalseTotal
if ((shift())->recv) { } 0 0 0
elsif (scalar %repository) { } 0 0 0
2626 0 $self->Error($cb, 'Unable to get Enforcer backup list');
2627 0 return;
2628 }
2629 elsif (scalar %repository) {
2630 0 $self->Successful($cb, { repository => [ values %repository ] });
2631 }
2632 else {
2633 0 $self->Successful($cb);
2634 }
2635 0 };
2636 }
2637 }
2638  
2639 =head2 ReadEnforcerRolloverList
2640  
2641 =cut
2642  
2643 0 ▶sub ReadEnforcerRolloverList {
Subroutine ReadEnforcerRolloverList: not called CC=4 SCAR=30.0
Pod documented
2644 0 my ($self, $cb, $q) = @_;
2645
2646 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
2647 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
2648 0 return;
2649 }
2650  
2651 0 ▶ if (exists $q->{zone}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $q->{'zone'}) { } 0 0 0
2652 0 ▶ my @zones = ref($q->{zone}) eq 'ARRAY' ? @{$q->{zone}} : ($q->{zone});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'zone'} eq 'ARRAY' ? : 0 0 0
2653 0 my @rollovers;
2654 0 weaken($self);
2655 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
2656 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2657 0 undef($cmd_cb);
2658 0 return;
2659 }
2660 0 ▶ if (my $zone = shift(@zones)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $zone = shift @zones) { } 0 0 0
2661 0 my ($data, $stderr);
2662 0 my $skip = 2;
2663 Lim::Util::run_cmd
2664 [
2665 'ods-ksmutil', 'rollover', 'list',
2666 '--zone', $zone->{name}
2667 ],
2668 '<', '/dev/null',
2669 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
2670 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
2671 0 $data .= $_[0];
2672
2673 0 $cb->reset_timeout;
2674
2675 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
2676 0 my $line = $1;
2677
2678 0 ▶ if ($skip) {
Branch: 1 branch
BranchTrueFalseTotal
if ($skip) 0 0 0
2679 0 $skip--;
2680 0 next;
2681 }
2682
2683 0 ▶ if ($line =~ /^(\S+)\s+(\S+)\s+(\S+\s+\S+)$/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^(\S+)\s+(\S+)\s+(\S+\s+\S+)$/ou) 0 0 0
2684 0 push(@rollovers, {
2685 name => $1,
2686 keytype => $2,
2687 rollover_expected => $3
2688 });
2689 }
2690 }
2691 }
2692 },
2693 '2>', \$stderr,
2694 timeout => 30,
2695 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2696 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2697 0 undef($cmd_cb);
2698 0 return;
2699 }
2700 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
2701 0 $self->Error($cb, 'Unable to get Enforcer rollover list for zone ', $zone->{name});
2702 0 undef($cmd_cb);
2703 0 return;
2704 }
2705 0 $cmd_cb->();
2706 0 };
2707 }
2708 else {
2709 0 ▶ if (scalar @rollovers == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @rollovers == 1) { } 0 0 0
elsif (scalar @rollovers) { } 0 0 0
2710 0 $self->Successful($cb, { zone => $rollovers[0] });
2711 }
2712 elsif (scalar @rollovers) {
2713 0 $self->Successful($cb, { zone => \@rollovers });
2714 }
2715 else {
2716 0 $self->Successful($cb);
2717 }
2718 0 undef($cmd_cb);
2719 }
2720 0 };
2721 0 $cmd_cb->();
2722 }
2723 else {
2724 0 weaken($self);
2725 0 my ($data, $stderr, @rollovers);
2726 0 my $skip = 2;
2727 Lim::Util::run_cmd
2728 [
2729 'ods-ksmutil', 'rollover', 'list'
2730 ],
2731 '<', '/dev/null',
2732 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
2733 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
2734 0 $data .= $_[0];
2735
2736 0 $cb->reset_timeout;
2737
2738 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
2739 0 my $line = $1;
2740
2741 0 ▶ if ($skip) {
Branch: 1 branch
BranchTrueFalseTotal
if ($skip) 0 0 0
2742 0 $skip--;
2743 0 next;
2744 }
2745
2746 0 ▶ if ($line =~ /^(\S+)\s+(\S+)\s+(\S+\s+\S+)$/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^(\S+)\s+(\S+)\s+(\S+\s+\S+)$/ou) 0 0 0
2747 0 push(@rollovers, {
2748 name => $1,
2749 keytype => $2,
2750 rollover_expected => $3
2751 });
2752 }
2753 }
2754 }
2755 },
2756 '2>', \$stderr,
2757 timeout => 30,
2758 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
2759 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2760 0 return;
2761 }
2762 0 ▶ if (shift->recv) {
Branch: 3 branches
BranchTrueFalseTotal
if ((shift())->recv) { } 0 0 0
elsif (scalar @rollovers == 1) { } 0 0 0
elsif (scalar @rollovers) { } 0 0 0
2763 0 $self->Error($cb, 'Unable to get Enforcer rollover list');
2764 0 return;
2765 }
2766 elsif (scalar @rollovers == 1) {
2767 0 $self->Successful($cb, { zone => $rollovers[0] });
2768 }
2769 elsif (scalar @rollovers) {
2770 0 $self->Successful($cb, { zone => \@rollovers });
2771 }
2772 else {
2773 0 $self->Successful($cb);
2774 }
2775 0 };
2776 }
2777 }
2778  
2779 =head2 CreateEnforcerDatabaseBackup
2780  
2781 =cut
2782  
2783 0 ▶sub CreateEnforcerDatabaseBackup {
Subroutine CreateEnforcerDatabaseBackup: not called CC=2 SCAR=17.9
Pod documented
2784 0 my ($self, $cb) = @_;
2785  
2786 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
2787 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
2788 0 return;
2789 }
2790  
2791 # TODO is there a way to send the database as base64 incrementaly to avoid hogning memory?
2792
2793 0 weaken($self);
2794 0 my ($stdout, $stderr);
2795 Lim::Util::run_cmd [ 'ods-ksmutil', 'database', 'backup' ],
2796 '<', '/dev/null',
2797 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2798 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
2799 0 $cb->reset_timeout;
2800 0 $stdout .= $_[0];
2801 }
2802 },
2803 '2>', \$stderr,
2804 timeout => 30,
2805 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2806 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2807 0 return;
2808 }
2809 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
2810 0 $self->Error($cb, 'Unable to backup Enforcer database');
2811 0 return;
2812 }
2813 0 $self->Successful($cb);
2814 0 };
2815 }
2816  
2817 =head2 ReadEnforcerZonelistExport
2818  
2819 =cut
2820  
2821 0 ▶sub ReadEnforcerZonelistExport {
Subroutine ReadEnforcerZonelistExport: not called CC=2 SCAR=17.9
Pod documented
2822 0 my ($self, $cb) = @_;
2823  
2824 0 ▶ unless ($self->{bin}->{ksmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"ksmutil"}) 0 0 0
2825 0 $self->Error($cb, 'No "ods-ksmutil" executable found or unsupported version, unable to continue');
2826 0 return;
2827 }
2828  
2829 # TODO is there a way to send the database as base64 incrementaly to avoid hogning memory?
2830
2831 0 weaken($self);
2832 0 my ($stdout, $stderr);
2833 Lim::Util::run_cmd [ 'ods-ksmutil', 'zonelist', 'export' ],
2834 '<', '/dev/null',
2835 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2836 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
2837 0 $cb->reset_timeout;
2838 0 $stdout .= $_[0];
2839 }
2840 },
2841 '2>', \$stderr,
2842 timeout => 30,
2843 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2844 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2845 0 return;
2846 }
2847 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
2848 0 $self->Error($cb, 'Unable to export zonelist');
2849 0 return;
2850 }
2851 0 $self->Successful($cb, { zonelist => $stdout });
2852 0 };
2853 }
2854  
2855 =head2 ReadSigner
2856  
2857 =cut
2858  
2859 0 ▶sub ReadSigner {
Subroutine ReadSigner: not called CC=1 SCAR=6.9
Pod documented
2860 0 my ($self, $cb) = @_;
2861  
2862 0 $self->Successful($cb);
2863 }
2864  
2865 =head2 UpdateSigner
2866  
2867 =cut
2868  
2869 0 ▶sub UpdateSigner {
Subroutine UpdateSigner: not called CC=1 SCAR=6.9
Pod documented
2870 0 my ($self, $cb) = @_;
2871  
2872 0 $self->Successful($cb);
2873 }
2874  
2875 =head2 ReadSignerZones
2876  
2877 =cut
2878  
2879 0 ▶sub ReadSignerZones {
Subroutine ReadSignerZones: not called CC=2 SCAR=17.9
Pod documented
2880 0 my ($self, $cb) = @_;
2881  
2882 0 ▶ unless ($self->{bin}->{signer}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"signer"}) 0 0 0
2883 0 $self->Error($cb, 'No "ods-signer" executable found or unsupported version, unable to continue');
2884 0 return;
2885 }
2886  
2887 0 weaken($self);
2888 0 my ($data, $stderr, @zones);
2889 Lim::Util::run_cmd [ 'ods-signer', 'zones' ],
2890 '<', '/dev/null',
2891 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
2892 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
2893 0 $data .= $_[0];
2894
2895 0 $cb->reset_timeout;
2896
2897 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
2898 0 my $line = $1;
2899
2900 0 ▶ if ($line =~ /^-\s+(\S+)$/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^-\s+(\S+)$/ou) 0 0 0
2901 0 push(@zones, {
2902 name => $1
2903 });
2904 }
2905 }
2906 }
2907 },
2908 '2>', \$stderr,
2909 timeout => 30,
2910 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
2911 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2912 0 return;
2913 }
2914 0 ▶ if (shift->recv) {
Branch: 3 branches
BranchTrueFalseTotal
if ((shift())->recv) { } 0 0 0
elsif (scalar @zones == 1) { } 0 0 0
elsif (scalar @zones) { } 0 0 0
2915 0 $self->Error($cb, 'Unable to get Signer zones');
2916 0 return;
2917 }
2918 elsif (scalar @zones == 1) {
2919 0 $self->Successful($cb, { zone => $zones[0] });
2920 }
2921 elsif (scalar @zones) {
2922 0 $self->Successful($cb, { zone => \@zones });
2923 }
2924 else {
2925 0 $self->Successful($cb);
2926 }
2927 0 };
2928 }
2929  
2930 =head2 UpdateSignerSign
2931  
2932 =cut
2933  
2934 0 ▶sub UpdateSignerSign {
Subroutine UpdateSignerSign: not called CC=4 SCAR=30.0
Pod documented
2935 0 my ($self, $cb, $q) = @_;
2936
2937 0 ▶ unless ($self->{bin}->{signer}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"signer"}) 0 0 0
2938 0 $self->Error($cb, 'No "ods-signer" executable found or unsupported version, unable to continue');
2939 0 return;
2940 }
2941  
2942 0 ▶ if (exists $q->{zone}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $q->{'zone'}) { } 0 0 0
2943 0 ▶ my @zones = ref($q->{zone}) eq 'ARRAY' ? @{$q->{zone}} : ($q->{zone});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'zone'} eq 'ARRAY' ? : 0 0 0
2944 0 weaken($self);
2945 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2946 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2947 0 undef($cmd_cb);
2948 0 return;
2949 }
2950 0 ▶ if (my $zone = shift(@zones)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $zone = shift @zones) { } 0 0 0
2951 0 my ($stdout, $stderr);
2952 Lim::Util::run_cmd
2953 [
2954 'ods-signer', 'sign', $zone->{name}
2955 ],
2956 '<', '/dev/null',
2957 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2958 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
2959 0 $cb->reset_timeout;
2960 0 $stdout .= $_[0];
2961 }
2962 },
2963 '2>', \$stderr,
2964 timeout => 30,
2965 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2966 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
2967 0 undef($cmd_cb);
2968 0 return;
2969 }
2970 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
2971 0 $self->Error($cb, 'Unable to issue sign to Signer for zone ', $zone->{name});
2972 0 undef($cmd_cb);
2973 0 return;
2974 }
2975 0 $cmd_cb->();
2976 0 };
2977 }
2978 else {
2979 0 $self->Successful($cb);
2980 0 undef($cmd_cb);
2981 }
2982 0 };
2983 0 $cmd_cb->();
2984 }
2985 else {
2986 0 weaken($self);
2987 0 my ($stdout, $stderr);
2988 Lim::Util::run_cmd
2989 [
2990 'ods-signer', 'sign', '--all'
2991 ],
2992 '<', '/dev/null',
2993 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2994 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
2995 0 $cb->reset_timeout;
2996 0 $stdout .= $_[0];
2997 }
2998 },
2999 '2>', \$stderr,
3000 timeout => 30,
3001 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
3002 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3003 0 return;
3004 }
3005 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
3006 0 $self->Error($cb, 'Unable to issue sign to Signer for all zones');
3007 0 return;
3008 }
3009 0 $self->Successful($cb);
3010 0 };
3011 }
3012 }
3013  
3014 =head2 UpdateSignerClear
3015  
3016 =cut
3017  
3018 0 ▶sub UpdateSignerClear {
Subroutine UpdateSignerClear: not called CC=3 SCAR=24.8
Pod documented
3019 0 my ($self, $cb, $q) = @_;
3020
3021 0 ▶ unless ($self->{bin}->{signer}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"signer"}) 0 0 0
3022 0 $self->Error($cb, 'No "ods-signer" executable found or unsupported version, unable to continue');
3023 0 return;
3024 }
3025  
3026 0 ▶ my @zones = ref($q->{zone}) eq 'ARRAY' ? @{$q->{zone}} : ($q->{zone});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'zone'} eq 'ARRAY' ? : 0 0 0
3027 0 weaken($self);
3028 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
3029 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3030 0 undef($cmd_cb);
3031 0 return;
3032 }
3033 0 ▶ if (my $zone = shift(@zones)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $zone = shift @zones) { } 0 0 0
3034 0 my ($stdout, $stderr);
3035 Lim::Util::run_cmd
3036 [
3037 'ods-signer', 'clear', $zone->{name}
3038 ],
3039 '<', '/dev/null',
3040 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
3041 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
3042 0 $cb->reset_timeout;
3043 0 $stdout .= $_[0];
3044 }
3045 },
3046 '2>', \$stderr,
3047 timeout => 30,
3048 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
3049 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3050 0 undef($cmd_cb);
3051 0 return;
3052 }
3053 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
3054 0 $self->Error($cb, 'Unable to issue clear to Signer for zone ', $zone->{name});
3055 0 undef($cmd_cb);
3056 0 return;
3057 }
3058 0 $cmd_cb->();
3059 0 };
3060 }
3061 else {
3062 0 $self->Successful($cb);
3063 0 undef($cmd_cb);
3064 }
3065 0 };
3066 0 $cmd_cb->();
3067 }
3068  
3069 =head2 ReadSignerQueue
3070  
3071 =cut
3072  
3073 0 ▶sub ReadSignerQueue {
Subroutine ReadSignerQueue: not called CC=2 SCAR=17.9
Pod documented
3074 0 my ($self, $cb) = @_;
3075  
3076 0 ▶ unless ($self->{bin}->{signer}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"signer"}) 0 0 0
3077 0 $self->Error($cb, 'No "ods-signer" executable found or unsupported version, unable to continue');
3078 0 return;
3079 }
3080  
3081 0 weaken($self);
3082 0 my ($data, $stderr, @task, $now);
3083 Lim::Util::run_cmd [ 'ods-signer', 'queue' ],
3084 '<', '/dev/null',
3085 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
3086 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
3087 0 $data .= $_[0];
3088
3089 0 $cb->reset_timeout;
3090
3091 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
3092 0 my $line = $1;
3093
3094 0 ▶ if ($line =~ /^It\s+is\s+now\s+(.+)$/o) {
Branch: 2 branches
BranchTrueFalseTotal
if ($line =~ /^It\s+is\s+now\s+(.+)$/ou) { } 0 0 0
elsif ($line =~ /On\s+(.+)\s+I\s+will\s+\[([^\]]+)\]\s+zone\s+(.+)/ou) { } 0 0 0
3095 0 $now = $1;
3096 }
3097 elsif ($line =~ /On\s+(.+)\s+I\s+will\s+\[([^\]]+)\]\s+zone\s+(.+)/o) {
3098 0 push(@task, {
3099 type => $2,
3100 date => $1,
3101 zone => $3
3102 });
3103 }
3104 }
3105 }
3106 },
3107 '2>', \$stderr,
3108 timeout => 30,
3109 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
3110 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3111 0 return;
3112 }
3113 0 ▶ if (shift->recv) {
Branch: 3 branches
BranchTrueFalseTotal
if ((shift())->recv) { } 0 0 0
elsif (scalar @task == 1) { } 0 0 0
elsif (scalar @task) { } 0 0 0
3114 0 $self->Error($cb, 'Unable to get Signer queue');
3115 0 return;
3116 }
3117 elsif (scalar @task == 1) {
3118 0 $self->Successful($cb, { now => $now, task => $task[0] });
3119 }
3120 elsif (scalar @task) {
3121 0 $self->Successful($cb, { now => $now, task => \@task });
3122 }
3123 else {
3124 0 $self->Successful($cb);
3125 }
3126 0 };
3127 }
3128  
3129 =head2 UpdateSignerFlush
3130  
3131 =cut
3132  
3133 0 ▶sub UpdateSignerFlush {
Subroutine UpdateSignerFlush: not called CC=2 SCAR=17.9
Pod documented
3134 0 my ($self, $cb) = @_;
3135  
3136 0 ▶ unless ($self->{bin}->{signer}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"signer"}) 0 0 0
3137 0 $self->Error($cb, 'No "ods-signer" executable found or unsupported version, unable to continue');
3138 0 return;
3139 }
3140  
3141 0 weaken($self);
3142 0 my ($stdout, $stderr);
3143 Lim::Util::run_cmd [ 'ods-signer', 'flush' ],
3144 '<', '/dev/null',
3145 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
3146 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
3147 0 $cb->reset_timeout;
3148 0 $stdout .= $_[0];
3149 }
3150 },
3151 '2>', \$stderr,
3152 timeout => 30,
3153 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
3154 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3155 0 return;
3156 }
3157 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
3158 0 $self->Error($cb, 'Unable to issue flush to Signer');
3159 0 return;
3160 }
3161 0 $self->Successful($cb);
3162 0 };
3163 }
3164  
3165 =head2 UpdateSignerUpdate
3166  
3167 =cut
3168  
3169 0 ▶sub UpdateSignerUpdate {
Subroutine UpdateSignerUpdate: not called CC=4 SCAR=30.0
Pod documented
3170 0 my ($self, $cb, $q) = @_;
3171
3172 0 ▶ unless ($self->{bin}->{signer}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"signer"}) 0 0 0
3173 0 $self->Error($cb, 'No "ods-signer" executable found or unsupported version, unable to continue');
3174 0 return;
3175 }
3176  
3177 0 ▶ if (exists $q->{zone}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $q->{'zone'}) { } 0 0 0
3178 0 ▶ my @zones = ref($q->{zone}) eq 'ARRAY' ? @{$q->{zone}} : ($q->{zone});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'zone'} eq 'ARRAY' ? : 0 0 0
3179 0 weaken($self);
3180 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
3181 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3182 0 undef($cmd_cb);
3183 0 return;
3184 }
3185 0 ▶ if (my $zone = shift(@zones)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $zone = shift @zones) { } 0 0 0
3186 0 my ($stdout, $stderr);
3187 Lim::Util::run_cmd
3188 [
3189 'ods-signer', 'update', $zone->{name}
3190 ],
3191 '<', '/dev/null',
3192 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
3193 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
3194 0 $cb->reset_timeout;
3195 0 $stdout .= $_[0];
3196 }
3197 },
3198 '2>', \$stderr,
3199 timeout => 30,
3200 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
3201 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3202 0 undef($cmd_cb);
3203 0 return;
3204 }
3205 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
3206 0 $self->Error($cb, 'Unable to issue update to Signer for zone ', $zone->{name});
3207 0 undef($cmd_cb);
3208 0 return;
3209 }
3210 0 $cmd_cb->();
3211 0 };
3212 }
3213 else {
3214 0 $self->Successful($cb);
3215 0 undef($cmd_cb);
3216 }
3217 0 };
3218 0 $cmd_cb->();
3219 }
3220 else {
3221 0 weaken($self);
3222 0 my ($stdout, $stderr);
3223 Lim::Util::run_cmd
3224 [
3225 'ods-signer', 'update', '--all'
3226 ],
3227 '<', '/dev/null',
3228 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
3229 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
3230 0 $cb->reset_timeout;
3231 0 $stdout .= $_[0];
3232 }
3233 },
3234 '2>', \$stderr,
3235 timeout => 30,
3236 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
3237 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3238 0 return;
3239 }
3240 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
3241 0 $self->Error($cb, 'Unable to issue update to Signer for all zones');
3242 0 return;
3243 }
3244 0 $self->Successful($cb);
3245 0 };
3246 }
3247 }
3248  
3249 =head2 ReadSignerRunning
3250  
3251 =cut
3252  
3253 0 ▶sub ReadSignerRunning {
Subroutine ReadSignerRunning: not called CC=2 SCAR=17.9
Pod documented
3254 0 my ($self, $cb) = @_;
3255  
3256 0 ▶ unless ($self->{bin}->{signer}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"signer"}) 0 0 0
3257 0 $self->Error($cb, 'No "ods-signer" executable found or unsupported version, unable to continue');
3258 0 return;
3259 }
3260  
3261 0 weaken($self);
3262 0 my ($stdout, $stderr);
3263 Lim::Util::run_cmd [ 'ods-signer', 'running' ],
3264 '<', '/dev/null',
3265 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
3266 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
3267 0 $cb->reset_timeout;
3268 0 $stdout .= $_[0];
3269 }
3270 },
3271 '2>', \$stderr,
3272 timeout => 30,
3273 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
3274 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3275 0 return;
3276 }
3277 0 ▶ if ($stderr =~ /Engine\s+not\s+running/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stderr =~ /Engine\s+not\s+running/ou) 0 0 0
3278 0 $self->Successful($cb, { running => 0 });
3279 0 return;
3280 }
3281 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
3282 0 $self->Error($cb, 'Unable to issue running to Signer');
3283 0 return;
3284 }
3285 0 $self->Successful($cb, { running => 1 });
3286 0 };
3287 }
3288  
3289 =head2 UpdateSignerReload
3290  
3291 =cut
3292  
3293 0 ▶sub UpdateSignerReload {
Subroutine UpdateSignerReload: not called CC=2 SCAR=17.9
Pod documented
3294 0 my ($self, $cb) = @_;
3295  
3296 0 ▶ unless ($self->{bin}->{signer}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"signer"}) 0 0 0
3297 0 $self->Error($cb, 'No "ods-signer" executable found or unsupported version, unable to continue');
3298 0 return;
3299 }
3300  
3301 0 weaken($self);
3302 0 my ($stdout, $stderr);
3303 Lim::Util::run_cmd [ 'ods-signer', 'reload' ],
3304 '<', '/dev/null',
3305 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
3306 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
3307 0 $cb->reset_timeout;
3308 0 $stdout .= $_[0];
3309 }
3310 },
3311 '2>', \$stderr,
3312 timeout => 30,
3313 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
3314 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3315 0 return;
3316 }
3317 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
3318 0 $self->Error($cb, 'Unable to issue reload to Signer');
3319 0 return;
3320 }
3321 0 $self->Successful($cb);
3322 0 };
3323 }
3324  
3325 =head2 UpdateSignerVerbosity
3326  
3327 =cut
3328  
3329 0 ▶sub UpdateSignerVerbosity {
Subroutine UpdateSignerVerbosity: not called CC=2 SCAR=17.9
Pod documented
3330 0 my ($self, $cb, $q) = @_;
3331  
3332 0 ▶ unless ($self->{bin}->{signer}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"signer"}) 0 0 0
3333 0 $self->Error($cb, 'No "ods-signer" executable found or unsupported version, unable to continue');
3334 0 return;
3335 }
3336  
3337 0 weaken($self);
3338 0 my ($stdout, $stderr);
3339 Lim::Util::run_cmd [ 'ods-signer', 'verbosity', $q->{verbosity} ],
3340 '<', '/dev/null',
3341 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
3342 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
3343 0 $cb->reset_timeout;
3344 0 $stdout .= $_[0];
3345 }
3346 },
3347 '2>', \$stderr,
3348 timeout => 30,
3349 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
3350 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3351 0 return;
3352 }
3353 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
3354 0 $self->Error($cb, 'Unable to issue verbosity ', $q->{verbosity}, ' to Signer');
3355 0 return;
3356 }
3357 0 $self->Successful($cb);
3358 0 };
3359 }
3360  
3361 =head2 CreateHsm
3362  
3363 =cut
3364  
3365 0 ▶sub CreateHsm {
Subroutine CreateHsm: not called CC=1 SCAR=6.9
Pod documented
3366 0 my ($self, $cb) = @_;
3367  
3368 0 $self->Successful($cb);
3369 }
3370  
3371 =head2 ReadHsm
3372  
3373 =cut
3374  
3375 0 ▶sub ReadHsm {
Subroutine ReadHsm: not called CC=1 SCAR=6.9
Pod documented
3376 0 my ($self, $cb) = @_;
3377  
3378 0 $self->Successful($cb);
3379 }
3380  
3381 =head2 DeleteHsm
3382  
3383 =cut
3384  
3385 0 ▶sub DeleteHsm {
Subroutine DeleteHsm: not called CC=1 SCAR=6.9
Pod documented
3386 0 my ($self, $cb) = @_;
3387  
3388 0 $self->Successful($cb);
3389 }
3390  
3391 =head2 ReadHsmList
3392  
3393 =cut
3394  
3395 0 ▶sub ReadHsmList {
Subroutine ReadHsmList: not called CC=4 SCAR=30.0
Pod documented
3396 0 my ($self, $cb, $q) = @_;
3397
3398 0 ▶ unless ($self->{bin}->{hsmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"hsmutil"}) 0 0 0
3399 0 $self->Error($cb, 'No "ods-hsmutil" executable found or unsupported version, unable to continue');
3400 0 return;
3401 }
3402  
3403 0 ▶ if (exists $q->{repository}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $q->{'repository'}) { } 0 0 0
3404 0 ▶ my @repositories = ref($q->{repository}) eq 'ARRAY' ? @{$q->{repository}} : ($q->{repository});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'repository'} eq 'ARRAY' ? : 0 0 0
3405 0 my @keys;
3406 0 weaken($self);
3407 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
3408 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3409 0 undef($cmd_cb);
3410 0 return;
3411 }
3412 0 ▶ if (my $repository = shift(@repositories)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $repository = shift @repositories) { } 0 0 0
3413 0 my ($data, $stderr);
3414 0 my $skip = 5;
3415 Lim::Util::run_cmd
3416 [
3417 'ods-hsmutil', 'list', $repository->{name}
3418 ],
3419 '<', '/dev/null',
3420 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
3421 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
3422 0 $data .= $_[0];
3423
3424 0 $cb->reset_timeout;
3425
3426 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
3427 0 my $line = $1;
3428
3429 0 ▶ if ($skip) {
Branch: 1 branch
BranchTrueFalseTotal
if ($skip) 0 0 0
3430 0 $skip--;
3431 0 next;
3432 }
3433
3434 0 ▶ if ($line =~ /^(\S+)\s+(\S+)\s+(\w+)\/(\d+)\s*$/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ m[^(\S+)\s+(\S+)\s+(\w+)/(\d+)\s*$]ou) 0 0 0
3435 0 push(@keys, {
3436 repository => $1,
3437 id => $2,
3438 keytype => $3,
3439 keysize => $4
3440 });
3441 }
3442 }
3443 }
3444 },
3445 '2>', \$stderr,
3446 timeout => 30,
3447 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
3448 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3449 0 undef($cmd_cb);
3450 0 return;
3451 }
3452 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
3453 0 $self->Error($cb, 'Unable to get hsm key list for repository ', $repository->{name});
3454 0 undef($cmd_cb);
3455 0 return;
3456 }
3457 0 $cmd_cb->();
3458 0 };
3459 }
3460 else {
3461 0 ▶ if (scalar @keys == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @keys == 1) { } 0 0 0
elsif (scalar @keys) { } 0 0 0
3462 0 $self->Successful($cb, { key => $keys[0] });
3463 }
3464 elsif (scalar @keys) {
3465 0 $self->Successful($cb, { key => \@keys });
3466 }
3467 else {
3468 0 $self->Successful($cb);
3469 }
3470 0 undef($cmd_cb);
3471 }
3472 0 };
3473 0 $cmd_cb->();
3474 }
3475 else {
3476 0 weaken($self);
3477 0 my ($data, $stderr, @keys);
3478 0 my $skip = 5;
3479 Lim::Util::run_cmd
3480 [
3481 'ods-hsmutil', 'list'
3482 ],
3483 '<', '/dev/null',
3484 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
3485 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
3486 0 $data .= $_[0];
3487
3488 0 $cb->reset_timeout;
3489
3490 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
3491 0 my $line = $1;
3492
3493 0 ▶ if ($skip) {
Branch: 1 branch
BranchTrueFalseTotal
if ($skip) 0 0 0
3494 0 $skip--;
3495 0 next;
3496 }
3497
3498 0 ▶ if ($line =~ /^(\S+)\s+(\S+)\s+(\w+)\/(\d+)\s*$/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ m[^(\S+)\s+(\S+)\s+(\w+)/(\d+)\s*$]ou) 0 0 0
3499 0 push(@keys, {
3500 repository => $1,
3501 id => $2,
3502 keytype => $3,
3503 keysize => $4
3504 });
3505 }
3506 }
3507 }
3508 },
3509 '2>', \$stderr,
3510 timeout => 30,
3511 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
3512 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3513 0 return;
3514 }
3515 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
3516 0 $self->Error($cb, 'Unable to get hsm key list');
3517 0 return;
3518 }
3519 0 ▶ if (scalar @keys == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @keys == 1) { } 0 0 0
elsif (scalar @keys) { } 0 0 0
3520 0 $self->Successful($cb, { key => $keys[0] });
3521 }
3522 elsif (scalar @keys) {
3523 0 $self->Successful($cb, { key => \@keys });
3524 }
3525 else {
3526 0 $self->Successful($cb);
3527 }
3528 0 };
3529 }
3530 }
3531  
3532 =head2 CreateHsmGenerate
3533  
3534 =cut
3535  
3536 0 ▶sub CreateHsmGenerate {
Subroutine CreateHsmGenerate: not called CC=3 SCAR=24.8
Pod documented
3537 0 my ($self, $cb, $q) = @_;
3538
3539 0 ▶ unless ($self->{bin}->{hsmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"hsmutil"}) 0 0 0
3540 0 $self->Error($cb, 'No "ods-hsmutil" executable found or unsupported version, unable to continue');
3541 0 return;
3542 }
3543  
3544 0 ▶ my @keys = ref($q->{key}) eq 'ARRAY' ? @{$q->{key}} : ($q->{key});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'key'} eq 'ARRAY' ? : 0 0 0
3545 0 my @generated;
3546 0 weaken($self);
3547 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
3548 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3549 0 undef($cmd_cb);
3550 0 return;
3551 }
3552 0 ▶ if (my $key = shift(@keys)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $key = shift @keys) { } 0 0 0
3553 0 my ($data, $stderr, $bits, $keytype, $repository, $id);
3554 Lim::Util::run_cmd
3555 [
3556 'ods-hsmutil', 'generate', $key->{repository}, 'rsa', $key->{keysize}
3557 ],
3558 '<', '/dev/null',
3559 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
3560 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
3561 0 $data .= $_[0];
3562
3563 0 $cb->reset_timeout;
3564
3565 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
3566 0 my $line = $1;
3567
3568 0 ▶ if ($line =~ /^Generating\s+(\d+)\s+bit\s+(\w+)\s+key\s+in\s+repository:\s+(.+)$/o) {
Branch: 2 branches
BranchTrueFalseTotal
if ($line =~ /^Generating\s+(\d+)\s+bit\s+(\w+)\s+key\s+in\s+repository:\s+(.+)$/ou) { } 0 0 0
elsif ($line =~ /^Key\s+generation\s+successful:\s+(\S+)$/ou) { } 0 0 0
3569 0 ($bits, $keytype, $repository) = ($1, $2, $3);
3570 }
3571 elsif ($line =~ /^Key\s+generation\s+successful:\s+(\S+)$/o) {
3572 0 $id = $1;
3573 }
3574 }
3575 }
3576 },
3577 '2>', \$stderr,
3578 timeout => 30,
3579 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
3580 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3581 0 undef($cmd_cb);
3582 0 return;
3583 }
3584 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
3585 0 $self->Error($cb, 'Unable to generate hsm key in repository ', $key->{name});
3586 0 undef($cmd_cb);
3587 0 return;
3588 }
3589 0 push(@generated, {
3590 repository => $repository,
3591 id => $id,
3592 keytype => $keytype,
3593 keysize => $bits
3594 });
3595 0 $cmd_cb->();
3596 0 };
3597 }
3598 else {
3599 0 ▶ if (scalar @generated == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @generated == 1) { } 0 0 0
elsif (scalar @generated) { } 0 0 0
3600 0 $self->Successful($cb, { key => $generated[0] });
3601 }
3602 elsif (scalar @generated) {
3603 0 $self->Successful($cb, { key => \@generated });
3604 }
3605 else {
3606 0 $self->Successful($cb);
3607 }
3608 0 undef($cmd_cb);
3609 }
3610 0 };
3611 0 $cmd_cb->();
3612 }
3613  
3614 =head2 DeleteHsmRemove
3615  
3616 =cut
3617  
3618 0 ▶sub DeleteHsmRemove {
Subroutine DeleteHsmRemove: not called CC=3 SCAR=24.8
Pod documented
3619 0 my ($self, $cb, $q) = @_;
3620
3621 0 ▶ unless ($self->{bin}->{hsmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"hsmutil"}) 0 0 0
3622 0 $self->Error($cb, 'No "ods-hsmutil" executable found or unsupported version, unable to continue');
3623 0 return;
3624 }
3625  
3626 0 ▶ my @keys = ref($q->{key}) eq 'ARRAY' ? @{$q->{key}} : ($q->{key});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'key'} eq 'ARRAY' ? : 0 0 0
3627 0 weaken($self);
3628 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
3629 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3630 0 undef($cmd_cb);
3631 0 return;
3632 }
3633 0 ▶ if (my $key = shift(@keys)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $key = shift @keys) { } 0 0 0
3634 0 my ($stdout, $stderr);
3635 Lim::Util::run_cmd
3636 [
3637 'ods-hsmutil', 'remove', $key->{id}
3638 ],
3639 '<', '/dev/null',
3640 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
3641 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
3642 0 $cb->reset_timeout;
3643 0 $stdout .= $_[0];
3644 }
3645 },
3646 '2>', \$stderr,
3647 timeout => 30,
3648 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
3649 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3650 0 undef($cmd_cb);
3651 0 return;
3652 }
3653 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
3654 0 $self->Error($cb, 'Unable to remove hsm key id ', $key->{id});
3655 0 undef($cmd_cb);
3656 0 return;
3657 }
3658 0 $cmd_cb->();
3659 0 };
3660 }
3661 else {
3662 0 $self->Successful($cb);
3663 0 undef($cmd_cb);
3664 }
3665 0 };
3666 0 $cmd_cb->();
3667 }
3668  
3669 =head2 DeleteHsmPurge
3670  
3671 =cut
3672  
3673 0 ▶sub DeleteHsmPurge {
Subroutine DeleteHsmPurge: not called CC=3 SCAR=24.8
Pod documented
3674 0 my ($self, $cb, $q) = @_;
3675
3676 0 ▶ unless ($self->{bin}->{hsmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"hsmutil"}) 0 0 0
3677 0 $self->Error($cb, 'No "ods-hsmutil" executable found or unsupported version, unable to continue');
3678 0 return;
3679 }
3680  
3681 0 ▶ my @repositories = ref($q->{repository}) eq 'ARRAY' ? @{$q->{repository}} : ($q->{repository});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'repository'} eq 'ARRAY' ? : 0 0 0
3682 0 weaken($self);
3683 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
3684 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3685 0 undef($cmd_cb);
3686 0 return;
3687 }
3688 0 ▶ if (my $repository = shift(@repositories)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $repository = shift @repositories) { } 0 0 0
3689 0 my ($stdout, $stderr, $stdin);
3690 0 $stdin = "YES\015";
3691 Lim::Util::run_cmd
3692 [
3693 'ods-hsmutil', 'purge', $repository->{name}
3694 ],
3695 '<', \$stdin,
3696 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
3697 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
3698 0 $cb->reset_timeout;
3699 0 $stdout .= $_[0];
3700 }
3701 },
3702 '2>', \$stderr,
3703 timeout => 30,
3704 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
3705 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3706 0 undef($cmd_cb);
3707 0 return;
3708 }
3709 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
3710 0 $self->Error($cb, 'Unable to purge hsm repository ', $repository->{name});
3711 0 undef($cmd_cb);
3712 0 return;
3713 }
3714 0 $cmd_cb->();
3715 0 };
3716 }
3717 else {
3718 0 $self->Successful($cb);
3719 0 undef($cmd_cb);
3720 }
3721 0 };
3722 0 $cmd_cb->();
3723 }
3724  
3725 =head2 CreateHsmDnskey
3726  
3727 =cut
3728  
3729 0 ▶sub CreateHsmDnskey {
Subroutine CreateHsmDnskey: not called CC=3 SCAR=24.8
Pod documented
3730 0 my ($self, $cb, $q) = @_;
3731
3732 0 ▶ unless ($self->{bin}->{hsmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"hsmutil"}) 0 0 0
3733 0 $self->Error($cb, 'No "ods-hsmutil" executable found or unsupported version, unable to continue');
3734 0 return;
3735 }
3736  
3737 0 ▶ my @keys = ref($q->{key}) eq 'ARRAY' ? @{$q->{key}} : ($q->{key});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'key'} eq 'ARRAY' ? : 0 0 0
3738 0 my @dnskeys;
3739 0 weaken($self);
3740 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
3741 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3742 0 undef($cmd_cb);
3743 0 return;
3744 }
3745 0 ▶ if (my $key = shift(@keys)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $key = shift @keys) { } 0 0 0
3746 0 my ($stdout, $stderr);
3747 Lim::Util::run_cmd
3748 [
3749 'ods-hsmutil', 'dnskey', $key->{id}, $key->{name}
3750 ],
3751 '<', '/dev/null',
3752 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
3753 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
3754 0 $cb->reset_timeout;
3755 0 $stdout .= $_[0];
3756 }
3757 },
3758 '2>', \$stderr,
3759 timeout => 30,
3760 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
3761 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3762 0 undef($cmd_cb);
3763 0 return;
3764 }
3765 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
3766 0 $self->Error($cb, 'Unable to remove hsm key id ', $key->{id});
3767 0 undef($cmd_cb);
3768 0 return;
3769 }
3770 0 $stdout =~ s/[\r\n].*//o;
3771 push(@dnskeys, {
3772 id => $key->{id},
3773 name => $key->{name},
3774 0 rr => $stdout
3775 });
3776 0 $cmd_cb->();
3777 0 };
3778 }
3779 else {
3780 0 ▶ if (scalar @dnskeys == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @dnskeys == 1) { } 0 0 0
elsif (scalar @dnskeys) { } 0 0 0
3781 0 $self->Successful($cb, { key => $dnskeys[0] });
3782 }
3783 elsif (scalar @dnskeys) {
3784 0 $self->Successful($cb, { key => \@dnskeys });
3785 }
3786 else {
3787 0 $self->Successful($cb);
3788 }
3789 0 undef($cmd_cb);
3790 }
3791 0 };
3792 0 $cmd_cb->();
3793 }
3794  
3795 =head2 ReadHsmTest
3796  
3797 =cut
3798  
3799 0 ▶sub ReadHsmTest {
Subroutine ReadHsmTest: not called CC=3 SCAR=24.8
Pod documented
3800 0 my ($self, $cb, $q) = @_;
3801
3802 0 ▶ unless ($self->{bin}->{hsmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"hsmutil"}) 0 0 0
3803 0 $self->Error($cb, 'No "ods-hsmutil" executable found or unsupported version, unable to continue');
3804 0 return;
3805 }
3806  
3807 0 ▶ my @repositories = ref($q->{repository}) eq 'ARRAY' ? @{$q->{repository}} : ($q->{repository});
Branch: 1 branch
BranchTrueFalseTotal
ref $q->{'repository'} eq 'ARRAY' ? : 0 0 0
3808 0 weaken($self);
3809 0 ▶ my $cmd_cb; $cmd_cb = sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
3810 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3811 0 undef($cmd_cb);
3812 0 return;
3813 }
3814 0 ▶ if (my $repository = shift(@repositories)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $repository = shift @repositories) { } 0 0 0
3815 0 my ($stdout, $stderr);
3816 Lim::Util::run_cmd
3817 [
3818 'ods-hsmutil', 'test', $repository->{name}
3819 ],
3820 '<', '/dev/null',
3821 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
3822 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
3823 0 $cb->reset_timeout;
3824 0 $stdout .= $_[0];
3825 }
3826 },
3827 '2>', \$stderr,
3828 timeout => 30,
3829 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
3830 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3831 0 undef($cmd_cb);
3832 0 return;
3833 }
3834 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
3835 0 $self->Error($cb, 'Unable to test hsm repository ', $repository->{name});
3836 0 undef($cmd_cb);
3837 0 return;
3838 }
3839 0 $cmd_cb->();
3840 0 };
3841 }
3842 else {
3843 0 $self->Successful($cb);
3844 0 undef($cmd_cb);
3845 }
3846 0 };
3847 0 $cmd_cb->();
3848 }
3849  
3850 =head2 ReadHsmInfo
3851  
3852 =cut
3853  
3854 0 ▶sub ReadHsmInfo {
Subroutine ReadHsmInfo: not called CC=2 SCAR=17.9
Pod documented
3855 0 my ($self, $cb, $q) = @_;
3856
3857 0 ▶ unless ($self->{bin}->{hsmutil}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"bin"}{"hsmutil"}) 0 0 0
3858 0 $self->Error($cb, 'No "ods-hsmutil" executable found or unsupported version, unable to continue');
3859 0 return;
3860 }
3861  
3862 0 my @repositories;
3863 0 weaken($self);
3864 0 my ($data, $stderr, $repository);
3865 Lim::Util::run_cmd
3866 [
3867 'ods-hsmutil', 'info'
3868 ],
3869 '<', '/dev/null',
3870 0 ▶ '>', sub {
Subroutine __ANON__: not called CC=14 SCAR=53.5
3871 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
3872 0 $data .= $_[0];
3873
3874 0 $cb->reset_timeout;
3875
3876 0 ▶ while ($data =~ s/^([^\r\n]*)\r?\n//o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/^([^\r\n]*)\r?\n//ou) 0 0 0
3877 0 my $line = $1;
3878 0 ▶ if ($line =~ /^Repository:\s+(.+)$/o) {
Branch: 7 branches
BranchTrueFalseTotal
if ($line =~ /^Repository:\s+(.+)$/ou) { } 0 0 0
elsif ($line =~ /Module:\s+(.+)$/ou) { } 0 0 0
elsif ($line =~ /Slot:\s+(\d+)$/ou) { } 0 0 0
elsif ($line =~ /Token\s+Label:\s+(\S+)/ou) { } 0 0 0
elsif ($line =~ /Manufacturer:\s+(\S+)/ou) { } 0 0 0
elsif ($line =~ /Model:\s+(\S+)/ou) { } 0 0 0
elsif ($line =~ /Serial:\s+(\S+)/ou) { } 0 0 0
3879 0 my $name = $1;
3880 0 ▶ if (defined $repository) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $repository) 0 0 0
3881 0 foreach (qw(name module slot token_label manufacturer model serial)) {
3882 0 ▶ unless (exists $repository->{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $repository->{$_}) 0 0 0
3883 0 undef($repository);
3884 0 last;
3885 }
3886 }
3887 0 ▶ if (defined $repository) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $repository) 0 0 0
3888 0 push(@repositories, $repository);
3889 }
3890 }
3891 $repository = {
3892 0 name => $name
3893 };
3894 }
3895 elsif ($line =~ /Module:\s+(.+)$/o) {
3896 0 $repository->{module} = $1;
3897 }
3898 elsif ($line =~ /Slot:\s+(\d+)$/o) {
3899 0 $repository->{slot} = $1;
3900 }
3901 # TODO spaces in names?
3902 elsif ($line =~ /Token\s+Label:\s+(\S+)/o) {
3903 0 $repository->{token_label} = $1;
3904 }
3905 elsif ($line =~ /Manufacturer:\s+(\S+)/o) {
3906 0 $repository->{manufacturer} = $1;
3907 }
3908 elsif ($line =~ /Model:\s+(\S+)/o) {
3909 0 $repository->{model} = $1;
3910 }
3911 elsif ($line =~ /Serial:\s+(\S+)/o) {
3912 0 $repository->{serial} = $1;
3913 }
3914 }
3915 }
3916 },
3917 '2>', \$stderr,
3918 timeout => 30,
3919 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=9 SCAR=45.0
3920 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
3921 0 return;
3922 }
3923 0 ▶ if (shift->recv) {
Branch: 1 branch
BranchTrueFalseTotal
if ((shift())->recv) 0 0 0
3924 0 $self->Error($cb, 'Unable to get hsm repository info');
3925 0 return;
3926 }
3927 0 ▶ if (defined $repository) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $repository) 0 0 0
3928 0 foreach (qw(name module slot token_label manufacturer model serial)) {
3929 0 ▶ unless (exists $repository->{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $repository->{$_}) 0 0 0
3930 0 undef($repository);
3931 0 last;
3932 }
3933 }
3934 0 ▶ if (defined $repository) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $repository) 0 0 0
3935 0 push(@repositories, $repository);
3936 }
3937 }
3938 0 ▶ if (scalar @repositories == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @repositories == 1) { } 0 0 0
elsif (scalar @repositories) { } 0 0 0
3939 0 $self->Successful($cb, { repository => $repositories[0] });
3940 }
3941 elsif (scalar @repositories) {
3942 0 $self->Successful($cb, { repository => \@repositories });
3943 }
3944 else {
3945 0 $self->Successful($cb);
3946 }
3947 0 };
3948 }
3949  
3950 =head1 AUTHOR
3951  
3952 Jerry Lundström, C<< <lundstrom.jerry at gmail.com> >>
3953  
3954 =head1 BUGS
3955  
3956 Please report any bugs or feature requests to L<https://github.com/jelu/lim-plugin-opendnssec/issues>.
3957  
3958 =head1 SUPPORT
3959  
3960 You can find documentation for this module with the perldoc command.
3961  
3962 perldoc Lim::Plugin::OpenDNSSEC
3963  
3964 You can also look for information at:
3965  
3966 =over 4
3967  
3968 =item * Lim issue tracker (report bugs here)
3969  
3970 L<https://github.com/jelu/lim-plugin-opendnssec/issues>
3971  
3972 =back
3973  
3974 =head1 ACKNOWLEDGEMENTS
3975  
3976 =head1 LICENSE AND COPYRIGHT
3977  
3978 Copyright 2012-2013 Jerry Lundström.
3979  
3980 This program is free software; you can redistribute it and/or modify it
3981 under the terms of either: the GNU General Public License as published
3982 by the Free Software Foundation; or the Artistic License.
3983  
3984 See http://dev.perl.org/licenses/ for more information.
3985  
3986  
3987 =cut
3988  
3989 1 1; # End of Lim::Plugin::OpenDNSSEC::Server
« OpenDNSSEC/CLI.pm ↑ Summary OpenDNSSEC.pm »