]> git.proxmox.com Git - pmg-api.git/commitdiff
certs: reload postfix to activate new certificate
authorStoiko Ivanov <s.ivanov@proxmox.com>
Thu, 18 Mar 2021 15:14:49 +0000 (16:14 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 18 Mar 2021 15:31:46 +0000 (16:31 +0100)
the current logic for reloading postfix only does so if the tls config
parameter changes (after rewriting the config files).
this does not cover the case where a certificate is replaced in a
setup, which already has tls enabled (config stays the same, so
postfix does not get reloaded)

the issue is mostly cosmetic, since postfix does eventually fork off
new smtpd instances, which read the files from disk, but it's
inconvenient, when trying out the new acme integration, and then
running a ssl-check on your PMG from external just to see that the
certificate was not updated.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
src/PMG/API2/Certificates.pm

index 1a6c434206ffb8bc8b33d6dcd953762b7c1910de..1a7ded68294ebba3508ceec22f4a28a15100e7d1 100644 (file)
@@ -69,16 +69,14 @@ my sub set_smtp : prototype($$) {
 
     my $code = sub {
        my $cfg = PMG::Config->new();
-       if (!$cfg->get('mail', 'tls') == !$on) {
-           return;
+       if (!$cfg->get('mail', 'tls') != !$on) {
+           print "Rewriting postfix config\n";
+           $cfg->set('mail', 'tls', $on);
+           $cfg->write();
+           my $changed = $cfg->rewrite_config_postfix();
        }
 
-       print "Rewriting postfix config\n";
-       $cfg->set('mail', 'tls', $on);
-       $cfg->write();
-       my $changed = $cfg->rewrite_config_postfix();
-
-       if ($changed && $reload) {
+       if ($reload) {
            print "Reloading postfix\n";
            PMG::Utils::service_cmd('postfix', 'reload');
        }