WE/DB/ComplexUser/AuthUnix.pm

filter: Statementstmt 50.0% 11 / 22 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 3 / 4 Podpod 0.0% 0 / 1 totaltotal 33.3% 14 / 42 CC 7 SCAR 36.8
CC
7
Cov
31%
identify_Unix
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 39.5
« WebEditor/OldFeatures/PrintTemplates.pm ↑ Summary WE/Util/MIME.pm »
1 # -*- perl -*-
2  
3 #
4 # $Id: AuthUnix.pm,v 1.2 2005/02/03 00:06:28 eserte Exp $
5 # Author: Slaven Rezic
6 #
7 # Copyright (C) 2005 Slaven Rezic. All rights reserved.
8 # This package is free software; you can redistribute it and/or
9 # modify it under the same terms as Perl itself.
10 #
11 # Mail: slaven@rezic.de
12 # WWW: http://www.rezic.de/eserte/
13 #
14  
15 package WE::DB::ComplexUser::AuthUnix;
16  
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use vars qw($VERSION $DEBUG);
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 $VERSION = sprintf("%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/);
20  
21 1 ▶use mixin::with 'WE::DB::ComplexUser';
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 # This works only on system without shadow passwords!
24  
25 0 ▶sub identify_Unix {
Subroutine identify_Unix: not called CC=7 SCAR=40.3
Pod undocumented
26 0 my($self, $user, $password) = @_;
27  
28 0 ▶ my $unix_user = $user->{Auth_Unix_User} || $user->Username;
Condition0%0/3
$user->{'Auth_Unix_User'} || $user->Username
l!l&&r!l&&!r
000
MC/DC0%0/2
$user->{'Auth_Unix_User'} || $user->Username
$user->{'Auth_Unix_User'} $user->Username
Truth table0%0/3
A || B
A= $user->{'Auth_Unix_User'}B= $user->Username
ABresult
1X1
011
000
29 0 ▶ warn "Try unix authentication with user=$unix_user...\n" if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $WE::DB::ComplexUser::AuthUnix::DEBUG 0 0 0
30  
31 0 my(undef, $pwd, $uid) = getpwnam($unix_user);
32 0 ▶ if (!defined $uid) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $uid) 0 0 0
33 0 ▶ warn "The unix user <$unix_user> is undefined" if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $WE::DB::ComplexUser::AuthUnix::DEBUG 0 0 0
34 0 return 0;
35 }
36
37 0 ▶ if (crypt($password, $pwd) eq $pwd) {
Branch: 1 branch
BranchTrueFalseTotal
if (crypt($password, $pwd) eq $pwd) { } 0 0 0
38 0 return 1;
39 } else {
40 0 ▶ warn "Password incorrect" if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $WE::DB::ComplexUser::AuthUnix::DEBUG 0 0 0
41 0 return 0;
42 }
43 }
44  
45 1 1;
46  
47 __END__
« WebEditor/OldFeatures/PrintTemplates.pm ↑ Summary WE/Util/MIME.pm »