| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Sys::Export::Linux; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Export subsets of a Linux system |
|
4
|
|
|
|
|
|
|
our $VERSION = '0.003'; # VERSION |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
301656
|
use v5.26; |
|
|
1
|
|
|
|
|
4
|
|
|
8
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
65
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use experimental qw( signatures ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
10
|
1
|
|
|
1
|
|
192
|
use parent 'Sys::Export::Unix'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
7
|
|
|
11
|
1
|
|
|
1
|
|
103
|
use Cwd 'abs_path'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
75
|
|
|
12
|
1
|
|
|
1
|
|
7
|
use Carp; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
783
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
1
|
7
|
sub add_passwd($self, %options) { |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
9
|
|
|
16
|
|
|
|
|
|
|
# If the dst_userdb hasn't been created, create it by filtering the src_userdb by which |
|
17
|
|
|
|
|
|
|
# group and user ids have been seen during the export. |
|
18
|
|
|
|
|
|
|
my $db= $self->dst_userdb // Sys::Export::Unix::UserDB->new( |
|
19
|
1
|
|
0
|
|
|
6
|
auto_import => ($self->{src_userdb} //= $self->_build_src_userdb), |
|
|
|
|
33
|
|
|
|
|
|
20
|
|
|
|
|
|
|
); |
|
21
|
1
|
|
|
|
|
4
|
$db->group($_) for keys $self->dst_gid_used->%*; |
|
22
|
1
|
|
|
|
|
5
|
$db->user($_) for keys $self->dst_uid_used->%*; |
|
23
|
1
|
|
|
|
|
3
|
$db->save(\my %contents); |
|
24
|
1
|
|
50
|
|
|
4
|
my $etc_path= $options{etc_path} // 'etc'; |
|
25
|
1
|
|
|
|
|
6
|
$self->add([ dir755 => "$etc_path", { uid => 0, gid => 0 }]); |
|
26
|
1
|
|
|
|
|
7
|
$self->add([ file644 => "$etc_path/passwd", $contents{passwd}, { uid => 0, gid => 0 }]); |
|
27
|
1
|
|
|
|
|
6
|
$self->add([ file600 => "$etc_path/shadow", $contents{shadow}, { uid => 0, gid => 0 }]); |
|
28
|
1
|
|
|
|
|
6
|
$self->add([ file644 => "$etc_path/group", $contents{group}, { uid => 0, gid => 0 }]); |
|
29
|
1
|
|
|
|
|
3
|
$self; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
|
0
|
1
|
|
sub add_localtime($self, $tz_name) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
34
|
0
|
0
|
0
|
|
|
|
if (exists $self->{dst_path_set}{"usr/share/zoneinfo/$tz_name"} |
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|| ($self->_dst->can('dst_abs') && -f $self->_dst->dst_abs . $tz_name) |
|
36
|
|
|
|
|
|
|
) { |
|
37
|
|
|
|
|
|
|
# zoneinfo is exported, and includes this timezone, so symlink to it |
|
38
|
0
|
|
|
|
|
|
$self->add([ sym => "etc/localtime" => "../usr/share/zoneinfo/$tz_name" ]); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
elsif (defined (my $src_path= $self->_src_abs_path("usr/share/zoneinfo/$tz_name"))) { |
|
41
|
0
|
|
|
|
|
|
$self->add([ file644 => 'etc/localtime', { data_path => $self->src_abs . $src_path } ]); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
elsif (defined (my $path= abs_path("/usr/share/zoneinfo/$tz_name"))) { |
|
44
|
0
|
|
|
|
|
|
$self->add([ file644 => 'etc/localtime', { data_path => $path } ]); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
else { |
|
47
|
0
|
|
|
|
|
|
croak "Can't find 'usr/share/zoneinfo/$tz_name' in destination, source, or host filesystem"; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Avoiding dependency on namespace::clean |
|
52
|
1
|
|
|
1
|
|
10
|
{ no strict 'refs'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
141
|
|
|
53
|
|
|
|
|
|
|
delete @{"Sys::Export::Linux::"}{qw( |
|
54
|
|
|
|
|
|
|
croak carp |
|
55
|
|
|
|
|
|
|
)}; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |