From f724ae0993329aee45eb98f9df336e29f9bc9c01 Mon Sep 17 00:00:00 2001 From: Jaap Marcus <9754650+jaapmarcus@users.noreply.github.com> Date: Mon, 14 Nov 2022 17:29:45 +0100 Subject: [PATCH] Improve some Hestia/Vesta API code - Password via v-create-tmp-file could leak to the admin user /tmp folder - Fix check with access hash / password authentication - redirect reseller login to HestiaCP/VestaCP --- src/bb-library/Server/Manager/Hestia.php | 23 ++------------- src/bb-library/Server/Manager/Vesta.php | 37 ++++++------------------ 2 files changed, 12 insertions(+), 48 deletions(-) diff --git a/src/bb-library/Server/Manager/Hestia.php b/src/bb-library/Server/Manager/Hestia.php index 40b4b2825..d6748b152 100644 --- a/src/bb-library/Server/Manager/Hestia.php +++ b/src/bb-library/Server/Manager/Hestia.php @@ -65,7 +65,7 @@ class Server_Manager_Hestia extends Server_Manager */ public function getResellerLoginUrl() { - return ''; + return 'https://hestiacp.com'; } private function _makeRequest($params) @@ -73,7 +73,7 @@ class Server_Manager_Hestia extends Server_Manager $host = 'https://'.$this->_config['host'].':'.$this->_getPort().'/api/'; // Server credentials - if ('' !== $this->_config['accesshash']) { + if ('' != $this->_config['accesshash']) { $params['hash'] = $this->_config['accesshash']; } else { $params['user'] = $this->_config['username']; @@ -161,23 +161,6 @@ class Server_Manager_Hestia extends Server_Manager * * @param Server_Account $a */ - public function create_tmp_file($password) - { - $vst_command = 'v-make-tmp-file'; - $vst_returncode = 'yes'; - $postvars = [ - 'returncode' => $vst_returncode, - 'cmd' => $vst_command, - 'arg1' => $password, - 'arg2' => 'hestiapass', - ]; - $result = $this->_makeRequest($postvars); - if ('0' === $result) { - return '/tmp/hestiapass'; - } else { - return false; - } - } public function createAccount(Server_Account $a) { @@ -192,7 +175,7 @@ class Server_Manager_Hestia extends Server_Manager 'returncode' => $vst_returncode, 'cmd' => $vst_command, 'arg1' => $a->getUsername(), - 'arg2' => $this->create_tmp_file($a->getPassword()), + 'arg2' => $a->getPassword(), 'arg3' => $client->getEmail(), 'arg4' => $packname, 'arg5' => trim($client->getFullName()), diff --git a/src/bb-library/Server/Manager/Vesta.php b/src/bb-library/Server/Manager/Vesta.php index fbc416231..03473b703 100644 --- a/src/bb-library/Server/Manager/Vesta.php +++ b/src/bb-library/Server/Manager/Vesta.php @@ -65,7 +65,7 @@ class Server_Manager_Vesta extends Server_Manager */ public function getResellerLoginUrl() { - return 'https://google.com'; + return 'https://vestacp.com'; } private function _makeRequest($params) @@ -73,7 +73,7 @@ class Server_Manager_Vesta extends Server_Manager $host = 'https://'.$this->_config['host'].':'.$this->_getPort().'/api/'; // Server credentials - if ('' !== $this->_config['accesshash']) { + if ('' != $this->_config['accesshash']) { $params['hash'] = $this->_config['accesshash']; } else { $params['user'] = $this->_config['username']; @@ -161,24 +161,6 @@ class Server_Manager_Vesta extends Server_Manager * * @param Server_Account $a */ - public function create_tmp_file($password) - { - $vst_command = 'v-make-tmp-file'; - $vst_returncode = 'yes'; - $postvars = [ - 'returncode' => $vst_returncode, - 'cmd' => $vst_command, - 'arg1' => $password, - 'arg2' => 'hestiapass', - ]; - $result = $this->_makeRequest($postvars); - if ('0' === $result) { - return '/tmp/hestiapass'; - } else { - return false; - } - } - public function createAccount(Server_Account $a) { $p = $a->getPackage(); @@ -195,7 +177,7 @@ class Server_Manager_Vesta extends Server_Manager 'returncode' => $vst_returncode, 'cmd' => $vst_command, 'arg1' => $a->getUsername(), - 'arg2' => $this->create_tmp_file($a->getPassword()), + 'arg2' => $a->getPassword(), 'arg3' => $client->getEmail(), 'arg4' => $packname, 'arg5' => trim($firstname), @@ -213,12 +195,11 @@ class Server_Manager_Vesta extends Server_Manager ]; $result2 = $this->_makeRequest($postvars2); if ('0' !== $result2) { - throw new Server_Exception('Server Manager Vesta CP Error: Create Domain failure '.$result2); + throw new Server_Exception('Server Manager Vesta CP Error: Create Domain failure! '.$result2); } - return true; } else { - throw new Server_Exception('Server Manager Vesta CP Error: Unable to create User '.$result1); + throw new Server_Exception('Server Manager Vesta CP Error: Unable to create User! '.$result1); } } @@ -242,7 +223,7 @@ class Server_Manager_Vesta extends Server_Manager return true; } if ('0' !== $result) { - throw new Server_Exception('Server Manager Vesta CP Error: Suspend Account Error '.$result.$suspended); + throw new Server_Exception('Server Manager Vesta CP Error: Suspend Account Error !'.$result); } return true; @@ -266,7 +247,7 @@ class Server_Manager_Vesta extends Server_Manager $result = $this->_makeRequest($postvars); if ('0' !== $result) { - throw new Server_Exception('Server Manager Vesta CP Error: Unsuspend Account Error '.$result); + throw new Server_Exception('Server Manager Vesta CP Error: Unsuspend Account Error! '.$result); } return true; @@ -295,7 +276,7 @@ class Server_Manager_Vesta extends Server_Manager return true; } else { if ('0' !== $result) { - throw new Server_Exception('Server Manager Vesta CP Error: Cancel Account Error '.$result); + throw new Server_Exception('Server Manager Vesta CP Error: Cancel Account Error! '.$result); } } @@ -373,7 +354,7 @@ class Server_Manager_Vesta extends Server_Manager // Make request and change password $result = $this->_makeRequest($postvars); if ('0' !== $result) { - throw new Server_Exception('Server Manager Vesta CP Error: Change Password Account Error '.$result); + throw new Server_Exception('Server Manager Vesta CP Error: Change Password Account Error! '.$result); } return true;