summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2002-07-24 09:27:15 +0000
committerfukachan <fukachan>2002-07-24 09:27:15 +0000
commit8e49892e39d6dc1f9b41dd9cddd9a23a628b0e06 (patch)
tree2130f8fada1088d89db2211985f0fae080057f49
parent15d93611567173e065df480a121d6768cc5b715b (diff)
downloadfml8-8e49892e39d6dc1f9b41dd9cddd9a23a628b0e06.tar.gz
fml8-8e49892e39d6dc1f9b41dd9cddd9a23a628b0e06.tar.bz2
fml8-8e49892e39d6dc1f9b41dd9cddd9a23a628b0e06.zip
change argv of FML::Credential::has_address_in_map():
($map, $address) -> ($map, $config, $address)
-rw-r--r--fml/lib/FML/Command/Admin/chaddr.pm6
-rw-r--r--fml/lib/FML/Command/UserControl.pm28
-rw-r--r--fml/lib/FML/Credential.pm18
3 files changed, 38 insertions, 14 deletions
diff --git a/fml/lib/FML/Command/Admin/chaddr.pm b/fml/lib/FML/Command/Admin/chaddr.pm
index 1f662dd3..fecd42f3 100644
--- a/fml/lib/FML/Command/Admin/chaddr.pm
+++ b/fml/lib/FML/Command/Admin/chaddr.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: chaddr.pm,v 1.3 2002/05/29 11:26:38 fukachan Exp $
+# $FML: chaddr.pm,v 1.4 2002/07/23 13:03:13 fukachan Exp $
#
package FML::Command::Admin::chaddr;
@@ -98,8 +98,8 @@ sub process
# the current member/recipient file must have $old_address
# but should not contain $new_address.
- if ($cred->has_address_in_map($map, $old_address)) {
- unless ($cred->has_address_in_map($map, $new_address)) {
+ if ($cred->has_address_in_map($map, $config, $old_address)) {
+ unless ($cred->has_address_in_map($map, $config, $new_address)) {
# remove the old address.
{
my $obj = new IO::Adapter $map, $config;
diff --git a/fml/lib/FML/Command/UserControl.pm b/fml/lib/FML/Command/UserControl.pm
index 8eeef28d..b535c968 100644
--- a/fml/lib/FML/Command/UserControl.pm
+++ b/fml/lib/FML/Command/UserControl.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: UserControl.pm,v 1.13 2002/07/17 12:13:23 fukachan Exp $
+# $FML: UserControl.pm,v 1.14 2002/07/23 13:03:12 fukachan Exp $
#
package FML::Command::UserControl;
@@ -16,6 +16,8 @@ use FML::Credential;
use FML::Log qw(Log LogWarn LogError);
use IO::Adapter;
+my $debug = 0;
+
=head1 NAME
@@ -55,13 +57,16 @@ sub useradd
my $address = $uc_args->{ address };
my $maplist = $uc_args->{ maplist };
my $msg_args = $command_args->{ msg_args };
+ my $trycount = 0;
$msg_args->{ _arg_address } = $address;
for my $map (@$maplist) {
my $cred = new FML::Credential;
- unless ($cred->has_address_in_map($map, $address)) {
+ unless ($cred->has_address_in_map($map, $config, $address)) {
$msg_args->{ _arg_map } = $curproc->which_map_nl($map);
+ $trycount++;
+
my $obj = new IO::Adapter $map, $config;
$obj->touch(); # create a new map entry (e.g. file) if needed.
$obj->add( $address );
@@ -83,6 +88,10 @@ sub useradd
return undef;
}
}
+
+ unless ($trycount) {
+ LogError("no trail to add $address");
+ }
}
@@ -98,17 +107,20 @@ sub userdel
my $address = $uc_args->{ address };
my $maplist = $uc_args->{ maplist };
my $msg_args = $command_args->{ msg_args };
+ my $trycount = 0;
$msg_args->{ _arg_address } = $address;
for my $map (@$maplist) {
my $cred = new FML::Credential;
- if ($cred->has_address_in_map($map, $address)) {
+ if ($cred->has_address_in_map($map, $config, $address)) {
$msg_args->{ _arg_map } = $curproc->which_map_nl($map);
+
+ $trycount++;
- my $obj = new IO::Adapter $map, $config;
+ my $obj = new IO::Adapter $map, $config;
$obj->delete( $address );
unless ($obj->error()) {
- Log("removed $address from map=$map");
+ Log("remove $address from map=$map");
$curproc->reply_message_nl('command.del_ok',
"$address removed.",
$msg_args);
@@ -121,9 +133,13 @@ sub userdel
}
}
else {
- LogWarn("no such user in map=$map");
+ LogWarn("no such user in map=$map") if $debug;
}
}
+
+ unless ($trycount) {
+ LogError("no trail to remove $address");
+ }
}
diff --git a/fml/lib/FML/Credential.pm b/fml/lib/FML/Credential.pm
index dd8bc52d..043dac7a 100644
--- a/fml/lib/FML/Credential.pm
+++ b/fml/lib/FML/Credential.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: Credential.pm,v 1.28 2002/07/17 09:35:17 fukachan Exp $
+# $FML: Credential.pm,v 1.29 2002/07/22 15:33:16 tmu Exp $
#
package FML::Credential;
@@ -14,6 +14,9 @@ use vars qw(%Credential @ISA @EXPORT @EXPORT_OK);
use Carp;
use ErrorStatus qw(errstr error error_set error_clear);
+my $debug = 0;
+
+
=head1 NAME
FML::Credential - functions to authenticate the mail sender
@@ -251,6 +254,7 @@ sub is_recipient
sub _is_member
{
my ($self, $curproc, $args, $optargs) = @_;
+ my $config = $curproc->config();
my $status = 0;
my $user = '';
my $domain = '';
@@ -274,7 +278,7 @@ sub _is_member
MAP:
for my $map (@$member_maps) {
if (defined $map) {
- $status = $self->has_address_in_map($map, $address);
+ $status = $self->has_address_in_map($map, $config, $address);
last MAP if $status;
}
}
@@ -285,21 +289,25 @@ sub _is_member
# Descriptions: $map contains $address or not in some ambiguity
# by is_same_address().
-# Arguments: OBJ($self) STR($map) STR($address)
+# Arguments: OBJ($self) STR($map) HASH_REF($config) STR($address)
# Side Effects: none
# Return Value: NUM(1 or 0)
sub has_address_in_map
{
- my ($self, $map, $address) = @_;
+ my ($self, $map, $config, $address) = @_;
my ($user, $domain) = split(/\@/, $address);
my $status = 0;
use IO::Adapter;
- my $obj = new IO::Adapter $map;
+ my $obj = new IO::Adapter $map, $config;
# 1. get all entries match /^$user/ from $map.
my $addrs = $obj->find( $user , { want => 'key', all => 1 });
+ if (ref($addrs) && $debug) {
+ print STDERR "cred: matched [ @$addrs ]\n";
+ }
+
# 2. try each address in the result matches $address to check.
if (defined $addrs) {
LOOP: