| 1 | package Protocol::DBus::Authn; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use IO::Framed (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | 8 | ▶ | use Module::Load (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use Socket (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use Protocol::DBus::X (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||
| 12 | 8 | ▶ | use constant _CRLF => "\x0d\x0a"; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||
| 14 | 8 | ▶ | use constant DEBUG => 0; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||
| 16 | sub new { | ||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | my ($class, %opts) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | 2 | my @missing = grep { !$opts{$_} } qw( socket mechanism ); | |||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | die "Need: @missing" if @missing; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||
| 22 | 2 | $opts{"_$_"} = delete $opts{$_} for keys %opts; | |||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||
| 24 | 2 | $opts{'_can_pass_unix_fd'} = Socket::MsgHdr->can('new'); | |||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | $opts{'_can_pass_unix_fd'} &&= Socket->can('SCM_RIGHTS'); | ||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts{"_can_pass_unix_fd"} &&= "Socket"->can("SCM_RIGHTS")
MC/DC0%0/2
$opts{"_can_pass_unix_fd"} &&= "Socket"->can("SCM_RIGHTS")
$opts{"_can_pass_unix_fd"}
"Socket"->can("SCM_RIGHTS")
Truth table33%1/3
A &&= B
A= $opts{"_can_pass_unix_fd"}B= "Socket"->can("SCM_RIGHTS")
| |||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | $opts{'_can_pass_unix_fd'} &&= _is_unix_socket($opts{'_socket'}); | ||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts{"_can_pass_unix_fd"} &&= _is_unix_socket($opts{"_socket"})
MC/DC0%0/2
$opts{"_can_pass_unix_fd"} &&= _is_unix_socket($opts{"_socket"})
$opts{"_can_pass_unix_fd"}
_is_unix_socket($opts{"_socket"})
Truth table33%1/3
A &&= B
A= $opts{"_can_pass_unix_fd"}B= _is_unix_socket($opts{"_socket"})
| |||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||
| 28 | 2 | $opts{'_io'} = IO::Framed->new( $opts{'_socket'} )->enable_write_queue(); | |||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||
| 30 | 2 | my $self = bless \%opts, $class; | |||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||
| 32 | 2 | ▶ | $self->_set_mechanism( $opts{'_mechanism'} ) or do { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 33 | 0 | die "“$opts{'_mechanism'}” is not a valid authn mechanism."; | |||||||||||||||||||||||||||||||||
| 34 | }; | ||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||
| 36 | 2 | return $self; | |||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||
| 39 | sub _set_mechanism { | ||||||||||||||||||||||||||||||||||
| 40 | 2 | ▶ | my ($self, $mechanism) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
_set_mechanism: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||
| 42 | 2 | ▶ | if (!ref $mechanism) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 43 | 2 | my $module = __PACKAGE__ . "::Mechanism::$mechanism"; | |||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||
| 45 | 2 | my $err = $@; | |||||||||||||||||||||||||||||||||
| 46 | 2 | ▶ | if (!eval { Module::Load::load($module); 1 } ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 47 | 0 | return 0; | |||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||
| 49 | 2 | $@ = $err; | |||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||
| 51 | 2 | $self->{'_mechanism'} = $module->new(); | |||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||
| 54 | 2 | $self->{'_xaction'} = $self->_create_xaction(); | |||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||
| 56 | 2 | return 1; | |||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||
| 59 | sub negotiated_unix_fd { | ||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | return $_[0]->{'_negotiated_unix_fd'} ? 1 : 0; | ||||||||||||||||||||||||||||||||
|
Subroutine
negotiated_unix_fd: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||
| 63 | # Whether a send is pending (1) or a receive (0). | ||||||||||||||||||||||||||||||||||
| 64 | sub pending_send { | ||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
pending_send: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||
| 67 | 0 | my $next_is_receive = $self->{'_xaction'}[0]; | |||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | $next_is_receive &&= $next_is_receive->[0]; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$next_is_receive &&= $next_is_receive->[0]
MC/DC0%0/2
$next_is_receive &&= $next_is_receive->[0]
$next_is_receive
$next_is_receive->[0]
Truth table0%0/3
A &&= B
A= $next_is_receiveB= $next_is_receive->[0]
| |||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if (!defined $next_is_receive) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 71 | 0 | die "Authn transaction is done!"; | |||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||
| 74 | 0 | return !$next_is_receive; | |||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||
| 77 | sub go { | ||||||||||||||||||||||||||||||||||
| 78 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
go: called CC=17 SCAR=39.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||
| 80 | 2 | my $s = $self->{'_socket'}; | |||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||
| 82 | # Don’t send_initial() if !must_send_initial(). | ||||||||||||||||||||||||||||||||||
| 83 | 2 | ▶ | $self->{'_sent_initial'} ||= !$self->{'_mechanism'}->must_send_initial() || $self->{'_mechanism'}->send_initial($s); | ||||||||||||||||||||||||||||||||
|
Condition33%2/6
$self->{"_sent_initial"} ||= !$self->{"_mechanism"}->must_send_initial || $self->{"_mechanism"}->send_initial($s)
!$self->{'_mechanism'}->must_send_initial || $self->{'_mechanism'}->send_initial($s)
MC/DC0%0/3
$self->{"_sent_initial"} ||= !$self->{"_mechanism"}->must_send_initial || $self->{"_mechanism"}->send_initial($s)
$self->{"_sent_initial"}
!$self->{'_mechanism'}->must_send_initial
$self->{'_mechanism'}->send_initial($s)
Truth table0%0/4
A ||= not(B) || C
A= $self->{"_sent_initial"}B= !$self->{'_mechanism'}->must_send_initialC= $self->{'_mechanism'}->send_initial($s)
| |||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||
| 85 | 2 | ▶ | if ($self->{'_sent_initial'}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 86 | LINES: | ||||||||||||||||||||||||||||||||||
| 87 | { | ||||||||||||||||||||||||||||||||||
| 88 | 2 | ▶ | if ( $self->{'_io'}->get_write_queue_count() ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | $self->flush_write_queue() or last LINES; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||
| 92 | 2 | my $dollar_at = $@; | |||||||||||||||||||||||||||||||||
| 93 | 2 | my $ok = eval { | |||||||||||||||||||||||||||||||||
| 94 | 2 | ▶ | while ( my $cur = $self->{'_xaction'}[0] ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 95 | 8 | ▶ | if ($cur->[0]) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 96 | 3 | ▶ | my $line = $self->_read_line() or last LINES; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 97 | 3 | $cur->[1]->($self, $line); | |||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||
| 99 | else { | ||||||||||||||||||||||||||||||||||
| 100 | 5 | my @line_parts; | |||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||
| 102 | 5 | ▶ | if ('CODE' eq ref $cur->[1]) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 103 | 1 | @line_parts = $cur->[1]->($self); | |||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||
| 105 | else { | ||||||||||||||||||||||||||||||||||
| 106 | 4 | @line_parts = @{$cur}[ 1 .. $#$cur ]; | |||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||
| 109 | 5 | ▶ | $self->_send_line("@line_parts") or last LINES; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||
| 111 | 5 | push @{ $self->{'_tried_mechanism'} }, $self->{'_mechanism'}->label(); | |||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||
| 114 | 8 | shift @{ $self->{'_xaction'} }; | |||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||
| 117 | 2 | 1; | |||||||||||||||||||||||||||||||||
| 118 | }; | ||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||
| 120 | 2 | ▶ | if (!$ok) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 121 | 0 | my $err = $@; | |||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | if (eval { $err->isa('Protocol::DBus::X::Rejected') }) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 123 | 0 | my @to_try; | |||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||
| 125 | 0 | for my $mech ( @{ $err->get('mechanisms') } ) { | |||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | if (!grep { $_ eq $mech } @{ $self->{'_tried_mechanism'} }) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 127 | 0 | push @to_try, $mech; | |||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | while (my $mech = shift @to_try) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | if ($self->_set_mechanism($mech)) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 133 | 0 | redo LINES; | |||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||
| 137 | 0 | die "Exhausted all authentication mechanisms! (@{ $self->{'_tried_mechanism'} })"; | |||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||
| 139 | else { | ||||||||||||||||||||||||||||||||||
| 140 | 0 | local $@ = $err; | |||||||||||||||||||||||||||||||||
| 141 | 0 | die; | |||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||
| 145 | 2 | return 1; | |||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||
| 149 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||
| 152 | sub cancel { | ||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
cancel: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||
| 155 | 0 | die 'unimplemented'; | |||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||
| 158 | sub _create_xaction { | ||||||||||||||||||||||||||||||||||
| 159 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_xaction: called CC=4 SCAR=15.0
| |||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||
| 161 | 2 | my $auth_label = 'AUTH'; | |||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||
| 163 | # Unless the mechanism sends its own initial NUL, might as well use the | ||||||||||||||||||||||||||||||||||
| 164 | # same system call to send the initial NUL as we use to send the AUTH. | ||||||||||||||||||||||||||||||||||
| 165 | 2 | ▶ | if (!$self->{'_sent_initial'} && !$self->{'_mechanism'}->must_send_initial()) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"_sent_initial"} or $self->{"_mechanism"}->must_send_initial
MC/DC0%0/2
$self->{"_sent_initial"} or $self->{"_mechanism"}->must_send_initial
$self->{"_sent_initial"}
$self->{"_mechanism"}->must_send_initial
Truth table33%1/3
A or B
A= $self->{"_sent_initial"}B= $self->{"_mechanism"}->must_send_initial
| |||||||||||||||||||||||||||||||||||
| 166 | 2 | substr( $auth_label, 0, 0 ) = "\0"; | |||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||
| 169 | # 0 = send; 1 = receive | ||||||||||||||||||||||||||||||||||
| 170 | my @xaction = ( | ||||||||||||||||||||||||||||||||||
| 171 | [ 0 => $auth_label, $self->{'_mechanism'}->label(), $self->{'_mechanism'}->INITIAL_RESPONSE() ], | ||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||
| 173 | # e.g., for exchange of DATA | ||||||||||||||||||||||||||||||||||
| 174 | 2 | $self->{'_mechanism'}->AFTER_AUTH(), | |||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||
| 176 | [ 1 => \&_consume_ok ], | ||||||||||||||||||||||||||||||||||
| 177 | ); | ||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||
| 179 | 2 | ▶ | if ($self->{'_can_pass_unix_fd'}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 180 | 0 | push @xaction, ( | |||||||||||||||||||||||||||||||||
| 181 | [ 0 => 'NEGOTIATE_UNIX_FD' ], | ||||||||||||||||||||||||||||||||||
| 182 | [ 1 => \&_consume_agree_unix_fd ], | ||||||||||||||||||||||||||||||||||
| 183 | ); | ||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||
| 186 | 2 | push @xaction, [ 0 => 'BEGIN' ]; | |||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||
| 188 | 2 | return \@xaction; | |||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||
| 191 | sub _consume_agree_unix_fd { | ||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | my ($self, $line) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
_consume_agree_unix_fd: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | if ($line eq 'AGREE_UNIX_FD') { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 195 | 0 | $self->{'_negotiated_unix_fd'} = 1; | |||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||
| 197 | elsif (index($line, 'ERROR ') == 0) { | ||||||||||||||||||||||||||||||||||
| 198 | 0 | warn "Server rejected unix fd passing: " . substr($line, 6) . $/; | |||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||
| 201 | 0 | return; | |||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||
| 204 | sub _consume_ok { | ||||||||||||||||||||||||||||||||||
| 205 | 2 | ▶ | my ($self, $line) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
_consume_ok: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||
| 207 | 2 | ▶ | if (index($line, 'OK ') == 0) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 208 | 2 | $self->{'_server_guid'} = substr($line, 3); | |||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||
| 210 | else { | ||||||||||||||||||||||||||||||||||
| 211 | 0 | die "Unrecognized response: $line"; | |||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||
| 214 | 2 | return; | |||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||
| 217 | sub _send_line { | ||||||||||||||||||||||||||||||||||
| 218 | 5 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
_send_line: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||
| 220 | 5 | DEBUG() && print STDERR "AUTHN SENDING: [$_[1]]$/"; | |||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||
| 222 | 5 | $self->{'_io'}->write( $_[1] . _CRLF() ); | |||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||
| 224 | 5 | return $self->_flush_write_queue(); | |||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||
| 227 | sub _flush_write_queue { | ||||||||||||||||||||||||||||||||||
| 228 | 5 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
_flush_write_queue: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||
| 230 | 5 | local $SIG{'PIPE'} = 'IGNORE'; | |||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||
| 232 | 5 | return $self->{'_io'}->flush_write_queue(); | |||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||
| 235 | sub _read_line { | ||||||||||||||||||||||||||||||||||
| 236 | 3 | ▶ | my $line; | ||||||||||||||||||||||||||||||||
|
Subroutine
_read_line: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||
| 238 | 3 | DEBUG() && print STDERR "AUTHN RECEIVING …$/"; | |||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||
| 240 | 3 | ▶ | if ($line = $_[0]->{'_io'}->read_until("\x0d\x0a")) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 241 | 3 | substr( $line, -2 ) = q<>; | |||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||
| 243 | 3 | DEBUG() && print STDERR "AUTHN RECEIVED: [$line]$/"; | |||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||
| 245 | 3 | ▶ | if (0 == index( $line, 'REJECTED ')) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 246 | 0 | die Protocol::DBus::X->create( | |||||||||||||||||||||||||||||||||
| 247 | 'Rejected', | ||||||||||||||||||||||||||||||||||
| 248 | split( m< >, substr( $line, 9 ) ), | ||||||||||||||||||||||||||||||||||
| 249 | ); | ||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||
| 253 | 3 | return $line; | |||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||
| 256 | sub _is_unix_socket { | ||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | my ($sk) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
_is_unix_socket: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | my $sname = getsockname($sk) or die "getsockname(): $!"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||
| 261 | 0 | return Socket::sockaddr_family($sname) == Socket::AF_UNIX(); | |||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||
| 264 | 8 | 1; | |||||||||||||||||||||||||||||||||