Skip to content

Commit fc10af5

Browse files
avoid out-of-memory serving large logfiles (hestiacp#2741)
* avoid out-of-memory serving large logfiles large logfiles previously resulted in out-of-memory errors, see hestiacp#2736 * formatting * Update php version + Resolve PHP issue Remove pcntl_exec, passthru, system, popen From disabled functions list Requires rebuild hestia-php * fix double-escape issue Co-authored-by: Jaap Marcus <9754650+jaapmarcus@users.noreply.github.com>
1 parent b68df3b commit fc10af5

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/deb/php/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Source: hestia-php
22
Package: hestia-php
33
Priority: optional
4-
Version: 8.1.7
4+
Version: 8.1.8
55
Section: admin
66
Maintainer: HestaCP <info@hestiacp.com>
77
Homepage: https://www.hestiacp.com

src/deb/php/php.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ serialize_precision = -1
309309
; This directive allows you to disable certain functions.
310310
; It receives a comma-delimited list of function names.
311311
; http://php.net/disable-functions
312-
disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,passthru,system,popen,show_source,
312+
disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,show_source,
313313

314314
; This directive allows you to disable certain classes.
315315
; It receives a comma-delimited list of class names.

web/download/web-log/index.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
// Check token
66
verify_csrf($_GET);
77

8-
$v_domain = $_GET['domain'];
9-
$v_domain = escapeshellarg($_GET['domain']);
108
if ($_GET['type'] == 'access') {
119
$type = 'access';
1210
}
@@ -20,17 +18,23 @@
2018
header("Content-Type: application/octet-stream; ");
2119
header("Content-Transfer-Encoding: binary");
2220

23-
$v_domain = escapeshellarg($_GET['domain']);
21+
$v_domain = $_GET['domain'];
2422
if ($_GET['type'] == 'access') {
2523
$type = 'access';
2624
}
2725
if ($_GET['type'] == 'error') {
2826
$type = 'error';
2927
}
30-
31-
exec(HESTIA_CMD."v-list-web-domain-".$type."log $user ".$v_domain." 5000", $output, $return_var);
32-
if ($return_var == 0) {
33-
foreach ($output as $file) {
34-
echo $file . "\n";
35-
}
28+
$cmd = implode(" ", array(
29+
escapeshellarg(HESTIA_CMD . "v-list-web-domain-" . $type . "log"),
30+
// $user is already shell-escaped
31+
$user,
32+
escapeshellarg($v_domain),
33+
"5000",
34+
));
35+
passthru($cmd, $return_var);
36+
if ($return_var != 0) {
37+
$errstr = "Internal server error: command returned non-zero: {$return_var}: {$cmd}";
38+
echo $errstr;
39+
throw new Exception($errstr); // make sure it ends up in an errorlog somewhere
3640
}

0 commit comments

Comments
 (0)