blib/lib/DJabberd/Authen/Dovecot.pm

filter: Statementstmt 33.3% 17 / 51 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 5 / 10 Podpod 0.0% 0 / 5 totaltotal 27.5% 22 / 80 CC 7 SCAR 25.1
CC
7
Cov
27%
check_cleartext
30.0
finalize
12.0
set_config_socket
2.0
CRAP 12.3
↑ Summary
1 #!/usr/bin/perl -w
2  
3 package DJabberd::Authen::Dovecot;
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use base 'DJabberd::Authen';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use DJabberd::Log;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = '0.1';
9  
10 1 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use MIME::Base64;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 0 ▶sub set_config_socket {
Subroutine set_config_socket: not called CC=1 SCAR=6.9
Pod undocumented
14 0 my ($self, $sock) = @_;
15 0 $self->{sock} = $sock;
16 }
17  
18 0 ▶sub set_config_realm {
Subroutine set_config_realm: not called CC=1 SCAR=6.9
Pod undocumented
19 0 my ($self, $realm) = @_;
20 0 $self->{realm} = $realm;
21 }
22  
23 0 ▶sub finalize {
Subroutine finalize: not called CC=3 SCAR=24.8
Pod undocumented
24 0 my $self = shift;
25 0 ▶ $self->{realm} ||= '';
Condition0%0/2
$self->{"realm"} ||= ""
l!l
00
MC/DC0%0/1
$self->{"realm"} ||= ""
$self->{"realm"}
Truth table0%0/2
A
A= $self->{"realm"}
Aresult
11
00
26 0 ▶ $self->{sock} ||="/var/run/dovecot/auth-client";
Condition0%0/2
$self->{"sock"} ||= "/var/run/dovecot/auth-client"
l!l
00
MC/DC0%0/1
$self->{"sock"} ||= "/var/run/dovecot/auth-client"
$self->{"sock"}
Truth table0%0/2
A
A= $self->{"sock"}
Aresult
11
00
27 }
28  
29 0 ▶sub can_retrieve_cleartext { 0 }
Subroutine can_retrieve_cleartext: not called CC=1 SCAR=6.9
Pod undocumented
30  
31 0 ▶sub check_cleartext {
Subroutine check_cleartext: not called CC=5 SCAR=34.0
Pod undocumented
32 0 my $self = shift;
33 0 my $cb = shift;
34 0 my %args = @_;
35 0 my $user=$args{username};
36 0 my $pass=$args{password};
37 0 my $ch=encode_base64("\0$user\0$pass");
38 0 my $auth;
39 0 socket($auth,PF_UNIX,SOCK_STREAM,0);
40 0 connect($auth,scalar(sockaddr_un($self->{sock})));
41 0 my $cpid="CPID\t$$\n";
42 0 my $data;
43 0 sysread($auth,$data,1024);
44 0 my @data=split("\n",$data);
45 0 ▶ while(my $l=shift(@data)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $l = shift @data) 0 0 0
46 0 ▶ if($l eq "DONE") {
Branch: 3 branches
BranchTrueFalseTotal
if ($l eq 'DONE') { } 0 0 0
elsif ($l =~ /^FAIL/) { } 0 0 0
elsif ($l =~ /^OK/) { } 0 0 0
47 0 syswrite($auth,"VERSION\t1\t1\n");
48 0 syswrite($auth,$cpid);
49 0 syswrite($auth,"AUTH\t1\tPLAIN\tservice=xmpp\tresp=$ch");
50 0 sysread($auth,$data,1024);
51 0 @data=split("\n",$data);
52 } elsif($l =~/^FAIL/) {
53 0 @data=();
54 0 $cb->reject();
55 } elsif($l =~/^OK/) {
56 0 @data=();
57 0 $cb->accept();
58 }
59 }
60 0 close($auth);
61 0 return 1;
62 }
63  
64 1 1;
65  
66 __END__
↑ Summary