Skip to content

Commit

Permalink
Item14205: Fixed a bug where two consequent auto-config button clicks…
Browse files Browse the repository at this point in the history
… led to a perl error.
  • Loading branch information
vrurg committed Nov 9, 2016
1 parent 74d590a commit ed6218f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions core/lib/Foswiki/Configure/Wizards/AutoConfigureEmail.pm
Expand Up @@ -487,6 +487,8 @@ our (
);
our $pad = ' ' x length('Net::SMTpXXX ');

my @Net_SMTP_default_ISA;

# Return 0 on failure
sub _autoconfigSMTP {
my ($reporter) = @_;
Expand All @@ -505,6 +507,9 @@ sub _autoconfigSMTP {
}
}

# Kinda simulate state variables.
@Net_SMTP_default_ISA = @Net::SMTP::ISA unless @Net_SMTP_default_ISA;

my $trySSL = 1;

# Make sure all SSL dependencies are available. If any fail, don't try SSL.
Expand Down Expand Up @@ -538,7 +543,7 @@ sub _autoconfigSMTP {

# Enable IPv6 if it's available
@Net::SMTP::ISA = (
grep( $_ !~ /^IO::Socket::I(?:NET|P)$/, @Net::SMTP::ISA ),
grep( $_ !~ /^IO::Socket::I(?:NET|P)$/, @Net_SMTP_default_ISA ),
'IO::Socket::IP'
);
}
Expand Down Expand Up @@ -623,15 +628,15 @@ sub _autoconfigSMTP {
# Configuration data for each method. Ports in priority order.

my $sockSSLisa = [
grep( $_ !~ /^IO::Socket::I(?:NET|P)$/, @Net::SMTP::ISA ),
grep( $_ !~ /^IO::Socket::I(?:NET|P)$/, @Net_SMTP_default_ISA ),
'IO::Socket::SSL'
];

my %config = (
starttls => {
ports => [qw/submission(587) smtp(25)/],
method => 'Net::SMTP (STARTTLS)',
isa => [@Net::SMTP::ISA],
isa => [@Net_SMTP_default_ISA],
ssl => [ SSL_version => 'TLSv1' ],
starttls => 1,
},
Expand All @@ -650,7 +655,7 @@ sub _autoconfigSMTP {
smtp => {
ports => [qw/submission(587) smtp(25)/],
method => 'Net::SMTP',
isa => [@Net::SMTP::ISA],
isa => [@Net_SMTP_default_ISA],
},
);
@Net::SMTP::ISA = 'Foswiki::Configure::Wizards::AutoConfigureEmail::SSL';
Expand Down Expand Up @@ -778,6 +783,7 @@ sub _autoconfigSMTP {
$tlsSsl = 0
if ( $startTls = $cfg->{starttls} );

@Foswiki::Configure::Wizards::AutoConfigureEmail::SSL::ISA = ();
@Foswiki::Configure::Wizards::AutoConfigureEmail::SSL::ISA =
@{ $cfg->{isa} };

Expand Down

0 comments on commit ed6218f

Please sign in to comment.