Dovecot 2.2+ has deprecated ssl_ca_file and similar https://sourceforge.net/p/webadmin/bugs/5117/

This commit is contained in:
Jamie Cameron 2018-04-16 16:30:01 -07:00
parent 3d06c34a59
commit e4eca67a48
3 changed files with 18 additions and 7 deletions

View File

@ -411,10 +411,20 @@ return $text{'default'};
# Returns the dovecot version number, or undef if not available # Returns the dovecot version number, or undef if not available
sub get_dovecot_version sub get_dovecot_version
{ {
local $out = `$config{'dovecot'} --version 2>&1`; local $out = &backquote_command("$config{'dovecot'} --version 2>&1");
return $out =~ /([0-9\.]+)/ ? $1 : undef; return $out =~ /([0-9\.]+)/ ? $1 : undef;
} }
# version_atleast(ver)
# Returns 1 if running at least some version or above
sub version_atleast
{
local ($wantver) = @_;
local $ver = &get_dovecot_version();
return 0 if (!$ver);
return &compare_version_numbers($wantver, $ver) >= 0;
}
sub list_lock_methods sub list_lock_methods
{ {
local ($forindex) = @_; local ($forindex) = @_;

View File

@ -9,7 +9,7 @@ print &ui_form_start("save_ssl.cgi", "post");
print &ui_table_start($text{'ssl_header'}, "width=100%", 4); print &ui_table_start($text{'ssl_header'}, "width=100%", 4);
# SSL cert and key files # SSL cert and key files
if (&find_value("ssl_cert", $conf, 2)) { if (&find_value("ssl_cert", $conf, 2) || &version_atleast("2.2")) {
$cert = &find_value("ssl_cert", $conf, 0, ""); $cert = &find_value("ssl_cert", $conf, 0, "");
$cert =~ s/^<//; $cert =~ s/^<//;
} }
@ -20,7 +20,7 @@ print &ui_table_row($text{'ssl_cert'},
&ui_opt_textbox("cert", $cert, 40, &getdef("ssl_cert_file")), 3, &ui_opt_textbox("cert", $cert, 40, &getdef("ssl_cert_file")), 3,
[ undef, "nowrap" ]); [ undef, "nowrap" ]);
if (&find_value("ssl_key", $conf, 2)) { if (&find_value("ssl_key", $conf, 2) || &version_atleast("2.2")) {
$key = &find_value("ssl_key", $conf, 0, ""); $key = &find_value("ssl_key", $conf, 0, "");
$key =~ s/^<//; $key =~ s/^<//;
} }
@ -38,7 +38,7 @@ print &ui_table_row($text{'ssl_pass'},
[ undef, "nowrap" ]); [ undef, "nowrap" ]);
# SSL CA file # SSL CA file
if (&find_value("ssl_ca", $conf, 2)) { if (&find_value("ssl_ca", $conf, 2) || &version_atleast("2.2")) {
$ca = &find_value("ssl_ca", $conf, 0, ""); $ca = &find_value("ssl_ca", $conf, 0, "");
$ca =~ s/^<//; $ca =~ s/^<//;
} }

View File

@ -10,7 +10,7 @@ $conf = &get_config();
# Save SSL cert and key # Save SSL cert and key
$in{'cert_def'} || -r $in{'cert'} || $in{'cert'} =~ /^[<>\|]/ || $in{'cert_def'} || -r $in{'cert'} || $in{'cert'} =~ /^[<>\|]/ ||
&error($text{'ssl_ecert'}); &error($text{'ssl_ecert'});
if (&find_value("ssl_cert", $conf, 2)) { if (&find_value("ssl_cert", $conf, 2) || &version_atleast("2.2")) {
$in{'cert'} = "<".$in{'cert'} if ($in{'cert'} =~ /^\//); $in{'cert'} = "<".$in{'cert'} if ($in{'cert'} =~ /^\//);
&save_directive($conf, "ssl_cert", &save_directive($conf, "ssl_cert",
$in{'cert_def'} ? undef : $in{'cert'}, ""); $in{'cert_def'} ? undef : $in{'cert'}, "");
@ -19,9 +19,10 @@ else {
&save_directive($conf, "ssl_cert_file", &save_directive($conf, "ssl_cert_file",
$in{'cert_def'} ? undef : $in{'cert'}); $in{'cert_def'} ? undef : $in{'cert'});
} }
$in{'key_def'} || -r $in{'key'} || $in{'key'} =~ /^[<>\|]/ || $in{'key_def'} || -r $in{'key'} || $in{'key'} =~ /^[<>\|]/ ||
&error($text{'ssl_ekey'}); &error($text{'ssl_ekey'});
if (&find_value("ssl_key", $conf, 2)) { if (&find_value("ssl_key", $conf, 2) || &version_atleast("2.2")) {
$in{'key'} = "<".$in{'key'} if ($in{'key'} =~ /^\//); $in{'key'} = "<".$in{'key'} if ($in{'key'} =~ /^\//);
&save_directive($conf, "ssl_key", &save_directive($conf, "ssl_key",
$in{'key_def'} ? undef : $in{'key'}, ""); $in{'key_def'} ? undef : $in{'key'}, "");
@ -34,7 +35,7 @@ else {
# Save SSL CA cert # Save SSL CA cert
$in{'ca_def'} || -r $in{'ca'} || $in{'ca'} =~ /^[<>\|]/ || $in{'ca_def'} || -r $in{'ca'} || $in{'ca'} =~ /^[<>\|]/ ||
&error($text{'ssl_eca'}); &error($text{'ssl_eca'});
if (&find_value("ssl_ca", $conf, 2)) { if (&find_value("ssl_ca", $conf, 2) || &version_atleast("2.2")) {
$in{'ca'} = "<".$in{'ca'} if ($in{'ca'} =~ /^\//); $in{'ca'} = "<".$in{'ca'} if ($in{'ca'} =~ /^\//);
&save_directive($conf, "ssl_ca", &save_directive($conf, "ssl_ca",
$in{'ca_def'} ? undef : $in{'ca'}, ""); $in{'ca_def'} ? undef : $in{'ca'}, "");