diff options
| author | fukachan <fukachan> | 2003-12-30 03:51:02 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2003-12-30 03:51:02 +0000 |
| commit | 226856777090a30c85b15bd288f7690914d683bb (patch) | |
| tree | 86205edc9300301b2c0d0809c2adab4af654bacd /fml/lib/FML/Command | |
| parent | 3ec97974b89e3dc36e164a24083e13f173bc7cdc (diff) | |
| download | fml8-226856777090a30c85b15bd288f7690914d683bb.tar.gz fml8-226856777090a30c85b15bd288f7690914d683bb.tar.bz2 fml8-226856777090a30c85b15bd288f7690914d683bb.zip | |
validate $address input as data.
$cred = $curproc->{ credential };
update comments.
Diffstat (limited to 'fml/lib/FML/Command')
| -rw-r--r-- | fml/lib/FML/Command/Auth.pm | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/fml/lib/FML/Command/Auth.pm b/fml/lib/FML/Command/Auth.pm index bb320381..a937ca89 100644 --- a/fml/lib/FML/Command/Auth.pm +++ b/fml/lib/FML/Command/Auth.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Auth.pm,v 1.28 2003/08/29 15:33:57 fukachan Exp $ +# $FML: Auth.pm,v 1.29 2003/11/30 09:59:18 fukachan Exp $ # package FML::Command::Auth; @@ -131,12 +131,15 @@ check the password if it is valid or not as an administrator. sub check_admin_member_password { my ($self, $curproc, $args, $optargs) = @_; - my $config = $curproc->config(); - my $maplist = $config->get_as_array_ref('admin_member_password_maps'); - my $status = 0; + my $function = "check_admin_member_password"; + my $cred = $curproc->{ credential }; + my $config = $curproc->config(); + my $status = 0; # simple sanity check: verify non empty input or not? + return 0 unless defined $optargs->{ address }; return 0 unless $optargs->{ address }; + return 0 unless defined $optargs->{ password }; return 0 unless $optargs->{ password }; # get a set of address and password @@ -146,17 +149,22 @@ sub check_admin_member_password return 0; } - # XXX-TODO: validate $address here ? - # get candidates + # 1. validate address. address representation is restricted. + # 2. but, password should be allowed arbitrary syntax. + use FML::Restriction::Base; + my $safe = new FML::Restriction::Base; + unless ($safe->regexp_match('address', $address)) { + $curproc->logerror("FML::Command::Auth: unsafe address input"); + return 0; + } my ($user, $domain) = split(/\@/, $address); - use FML::Credential; - my $cred = new FML::Credential $curproc; - + # o.k. start ... $curproc->lock($lock_channel); # search $user in password database map, which has a hash of - # { $user => $encryptd_passwrod }. + # { $user => $encrypted_passwrod }. + my $maplist = $config->get_as_array_ref('admin_member_password_maps'); for my $map (@$maplist) { use IO::Adapter; my $obj = new IO::Adapter $map, $config; @@ -173,14 +181,12 @@ sub check_admin_member_password my ($u, $p_infile) = split(/\s+/, $r); my $p_input = $crypt->unix_crypt($password, $p_infile); - # XXX-TODO: is_same_assress() validates input ??? - # XXX-TODO: we need to validate addresses here ??? - # 1.1 user match ? + # 1.1 user match ? ($address syntax is checked above.) if ($cred->is_same_address($u, $address)) { # 1.2 password match ? if ($p_infile eq $p_input) { if ($debug) { - $curproc->log("check_admin_member_password: password match"); + $curproc->log("$function: password match"); } $status = 1; last PASSWORD_ENTRY; @@ -192,7 +198,7 @@ sub check_admin_member_password $curproc->unlock($lock_channel); - $curproc->logwarn("check_admin_member_password: password not match") unless $status; + $curproc->logerror("$function: password mismatch") unless $status; return $status; } |
