1 |
From f9399950f369c9557bbff6fe77fb22ac5a079ff4 Mon Sep 17 00:00:00 2001 |
2 |
From: Hanno Hecker <vetinari@ankh-morp.org> |
3 |
Date: Fri, 6 Mar 2009 14:56:12 +0800 |
4 |
Subject: plugins/rcpt_map cleanup |
5 |
|
6 |
* enforce having a "domain" parameter |
7 |
* unique default message (missing dot added) |
8 |
--- |
9 |
plugins/rcpt_map | 31 +++++++++++++++++-------------- |
10 |
1 files changed, 17 insertions(+), 14 deletions(-) |
11 |
|
12 |
diff --git a/plugins/rcpt_map b/plugins/rcpt_map |
13 |
index 727ae7d..77f3f67 100644 |
14 |
--- a/plugins/rcpt_map |
15 |
+++ b/plugins/rcpt_map |
16 |
@@ -12,6 +12,9 @@ matches, the return code from that line and the comment are returned to |
17 |
qpsmtpd. Return code can be any valid plugin return code from |
18 |
L<Qpsmtpd::Constants>. Matching is always done case insenstive. |
19 |
|
20 |
+When the given map file changes on disk, it is re-read in the pre-connection |
21 |
+hook. |
22 |
+ |
23 |
=head1 ARGUMENTS |
24 |
|
25 |
The C<file MAP> and C<domain NAME> arguments are required. The default value of |
26 |
@@ -91,18 +94,13 @@ sub register { |
27 |
next unless exists $args{$arg}; |
28 |
if ($arg eq "default") { |
29 |
my ($code, $msg) = split /=/, $args{$arg}; |
30 |
+ |
31 |
$code = Qpsmtpd::Constants::return_code($code); |
32 |
- unless (defined $code) { |
33 |
- $self->log(LOGERROR, "Not a valid constant for 'default' arg"); |
34 |
- die "Not a valid constant for 'default' arg"; |
35 |
- } |
36 |
- |
37 |
- if ($msg) { |
38 |
- $msg =~ s/_/ /g; |
39 |
- } |
40 |
- else { |
41 |
- $msg = "No such user."; |
42 |
- } |
43 |
+ die "Not a valid constant for 'default' arg" |
44 |
+ unless defined $code; |
45 |
+ |
46 |
+ $msg or $msg = "No such user."; |
47 |
+ $msg =~ s/_/ /g; |
48 |
|
49 |
$self->{_default} = [$code, $msg]; |
50 |
} |
51 |
@@ -112,14 +110,19 @@ sub register { |
52 |
} |
53 |
|
54 |
$self->{_default} |
55 |
- or $self->{_default} = [DENY, "No such user"]; |
56 |
+ or $self->{_default} = [DENY, "No such user."]; |
57 |
|
58 |
$self->{_file} |
59 |
or die "No map file given..."; |
60 |
|
61 |
- $self->log(LOGDEBUG, "Using file ".$self->{_file}); |
62 |
+ $self->{_domain} |
63 |
+ or die "No domain name given..."; |
64 |
+ $self->{_domain} = lc $self->{_domain}; |
65 |
+ |
66 |
+ $self->log(LOGDEBUG, |
67 |
+ "Using map ".$self->{_file}." for domain ".$self->{_domain}); |
68 |
%map = $self->read_map(1); |
69 |
- die "Empty map file" |
70 |
+ die "Empty map file ".$self->{_file} |
71 |
unless keys %map; |
72 |
} |
73 |
|
74 |
-- |
75 |
1.7.2.2 |
76 |
|