From 67e8b622d865e260e3759366dbc7beb218b3603f Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Mon, 11 Mar 2024 08:00:26 +0100 Subject: [PATCH] correctly save pass_authorizationheader flag for php-configs if FCGID is used; correctly add 'FcgidPassHeader' for froxlor-vhost itself if set Signed-off-by: Michael Kaufmann --- lib/Froxlor/Api/Commands/PhpSettings.php | 16 +++++++--------- lib/Froxlor/Cron/Http/Apache.php | 4 +++- .../admin/phpconfig/formfield.phpconfig_add.php | 2 +- .../admin/phpconfig/formfield.phpconfig_edit.php | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/Froxlor/Api/Commands/PhpSettings.php b/lib/Froxlor/Api/Commands/PhpSettings.php index 588c04a6..8c500660 100644 --- a/lib/Froxlor/Api/Commands/PhpSettings.php +++ b/lib/Froxlor/Api/Commands/PhpSettings.php @@ -222,8 +222,8 @@ class PhpSettings extends ApiCommand implements ResourceEntity * optional request terminate timeout if FPM is used, default is '60s' * @param string $phpfpm_reqslowtimeout * optional request slowlog timeout if FPM is used, default is '5s' - * @param bool $phpfpm_pass_authorizationheader - * optional whether to pass authorization header to webserver if FPM is used, default is 0 (false) + * @param bool $pass_authorizationheader + * optional whether to pass authorization header to webserver if FPM/FCGID is used, default is 0 (false) * @param bool $override_fpmconfig * optional whether to override fpm-daemon-config value for the following settings if FPM is used, * default is 0 (false) @@ -276,7 +276,7 @@ class PhpSettings extends ApiCommand implements ResourceEntity $fpm_enableslowlog = $this->getBoolParam('phpfpm_enable_slowlog', true, 0); $fpm_reqtermtimeout = $this->getParam('phpfpm_reqtermtimeout', true, "60s"); $fpm_reqslowtimeout = $this->getParam('phpfpm_reqslowtimeout', true, "5s"); - $fpm_pass_authorizationheader = $this->getBoolParam('phpfpm_pass_authorizationheader', true, 0); + $pass_authorizationheader = $this->getBoolParam('pass_authorizationheader', true, 0); $override_fpmconfig = $this->getBoolParam('override_fpmconfig', true, 0); $def_fpmconfig = $this->apiCall('FpmDaemons.get', [ @@ -312,7 +312,6 @@ class PhpSettings extends ApiCommand implements ResourceEntity $fpm_enableslowlog = 0; $fpm_reqtermtimeout = 0; $fpm_reqslowtimeout = 0; - $fpm_pass_authorizationheader = 0; $override_fpmconfig = 0; } elseif (Settings::Get('phpfpm.enabled') == 1) { $fpm_reqtermtimeout = Validate::validate($fpm_reqtermtimeout, 'phpfpm_reqtermtimeout', '/^([0-9]+)(|s|m|h|d)$/', '', [], true); @@ -377,7 +376,7 @@ class PhpSettings extends ApiCommand implements ResourceEntity 'fpmreqslow' => $fpm_reqslowtimeout, 'phpsettings' => $phpsettings, 'fpmsettingid' => $fpm_config_id, - 'fpmpassauth' => $fpm_pass_authorizationheader, + 'fpmpassauth' => $pass_authorizationheader, 'ofc' => $override_fpmconfig, 'pm' => $pmanager, 'max_children' => $max_children, @@ -464,7 +463,7 @@ class PhpSettings extends ApiCommand implements ResourceEntity * optional request terminate timeout if FPM is used, default is '60s' * @param string $phpfpm_reqslowtimeout * optional request slowlog timeout if FPM is used, default is '5s' - * @param bool $phpfpm_pass_authorizationheader + * @param bool $pass_authorizationheader * optional whether to pass authorization header to webserver if FPM is used, default is 0 (false) * @param bool $override_fpmconfig * optional whether to override fpm-daemon-config value for the following settings if FPM is used, @@ -516,7 +515,7 @@ class PhpSettings extends ApiCommand implements ResourceEntity $fpm_enableslowlog = $this->getBoolParam('phpfpm_enable_slowlog', true, $result['fpm_slowlog']); $fpm_reqtermtimeout = $this->getParam('phpfpm_reqtermtimeout', true, $result['fpm_reqterm']); $fpm_reqslowtimeout = $this->getParam('phpfpm_reqslowtimeout', true, $result['fpm_reqslow']); - $fpm_pass_authorizationheader = $this->getBoolParam('phpfpm_pass_authorizationheader', true, $result['pass_authorizationheader']); + $pass_authorizationheader = $this->getBoolParam('pass_authorizationheader', true, $result['pass_authorizationheader']); $override_fpmconfig = $this->getBoolParam('override_fpmconfig', true, $result['override_fpmconfig']); $pmanager = $this->getParam('pm', true, $result['pm']); $max_children = $this->getParam('max_children', true, $result['max_children']); @@ -548,7 +547,6 @@ class PhpSettings extends ApiCommand implements ResourceEntity $fpm_enableslowlog = 0; $fpm_reqtermtimeout = 0; $fpm_reqslowtimeout = 0; - $fpm_pass_authorizationheader = 0; $override_fpmconfig = 0; } elseif (Settings::Get('phpfpm.enabled') == 1) { $fpm_reqtermtimeout = Validate::validate($fpm_reqtermtimeout, 'phpfpm_reqtermtimeout', '/^([0-9]+)(|s|m|h|d)$/', '', [], true); @@ -614,7 +612,7 @@ class PhpSettings extends ApiCommand implements ResourceEntity 'fpmreqslow' => $fpm_reqslowtimeout, 'phpsettings' => $phpsettings, 'fpmsettingid' => $fpm_config_id, - 'fpmpassauth' => $fpm_pass_authorizationheader, + 'fpmpassauth' => $pass_authorizationheader, 'ofc' => $override_fpmconfig, 'pm' => $pmanager, 'max_children' => $max_children, diff --git a/lib/Froxlor/Cron/Http/Apache.php b/lib/Froxlor/Cron/Http/Apache.php index f4c6f6d1..24f1420e 100644 --- a/lib/Froxlor/Cron/Http/Apache.php +++ b/lib/Froxlor/Cron/Http/Apache.php @@ -208,7 +208,9 @@ class Apache extends HttpConfigBase ]; $php = new PhpInterface($domain); $phpconfig = $php->getPhpConfig(Settings::Get('system.mod_fcgid_defaultini_ownvhost')); - + if ($phpconfig['pass_authorizationheader'] == '1') { + $this->virtualhosts_data[$vhosts_filename] .= ' FcgidPassHeader Authorization' . "\n"; + } $starter_filename = FileDir::makeCorrectFile($configdir . '/php-fcgi-starter'); $this->virtualhosts_data[$vhosts_filename] .= ' SuexecUserGroup "' . Settings::Get('system.mod_fcgid_httpuser') . '" "' . Settings::Get('system.mod_fcgid_httpgroup') . '"' . "\n"; $this->virtualhosts_data[$vhosts_filename] .= ' ' . "\n"; diff --git a/lib/formfields/admin/phpconfig/formfield.phpconfig_add.php b/lib/formfields/admin/phpconfig/formfield.phpconfig_add.php index 157171f0..faa57dba 100644 --- a/lib/formfields/admin/phpconfig/formfield.phpconfig_add.php +++ b/lib/formfields/admin/phpconfig/formfield.phpconfig_add.php @@ -103,7 +103,7 @@ return [ 'maxlength' => 10, 'value' => '5s' ], - 'phpfpm_pass_authorizationheader' => [ + 'pass_authorizationheader' => [ 'visible' => Settings::Get('system.webserver') == "apache2", 'label' => lng('admin.phpsettings.pass_authorizationheader'), 'type' => 'checkbox', diff --git a/lib/formfields/admin/phpconfig/formfield.phpconfig_edit.php b/lib/formfields/admin/phpconfig/formfield.phpconfig_edit.php index 8216c27b..746616a7 100644 --- a/lib/formfields/admin/phpconfig/formfield.phpconfig_edit.php +++ b/lib/formfields/admin/phpconfig/formfield.phpconfig_edit.php @@ -106,7 +106,7 @@ return [ 'maxlength' => 10, 'value' => $result['fpm_reqslow'] ], - 'phpfpm_pass_authorizationheader' => [ + 'pass_authorizationheader' => [ 'visible' => Settings::Get('system.webserver') == "apache2", 'label' => lng('admin.phpsettings.pass_authorizationheader'), 'type' => 'checkbox',