Przeglądaj źródła

[Fix] Cleanup temporary files when uploading custom SSL cert from WebUi

Robert Zollner 5 lat temu
rodzic
commit
dcc5eb10fc
2 zmienionych plików z 11 dodań i 0 usunięć
  1. 6 0
      web/add/web/index.php
  2. 5 0
      web/edit/server/index.php

+ 6 - 0
web/add/web/index.php

@@ -197,6 +197,12 @@ if (!empty($_POST['ok'])) {
              exec (HESTIA_CMD."v-add-web-domain-ssl ".$user." ".escapeshellarg($v_domain)." ".$tmpdir." ".$v_ssl_home." 'no'", $output, $return_var);
              exec (HESTIA_CMD."v-add-web-domain-ssl ".$user." ".escapeshellarg($v_domain)." ".$tmpdir." ".$v_ssl_home." 'no'", $output, $return_var);
              check_return_code($return_var,$output);
              check_return_code($return_var,$output);
              unset($output);
              unset($output);
+
+            // Cleanup certificate tempfiles
+            if (!empty($_POST['v_ssl_crt'])) unlink($tmpdir."/".$v_domain.".crt");
+            if (!empty($_POST['v_ssl_key'])) unlink($tmpdir."/".$v_domain.".key");
+            if (!empty($_POST['v_ssl_ca']))  unlink($tmpdir."/".$v_domain.".ca");
+            rmdir($tmpdir);
          }
          }
      }
      }
 
 

+ 5 - 0
web/edit/server/index.php

@@ -509,6 +509,11 @@ if (!empty($_POST['save'])) {
             $v_ssl_signature = $ssl_str['HESTIA']['SIGNATURE'];
             $v_ssl_signature = $ssl_str['HESTIA']['SIGNATURE'];
             $v_ssl_pub_key = $ssl_str['HESTIA']['PUB_KEY'];
             $v_ssl_pub_key = $ssl_str['HESTIA']['PUB_KEY'];
             $v_ssl_issuer = $ssl_str['HESTIA']['ISSUER'];
             $v_ssl_issuer = $ssl_str['HESTIA']['ISSUER'];
+
+            // Cleanup certificate tempfiles
+            if (file_exists($tmpdir . '/certificate.crt')) unlink($tmpdir . '/certificate.crt');
+            if (file_exists($tmpdir . '/certificate.key')) unlink($tmpdir . '/certificate.key');
+            rmdir($tmpdir);
         }
         }
     }
     }