From 7711ce1d66c6086f3e9acc164b800e39c351db70 Mon Sep 17 00:00:00 2001 From: Lukas Bableck <42083846+lukasbableck@users.noreply.github.com> Date: Tue, 25 Apr 2023 19:42:27 +0200 Subject: [PATCH] Allow admins to edit openbasedir_path for domains (#1125) * Add openbasedir_path formfield * Add openbasedir_path field values to admin_domains page --- admin_domains.php | 12 +++++++++ lib/Froxlor/Api/Commands/Domains.php | 25 +++++++++++++++++-- .../admin/domains/formfield.domains_add.php | 6 +++++ .../admin/domains/formfield.domains_edit.php | 6 +++++ 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/admin_domains.php b/admin_domains.php index 77dd9c65..59755968 100644 --- a/admin_domains.php +++ b/admin_domains.php @@ -282,6 +282,12 @@ if ($page == 'domains' || $page == 'overview') { } } + $openbasedir = [ + 0 => lng('domain.docroot'), + 1 => lng('domain.homedir'), + 2 => lng('domain.docparent') + ]; + // create serveralias options $serveraliasoptions = [ 0 => lng('domains.serveraliasoption_wildcard'), @@ -545,6 +551,12 @@ if ($page == 'domains' || $page == 'overview') { $result['temporary_ssl_redirect'] = $result['ssl_redirect']; $result['ssl_redirect'] = ($result['ssl_redirect'] == 0 ? 0 : 1); + $openbasedir = [ + 0 => lng('domain.docroot'), + 1 => lng('domain.homedir'), + 2 => lng('domain.docparent') + ]; + $serveraliasoptions = [ 0 => lng('domains.serveraliasoption_wildcard'), 1 => lng('domains.serveraliasoption_www'), diff --git a/lib/Froxlor/Api/Commands/Domains.php b/lib/Froxlor/Api/Commands/Domains.php index 86667043..c71c6168 100644 --- a/lib/Froxlor/Api/Commands/Domains.php +++ b/lib/Froxlor/Api/Commands/Domains.php @@ -225,6 +225,8 @@ class Domains extends ApiCommand implements ResourceEntity * optional, whether php is enabled for this domain, default 0 (false) * @param bool $openbasedir * optional, whether to activate openbasedir restriction for this domain, default 0 (false) + * @param int $openbasedir_path + * optional, either 0 for domains-docroot, 1 for customers-homedir or 2 for parent-directory of domains-docroot * @param int $phpsettingid * optional, specify php-configuration that is being used by id, default 1 (system-default) * @param int $mod_fcgid_starter @@ -312,6 +314,7 @@ class Domains extends ApiCommand implements ResourceEntity $documentroot = $this->getParam('documentroot', true, ''); $phpenabled = $this->getBoolParam('phpenabled', true, 0); $openbasedir = $this->getBoolParam('openbasedir', true, 0); + $openbasedir_path = $this->getParam('openbasedir_path', true, 0); $phpsettingid = $this->getParam('phpsettingid', true, 1); $mod_fcgid_starter = $this->getParam('mod_fcgid_starter', true, -1); $mod_fcgid_maxrequests = $this->getParam('mod_fcgid_maxrequests', true, -1); @@ -529,7 +532,11 @@ class Domains extends ApiCommand implements ResourceEntity $mod_fcgid_starter = '-1'; $mod_fcgid_maxrequests = '-1'; } - + + if ($openbasedir_path > 2 && $openbasedir_path < 0) { + $openbasedir_path = 0; + } + // check non-ssl IP $ipandports = $this->validateIpAddresses($p_ipandports); // check ssl IP @@ -701,6 +708,7 @@ class Domains extends ApiCommand implements ResourceEntity 'caneditdomain' => $caneditdomain, 'phpenabled' => $phpenabled, 'openbasedir' => $openbasedir, + 'openbasedir_path' => $openbasedir_path, 'speciallogfile' => $speciallogfile, 'specialsettings' => $specialsettings, 'ssl_specialsettings' => $ssl_specialsettings, @@ -754,6 +762,7 @@ class Domains extends ApiCommand implements ResourceEntity `caneditdomain` = :caneditdomain, `phpenabled` = :phpenabled, `openbasedir` = :openbasedir, + `openbasedir_path` = :openbasedir_path, `speciallogfile` = :speciallogfile, `specialsettings` = :specialsettings, `ssl_specialsettings` = :ssl_specialsettings, @@ -1101,6 +1110,8 @@ class Domains extends ApiCommand implements ResourceEntity * from setting system.apply_phpconfigs_default * @param bool $openbasedir * optional, whether to activate openbasedir restriction for this domain, default 0 (false) + * @param int $openbasedir_path + * optional, either 0 for domains-docroot, 1 for customers-homedir or 2 for parent-directory of domains-docroot * @param int $phpsettingid * optional, specify php-configuration that is being used by id, default 1 (system-default) * @param int $mod_fcgid_starter @@ -1198,6 +1209,7 @@ class Domains extends ApiCommand implements ResourceEntity $phpenabled = $this->getBoolParam('phpenabled', true, $result['phpenabled']); $phpfs = $this->getBoolParam('phpsettingsforsubdomains', true, Settings::Get('system.apply_phpconfigs_default')); $openbasedir = $this->getBoolParam('openbasedir', true, $result['openbasedir']); + $openbasedir_path = $this->getParam('openbasedir_path', true, $result['openbasedir_path']); $phpsettingid = $this->getParam('phpsettingid', true, $result['phpsettingid']); $mod_fcgid_starter = $this->getParam('mod_fcgid_starter', true, $result['mod_fcgid_starter']); $mod_fcgid_maxrequests = $this->getParam('mod_fcgid_maxrequests', true, $result['mod_fcgid_maxrequests']); @@ -1488,6 +1500,11 @@ class Domains extends ApiCommand implements ResourceEntity $mod_fcgid_starter = $result['mod_fcgid_starter']; $mod_fcgid_maxrequests = $result['mod_fcgid_maxrequests']; } + + // check changes of openbasedir-path variable + if ($openbasedir_path > 2 && $openbasedir_path < 0) { + $openbasedir_path = 0; + } // check non-ssl IP $ipandports = $this->validateIpAddresses($p_ipandports, false, $result['id']); @@ -1806,7 +1823,8 @@ class Domains extends ApiCommand implements ResourceEntity $update_data['wwwserveralias'] = $wwwserveralias; $update_data['iswildcarddomain'] = $iswildcarddomain; $update_data['phpenabled'] = $phpenabled; - $update_data['openbasedir'] = $openbasedir; + $update_data['openbasedir'] = $openbasedir;; + $update_data['openbasedir_path'] = $openbasedir_path; $update_data['speciallogfile'] = $speciallogfile; $update_data['phpsettingid'] = $phpsettingid; $update_data['mod_fcgid_starter'] = $mod_fcgid_starter; @@ -1854,6 +1872,7 @@ class Domains extends ApiCommand implements ResourceEntity `iswildcarddomain` = :iswildcarddomain, `phpenabled` = :phpenabled, `openbasedir` = :openbasedir, + `openbasedir_path` = :openbasedir_path, `speciallogfile` = :speciallogfile, `phpsettingid` = :phpsettingid, `mod_fcgid_starter` = :mod_fcgid_starter, @@ -1889,6 +1908,7 @@ class Domains extends ApiCommand implements ResourceEntity $_update_data['adminid'] = $adminid; $_update_data['phpenabled'] = $phpenabled; $_update_data['openbasedir'] = $openbasedir; + $_update_data['openbasedir_path'] = $openbasedir_path; $_update_data['mod_fcgid_starter'] = $mod_fcgid_starter; $_update_data['mod_fcgid_maxrequests'] = $mod_fcgid_maxrequests; $_update_data['notryfiles'] = $notryfiles; @@ -1922,6 +1942,7 @@ class Domains extends ApiCommand implements ResourceEntity `adminid` = :adminid, `phpenabled` = :phpenabled, `openbasedir` = :openbasedir, + `openbasedir_path` = :openbasedir_path, `mod_fcgid_starter` = :mod_fcgid_starter, `mod_fcgid_maxrequests` = :mod_fcgid_maxrequests, `notryfiles` = :notryfiles, diff --git a/lib/formfields/admin/domains/formfield.domains_add.php b/lib/formfields/admin/domains/formfield.domains_add.php index 3dfd93cb..c48d0ce3 100644 --- a/lib/formfields/admin/domains/formfield.domains_add.php +++ b/lib/formfields/admin/domains/formfield.domains_add.php @@ -364,6 +364,12 @@ return [ 'value' => '1', 'checked' => true ], + 'openbasedir_path' => [ + 'label' => lng('domain.openbasedirpath'), + 'type' => 'select', + 'select_var' => $openbasedir, + 'selected' => 0 + ], 'phpenabled' => [ 'label' => lng('admin.phpenabled'), 'type' => 'checkbox', diff --git a/lib/formfields/admin/domains/formfield.domains_edit.php b/lib/formfields/admin/domains/formfield.domains_edit.php index 7c15eef9..c8f81bea 100644 --- a/lib/formfields/admin/domains/formfield.domains_edit.php +++ b/lib/formfields/admin/domains/formfield.domains_edit.php @@ -390,6 +390,12 @@ return [ 'value' => '1', 'checked' => $result['openbasedir'] ], + 'openbasedir_path' => [ + 'label' => lng('domain.openbasedirpath'), + 'type' => 'select', + 'select_var' => $openbasedir, + 'selected' => $result['openbasedir_path'] + ], 'phpenabled' => [ 'label' => lng('admin.phpenabled'), 'type' => 'checkbox',