line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PlugAuth::Plugin::Finger; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
20123
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
49
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
49
|
|
5
|
2
|
|
|
2
|
|
47
|
use 5.010001; |
|
2
|
|
|
|
|
7
|
|
6
|
2
|
|
|
2
|
|
709
|
use Role::Tiny::With; |
|
2
|
|
|
|
|
5971
|
|
|
2
|
|
|
|
|
105
|
|
7
|
2
|
|
|
2
|
|
853
|
use AnyEvent::Finger::Server; |
|
2
|
|
|
|
|
53876
|
|
|
2
|
|
|
|
|
65
|
|
8
|
2
|
|
|
2
|
|
1251
|
use Log::Log4perl qw( :easy ); |
|
2
|
|
|
|
|
53227
|
|
|
2
|
|
|
|
|
15
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'PlugAuth::Role::Plugin'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: Add a finger protocol interface to your PlugAuth server |
13
|
|
|
|
|
|
|
our $VERSION = '0.02'; # VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init |
17
|
|
|
|
|
|
|
{ |
18
|
1
|
|
|
1
|
0
|
1860
|
my($self) = @_; |
19
|
|
|
|
|
|
|
|
20
|
1
|
50
|
33
|
|
|
4
|
my $port = $self->plugin_config->port( |
21
|
|
|
|
|
|
|
default => $> && $^O !~ /^(cygwin|MSWin32)$/ ? 8079 : 79, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
69
|
INFO "finger binding to port $port"; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
1022
|
my $server = $self->{server} = AnyEvent::Finger::Server->new( |
27
|
|
|
|
|
|
|
port => $port, |
28
|
|
|
|
|
|
|
forward_deny => 1, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$server->start(sub { |
32
|
5
|
|
|
5
|
|
184669
|
my $tx = shift; |
33
|
5
|
|
|
|
|
20
|
$self->app->refresh; |
34
|
5
|
100
|
|
|
|
5249
|
if($tx->req->listing_request) |
35
|
|
|
|
|
|
|
{ |
36
|
1
|
|
|
|
|
20
|
$tx->res->say("users:"); |
37
|
1
|
|
|
|
|
80
|
$tx->res->say(" $_") for $self->app->auth->all_users; |
38
|
1
|
|
|
|
|
344
|
$tx->res->say("groups:"); |
39
|
1
|
|
|
|
|
64
|
$tx->res->say(" $_") for $self->app->authz->all_groups; |
40
|
1
|
50
|
|
|
|
275
|
if($tx->req->verbose) |
41
|
|
|
|
|
|
|
{ |
42
|
0
|
|
|
|
|
0
|
$tx->res->say("grants:"); |
43
|
0
|
|
|
|
|
0
|
$tx->res->say(" $_") for @{ $self->app->authz->granted }; |
|
0
|
|
|
|
|
0
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else |
47
|
|
|
|
|
|
|
{ |
48
|
4
|
|
|
|
|
80
|
my $name = lc $tx->req->as_string; # stringifying gets the user and the hostname, but not the verbosity |
49
|
4
|
|
|
|
|
58
|
my $found = 0; |
50
|
4
|
100
|
|
|
|
14
|
if(my $groups = $self->app->authz->groups_for_user($name)) |
|
|
100
|
|
|
|
|
|
51
|
|
|
|
|
|
|
{ |
52
|
2
|
|
|
|
|
207
|
$tx->res->say("user:" . $name); |
53
|
2
|
|
|
|
|
182
|
$tx->res->say("belongs to:"); |
54
|
2
|
|
|
|
|
133
|
$tx->res->say(" " . join(', ', sort @$groups)); |
55
|
2
|
|
|
|
|
172
|
$found = 1; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
elsif(my $users = $self->app->authz->users_in_group($name)) |
58
|
|
|
|
|
|
|
{ |
59
|
1
|
|
|
|
|
180
|
$tx->res->say("group:" . $name); |
60
|
1
|
|
|
|
|
81
|
$tx->res->say("members:"); |
61
|
1
|
|
|
|
|
66
|
$tx->res->say(" " . join(', ', sort @$users)); |
62
|
1
|
|
|
|
|
65
|
$found = 1; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
else |
65
|
|
|
|
|
|
|
{ |
66
|
1
|
|
|
|
|
173
|
$tx->res->say("no such user or group"); |
67
|
|
|
|
|
|
|
} |
68
|
4
|
50
|
33
|
|
|
100
|
if($tx->req->verbose && $found) |
69
|
|
|
|
|
|
|
{ |
70
|
0
|
|
|
|
|
0
|
$tx->res->say("granted:"); |
71
|
0
|
|
|
|
|
0
|
foreach my $grant (@{ $self->app->authz->granted }) |
|
0
|
|
|
|
|
0
|
|
72
|
|
|
|
|
|
|
{ |
73
|
|
|
|
|
|
|
$tx->res->say(" $grant") |
74
|
0
|
0
|
0
|
|
|
0
|
if $grant =~ /:(.*)$/ && grep { $name eq lc $_ || $_ eq '#u' } map { s/^\s+//; s/\s+$//; $_ } split /,/, $1; |
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
5
|
|
|
|
|
77
|
$tx->res->done; |
79
|
1
|
|
|
|
|
30
|
}); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |