1 |
wellsi |
1.1 |
diff -ruN e-smith-email-5.4.0.old/root/usr/local/sbin/smtp-auth-proxy.pl e-smith-email-5.4.0/root/usr/local/sbin/smtp-auth-proxy.pl |
2 |
|
|
--- e-smith-email-5.4.0.old/root/usr/local/sbin/smtp-auth-proxy.pl 2013-02-06 13:56:01.000000000 -0800 |
3 |
|
|
+++ e-smith-email-5.4.0/root/usr/local/sbin/smtp-auth-proxy.pl 2013-12-14 12:27:33.000000000 -0800 |
4 |
|
|
@@ -114,13 +114,29 @@ |
5 |
|
|
|
6 |
|
|
if ($smtp->supports("AUTH")) |
7 |
|
|
{ |
8 |
|
|
- foreach (split (/ /, $self->get_property('Blacklist'))) |
9 |
|
|
- {${*$smtp}{'net_smtp_esmtp'}->{"AUTH"} =~ s/$_//;} |
10 |
|
|
- |
11 |
|
|
- unless ($smtp->auth($name, $pass)) |
12 |
|
|
+ my $authenticated = 0; |
13 |
|
|
+ my $blacklist = $self->get_property('Blacklist') || "";; |
14 |
|
|
+ foreach my $method (split (/ /, ${*$smtp}{'net_smtp_esmtp'}->{"AUTH"})) |
15 |
|
|
+ { |
16 |
|
|
+ # Skip $method if in the blacklist |
17 |
|
|
+ next unless ($blacklist !~ /$method/); |
18 |
|
|
+ # Only present one auth method at a time to NET::SMTP |
19 |
|
|
+ {${*$smtp}{'net_smtp_esmtp'}->{"AUTH"} = $method;} |
20 |
|
|
+ |
21 |
|
|
+ if ($smtp->auth($name, $pass)) |
22 |
|
|
+ { |
23 |
|
|
+ $authenticated++; |
24 |
|
|
+ last; |
25 |
|
|
+ } |
26 |
|
|
+ else |
27 |
|
|
+ { |
28 |
|
|
+ warn "SMTP authentication (with $method) with ISP server failed\n"; |
29 |
|
|
+ } |
30 |
|
|
+ } |
31 |
|
|
+ unless ($authenticated) |
32 |
|
|
{ |
33 |
|
|
print "451 Could not auth to mail server\n"; |
34 |
|
|
- warn "SMTP authentication with ISP server failed\n"; |
35 |
|
|
+ warn "all SMTP authentication methods failed\n"; |
36 |
|
|
$smtp->quit; |
37 |
|
|
exit; |
38 |
|
|
} |
39 |
|
|
@@ -133,19 +149,19 @@ |
40 |
|
|
|
41 |
|
|
my $discard = <STDIN>; # Swallow EHLO |
42 |
|
|
while (my $msg = shift @ehlo) { |
43 |
|
|
- my $sep = (@ehlo ? "-" : " "); |
44 |
|
|
- print "250$sep$msg"; |
45 |
|
|
+ my $sep = (@ehlo ? "-" : " "); |
46 |
|
|
+ print "250$sep$msg"; |
47 |
|
|
} |
48 |
|
|
|
49 |
|
|
die "can't fork: $!" unless defined ($kidpid = fork()); |
50 |
|
|
if ($kidpid) |
51 |
|
|
{ |
52 |
|
|
- print $smtp $_ while <STDIN>; |
53 |
|
|
+ print $smtp $_ while <STDIN>; |
54 |
|
|
kill ("TERM" => $kidpid); |
55 |
|
|
} |
56 |
|
|
else |
57 |
|
|
{ |
58 |
|
|
- print while <$smtp>; |
59 |
|
|
+ print while <$smtp>; |
60 |
|
|
kill ("TERM" => getppid()); |
61 |
|
|
} |
62 |
|
|
} |