diff --git a/pandora_console/godmode/setup/license.php b/pandora_console/godmode/setup/license.php index cd7a8db4cd..9be97a8685 100644 --- a/pandora_console/godmode/setup/license.php +++ b/pandora_console/godmode/setup/license.php @@ -59,6 +59,8 @@ if (is_metaconsole()) { enterprise_include_once('include/functions_license.php'); } +enterprise_include_once('include/functions_crypto.php'); + if ($renew_license_result !== null) { echo $renew_license_result; } @@ -74,8 +76,32 @@ if ($update_settings) { ); } + $customer_key = $_POST['keys']['customer_key']; + + $license_encryption_key = get_parameter('license_encryption_key', ''); + $check = db_get_value_sql('SELECT `key` FROM tupdate_settings WHERE `key` LIKE "license_encryption_key"'); + if ($check === false) { + db_process_sql_insert( + 'tupdate_settings', + [ + db_escape_key_identifier('value') => $license_encryption_key, + db_escape_key_identifier('key') => 'license_encryption_key', + ] + ); + } else { + db_process_sql_update( + 'tupdate_settings', + [db_escape_key_identifier('value') => $license_encryption_key], + [db_escape_key_identifier('key') => 'license_encryption_key'] + ); + } + + if (empty($license_encryption_key) === false) { + $customer_key = openssl_blowfish_encrypt_hex($customer_key, io_safe_output($license_encryption_key)); + } + // Update the license file. - $result = file_put_contents($config['remote_config'].'/'.LICENSE_FILE, $_POST['keys']['customer_key']); + $result = file_put_contents($config['remote_config'].'/'.LICENSE_FILE, $customer_key); if ($result === false) { ui_print_error_message(__('Failed to Update license file')); } @@ -153,8 +179,24 @@ $table->data[7][1] = html_print_input_text('expires', ($license['nms'] == 1 ? __ $table->data[8][0] = ''.__('Satellite').''; $table->data[8][1] = html_print_input_text('expires', ($license['dhpm'] == 1 ? __('enabled') : __('disabled')), '', 10, 255, true, true); -$table->data[9][0] = ''.__('Licensed to').''; -$table->data[9][1] = html_print_input_text('licensed_to', $license['licensed_to'], '', 64, 255, true, true); +if ($license['dhpm'] == 1) { + $table->data[9][0] = ''.__('License encryption key').''.ui_print_help_tip( + __('This key is used to encrypt your Pandora FMS license when it is shared with other Pandora FMS components'), + true + ); + $table->data[9][1] = html_print_input_password( + 'license_encryption_key', + io_safe_output($settings->license_encryption_key), + '', + 10, + 255, + true, + false + ); +} + +$table->data[10][0] = ''.__('Licensed to').''; +$table->data[10][1] = html_print_input_text('licensed_to', $license['licensed_to'], '', 64, 255, true, true); html_print_table($table); diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 3bf6845eae..5b53b9119b 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -14757,6 +14757,11 @@ function api_set_metaconsole_license_file($key) return; } + $license_encryption_key = db_get_value('value', 'tupdate_settings', '`key`', 'license_encryption_key'); + if (empty($license_encryption_key) === false) { + $key = openssl_blowfish_encrypt_hex($key, io_safe_output($license_encryption_key)); + } + // Update the license file. $result = file_put_contents($config['remote_config'].'/'.LICENSE_FILE, $key); if ($result === false) {