summaryrefslogtreecommitdiff
path: root/fml/lib/FML/Command/Auth.pm
diff options
context:
space:
mode:
authorfukachan <fukachan>2002-03-23 14:24:35 +0000
committerfukachan <fukachan>2002-03-23 14:24:35 +0000
commit71266163c0b14a01a57c7e4781847f7ef8fba252 (patch)
tree1a957665eed3a5cb380f08f32bba4c3ab5135ee2 /fml/lib/FML/Command/Auth.pm
parent77bb021b4a05d67a55315e790c64cd8417f510b8 (diff)
downloadfml8-71266163c0b14a01a57c7e4781847f7ef8fba252.tar.gz
fml8-71266163c0b14a01a57c7e4781847f7ef8fba252.tar.bz2
fml8-71266163c0b14a01a57c7e4781847f7ef8fba252.zip
implement password authentication for admin commands
Diffstat (limited to 'fml/lib/FML/Command/Auth.pm')
-rw-r--r--fml/lib/FML/Command/Auth.pm44
1 files changed, 42 insertions, 2 deletions
diff --git a/fml/lib/FML/Command/Auth.pm b/fml/lib/FML/Command/Auth.pm
index 04927857..7a361bc1 100644
--- a/fml/lib/FML/Command/Auth.pm
+++ b/fml/lib/FML/Command/Auth.pm
@@ -4,13 +4,18 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: @template.pm,v 1.5 2002/01/18 15:37:38 fukachan Exp $
+# $FML: Auth.pm,v 1.1 2002/03/22 15:30:45 fukachan Exp $
#
package FML::Command::Auth;
use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
use Carp;
+use FML::Log qw(Log LogWarn LogError);
+
+# always use this module's crypt
+BEGIN { $Crypt::UnixCrpyt::OVERRIDE_BUILTIN = 1 }
+use Crypt::UnixCrypt;
=head1 NAME
@@ -45,7 +50,42 @@ sub reject
sub check_password
{
- return 1;
+ my ($self, $curproc, $args, $optargs) = @_;
+ my $config = $curproc->{ config };
+ my $maplist = $config->get_as_array_ref('admin_member_passwd_maps');
+ my $address = $optargs->{ address };
+ my $password = $optargs->{ password };
+
+ # simple sanity check: verify non empty input or not?
+ unless ($address && $password) {
+ return 0;
+ }
+
+ # get candidates
+ my ($user, $domain) = split(/\@/, $address);
+
+ for my $map (@$maplist) {
+ use IO::Adapter;
+ my $obj = new IO::Adapter $map;
+ my $addrs = $obj->find( $user , { want => 'key,value', all => 1 });
+
+ if (defined $addrs) {
+ LOOP:
+ for my $r (@$addrs) {
+ my ($u, $p_infile) = split(/\s+/, $r);
+ my $p_input = crypt( $password, $p_infile );
+
+ # password match
+ if ($p_infile eq $p_input) {
+ Log("check_password: password match");
+ return 1;
+ }
+ }
+ }
+ }
+
+ LogWarn("check_password: password not match");
+ return 0;
}