Skip to content

Commit dd8e7a5

Browse files
nitpicks (hestiacp#5055)
* nitpicks no need to call cli mktemp, php have tmpfile(). technically if the tmp dir is in a custom location, quoteshellarg is needed (in practice it /is/ /tmp/ and we don't need it, but it's good practice to use quoteshellarg anyway) * Fix format --------- Co-authored-by: Jaap Marcus <9754650+jaapmarcus@users.noreply.github.com>
1 parent 397ba4c commit dd8e7a5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

web/edit/server/hestiaweb/index.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use function Hestiacp\quoteshellarg\quoteshellarg;
34
$TAB = "SERVER";
45

56
// Main include
@@ -14,23 +15,24 @@
1415
// Check POST request
1516
if (!empty($_POST["save"])) {
1617
if (!empty($_POST["v_config"])) {
17-
exec("mktemp", $mktemp_output, $return_var);
18-
$new_conf = $mktemp_output[0];
19-
$fp = fopen($new_conf, "w");
18+
$fp = tmpfile();
19+
$new_conf = stream_get_meta_data($fp)["uri"];
2020
$config = str_replace("\r\n", "\n", $_POST["v_config"]);
2121
if (!str_ends_with($config, "\n")) {
2222
$config .= "\n";
2323
}
2424
fwrite($fp, $config);
25-
fclose($fp);
2625
exec(
27-
HESTIA_CMD . "v-change-sys-service-config " . $new_conf . " hestiaweb yes",
26+
HESTIA_CMD .
27+
"v-change-sys-service-config " .
28+
quoteshellarg($new_conf) .
29+
" hestiaweb yes",
2830
$output,
2931
$return_var,
3032
);
3133
check_return_code($return_var, $output);
3234
unset($output);
33-
unlink($new_conf);
35+
fclose($fp);
3436
}
3537
}
3638

0 commit comments

Comments
 (0)