| 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
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
| |||||||||||||||||||||
| 29 | 0 | ▶ | warn "Try unix authentication with user=$unix_user...\n" if $DEBUG; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 0 | my(undef, $pwd, $uid) = getpwnam($unix_user); | |||||||||||||||||||
| 32 | 0 | ▶ | if (!defined $uid) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 33 | 0 | ▶ | warn "The unix user <$unix_user> is undefined" if $DEBUG; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 34 | 0 | return 0; | |||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 0 | ▶ | if (crypt($password, $pwd) eq $pwd) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 38 | 0 | return 1; | |||||||||||||||||||
| 39 | } else { | ||||||||||||||||||||
| 40 | 0 | ▶ | warn "Password incorrect" if $DEBUG; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 41 | 0 | return 0; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 1 | 1; | |||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | __END__ | ||||||||||||||||||||