From 86f2beb5875e56408b8fdff25ff3037a6b0b17c5 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 11 Jun 2021 13:55:18 +0200 Subject: [PATCH] Agent collection synchronization aysnc some improvements --- pandora_console/include/api.php | 6 ++---- pandora_server/bin/pandora_server | 10 ++++++---- pandora_server/lib/PandoraFMS/Config.pm | 4 +++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pandora_console/include/api.php b/pandora_console/include/api.php index 0590aec03f..0014e0a155 100644 --- a/pandora_console/include/api.php +++ b/pandora_console/include/api.php @@ -95,10 +95,8 @@ if ($info == 'version') { if (empty($apiPassword) === true || (empty($apiPassword) === false && $api_password === $apiPassword) - && enterprise_hook( - 'metaconsole_validate_origin', - [get_parameter('server_auth')] -) === true + && (enterprise_hook('metaconsole_validate_origin', [get_parameter('server_auth')]) === true + || enterprise_hook('console_validate_origin', [get_parameter('server_auth')]) === true) ) { // Allow internal direct node -> metaconsole connection. $config['id_usuario'] = 'admin'; diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server index 208f0bbbe2..65d967d2af 100755 --- a/pandora_server/bin/pandora_server +++ b/pandora_server/bin/pandora_server @@ -650,9 +650,6 @@ sub main() { close (CFG); - pandora_set_tconfig_token($DBH, 'internal_user_pass', - pandora_input_password(\%Config, $Config{"console_pass"}) - ); } else { logger(\%Config, "[WARNING] Error with configuration file when define `console_pass`: $!", 3); } @@ -698,7 +695,6 @@ sub main() { print CFG "console_user " . $Config{"console_user"} . "\n"; close (CFG); - pandora_set_tconfig_token($DBH, 'internal_user', $Config{"console_user"}); } else { logger(\%Config, "Warning. Was not possible edit configuration file for add console user", 3); } @@ -715,6 +711,12 @@ sub main() { if ( $res_testing_api[0] ne 'OK' ) { logger(\%Config, "Warning! The server does not have access to the API, this can trigger problems in the generation of reports and graphs.", 1); pandora_event (\%Config, "Server does not have access to the API", 0, 0, 0, 0, 0, 'system', 0, $DBH); + } else { + # Test successful. + pandora_set_tconfig_token($DBH, 'internal_user_pass', + pandora_input_password(\%Config, $Config{"console_pass"}) + ); + pandora_set_tconfig_token($DBH, 'internal_user', $Config{"console_user"}); } # Generate 'going up' events diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index b76e41915c..b52bc56d45 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -1340,7 +1340,9 @@ sub pandora_get_tconfig_token ($$$) { sub pandora_set_tconfig_token ($$$) { my ($dbh, $token, $value) = @_; - my $token_value = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = ?", $token); + my $token_value = get_db_value ($dbh, + "SELECT `value` FROM `tconfig` WHERE `token` = ?", $token + ); if (defined ($token_value) && $token_value ne '') { db_update($dbh, 'UPDATE `tconfig` SET `value`=? WHERE `token`= ?',