File Coverage

blib/lib/DJabberd/SASL/NTLM.pm
Criterion Covered Total %
statement 18 46 39.1
branch 0 10 0.0
condition 0 3 0.0
subroutine 6 11 54.5
pod 0 4 0.0
total 24 74 32.4


line stmt bran cond sub pod time code
1             package DJabberd::SASL::NTLM;
2              
3 1     1   28975 use strict;
  1         2  
  1         37  
4 1     1   6 use warnings;
  1         1  
  1         31  
5 1     1   4 use base qw/DJabberd::SASL/;
  1         19  
  1         741  
6 1     1   1020 use IPC::Open3;
  1         4957  
  1         68  
7 1     1   1342 use IO::Select;
  1         1771  
  1         50  
8 1     1   7 use Carp;
  1         2  
  1         489  
9              
10             our $VERSION = '0.03';
11              
12 0     0 0   sub manager_class { 'DJabberd::SASL::NTLMManager' }
13              
14             sub mechanisms {
15 0     0 0   my $plugin = shift;
16 0           return { NTLM => 1 };
17             }
18              
19             sub set_config_ntlmauthhelper {
20 0     0 0   my ( $self, $val ) = @_;
21 0           $val =~ s/^\s*\b(.+)\b\s*$/$1/;
22 0           my ( $ntlmauthhelper, @params ) = split( /\s+/, $val );
23 0 0 0       croak "Invalid NTLM helper: $ntlmauthhelper"
24             unless ( -f $ntlmauthhelper && -x $ntlmauthhelper );
25 0           $self->{err} = 1; # set STDERR for child
26 0           $self->{pid} =
27             open3( $self->{out}, $self->{in}, $self->{err}, $ntlmauthhelper,
28             @params );
29 0           $self->{s} = IO::Select->new();
30 0           $self->{s}->add( $self->{in} );
31 0           $self->{helper} = $ntlmauthhelper;
32 0           $self->{params} = [@params];
33              
34 0 0         croak "Can't open bidirectional pipe to NTLM helper"
35             unless ( $self->{pid} );
36             }
37              
38             ## XXX dupe sux
39             sub register {
40 0     0 0   my ( $plugin, $vhost ) = @_;
41 0           $plugin->SUPER::register($vhost);
42              
43             $vhost->register_hook(
44             "SendFeatures",
45             sub {
46 0     0     my ( $vh, $cb, $conn ) = @_;
47 0 0         if ( my $sasl_conn = $conn->sasl ) {
48 0 0         if ( $sasl_conn->is_success ) {
49 0           return;
50             }
51             }
52 0           my @mech = $plugin->mechanisms_list;
53 0           my $xml_mechanisms =
54             "";
55 0           $xml_mechanisms .= join "",
56 0           map { "$_" } @mech;
57 0 0         $xml_mechanisms .= "" if $plugin->is_optional;
58 0           $xml_mechanisms .= "";
59 0           $cb->stanza($xml_mechanisms);
60             }
61 0           );
62             }
63              
64             1;
65             __END__