line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Interface::Connection::Base; |
6
|
|
|
|
|
|
|
|
7
|
67
|
|
|
67
|
|
1012
|
use v5.12.5; |
|
67
|
|
|
|
|
334
|
|
8
|
67
|
|
|
67
|
|
527
|
use warnings; |
|
67
|
|
|
|
|
272
|
|
|
67
|
|
|
|
|
4006
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.14.2.3'; # TRIAL VERSION |
11
|
|
|
|
|
|
|
|
12
|
67
|
|
|
67
|
|
633
|
use Rex::Interface::Fs; |
|
67
|
|
|
|
|
270
|
|
|
67
|
|
|
|
|
1424
|
|
13
|
67
|
|
|
67
|
|
2765
|
use Rex::Interface::Exec; |
|
67
|
|
|
|
|
231
|
|
|
67
|
|
|
|
|
1051
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
106
|
|
|
106
|
0
|
362
|
my $that = shift; |
17
|
106
|
|
33
|
|
|
681
|
my $proto = ref($that) || $that; |
18
|
106
|
|
|
|
|
316
|
my $self = {@_}; |
19
|
|
|
|
|
|
|
|
20
|
106
|
|
|
|
|
363
|
bless( $self, $proto ); |
21
|
|
|
|
|
|
|
|
22
|
106
|
|
|
|
|
602
|
$self->{__sudo_options__} = []; |
23
|
|
|
|
|
|
|
|
24
|
106
|
|
|
|
|
398
|
return $self; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
0
|
0
|
0
|
sub error { die("Must be implemented by Interface Class"); } |
28
|
0
|
|
|
0
|
0
|
0
|
sub connect { die("Must be implemented by Interface Class"); } |
29
|
0
|
|
|
0
|
0
|
0
|
sub disconnect { die("Must be implemented by Interface Class"); } |
30
|
0
|
|
|
0
|
0
|
0
|
sub get_connection_object { die("Must be implemented by Interface Class"); } |
31
|
0
|
|
|
0
|
0
|
0
|
sub is_connected { die("Must be implemented by Interface Class"); } |
32
|
0
|
|
|
0
|
0
|
0
|
sub is_authenticated { die("Must be implemented by Interface Class"); } |
33
|
0
|
|
|
0
|
0
|
0
|
sub get_connection_type { die("Must be implemented by Interface Class") } |
34
|
|
|
|
2
|
0
|
|
sub reconnect { } |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub get_fs_connection_object { |
37
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
38
|
0
|
|
|
|
|
0
|
return $self; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub get_fs { |
42
|
0
|
|
|
0
|
0
|
0
|
my $fs = Rex::Interface::Fs->create; |
43
|
0
|
|
|
|
|
0
|
return $fs; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub get_exec { |
47
|
0
|
|
|
0
|
0
|
0
|
my $exec = Rex::Interface::Exec->create; |
48
|
0
|
|
|
|
|
0
|
return $exec; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub server { |
52
|
386
|
|
|
386
|
0
|
1149
|
my ($self) = @_; |
53
|
386
|
|
|
|
|
2624
|
return $self->{server}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub get_auth_user { |
57
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
0
|
if ( exists $self->{__auth_info__} ) { |
60
|
0
|
|
|
|
|
0
|
return $self->{__auth_info__}->{user}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
0
|
return ""; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub get_auth { |
67
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
0
|
if ( exists $self->{__auth_info__} ) { |
70
|
0
|
|
|
|
|
0
|
return $self->{__auth_info__}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub push_sudo_options { |
75
|
0
|
|
|
0
|
0
|
0
|
my ( $self, @option ) = @_; |
76
|
0
|
0
|
|
|
|
0
|
if ( ref $option[0] eq "HASH" ) { |
77
|
0
|
|
|
|
|
0
|
push @{ $self->{__sudo_options__} }, $option[0]; |
|
0
|
|
|
|
|
0
|
|
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
else { |
80
|
0
|
|
|
|
|
0
|
push @{ $self->{__sudo_options__} }, {@option}; |
|
0
|
|
|
|
|
0
|
|
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub get_current_sudo_options { |
85
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
86
|
0
|
|
|
|
|
0
|
return $self->{__sudo_options__}->[-1]; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub push_use_sudo { |
90
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $use ) = @_; |
91
|
0
|
|
|
|
|
0
|
push @{ $self->{__use_sudo__} }, $use; |
|
0
|
|
|
|
|
0
|
|
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub get_current_use_sudo { |
95
|
3719
|
|
|
3719
|
0
|
10466
|
my ($self) = @_; |
96
|
|
|
|
|
|
|
|
97
|
3719
|
50
|
|
|
|
10141
|
if ( $self->{is_sudo} ) { |
98
|
0
|
|
|
|
|
0
|
return 1; |
99
|
|
|
|
|
|
|
} |
100
|
3719
|
|
|
|
|
19401
|
return $self->{__use_sudo__}->[-1]; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub pop_sudo_options { |
104
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
105
|
0
|
|
|
|
|
|
pop @{ $self->{__sudo_options__} }; |
|
0
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub pop_use_sudo { |
109
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
110
|
0
|
|
|
|
|
|
pop @{ $self->{__use_sudo__} }; |
|
0
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub run_sudo_unmodified { |
114
|
0
|
|
|
0
|
0
|
|
my ( $self, $code ) = @_; |
115
|
0
|
|
|
|
|
|
$self->push_sudo_options( {} ); |
116
|
0
|
|
|
|
|
|
$code->(); |
117
|
0
|
|
|
|
|
|
$self->pop_sudo_options(); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |