From b13b82112a0b26ec0db5f56f34de75b786ff0da9 Mon Sep 17 00:00:00 2001 From: divinity76 Date: Sat, 9 Jul 2022 11:16:02 +0200 Subject: [PATCH] avoid out-of-memory serving large logfiles large logfiles previously resulted in out-of-memory errors, see https://github.com/hestiacp/hestiacp/issues/2736 hestacp PR: https://github.com/hestiacp/hestiacp/pull/2741 and no, removing the php end tag was not an accident, it was intentional. end tags, ideally, should only be used when they're absolutely required, because they can easily introduce bugs like printing a newline after the end tag. --- web/download/web-log/index.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/web/download/web-log/index.php b/web/download/web-log/index.php index 35ebc335..9078d20c 100644 --- a/web/download/web-log/index.php +++ b/web/download/web-log/index.php @@ -25,11 +25,18 @@ $v_domain = escapeshellarg($_GET['domain']); if ($_GET['type'] == 'access') $type = 'access'; if ($_GET['type'] == 'error') $type = 'error'; -exec (VESTA_CMD."v-list-web-domain-".$type."log $user ".$v_domain." 5000", $output, $return_var); -if ($return_var == 0 ) { - foreach($output as $file) { - echo $file . "\n"; - } + + +$cmd = implode(" ", array( + escapeshellarg(HESTIA_CMD . "v-list-web-domain-" . $type . "log"), + escapeshellarg($user), + escapeshellarg($v_domain), + "5000", +)); +passthru($cmd, $return_var); +if ($return_var != 0) { + $errstr = "Internal server error: command returned non-zero: {$return_var}: {$cmd}"; + echo $errstr; + throw new Exception($errstr); // make sure it ends up in an errorlog somewhere } -?>