| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# This file is part of StorageDisplay |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# This software is copyright (c) 2014-2023 by Vincent Danjean. |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
|
7
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
|
8
|
|
|
|
|
|
|
# |
|
9
|
9
|
|
|
9
|
|
87
|
use strict; |
|
|
9
|
|
|
|
|
25
|
|
|
|
9
|
|
|
|
|
438
|
|
|
10
|
9
|
|
|
9
|
|
54
|
use warnings; |
|
|
9
|
|
|
|
|
812
|
|
|
|
9
|
|
|
|
|
1479
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package StorageDisplay::Data::LUKS; |
|
13
|
|
|
|
|
|
|
# ABSTRACT: Handle LUKS data for StorageDisplay |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '2.06'; # VERSION |
|
16
|
|
|
|
|
|
|
|
|
17
|
9
|
|
|
9
|
|
387
|
use Moose; |
|
|
9
|
|
|
|
|
324
|
|
|
|
9
|
|
|
|
|
84
|
|
|
18
|
9
|
|
|
9
|
|
74167
|
use namespace::sweep; |
|
|
9
|
|
|
|
|
351
|
|
|
|
9
|
|
|
|
|
157
|
|
|
19
|
|
|
|
|
|
|
extends 'StorageDisplay::Data::Elem'; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
with ( |
|
22
|
|
|
|
|
|
|
'StorageDisplay::Role::HasBlock', |
|
23
|
|
|
|
|
|
|
'StorageDisplay::Role::Style::IsSubGraph', |
|
24
|
|
|
|
|
|
|
'StorageDisplay::Role::Style::Grey', |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has 'encrypted' => ( |
|
28
|
|
|
|
|
|
|
is => 'ro', |
|
29
|
|
|
|
|
|
|
isa => 'StorageDisplay::Data::LUKS::Encrypted', |
|
30
|
|
|
|
|
|
|
writer => '_encrypted', |
|
31
|
|
|
|
|
|
|
required => 0, |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has 'decrypted' => ( |
|
35
|
|
|
|
|
|
|
is => 'ro', |
|
36
|
|
|
|
|
|
|
isa => 'StorageDisplay::Data::LUKS::Decrypted', |
|
37
|
|
|
|
|
|
|
writer => '_decrypted', |
|
38
|
|
|
|
|
|
|
required => 0, |
|
39
|
|
|
|
|
|
|
); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has 'luks_version' => ( |
|
42
|
|
|
|
|
|
|
is => 'ro', |
|
43
|
|
|
|
|
|
|
isa => 'Str', |
|
44
|
|
|
|
|
|
|
required => 1, |
|
45
|
|
|
|
|
|
|
); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
around BUILDARGS => sub { |
|
48
|
|
|
|
|
|
|
my $orig = shift; |
|
49
|
|
|
|
|
|
|
my $class = shift; |
|
50
|
|
|
|
|
|
|
my $devname = shift; |
|
51
|
|
|
|
|
|
|
my $st = shift; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#$st->get_infos |
|
54
|
|
|
|
|
|
|
$st->log({level=>1}, 'LUKS for device '.$devname); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $info = $st->get_info('luks', $devname); |
|
57
|
|
|
|
|
|
|
my $block = $st->block($devname); |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
return $class->$orig( |
|
60
|
|
|
|
|
|
|
'name' => $block->name, |
|
61
|
|
|
|
|
|
|
'block' => $block, |
|
62
|
|
|
|
|
|
|
'consume' => [], |
|
63
|
|
|
|
|
|
|
'st' => $st, |
|
64
|
|
|
|
|
|
|
'luks-info' => $info, |
|
65
|
|
|
|
|
|
|
'luks_version' => $info->{VERSION}, |
|
66
|
|
|
|
|
|
|
@_ |
|
67
|
|
|
|
|
|
|
); |
|
68
|
|
|
|
|
|
|
}; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub BUILD { |
|
71
|
5
|
|
|
5
|
0
|
9144
|
my $self=shift; |
|
72
|
5
|
|
|
|
|
9
|
my $args=shift; |
|
73
|
5
|
|
|
|
|
12
|
my $st = $args->{st}; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$self->_encrypted($self->newChild('LUKS::Encrypted', |
|
76
|
5
|
|
|
|
|
44
|
$self, $st, $args->{'luks-info'})); |
|
77
|
5
|
50
|
|
|
|
20
|
if (defined($args->{'luks-info'}->{decrypted})) { |
|
78
|
|
|
|
|
|
|
$self->_decrypted( |
|
79
|
|
|
|
|
|
|
$self->newChild('LUKS::Decrypted::Present', |
|
80
|
5
|
|
|
|
|
21
|
$self, $st, $args->{'luks-info'})); |
|
81
|
|
|
|
|
|
|
} else { |
|
82
|
|
|
|
|
|
|
$self->_decrypted( |
|
83
|
|
|
|
|
|
|
$self->newChild('LUKS::Decrypted::None', |
|
84
|
0
|
|
|
|
|
0
|
$self, $st, $args->{'luks-info'})); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
5
|
|
|
|
|
23
|
return $self; |
|
87
|
|
|
|
|
|
|
}; |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub dname { |
|
90
|
10
|
|
|
10
|
0
|
13
|
my $self=shift; |
|
91
|
10
|
|
|
|
|
248
|
return 'LUKS: '.$self->block->dname; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub dotLabel { |
|
95
|
10
|
|
|
10
|
0
|
20
|
my $self = shift; |
|
96
|
|
|
|
|
|
|
return ( |
|
97
|
10
|
|
|
|
|
459
|
$self->block->dname, |
|
98
|
|
|
|
|
|
|
'LUKS version '.$self->luks_version, |
|
99
|
|
|
|
|
|
|
); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub dotLinks { |
|
103
|
5
|
|
|
5
|
0
|
6
|
my $self = shift; |
|
104
|
|
|
|
|
|
|
return ( |
|
105
|
5
|
|
|
|
|
135
|
$self->encrypted->linkname.' -> '.$self->decrypted->linkname |
|
106
|
|
|
|
|
|
|
); |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
################################################################## |
|
112
|
|
|
|
|
|
|
package StorageDisplay::Data::LUKS::Encrypted; |
|
113
|
|
|
|
|
|
|
|
|
114
|
9
|
|
|
9
|
|
6172
|
use Moose; |
|
|
9
|
|
|
|
|
24
|
|
|
|
9
|
|
|
|
|
55
|
|
|
115
|
9
|
|
|
9
|
|
75120
|
use namespace::sweep; |
|
|
9
|
|
|
|
|
23
|
|
|
|
9
|
|
|
|
|
62
|
|
|
116
|
|
|
|
|
|
|
extends 'StorageDisplay::Data::Elem'; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
with ( |
|
119
|
|
|
|
|
|
|
'StorageDisplay::Role::HasBlock', |
|
120
|
|
|
|
|
|
|
'StorageDisplay::Role::Style::WithSize', |
|
121
|
|
|
|
|
|
|
'StorageDisplay::Role::Style::FromBlockState', |
|
122
|
|
|
|
|
|
|
); |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
around BUILDARGS => sub { |
|
125
|
|
|
|
|
|
|
my $orig = shift; |
|
126
|
|
|
|
|
|
|
my $class = shift; |
|
127
|
|
|
|
|
|
|
my $luks = shift; |
|
128
|
|
|
|
|
|
|
my $st = shift; |
|
129
|
|
|
|
|
|
|
my $info = shift; |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
my $block = $luks->block; |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
return $class->$orig( |
|
134
|
|
|
|
|
|
|
'name' => $block->name, |
|
135
|
|
|
|
|
|
|
'consume' => [$block], |
|
136
|
|
|
|
|
|
|
'block' => $block, |
|
137
|
|
|
|
|
|
|
'size' => $st->get_info('lsblk', $block->name, 'size'), |
|
138
|
|
|
|
|
|
|
@_ |
|
139
|
|
|
|
|
|
|
); |
|
140
|
|
|
|
|
|
|
}; |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub dotLabel { |
|
143
|
10
|
|
|
10
|
0
|
22
|
my $self = shift; |
|
144
|
10
|
|
|
|
|
406
|
return ($self->block->dname); |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
################################################################## |
|
150
|
|
|
|
|
|
|
package StorageDisplay::Data::LUKS::Decrypted; |
|
151
|
|
|
|
|
|
|
|
|
152
|
9
|
|
|
9
|
|
2927
|
use Moose; |
|
|
9
|
|
|
|
|
20
|
|
|
|
9
|
|
|
|
|
55
|
|
|
153
|
9
|
|
|
9
|
|
71183
|
use namespace::sweep; |
|
|
9
|
|
|
|
|
20
|
|
|
|
9
|
|
|
|
|
63
|
|
|
154
|
|
|
|
|
|
|
extends 'StorageDisplay::Data::Elem'; |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
1; |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
################################################################## |
|
159
|
|
|
|
|
|
|
package StorageDisplay::Data::LUKS::Decrypted::Present; |
|
160
|
|
|
|
|
|
|
|
|
161
|
9
|
|
|
9
|
|
1171
|
use Moose; |
|
|
9
|
|
|
|
|
18
|
|
|
|
9
|
|
|
|
|
50
|
|
|
162
|
9
|
|
|
9
|
|
71781
|
use namespace::sweep; |
|
|
9
|
|
|
|
|
23
|
|
|
|
9
|
|
|
|
|
65
|
|
|
163
|
|
|
|
|
|
|
extends 'StorageDisplay::Data::LUKS::Decrypted'; |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
with ( |
|
166
|
|
|
|
|
|
|
'StorageDisplay::Role::HasBlock', |
|
167
|
|
|
|
|
|
|
'StorageDisplay::Role::Style::WithSize', |
|
168
|
|
|
|
|
|
|
'StorageDisplay::Role::Style::FromBlockState', |
|
169
|
|
|
|
|
|
|
); |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
around BUILDARGS => sub { |
|
172
|
|
|
|
|
|
|
my $orig = shift; |
|
173
|
|
|
|
|
|
|
my $class = shift; |
|
174
|
|
|
|
|
|
|
my $luks = shift; |
|
175
|
|
|
|
|
|
|
my $st = shift; |
|
176
|
|
|
|
|
|
|
my $info = shift; |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
my $block = $st->block($info->{'decrypted'}//($luks->name."none")); |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
return $class->$orig( |
|
181
|
|
|
|
|
|
|
'name' => $block->name, |
|
182
|
|
|
|
|
|
|
'consume' => [], |
|
183
|
|
|
|
|
|
|
'block' => $block, |
|
184
|
|
|
|
|
|
|
'size' => $st->get_info('lsblk', $block->name, 'size'), |
|
185
|
|
|
|
|
|
|
@_ |
|
186
|
|
|
|
|
|
|
); |
|
187
|
|
|
|
|
|
|
}; |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub BUILD { |
|
190
|
5
|
|
|
5
|
0
|
7452
|
my $self = shift; |
|
191
|
5
|
|
|
|
|
234
|
$self->provideBlock($self->block); |
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
sub dotLabel { |
|
195
|
10
|
|
|
10
|
0
|
16
|
my $self = shift; |
|
196
|
10
|
|
|
|
|
378
|
return ($self->block->dname); |
|
197
|
|
|
|
|
|
|
} |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
1; |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
################################################################## |
|
202
|
|
|
|
|
|
|
package StorageDisplay::Data::LUKS::Decrypted::None; |
|
203
|
|
|
|
|
|
|
|
|
204
|
9
|
|
|
9
|
|
3400
|
use Moose; |
|
|
9
|
|
|
|
|
18
|
|
|
|
9
|
|
|
|
|
72
|
|
|
205
|
9
|
|
|
9
|
|
68644
|
use namespace::sweep; |
|
|
9
|
|
|
|
|
22
|
|
|
|
9
|
|
|
|
|
60
|
|
|
206
|
|
|
|
|
|
|
extends 'StorageDisplay::Data::LUKS::Decrypted'; |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
with ( |
|
209
|
|
|
|
|
|
|
'StorageDisplay::Role::Style::Plain', |
|
210
|
|
|
|
|
|
|
); |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
around BUILDARGS => sub { |
|
213
|
|
|
|
|
|
|
my $orig = shift; |
|
214
|
|
|
|
|
|
|
my $class = shift; |
|
215
|
|
|
|
|
|
|
my $luks = shift; |
|
216
|
|
|
|
|
|
|
my $st = shift; |
|
217
|
|
|
|
|
|
|
my $info = shift; |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
return $class->$orig( |
|
220
|
|
|
|
|
|
|
'name' => $luks->name."@@", |
|
221
|
|
|
|
|
|
|
'consume' => [], |
|
222
|
|
|
|
|
|
|
@_ |
|
223
|
|
|
|
|
|
|
); |
|
224
|
|
|
|
|
|
|
}; |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
sub BUILD { |
|
227
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
228
|
|
|
|
|
|
|
} |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
sub dotLabel { |
|
231
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
232
|
0
|
|
|
|
|
|
return ('Not decrypted'); |
|
233
|
|
|
|
|
|
|
} |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
1; |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
__END__ |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=pod |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=encoding UTF-8 |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head1 NAME |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
StorageDisplay::Data::LUKS - Handle LUKS data for StorageDisplay |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head1 VERSION |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
version 2.06 |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head1 AUTHOR |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
Vincent Danjean <Vincent.Danjean@ens-lyon.org> |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
This software is copyright (c) 2014-2023 by Vincent Danjean. |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
260
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=cut |