ent 7914 status scaling

This commit is contained in:
edu.corral 2022-11-02 12:53:14 +01:00
commit 6a9e30ae6d
100 changed files with 53090 additions and 51325 deletions

View File

@ -170,7 +170,7 @@ http://rpms.remirepo.net/enterprise/remi-release-7.rpm \
https://repo.percona.com/yum/percona-release-latest.noarch.rpm"
execute_cmd "yum install -y $extra_repos" "Installing extra repositories"
execute_cmd "yum-config-manager --enable remi-php74" "Configuring PHP"
execute_cmd "yum-config-manager --enable remi-php80" "Configuring PHP"
# Install percona Database
#[ -f /etc/my.cnf ] && rm -rf /etc/my.cnf

View File

@ -20,7 +20,7 @@ LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
# define default variables
[ "$TZ" ] || TZ="Europe/Madrid"
[ "$MYVER" ] || MYVER=57
[ "$PHPVER" ] || PHPVER=7
[ "$PHPVER" ] || PHPVER=8
[ "$DBHOST" ] || DBHOST=127.0.0.1
[ "$DBNAME" ] || DBNAME=pandora
[ "$DBUSER" ] || DBUSER=pandora

View File

@ -21,7 +21,7 @@ LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
# define default variables
[ "$TZ" ] || TZ="Europe/Madrid"
[ "$PHPVER" ] || PHPVER=7.4
[ "$PHPVER" ] || PHPVER=8.0
[ "$DBHOST" ] || DBHOST=127.0.0.1
[ "$DBNAME" ] || DBNAME=pandora
[ "$DBUSER" ] || DBUSER=pandora
@ -138,6 +138,9 @@ check_root_permissions
# Connectivity
check_repo_connection
#Install awk, sed, grep if not present
execute_cmd "apt install -y gawk sed grep" 'Installing needed tools'
# Systemd
execute_cmd "systemctl --version" "Checking SystemD" 'This is not a SystemD enable system, if tryng to use in a docker env please check: https://github.com/pandorafms/pandorafms/tree/develop/extras/docker/centos8'
@ -155,7 +158,7 @@ execute_cmd "timedatectl set-timezone $TZ" "Setting Timezone $TZ"
execute_cmd "awk --version" 'Checking needed tools: awk'
execute_cmd "grep --version" 'Checking needed tools: grep'
execute_cmd "sed --version" 'Checking needed tools: sed'
execute_cmd "apt --version" 'Checking needed tools: dnf'
execute_cmd "apt --version" 'Checking needed tools: apt'
# Creating working directory
rm -rf "$WORKDIR" &>> "$LOGFILE"

View File

@ -5,7 +5,7 @@
# Tentacle have IANA assigned port tpc/41121 as official port.
##########################################################################
# Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es>
# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L
# Copyright (c) 2005-2022 Artica Soluciones Tecnologicas S.L
#
# tentacle_server.pl Tentacle Server. See https://pandorafms.com/docs/ for
# protocol description.
@ -1740,6 +1740,19 @@ sub callback_stop {
Win32::Daemon::StopService();
}
################################################################################
## SUB check_ssleay_version
## Print a message if the installed version of Net::SSLeay may leak memory.
################################################################################
sub check_ssleay_version {
eval {
require Net::SSLeay;
return unless defined($Net::SSLeay::VERSION) && $Net::SSLeay::VERSION =~ m/^(\d+)\.(\d+)/ && $1 <= 1 && $2 < 88;
print_log ("Net::SSLeay version $Net::SSLeay::VERSION detected. Versions prior to 1.88 may leak memory. To upgrade it see: https://metacpan.org/pod/Net::SSLeay");
};
}
################################################################################
# Main
################################################################################
@ -1753,12 +1766,20 @@ if ($> == 0 && $^O ne 'MSWin32') {
# Parse command line options
parse_options ();
# Try to open the log file.
if (defined($log_file)) {
open(my $fh, ">>", $log_file) || die("Error opening the log file '$log_file': $!.\n");
close($fh);
}
# Check command line arguments
if ($#ARGV != -1) {
print_help ();
exit 1;
}
check_ssleay_version() if $t_ssl == 1;
# Show IPv6 status
if ($SOCKET_MODULE eq 'IO::Socket::INET') {
print_log ("IO::Socket::INET6 is not found. IPv6 is disabled.");

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.765-221021
Version: 7.0NG.765-221102
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.765-221021"
pandora_version="7.0NG.765-221102"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -1015,7 +1015,7 @@ my $Sem = undef;
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.765';
use constant AGENT_BUILD => '221021';
use constant AGENT_BUILD => '221102';
# Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 7.0NG.765
%define release 221021
%define release 221102
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 7.0NG.765
%define release 221021
%define release 221102
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.765"
PI_BUILD="221021"
PI_BUILD="221102"
OS_NAME=`uname -s`
FORCE=0

View File

@ -5,7 +5,7 @@
# Tentacle have IANA assigned port tpc/41121 as official port.
##########################################################################
# Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es>
# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L
# Copyright (c) 2005-2022 Artica Soluciones Tecnologicas S.L
#
# tentacle_server.pl Tentacle Server. See https://pandorafms.com/docs/ for
# protocol description.
@ -1740,6 +1740,19 @@ sub callback_stop {
Win32::Daemon::StopService();
}
################################################################################
## SUB check_ssleay_version
## Print a message if the installed version of Net::SSLeay may leak memory.
################################################################################
sub check_ssleay_version {
eval {
require Net::SSLeay;
return unless defined($Net::SSLeay::VERSION) && $Net::SSLeay::VERSION =~ m/^(\d+)\.(\d+)/ && $1 <= 1 && $2 < 88;
print_log ("Net::SSLeay version $Net::SSLeay::VERSION detected. Versions prior to 1.88 may leak memory. To upgrade it see: https://metacpan.org/pod/Net::SSLeay");
};
}
################################################################################
# Main
################################################################################
@ -1753,12 +1766,20 @@ if ($> == 0 && $^O ne 'MSWin32') {
# Parse command line options
parse_options ();
# Try to open the log file.
if (defined($log_file)) {
open(my $fh, ">>", $log_file) || die("Error opening the log file '$log_file': $!.\n");
close($fh);
}
# Check command line arguments
if ($#ARGV != -1) {
print_help ();
exit 1;
}
check_ssleay_version() if $t_ssl == 1;
# Show IPv6 status
if ($SOCKET_MODULE eq 'IO::Socket::INET') {
print_log ("IO::Socket::INET6 is not found. IPv6 is disabled.");

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{221021}
{221102}
ViewReadme
{Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.765 Build 221021")
#define PANDORA_VERSION ("7.0NG.765 Build 221102")
string pandora_path;
string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.765(Build 221021))"
VALUE "ProductVersion", "(7.0NG.765(Build 221102))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.765-221021
Version: 7.0NG.765-221102
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.765-221021"
pandora_version="7.0NG.765-221102"
package_pear=0
package_pandora=1

View File

@ -1,5 +1,9 @@
START TRANSACTION;
ALTER TABLE `trecon_task` ADD COLUMN `snmp_skip_non_enabled_ifs` TINYINT UNSIGNED DEFAULT 1;
ALTER TABLE `tlayout` ADD COLUMN `maintenance_mode` TEXT;
ALTER TABLE `tusuario` ADD COLUMN `auth_token_secret` VARCHAR(45) DEFAULT NULL;
ALTER TABLE `tmodule_inventory` ADD COLUMN `script_mode` INT NOT NULL DEFAULT 2;
@ -7,11 +11,15 @@ ALTER TABLE `tmodule_inventory` ADD COLUMN `script_path` VARCHAR(1000) DEFAULT '
ALTER TABLE `tevent_filter` ADD COLUMN `search_recursive_groups` INT NOT NULL DEFAULT 0;
<<<<<<< HEAD
ALTER TABLE `tagente_modulo` ADD COLUMN `warning_time` int(10) UNSIGNED DEFAULT 0;
ALTER TABLE `tnetwork_component` ADD COLUMN `warning_time` int(10) UNSIGNED DEFAULT 0;
ALTER TABLE `tlocal_component` ADD COLUMN `warning_time` int(10) UNSIGNED DEFAULT 0;
ALTER TABLE `tpolicy_modules` ADD COLUMN `warning_time` int(10) UNSIGNED DEFAULT 0;
ALTER TABLE `tagente_estado` ADD COLUMN `warning_count` int(10) UNSIGNED DEFAULT 0;
=======
ALTER TABLE `tcredential_store` MODIFY COLUMN `product` ENUM('CUSTOM', 'AWS', 'AZURE', 'GOOGLE', 'SAP', 'WMI', 'SNMP') DEFAULT 'CUSTOM';
>>>>>>> develop
COMMIT;

View File

@ -167,7 +167,7 @@ if (!$double_auth_enabled
resizable: true,
draggable: true,
modal: true,
title: "<?php echo __('Double autentication activation'); ?>",
title: "<?php echo __('Double authentication activation'); ?>",
overlay: {
opacity: 0.5,
background: "black"

View File

@ -40,16 +40,7 @@ require_once $config['homedir'].'/include/functions_modules.php';
require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_servers.php';
$search_string = io_safe_output(
urldecode(
trim(
get_parameter(
'search_string',
''
)
)
)
);
$search_string = get_parameter('search_string');
global $policy_page;

View File

@ -140,6 +140,49 @@ if ($id_module_type >= 6 && $id_module_type <= 7) {
push_table_simple($data, 'target_ip');
$user_groups = users_get_groups(false, 'AR');
if (users_is_admin() === true || isset($user_groups[0]) === true) {
$credentials = db_get_all_rows_sql(
'SELECT identifier FROM tcredential_store WHERE product LIKE "SNMP"'
);
} else {
$credentials = db_get_all_rows_sql(
sprintf(
'SELECT identifier FROM tcredential_store WHERE product LIKE "SNMP" AND id_group IN (%s)',
implode(',', array_keys($user_groups))
)
);
}
if (empty($credentials) === false) {
$fields = [];
foreach ($credentials as $key => $value) {
$fields[$value['identifier']] = $value['identifier'];
}
$data = [];
$data[0] = __('Credential store');
$data[1] = html_print_select(
$fields,
'credentials',
0,
'',
__('None'),
0,
true,
false,
false,
'',
false,
false,
'',
false
);
push_table_simple($data, 'snmp_credentials');
}
$snmp_versions['1'] = 'v. 1';
$snmp_versions['2'] = 'v. 2';
$snmp_versions['2c'] = 'v. 2c';
@ -316,6 +359,7 @@ if ($id_module_type < 15 || $id_module_type > 18) {
// NOT SNMP.
$table_simple->rowstyle['snmp_1'] = 'display: none';
$table_simple->rowstyle['snmp_2'] = 'display: none';
$table_simple->rowstyle['snmp_credentials'] = 'display: none';
}
// For a policy.
@ -569,6 +613,49 @@ $(document).ready (function () {
$(this).css ("width", "180px");
});
$("#credentials").change (function() {
if ($('#credentials').val() !== '0') {
$.ajax({
method: "post",
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
data: {
page: "godmode/agentes/agent_wizard",
method: "getCredentials",
identifier: $('#credentials').val()
},
datatype: "json",
success: function(data) {
data = JSON.parse(data);
extra = JSON.parse(data['extra_1']);
$('#snmp_version').val(extra['version']);
$('#snmp_version').trigger('change');
$('#text-snmp_community').val(extra['community']);
if (extra['version'] === '3') {
$('#snmp3_security_level').val(extra['securityLevelV3']);
$('#snmp3_security_level').trigger('change');
$('#text-snmp3_auth_user').val(extra['authUserV3']);
if (extra['securityLevelV3'] === 'authNoPriv' || extra['securityLevelV3'] === 'authPriv') {
$('#snmp3_auth_method').val(extra['authMethodV3']);
$('#snmp3_auth_method').trigger('change');
$('#password-snmp3_auth_pass').val(extra['authPassV3']);
if (extra['securityLevelV3'] === 'authPriv') {
$('#snmp3_privacy_method').val(extra['privacyMethodV3']);
$('#snmp3_privacy_method').trigger('change');
$('#password-snmp3_privacy_pass').val(extra['privacyPassV3']);
}
}
}
},
error: function(e) {
console.error(e);
}
});
}
});
$("#id_module_type").click (
function () {
$(this).css ("width", "auto");

View File

@ -442,8 +442,12 @@ $table->data[10][1] = html_print_select(
true
);
$repeated_sel[0] = __('All events');
$repeated_sel[1] = __('Group events');
$repeated_sel = [
EVENT_GROUP_REP_ALL => __('All events'),
EVENT_GROUP_REP_EVENTS => __('Group events'),
EVENT_GROUP_REP_AGENTS => __('Group agents'),
EVENT_GROUP_REP_EXTRAIDS => __('Group extra id'),
];
$table->data[11][0] = '<b>'.__('Repeated').'</b>';
$table->data[11][1] = html_print_select(
$repeated_sel,

View File

@ -141,6 +141,7 @@ if ($table !== null) {
unset($table);
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox filters';
$table->data = [];

View File

@ -0,0 +1,717 @@
<?php
/**
* View for edit users in Massive Operations
*
* @category Configuration
* @package Pandora FMS
* @subpackage Massive Operations
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
check_login();
global $config;
if (users_is_admin() === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access massive edit users'
);
include 'general/noaccess.php';
return;
}
if (is_management_allowed() === false) {
if (is_metaconsole() === false) {
$url = '<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/users_setup&tab=profile&pure='.(int) $config['pure']
).'">'.__('metaconsole').'</a>';
} else {
$url = __('any node');
}
ui_print_warning_message(
__(
'This node is configured with centralized mode. All profiles user information is read only. Go to %s to manage it.',
$url
)
);
return;
}
if (is_metaconsole() === true) {
include_once $config['homedir'].'/include/functions_visual_map.php';
open_meta_frame();
}
$edit_users = (int) get_parameter('edit_users');
if ($edit_users === 1) {
$users = get_parameter('id_users', false, false);
if ($users !== false) {
$update = [];
$language = (string) get_parameter('language', '-1');
if ($language !== '-1') {
$update['language'] = $language;
}
$block_size_change = (int) get_parameter('block_size_change');
if ($block_size_change === 0) {
$block_size = (int) get_parameter('block_size', -1);
if ($block_size !== -1) {
$update['block_size'] = $block_size;
}
}
$section = get_parameter('section', '-1');
if ($section !== '-1') {
$update['section'] = $section;
}
$data_section = get_parameter('data_section', '');
$dashboard = get_parameter('dashboard', '');
$visual_console = get_parameter('visual_console', '');
$section = io_safe_output($section);
if (($section === 'Event list') || ($section === 'Group view')
|| ($section === 'Alert detail') || ($section === 'Tactical view')
|| ($section === 'Default')
) {
$update['data_section'] = '';
} else if ($section === 'Dashboard') {
$update['data_section'] = $dashboard;
} else if ($section === 'Visual console') {
$update['data_section'] = $visual_console;
}
$event = (int) get_parameter('event_filter', -1);
if ($event !== -1) {
$update['default_event_filter'] = $event;
}
$autorefresh_list = get_parameter_post('autorefresh_list', [0 => '-1']);
if ($autorefresh_list[0] !== '-1') {
if (($autorefresh_list[0] === '') || ($autorefresh_list[0] === '0')) {
$update['autorefresh_white_list'] = '';
} else {
$update['autorefresh_white_list'] = json_encode($autorefresh_list);
}
}
$time_autorefresh = (int) get_parameter('time_autorefresh', -1);
if ($time_autorefresh !== -1) {
$update['time_autorefresh'] = $time_autorefresh;
}
$timezone = (string) get_parameter('timezone', '-1');
if ($timezone !== '-1') {
$update['timezone'] = $timezone;
}
$disabled = (int) get_parameter('disabled', -1);
if ($disabled !== -1) {
$update['disabled'] = $disabled;
}
$error = [];
$success = [];
foreach ($users as $key => $user) {
if (empty($update) === false) {
$result = update_user($user, $update);
if ($result === false) {
$error[] = $user;
} else {
$success[] = $user;
}
} else {
$error[] = $user;
}
}
if (empty($success) === false) {
ui_print_success_message(
__(
'Users updated successfully (%s)',
implode(
',',
$success
)
)
);
}
if (empty($error) === false) {
ui_print_error_message(
__(
'Users cannot be updated (%s)',
implode(',', $error)
)
);
}
}
}
if (is_metaconsole() === false) {
include 'include/javascript/timezonepicker/includes/parser.inc';
// Read in options for map builder.
$bases = [
'gray' => 'Gray',
'blue-marble' => 'Blue marble',
'night-electric' => 'Night Electric',
'living' => 'Living Earth',
];
$local_file = 'include/javascript/timezonepicker/images/gray-400.png';
// Dimensions must always be exact since the imagemap does not scale.
$array_size = getimagesize($local_file);
$map_width = $array_size[0];
$map_height = $array_size[1];
$timezones = timezone_picker_parse_files(
$map_width,
$map_height,
'include/javascript/timezonepicker/tz_world.txt',
'include/javascript/timezonepicker/tz_islands.txt'
);
}
$get_users = get_users();
$users = [];
if (empty($get_users) === false) {
foreach ($get_users as $key => $value) {
$users[$key] = $key;
}
}
$users_div = '<div class="label_select"><p class="edit_user_labels">'.__('Users').'</p>';
$users_div .= html_print_select(
$users,
'id_users[]',
0,
false,
'',
'',
true,
true,
true,
'',
false,
'',
false,
false,
false,
'',
false,
false,
false,
false,
true,
true,
true
).'</div>';
echo '<form method="post" id="form_profiles" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_users&option=edit_users">';
echo '<div class="user_edit_second_row white_box">';
echo '<div class="" style="width:65%">'.$users_div.'</div>';
echo '</div>';
// Language.
$language_db = db_get_all_rows_sql('SELECT id_language, name FROM tlanguage');
array_unshift($language_db, ['id_language' => 'default', 'name' => __('Default')]);
$language_list = [];
foreach ($language_db as $key => $value) {
$language_list[$value['id_language']] = $value['name'];
}
$language = '<div class="label_select"><p class="edit_user_labels">'.__('Language').'</p>';
$language .= html_print_select(
$language_list,
'language',
'',
'',
__('No change'),
-1,
true,
false,
false
).'</div>';
// Pagination.
$block_size = $config['global_block_size'];
$size_pagination = '<div class="label_select_simple"><p class="edit_user_labels">'.__('Block size for pagination').'</p>';
$size_pagination .= html_print_input_text('block_size', $block_size, '', 5, 5, true);
$size_pagination .= html_print_checkbox_switch('block_size_change', 1, 1, true);
$size_pagination .= '<span>'.__('No change').'</span>';
$size_pagination .= '</div>';
// Home screen.
$home_screen = '<div class="label_select"><p class="edit_user_labels">'.__('Home screen').ui_print_help_tip(__('User can customize the home page. By default, will display \'Agent Detail\'. Example: Select \'Other\' and type index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1 to show agent detail view'), true).'</p>';
$values = [
'-1' => __('No change'),
'Default' => __('Default'),
'Visual console' => __('Visual console'),
'Event list' => __('Event list'),
'Group view' => __('Group view'),
'Tactical view' => __('Tactical view'),
'Alert detail' => __('Alert detail'),
'Other' => __('Other'),
'Dashboard' => __('Dashboard'),
];
$home_screen .= html_print_select(
$values,
'section',
'',
'show_data_section();',
'',
-1,
true,
false,
false,
'',
false,
'',
'',
10
).'</div>';
$dashboards = get_user_dashboards($config['id_user']);
$dashboards_aux = [];
if ($dashboards === false) {
$dashboards = ['None' => 'None'];
} else {
foreach ($dashboards as $key => $dashboard) {
$dashboards_aux[$dashboard['id']] = $dashboard['name'];
}
}
$home_screen .= '<div id="show_db" style="display: none; width: 100%;">';
$home_screen .= html_print_select($dashboards_aux, 'dashboard', '', '', '', '', true, false, false, '');
$home_screen .= '</div>';
$layouts = visual_map_get_user_layouts($config['id_user'], true);
$layouts_aux = [];
if (empty($layouts) === true) {
$layouts_aux = ['None' => 'None'];
} else {
foreach ($layouts as $layout) {
$layouts_aux[$layout] = $layout;
}
}
$home_screen .= '<div id="show_vc" style="display: none; width: 100%;">';
$home_screen .= html_print_select($layouts_aux, 'visual_console', '', '', '', '', true);
$home_screen .= '</div>';
$home_screen .= html_print_input_text('data_section', '', '', 60, 255, true, false);
// Event filter.
$user_groups = implode(',', array_keys((users_get_groups($config['id_user'], 'AR', true))));
$event_list = db_get_all_rows_sql('SELECT id_filter, id_name AS name FROM tevent_filter WHERE id_group_filter IN ('.$user_groups.')');
if (empty($event_list) === true) {
$event_list = [];
}
array_unshift($event_list, ['id_filter' => 'none', 'name' => __('None')]);
$event_filter = '<div class="label_select"><p class="edit_user_labels">'.__('Event filter').'</p>';
$event_filter .= html_print_select(
$event_list,
'event_filter',
'',
'',
__('No change'),
-1,
true,
false,
false
).'</div>';
// Autorefresh.
$autorefresh_list_out = [];
if (is_metaconsole() === false || is_centralized() === true) {
$autorefresh_list_out['operation/agentes/estado_agente'] = 'Agent detail';
$autorefresh_list_out['operation/agentes/alerts_status'] = 'Alert detail';
$autorefresh_list_out['enterprise/operation/cluster/cluster'] = 'Cluster view';
$autorefresh_list_out['operation/gis_maps/render_view'] = 'Gis Map';
$autorefresh_list_out['operation/reporting/graph_viewer'] = 'Graph Viewer';
$autorefresh_list_out['operation/snmpconsole/snmp_view'] = 'SNMP console';
if (enterprise_installed()) {
$autorefresh_list_out['general/sap_view'] = 'SAP view';
}
}
$autorefresh_list_out['operation/agentes/tactical'] = 'Tactical view';
$autorefresh_list_out['operation/agentes/group_view'] = 'Group view';
$autorefresh_list_out['operation/agentes/status_monitor'] = 'Monitor detail';
$autorefresh_list_out['enterprise/operation/services/services'] = 'Services';
$autorefresh_list_out['operation/dashboard/dashboard'] = 'Dashboard';
$autorefresh_list_out['operation/agentes/pandora_networkmap'] = 'Network map';
$autorefresh_list_out['operation/visual_console/render_view'] = 'Visual console';
$autorefresh_list_out['operation/events/events'] = 'Events';
$autorefresh_show = '<p class="edit_user_labels">'._('Autorefresh').ui_print_help_tip(
__('This will activate autorefresh in selected pages'),
true
).'</p>';
$select_out = html_print_select(
$autorefresh_list_out,
'autorefresh_list_out[]',
'',
'',
'',
'',
true,
true,
true,
'',
false,
'width:100%;min-height: 150px;'
);
$arrows = ' ';
$autorefresh_list = [];
$autorefresh_list['-1'] = __('No change');
$autorefresh_list[] = __('None');
$select_in = html_print_select(
$autorefresh_list,
'autorefresh_list[]',
'-1',
'',
'',
'',
true,
true,
true,
'',
false,
'width:100%;min-height: 150px;'
);
$table_ichanges = '<div class="autorefresh_select">
<div class="autorefresh_select_list_out">
<p class="autorefresh_select_text">'.__('Full list of pages').': </p>
<div>'.$select_out.'</div>
</div>
<div class="autorefresh_select_arrows" style="display:grid">
<a href="javascript:">'.html_print_image(
'images/darrowright_green.png',
true,
[
'id' => 'right_autorefreshlist',
'alt' => __('Push selected pages into autorefresh list'),
'title' => __('Push selected pages into autorefresh list'),
]
).'</a>
<a href="javascript:">'.html_print_image(
'images/darrowleft_green.png',
true,
[
'id' => 'left_autorefreshlist',
'alt' => __('Pop selected pages out of autorefresh list'),
'title' => __('Pop selected pages out of autorefresh list'),
]
).'</a>
</div>
<div class="autorefresh_select_list">
<p class="autorefresh_select_text">'.__('List of pages with autorefresh').': </p>
<div>'.$select_in.'</div>
</div>
</div>';
$autorefresh_show .= $table_ichanges;
// Time autorefresh.
$times = get_refresh_time_array();
$time_autorefresh = '<div class="label_select"><p class="edit_user_labels">'.__('Time autorefresh');
$time_autorefresh .= ui_print_help_tip(
__('Interval of autorefresh of the elements, by default they are 30 seconds, needing to enable the autorefresh first'),
true
).'</p>';
$time_autorefresh .= html_print_select(
$times,
'time_autorefresh',
'',
'',
__('No change'),
'-1',
true,
false,
false
).'</div>';
$timezone = '<div class="label_select"><p class="edit_user_labels">'.__('Timezone').ui_print_help_tip(__('The timezone must be that of the associated server.'), true).'</p>';
$timezone .= html_print_timezone_select('timezone', '-1', __('No change'), '-1').'</div>';
$timezone_map = '';
if (is_metaconsole() === false) {
foreach ($timezones as $timezone_name => $tz) {
if ($timezone_name == 'America/Montreal') {
$timezone_name = 'America/Toronto';
} else if ($timezone_name == 'Asia/Chongqing') {
$timezone_name = 'Asia/Shanghai';
}
$area_data_timezone_polys .= '';
foreach ($tz['polys'] as $coords) {
$area_data_timezone_polys .= '<area data-timezone="'.$timezone_name.'" data-country="'.$tz['country'].'" data-pin="'.implode(',', $tz['pin']).'" data-offset="'.$tz['offset'].'" shape="poly" coords="'.implode(',', $coords).'" />';
}
$area_data_timezone_rects .= '';
foreach ($tz['rects'] as $coords) {
$area_data_timezone_rects .= '<area data-timezone="'.$timezone_name.'" data-country="'.$tz['country'].'" data-pin="'.implode(',', $tz['pin']).'" data-offset="'.$tz['offset'].'" shape="rect" coords="'.implode(',', $coords).'" />';
}
}
$timezone_map = '<div id="timezone-picker" style="width:0px">
<img id="timezone-image" src="'.$local_file.'" width="'.$map_width.'" height="'.$map_height.'" usemap="#timezone-map" />
<img class="timezone-pin pdd_t_4px" src="include/javascript/timezonepicker/images/pin.png" />
<map name="timezone-map" id="timezone-map">'.$area_data_timezone_polys.$area_data_timezone_rects.'</map>
</div>';
}
// Status (Disable / Enable).
$status = '</br>';
$status .= '<div class="label_select"><p class="edit_user_labels">'.__('Status').'</p>';
$table = new StdClass();
$table->width = '100%';
$table->class = 'databox filters';
$table->data[0][0] = __('No change');
$table->data[0][0] .= html_print_radio_button_extended(
'disabled',
-1,
'',
-1,
false,
'',
'class="mrgn_right_40px"',
true
);
$table->data[0][0] .= __('Disable');
$table->data[0][0] .= html_print_radio_button_extended(
'disabled',
1,
'',
'',
false,
'',
'class="mrgn_right_40px"',
true
);
$table->data[0][0] .= __('Enable');
$table->data[0][0] .= html_print_radio_button_extended(
'disabled',
0,
'',
'',
false,
'',
'class="mrgn_right_40px"',
true
);
$status .= html_print_table($table, true);
echo '<div id="users_options" class="user_edit_second_row white_box" style="display: none">';
echo sprintf(
'<div class="edit_user_options">%s %s %s %s %s %s %s %s %s %s</div>',
$language,
$size_pagination,
$skin,
$home_screen,
$event_filter,
$autorefresh_show,
$time_autorefresh,
$timezone,
$timezone_map,
$status
);
echo '</div>';
attachActionButton('edit_users', 'update', '100%');
echo '</form>';
if (is_metaconsole() === false) {
// Include OpenLayers and timezone user map library.
echo '<script type="text/javascript" src="'.ui_get_full_url('include/javascript/timezonepicker/lib/jquery.timezone-picker.min.js').'"></script>'."\n\t";
echo '<script type="text/javascript" src="'.ui_get_full_url('include/javascript/timezonepicker/lib/jquery.maphilight.min.js').'"></script>'."\n\t";
// Closes no meta condition.
?>
<style>
/* Styles for timezone map */
#timezone-picker div.timezone-picker {
margin: 0 auto;
}
</style>
<script language="javascript" type="text/javascript">
$(document).ready (function () {
// Set up the picker to update target timezone and country select lists.
$('#timezone-image').timezonePicker({
target: '#timezone',
});
// Optionally an auto-detect button to trigger JavaScript geolocation.
$('#timezone-detect').click(function() {
$('#timezone-image').timezonePicker('detectLocation');
});
});
</script>
<?php
} else {
close_meta_frame();
}
?>
<script type="text/javascript">
$(document).ready(function() {
show_data_section();
$('#id_users').change(function() {
const users = $("#id_users option:selected").length;
if (users === 0) {
$('#users_options').hide();
} else {
$('#users_options').show();
}
});
$("#right_autorefreshlist").click (function () {
jQuery.each($("select[name='autorefresh_list_out[]'] option:selected"), function (key, value) {
imodule_name = $(value).html();
if (imodule_name != <?php echo "'".__('None')."'"; ?> || imodule_name != <?php echo "'".__('No change')."'"; ?>) {
id_imodule = $(value).attr('value');
$("select[name='autorefresh_list[]']").append($("<option></option>").val(id_imodule).html('<i>' + imodule_name + '</i>'));
// $("select[name='autorefresh_list[]']").val(id_imodule).prop("selected", "selected");
$("#autorefresh_list_out").find("option[value='" + id_imodule + "']").remove();
$("#autorefresh_list").find("option[value='-1']").remove();
$("#autorefresh_list").find("option[value='0']").remove();
if($("#autorefresh_list_out option").length == 0) {
$("select[name='autorefresh_list_out[]']").append($("<option></option>").val('0').html('<i><?php echo __('None'); ?></i>'));
}
}
});
$('#autorefresh_list option').prop('selected', true);
});
$("#left_autorefreshlist").click (function () {
jQuery.each($("select[name='autorefresh_list[]'] option:selected"), function (key, value) {
imodule_name = $(value).html();
if (imodule_name != <?php echo "'".__('None')."'"; ?> || imodule_name != <?php echo "'".__('No change')."'"; ?>) {
id_imodule = $(value).attr('value');
$("#autorefresh_list").find("option[value='" + id_imodule + "']").remove();
$("#autorefresh_list_out").find("option[value='0']").remove();
$("select[name='autorefresh_list_out[]']").append($("<option><option>").val(id_imodule).html('<i>' + imodule_name + '</i>'));
$("#autorefresh_list_out option").last().remove();
if($("#autorefresh_list option").length == 0) {
$("select[name='autorefresh_list[]']").append($("<option></option>").val('-1').html('<i><?php echo __('No change'); ?></i>'));
$("select[name='autorefresh_list[]']").append($("<option></option>").val('0').html('<i><?php echo __('None'); ?></i>'));
$('#autorefresh_list').val('-1').prop('selected', true);
}
}
});
});
});
function show_data_section () {
section = $("#section").val();
switch (section) {
case <?php echo "'".'Dashboard'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "inline-grid");
break;
case <?php echo "'".'Visual console'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "");
$("#show_vc").css("display", "inline-grid");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Event list'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Group view'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Tactical view'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Alert detail'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Other'."'"; ?>:
$("#text-data_section").css("display", "");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
default:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
}
}
</script>

View File

@ -70,10 +70,16 @@ $options_agents = [
];
if (check_acl($config['id_user'], 0, 'UM')) {
$options_users = [
'add_profiles' => __('Bulk profile add'),
'delete_profiles' => __('Bulk profile delete'),
];
if (is_metaconsole() === false) {
$options_users = [
'add_profiles' => __('Bulk profile add'),
'delete_profiles' => __('Bulk profile delete'),
];
}
if (users_is_admin() === true) {
$options_users['edit_users'] = __('Edit users in bulk');
}
} else {
$options_users = [];
}
@ -479,6 +485,10 @@ switch ($option) {
include_once $config['homedir'].'/godmode/massive/massive_edit_plugins.php';
break;
case 'edit_users':
include_once $config['homedir'].'/godmode/massive/massive_edit_users.php';
break;
default:
if (!enterprise_hook('massive_operations', [$option])) {
include_once $config['homedir'].'/godmode/massive/massive_config.php';

View File

@ -76,6 +76,7 @@ if ($generate_trap) {
);
}
$table = new stdClass();
$traps_generator = '<form method="POST" action="index.php?sec=snmpconsole&sec2=godmode/snmpconsole/snmp_trap_generator">';
$table->width = '100%';
$table->class = 'databox filters';

View File

@ -442,6 +442,13 @@ if ($create_user) {
$password_new = '';
$password_confirm = '';
$new_user = true;
} else if (excludedPassword($password_new) === true) {
$is_err = true;
ui_print_error_message(__('The password provided is not valid. Please set another one.'));
$user_info = $values;
$password_new = '';
$password_confirm = '';
$new_user = true;
} else {
if ((!is_user_admin($config['id_user']) || $config['enable_pass_policy_admin']) && $config['enable_pass_policy']) {
$pass_ok = login_validate_pass($password_new, $id, true);
@ -1964,7 +1971,7 @@ function show_double_auth_activation () {
resizable: true,
draggable: true,
modal: true,
title: "<?php echo __('Double autentication activation'); ?>",
title: "<?php echo __('Double authentication activation'); ?>",
overlay: {
opacity: 0.5,
background: "black"
@ -2042,7 +2049,7 @@ function show_double_auth_deactivation () {
resizable: true,
draggable: true,
modal: true,
title: "<?php echo __('Double autentication activation'); ?>",
title: "<?php echo __('Double authentication activation'); ?>",
overlay: {
opacity: 0.5,
background: "black"

View File

@ -509,6 +509,7 @@ class HostDevices extends Wizard
$snmp_privacy_pass = get_parameter('snmp_privacy_pass', null);
$snmp_auth_method = get_parameter('snmp_auth_method', null);
$snmp_security_level = get_parameter('snmp_security_level', null);
$snmp_skip_non_enabled_ifs = get_parameter_switch('snmp_skip_non_enabled_ifs');
$auth_strings = get_parameter('auth_strings', []);
if ($snmp_version == 3) {
@ -556,6 +557,7 @@ class HostDevices extends Wizard
$this->task['snmp_privacy_pass'] = $snmp_privacy_pass;
$this->task['snmp_auth_method'] = $snmp_auth_method;
$this->task['snmp_security_level'] = $snmp_security_level;
$this->task['snmp_skip_non_enabled_ifs'] = $snmp_skip_non_enabled_ifs;
$this->task['auth_strings'] = '';
if (is_array($auth_strings) === true) {
$this->task['auth_strings'] = join(
@ -1215,6 +1217,24 @@ class HostDevices extends Wizard
],
];
$form['inputs'][] = [
'hidden' => 1,
'block_id' => 'snmp_options_skip_non_enabled_ifs',
'class' => 'indented',
'block_content' => [
[
'label' => __('Skip non-enabled interfaces'),
'arguments' => [
'name' => 'snmp_skip_non_enabled_ifs',
'type' => 'switch',
'value' => (isset($this->task['snmp_enabled']) === true) ? $this->task['snmp_skip_non_enabled_ifs'] : 1,
'size' => 25,
'return' => true,
],
],
],
];
// SNMP Options pack v1.
$form['inputs'][] = [
'hidden' => 1,
@ -1487,6 +1507,7 @@ class HostDevices extends Wizard
function SNMPExtraShow(target) {
$("#snmp_options_basic").hide();
$("#snmp_options_skip_non_enabled_ifs").hide();
$("#snmp_options_v3").hide();
if (document.getElementsByName("snmp_enabled")[0].checked) {
$("#snmp_extra").show();
@ -1494,6 +1515,7 @@ class HostDevices extends Wizard
$("#snmp_options_v3").show();
} else {
$("#snmp_options_basic").show();
$("#snmp_options_skip_non_enabled_ifs").show();
}
}
}
@ -1519,6 +1541,7 @@ class HostDevices extends Wizard
// Hide unusable sections
$("#snmp_extra").hide();
$("#snmp_options_basic").hide();
$("#snmp_options_skip_non_enabled_ifs").hide();
$("#snmp_options_v3").hide();
// Disable snmp dependant checks

View File

@ -90,7 +90,7 @@ $node_id = (int) get_parameter('node_id', 0);
if ($get_comments === true) {
$event = get_parameter('event', false);
$event_rep = get_parameter('event_rep', false);
$event_rep = (int) get_parameter('event_rep', 0);
if ($event === false) {
return __('Failed to retrieve comments');
}
@ -98,7 +98,7 @@ if ($get_comments === true) {
$eventsGrouped = [];
// Consider if the event is grouped.
$whereGrouped = '1=1';
if (isset($event_rep) === true && $event_rep > 0) {
if ($event_rep === EVENT_GROUP_REP_EVENTS) {
// Default grouped message filtering (evento and estado).
$whereGrouped = sprintf(
'`evento` = "%s"',
@ -119,6 +119,11 @@ if ($get_comments === true) {
(int) $event['id_agentmodule']
);
}
} else if ($event_rep === EVENT_GROUP_REP_EXTRAIDS) {
$whereGrouped = sprintf(
'`id_extra` = "%s"',
$event['id_extra']
);
} else {
$whereGrouped = sprintf('`id_evento` = %d', $event['id_evento']);
}
@ -175,7 +180,7 @@ if ($delete_event === true) {
$filter = get_parameter('filter', []);
$id_evento = (int) get_parameter('id_evento', 0);
$server_id = (int) get_parameter('server_id', 0);
$event_rep = get_parameter('event_rep', 0);
$event_rep = (int) get_parameter('event_rep', 0);
try {
if (is_metaconsole() === true
@ -228,7 +233,7 @@ if ($validate_event === true) {
$filter = get_parameter('filter', []);
$id_evento = (int) get_parameter('id_evento', 0);
$server_id = (int) get_parameter('server_id', 0);
$event_rep = get_parameter('event_rep', 0);
$event_rep = (int) get_parameter('event_rep', 0);
try {
if (is_metaconsole() === true
@ -240,7 +245,7 @@ if ($validate_event === true) {
if ($event_rep === 0) {
// Disable group by when there're result is unique.
$filter['group_rep'] = 0;
$filter['group_rep'] = EVENT_GROUP_REP_ALL;
}
// Check acl.
@ -285,7 +290,7 @@ if ($in_process_event === true) {
$filter = get_parameter('filter', []);
$id_evento = (int) get_parameter('id_evento', 0);
$server_id = (int) get_parameter('server_id', 0);
$event_rep = get_parameter('event_rep', 0);
$event_rep = (int) get_parameter('event_rep', 0);
try {
if (is_metaconsole() === true
@ -297,7 +302,7 @@ if ($in_process_event === true) {
if ($event_rep === 0) {
// Disable group by when there're result is unique.
$filter['group_rep'] = 0;
$filter['group_rep'] = EVENT_GROUP_REP_ALL;
}
// Check acl.
@ -466,7 +471,6 @@ if ($get_filter_values) {
$event_filter = [
'status' => EVENT_NO_VALIDATED,
'event_view_hr' => $config['event_view_hr'],
'group_rep' => 1,
'tag_with' => [],
'tag_without' => [],
'history' => false,
@ -483,7 +487,7 @@ if ($get_filter_values) {
'time_to' => '',
'severity' => '',
'event_type' => '',
'group_rep' => 0,
'group_rep' => EVENT_GROUP_REP_ALL,
'id_group' => 0,
'id_group_filter' => 0,
'group_name' => 'All',
@ -2418,7 +2422,7 @@ if ($get_events_fired) {
'id_agent_module' => 0,
'pagination' => 0,
'id_user_ack' => 0,
'group_rep' => 0,
'group_rep' => EVENT_GROUP_REP_ALL,
'tag_with' => [],
'tag_without' => [],
'filter_only_alert' => -1,

View File

@ -37,6 +37,7 @@ $ajax = true;
$render_map = (bool) get_parameter('render_map', false);
$graph_javascript = (bool) get_parameter('graph_javascript', false);
$force_remote_check = (bool) get_parameter('force_remote_check', false);
$update_maintanance_mode = (bool) get_parameter('update_maintanance_mode', false);
$load_css_cv = (bool) get_parameter('load_css_cv', false);
if ($render_map) {
@ -99,3 +100,29 @@ if ($load_css_cv === true) {
echo $output;
return;
}
if ($update_maintanance_mode === true) {
$idVisualConsole = (int) get_parameter('idVisualConsole', 0);
$mode = (bool) get_parameter('mode', false);
$values = [];
if ($mode === true) {
$values['maintenance_mode'] = json_encode(
[
'user' => $config['id_user'],
'timestamp' => time(),
]
);
} else {
$values['maintenance_mode'] = null;
}
$result = db_process_sql_update(
'tlayout',
$values,
['id' => $idVisualConsole]
);
echo json_encode(['result' => $result]);
return;
}

View File

@ -305,7 +305,7 @@ function process_user_login_remote($login, $pass, $api=false)
// Authentication ok, check if the user exists in the local database
if (is_user($login)) {
if (!user_can_login($login)) {
if (!user_can_login($login) && $api === false) {
return false;
}
@ -758,6 +758,12 @@ function delete_user(string $id_user)
function update_user_password(string $user, string $password_new)
{
global $config;
if (excludedPassword($password_new) === true) {
$config['auth_error'] = __('The password provided is not valid. Please, set another one.');
return false;
}
if (isset($config['auth']) === true && $config['auth'] === 'pandora') {
$sql = sprintf(
"UPDATE tusuario SET password = '".md5($password_new)."', last_pass_change = '".date('Y-m-d H:i:s', get_system_time())."' WHERE id_user = '".$user."'"
@ -840,6 +846,9 @@ function ldap_process_user_login($login, $password, $secondary_server=false)
$ldap[$token] = $secondary_server === true ? $config[$token.'_secondary'] : $config[$token];
}
// Remove entities ldap admin pass.
$ldap['ldap_admin_pass'] = io_safe_output($ldap['ldap_admin_pass']);
// Connect to the LDAP server
if (stripos($ldap['ldap_server'], 'ldap://') !== false
|| stripos($ldap['ldap_server'], 'ldaps://') !== false

View File

@ -33,6 +33,7 @@ global $config;
require_once $config['homedir'].'/include/class/HTML.class.php';
require_once $config['homedir'].'/include/functions_snmp_browser.php';
require_once $config['homedir'].'/include/functions_wmi.php';
require_once $config['homedir'].'/include/class/CredentialStore.class.php';
use PandoraFMS\Module;
@ -696,6 +697,43 @@ class AgentWizard extends HTML
'return' => true,
],
];
$user_groups = users_get_groups(false, 'AR');
if (users_is_admin() === true || isset($user_groups[0]) === true) {
$credentials = db_get_all_rows_sql(
'SELECT identifier FROM tcredential_store WHERE product LIKE "WMI"'
);
} else {
$credentials = db_get_all_rows_sql(
sprintf(
'SELECT identifier FROM tcredential_store WHERE product LIKE "WMI" AND id_group IN (%s)',
implode(',', array_keys($user_groups))
)
);
}
if (empty($credentials) === false) {
$fields = [];
foreach ($credentials as $key => $value) {
$fields[$value['identifier']] = $value['identifier'];
}
$inputs[] = [
'label' => __('Credential store'),
'id' => 'slc-credential',
'arguments' => [
'name' => 'credential',
'input_class' => 'flex-row',
'type' => 'select',
'nothing' => __('None'),
'nothing_value' => 0,
'fields' => $fields,
'class' => '',
'return' => true,
'sort' => true,
],
];
}
}
$hint_server = '&nbsp;';
@ -716,6 +754,43 @@ class AgentWizard extends HTML
];
if ($this->actionType === 'snmp') {
$user_groups = users_get_groups(false, 'AR');
if (users_is_admin() === true || isset($user_groups[0]) === true) {
$credentials = db_get_all_rows_sql(
'SELECT identifier FROM tcredential_store WHERE product LIKE "SNMP"'
);
} else {
$credentials = db_get_all_rows_sql(
sprintf(
'SELECT identifier FROM tcredential_store WHERE product LIKE "SNMP" AND id_group IN (%s)',
implode(',', array_keys($user_groups))
)
);
}
if (empty($credentials) === false) {
$fields = [];
foreach ($credentials as $key => $value) {
$fields[$value['identifier']] = $value['identifier'];
}
$inputs[] = [
'label' => __('Credential store'),
'id' => 'slc-credential',
'arguments' => [
'name' => 'credential',
'input_class' => 'flex-row',
'type' => 'select',
'nothing' => __('None'),
'nothing_value' => 0,
'fields' => $fields,
'class' => '',
'return' => true,
'sort' => true,
],
];
}
$inputs[] = [
'label' => __('SNMP community'),
'id' => 'txt-community',
@ -1336,6 +1411,21 @@ class AgentWizard extends HTML
}
/**
* Build an array with Product credentials.
*
* @return array with credentials (pass and id).
*/
public function getCredentials(string $identifier='')
{
if (empty($identifier) === true) {
$identifier = get_parameter('identifier', '');
}
echo json_encode(credentialStore::getKey($identifier));
}
/**
* Prepare data module to create.
*
@ -5813,6 +5903,58 @@ class AgentWizard extends HTML
filterInterfaces();
});
$('#credential').change(function() {
if ($('#credential').val() !== '0') {
$.ajax({
method: "post",
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
data: {
page: "<?php echo $this->ajaxController; ?>",
method: "getCredentials",
identifier: $('#credential').val()
},
datatype: "json",
success: function(data) {
data = JSON.parse(data);
if ($('#text-namespaceWMI').length > 0) {
// WMI.
$('#text-namespaceWMI').val(data['extra_1']);
$('#text-usernameWMI').val(data['username']);
$('#password-passwordWMI').val(data['password']);
} else {
// SNMP.
extra = JSON.parse(data['extra_1']);
$('#version').val(extra['version']);
$('#version').trigger('change');
$('#text-community').val(extra['community']);
if (extra['version'] === '3') {
$('#securityLevelV3').val(extra['securityLevelV3']);
$('#securityLevelV3').trigger('change');
$('#text-authUserV3').val(extra['authUserV3']);
if (extra['securityLevelV3'] === 'authNoPriv' || extra['securityLevelV3'] === 'authPriv') {
$('#authMethodV3').val(extra['authMethodV3']);
$('#authMethodV3').trigger('change');
$('#password-authPassV3').val(extra['authPassV3']);
if (extra['securityLevelV3'] === 'authPriv') {
$('#privacyMethodV3').val(extra['privacyMethodV3']);
$('#privacyMethodV3').trigger('change');
$('#password-privacyPassV3').val(extra['privacyPassV3']);
}
}
}
}
},
error: function(e) {
showMsg(e);
}
});
}
});
// Loading.
$('#submit-sub-protocol').click(function() {
$('.wizard-result').remove();

View File

@ -617,33 +617,71 @@ class CredentialStore extends Wizard
$password = $google_creds->private_key_id;
}
if (empty($identifier) === true) {
$error = __('Key identifier is required');
} else if ($id_group === null) {
$error = __('You must select a group where store this key!');
} else if (empty($product) === true) {
$error = __('You must specify a product type');
} else if (empty($username) === true || (empty($password) === true)) {
$error = __('You must specify a username and/or password');
} else if (evaluate_ascii_valid_string(io_safe_output($identifier)) === false) {
$error = __('Identifier with forbidden characters. Check the documentation.');
}
if ($product !== 'SNMP') {
if (empty($identifier) === true) {
$error = __('Key identifier is required');
} else if ($id_group === null) {
$error = __('You must select a group where store this key!');
} else if (empty($product) === true) {
$error = __('You must specify a product type');
} else if (empty($username) === true || (empty($password) === true)) {
$error = __('You must specify a username and/or password');
} else if (evaluate_ascii_valid_string(io_safe_output($identifier)) === false) {
$error = __('Identifier with forbidden characters. Check the documentation.');
}
if (isset($error) === true) {
$this->ajaxMsg('error', $error);
exit;
}
if (isset($error) === true) {
$this->ajaxMsg('error', $error);
exit;
}
// Encrypt content (if needed).
$values = [
'identifier' => $identifier,
'id_group' => $id_group,
'product' => $product,
'username' => io_input_password(io_safe_output($username)),
'password' => io_input_password(io_safe_output($password)),
'extra_1' => io_input_password(io_safe_output($extra_1)),
'extra_2' => io_input_password(io_safe_output($extra_2)),
];
// Encrypt content (if needed).
$values = [
'identifier' => $identifier,
'id_group' => $id_group,
'product' => $product,
'username' => io_input_password(io_safe_output($username)),
'password' => io_input_password(io_safe_output($password)),
'extra_1' => io_input_password(io_safe_output($extra_1)),
'extra_2' => io_input_password(io_safe_output($extra_2)),
];
} else {
$values = [
'identifier' => $identifier,
'id_group' => $id_group,
'product' => $product,
];
$community = (string) get_parameter('community', '');
$version = (string) get_parameter('version', '1');
$extra_json = [
'community' => $community,
'version' => $version,
];
if ($version === '3') {
$securityLevelV3 = (string) get_parameter('securityLevelV3', 'authNoPriv');
$extra_json['securityLevelV3'] = $securityLevelV3;
$authUserV3 = (string) get_parameter('authUserV3', '');
$extra_json['authUserV3'] = $authUserV3;
if ($securityLevelV3 === 'authNoPriv' || $securityLevelV3 === 'authPriv') {
$authUserV3 = (string) get_parameter('authUserV3', '');
$extra_json['authUserV3'] = $authUserV3;
$authMethodV3 = (string) get_parameter('authMethodV3', 'MD5');
$extra_json['authMethodV3'] = $authMethodV3;
$authPassV3 = (string) get_parameter('authPassV3', '');
$extra_json['authPassV3'] = $authPassV3;
if ($securityLevelV3 === 'authPriv') {
$privacyMethodV3 = (string) get_parameter('privacyMethodV3', 'AES');
$extra_json['privacyMethodV3'] = $privacyMethodV3;
$privacyPassV3 = (string) get_parameter('privacyPassV3', '');
$extra_json['privacyPassV3'] = $privacyPassV3;
}
}
}
$values['extra_1'] = json_encode($extra_json);
}
// Spaces are not allowed.
$values['identifier'] = \io_safe_input(
@ -947,6 +985,8 @@ class CredentialStore extends Wizard
'AZURE' => __('Azure'),
'SAP' => __('SAP'),
'GOOGLE' => __('Google'),
'WMI' => __('WMI'),
'SNMP' => __('SNMP'),
],
'selected' => (isset($values['product']) ? $values['product'] : 'CUSTOM'),
'disabled' => (bool) $values['product'],
@ -989,6 +1029,19 @@ class CredentialStore extends Wizard
$extra1_type = 'textarea';
break;
case 'WMI':
$extra_1_label = __('Namespace');
$extra1 = true;
$extra2 = false;
break;
case 'SNMP':
$user = false;
$pass = false;
$extra1 = false;
$extra2 = false;
break;
case 'CUSTOM':
case 'SAP':
$user_label = __('Account ID');
@ -1059,6 +1112,141 @@ class CredentialStore extends Wizard
];
}
if ($values['product'] === 'SNMP') {
$json_values = json_decode($values['extra_1'], true);
$inputs[] = [
'label' => __('SNMP community'),
'id' => 'li_snmp_1',
'arguments' => [
'name' => 'community',
'input_class' => 'flex-row',
'type' => 'text',
'value' => $json_values['community'],
'return' => true,
],
];
$inputs[] = [
'label' => __('SNMP version'),
'id' => 'li_snmp_2',
'arguments' => [
'name' => 'version',
'input_class' => 'flex-row',
'type' => 'select',
'script' => 'showVersion()',
'fields' => [
'1' => __('1'),
'2' => __('2'),
'2c' => __('2c'),
'3' => __('3'),
],
'selected' => (isset($json_values['version']) ? $json_values['version'] : '1'),
'return' => true,
],
];
$inputs[] = [
'label' => __('Security level'),
'id' => 'li_snmp_3',
'style' => ($json_values['version'] !== '3') ? 'display: none;' : '',
'arguments' => [
'name' => 'securityLevelV3',
'input_class' => 'flex-row',
'type' => 'select',
'script' => 'showSecurity()',
'fields' => [
'authNoPriv' => __('Authenticated and non-private method'),
'authPriv' => __('Authenticated and private method'),
'noAuthNoPriv' => __('Non-authenticated and non-private method'),
],
'selected' => (isset($json_values['securityLevelV3']) ? $json_values['securityLevelV3'] : 'authNoPriv'),
'return' => true,
],
];
$inputs[] = [
'label' => __('User authentication'),
'id' => 'li_snmp_4',
'style' => ($json_values['version'] !== '3') ? 'display: none;' : '',
'arguments' => [
'name' => 'authUserV3',
'input_class' => 'flex-row',
'type' => 'text',
'value' => $json_values['authUserV3'],
'return' => true,
],
];
$authNoPrivate = (
isset($json_values['securityLevelV3']) &&
($json_values['securityLevelV3'] === 'authNoPriv' || $json_values['securityLevelV3'] === 'authPriv')
) ? '' : 'display: none;';
$inputs[] = [
'label' => __('Authentication method'),
'id' => 'li_snmp_5',
'style' => $authNoPrivate,
'arguments' => [
'name' => 'authMethodV3',
'input_class' => 'flex-row',
'type' => 'select',
'fields' => [
'MD5' => __('MD5'),
'SHA' => __('SHA'),
],
'selected' => (isset($json_values['authMethodV3']) ? $json_values['authMethodV3'] : 'MD5'),
'return' => true,
],
];
$inputs[] = [
'label' => __('Password authentication'),
'id' => 'li_snmp_6',
'style' => $authNoPrivate,
'arguments' => [
'name' => 'authPassV3',
'input_class' => 'flex-row',
'type' => 'password',
'value' => $json_values['authPassV3'],
'return' => true,
],
];
$authPrivate = (isset($json_values['securityLevelV3']) && $json_values['securityLevelV3'] === 'authPriv')
? ''
: 'display: none;';
$inputs[] = [
'label' => __('Privacy method'),
'id' => 'li_snmp_7',
'style' => $authPrivate,
'arguments' => [
'name' => 'privacyMethodV3',
'input_class' => 'flex-row',
'type' => 'select',
'fields' => [
'AES' => __('AES'),
'DES' => __('DES'),
],
'selected' => (isset($json_values['privacyMethodV3']) ? $json_values['privacyMethodV3'] : 'AES'),
'return' => true,
],
];
$inputs[] = [
'label' => __('Privacy pass'),
'id' => 'li_snmp_8',
'style' => $authPrivate,
'arguments' => [
'name' => 'privacyPassV3',
'input_class' => 'flex-row',
'type' => 'password',
'value' => $json_values['privacyPassV3'],
'return' => true,
],
];
}
return $this->printForm(
[
'form' => $form,
@ -1175,9 +1363,248 @@ class CredentialStore extends Wizard
$('<textarea name="extra_1" id="text-extra_1">'+val+'</textarea>')
);
$('#div-extra_1').show();
} else if ($('#product :selected').val() == "WMI") {
$('#div-username label').text('<?php echo __('Username'); ?>');
$('#div-password label').text('<?php echo __('Password'); ?>');
$('#div-extra_1 label').text('<?php echo __('Namespace'); ?>');
$('#div-username').show();
$('#div-password').show();
$('#div-extra_1').show();
$('#div-extra_2').hide();
} else if ($('#product :selected').val() == "SNMP") {
$('#div-username').hide();
$('#div-password').hide();
$('#div-extra_1').hide();
$('#div-extra_2').hide();
if ($('#li_snmp_1').length > 0) {
console.log($('#li_snmp_1').length);
const test = '<?php echo $json_values; ?>';
console.log(test);
} else {
const ul = $('#modal_form').children('ul')[0];
// SNMP community.
const li_community = document.createElement("li");
li_community.id = 'li_snmp_1';
const label_community = document.createElement("label");
label_community.textContent = '<?php echo __('SNMP community'); ?>';
const input_community = document.createElement("input");
input_community.type = 'text';
input_community.className = 'text_input';
input_community.name = 'community';
li_community.append(label_community);
li_community.append(input_community);
ul.append(li_community);
// SNMP version.
const li_version = document.createElement("li");
li_version.id = 'li_snmp_2';
const label_version = document.createElement("label");
label_version.textContent = '<?php echo __('SNMP version'); ?>';
const select_version = document.createElement("select");
select_version.name = 'version';
select_version.id = 'version';
select_version.onchange = function() {
showVersion();
};
let option1 = document.createElement("option");
let option2 = document.createElement("option");
let option2c = document.createElement("option");
let option3 = document.createElement("option");
option1.value = '1';
option1.text = '1';
option2.value = '2';
option2.text = '2';
option2c.value = '2c';
option2c.text = '2c';
option3.value = '3';
option3.text = '3';
select_version.appendChild(option1);
select_version.appendChild(option2);
select_version.appendChild(option2c);
select_version.appendChild(option3);
li_version.append(label_version);
li_version.append(select_version);
ul.append(li_version);
$("#version").select2();
// Security.
const li_security = document.createElement("li");
li_security.id = 'li_snmp_3';
const label_security = document.createElement("label");
label_security.textContent = '<?php echo __('Security level'); ?>';
const select_security = document.createElement("select");
select_security.name = 'securityLevelV3';
select_security.id = 'securityLevelV3';
select_security.onchange = function() {
showSecurity();
}
option1 = document.createElement("option");
option2 = document.createElement("option");
option3 = document.createElement("option");
option1.value = 'authNoPriv';
option1.text = '<?php echo __('Authenticated and non-private method'); ?>';
option2.value = 'authPriv';
option2.text = '<?php echo __('Authenticated and private method'); ?>';
option3.value = 'noAuthNoPriv';
option3.text = '<?php echo __('Non-authenticated and non-private method'); ?>';
select_security.appendChild(option1);
select_security.appendChild(option2);
select_security.appendChild(option3);
li_security.append(label_security);
li_security.append(select_security);
ul.append(li_security);
$("#securityLevelV3").select2();
// User.
const li_user = document.createElement("li");
li_user.id = 'li_snmp_4';
const label_user = document.createElement("label");
label_user.textContent = '<?php echo __('User authentication'); ?>';
const input_user = document.createElement("input");
input_user.type = 'text';
input_user.className = 'text_input';
input_user.name = 'authUserV3';
li_user.append(label_user);
li_user.append(input_user);
ul.append(li_user);
// Authentication method.
const li_method = document.createElement("li");
li_method.id = 'li_snmp_5';
const label_method = document.createElement("label");
label_method.textContent = '<?php echo __('Authentication method'); ?>';
const select_method = document.createElement("select");
select_method.name = 'authMethodV3';
select_method.id = 'method';
option1 = document.createElement("option");
option2 = document.createElement("option");
option1.value = 'MD5';
option1.text = '<?php echo __('MD5'); ?>';
option2.value = 'SHA';
option2.text = '<?php echo __('SHA'); ?>';
select_method.appendChild(option1);
select_method.appendChild(option2);
li_method.append(label_method);
li_method.append(select_method);
ul.append(li_method);
$("#method").select2();
// Password.
const li_password = document.createElement("li");
li_password.id = 'li_snmp_6';
const label_password = document.createElement("label");
label_password.textContent = '<?php echo __('Password authentication'); ?>';
const input_password = document.createElement("input");
input_password.type = 'password';
input_password.className = 'text_input';
input_password.name = 'authPassV3';
li_password.append(label_password);
li_password.append(input_password);
ul.append(li_password);
// Privacy method.
const li_privacy = document.createElement("li");
li_privacy.id = 'li_snmp_7';
const label_privacy = document.createElement("label");
label_privacy.textContent = '<?php echo __('Privacy method'); ?>';
const select_privacy = document.createElement("select");
select_privacy.name = 'privacyMethodV3';
select_privacy.id = 'privacy';
option1 = document.createElement("option");
option2 = document.createElement("option");
option1.value = 'AES';
option1.text = '<?php echo __('AES'); ?>';
option2.value = 'DES';
option2.text = '<?php echo __('DES'); ?>';
select_privacy.appendChild(option1);
select_privacy.appendChild(option2);
li_privacy.append(label_privacy);
li_privacy.append(select_privacy);
ul.append(li_privacy);
$("#privacy").select2();
// Privacy pass.
const li_privacyPassV3 = document.createElement("li");
li_privacyPassV3.id = 'li_snmp_8';
const label_privacyPassV3 = document.createElement("label");
label_privacyPassV3.textContent = '<?php echo __('Privacy pass'); ?>';
const input_privacyPassV3 = document.createElement("input");
input_privacyPassV3.type = 'password';
input_privacyPassV3.className = 'text_input';
input_privacyPassV3.name = 'privacyPassV3';
li_privacyPassV3.append(label_privacyPassV3);
li_privacyPassV3.append(input_privacyPassV3);
ul.append(li_privacyPassV3);
$('#li_snmp_3').hide();
$('#li_snmp_4').hide();
$('#li_snmp_5').hide();
$('#li_snmp_6').hide();
$('#li_snmp_7').hide();
$('#li_snmp_8').hide();
}
}
}
function showVersion() {
if ($('#version').val() === '3') {
$('#li_snmp_3').show();
$('#li_snmp_4').show();
$('#li_snmp_5').show();
$('#li_snmp_6').show();
} else {
$('#li_snmp_3').hide();
$('#li_snmp_4').hide();
$('#li_snmp_5').hide();
$('#li_snmp_6').hide();
$('#li_snmp_7').hide();
$('#li_snmp_8').hide();
}
}
function showSecurity() {
const value = $('#securityLevelV3').val();
switch (value) {
case 'noAuthNoPriv':
$('#li_snmp_4').show();
$('#li_snmp_5').hide();
$('#li_snmp_6').hide();
$('#li_snmp_7').hide();
$('#li_snmp_8').hide();
break;
case 'authPriv':
$('#li_snmp_4').show();
$('#li_snmp_5').show();
$('#li_snmp_6').show();
$('#li_snmp_7').show();
$('#li_snmp_8').show();
break;
case 'authNoPriv':
default:
$('#li_snmp_4').show();
$('#li_snmp_5').show();
$('#li_snmp_6').show();
$('#li_snmp_7').hide();
$('#li_snmp_8').hide();
break;
}
}
function hideSNMP() {
$('#li_snmp_1').hide();
$('#li_snmp_2').hide();
$('#li_snmp_3').hide();
$('#li_snmp_4').hide();
$('#li_snmp_5').hide();
$('#li_snmp_6').hide();
$('#li_snmp_7').hide();
$('#li_snmp_8').hide();
}
/**
* Process ajax responses and shows a dialog with results.
*/

View File

@ -485,6 +485,10 @@ class HTML
$class = '';
}
if (empty($input['style']) === false) {
$style_li = $input['style'];
}
if (isset($input['class']) === true) {
$class = $input['class'].$class;
}
@ -498,7 +502,7 @@ class HTML
}
// Print independent block of inputs.
$output .= '<li id="li-'.($input['block_id'] ?? '').'" class="'.$class.'">';
$output .= '<li id="li-'.($input['block_id'] ?? '').'" class="'.$class.'" style="'.$style_li.'">';
if (isset($input['wrapper']) === true) {
$output .= '<'.$input['wrapper'].' id="'.($input['block_id'] ?? '').'" class="'.$class.'">';
@ -562,7 +566,7 @@ class HTML
}
if (!$direct) {
$output .= '<li id="'.($input['id'] ?? '').'" class="'.$class.'">';
$output .= '<li id="'.($input['id'] ?? '').'" class="'.$class.'" style="'.$style_li.'">';
}
if (isset($input['label']) === true) {

View File

@ -223,8 +223,9 @@ class SatelliteAgent extends HTML
echo $modal.$msg.$aux;
echo '<div id="satellite_actions" class="action-buttons" style="width: 100%">';
echo '<div style="display: flex;justify-content: space-between;">';
echo '<div class="flex-content-left">';
html_print_select(
[
'0' => 'Disable / Enable selected agents',
@ -248,18 +249,18 @@ class SatelliteAgent extends HTML
);
echo '</div>';
echo '</br></br>';
// Create button.
echo '<div class="w100p flex-content-right">';
// Create button add host.
echo '<div class="flex-content-right">';
html_print_submit_button(
__('Add host'),
'create',
false,
'class="sub next"'
);
echo '</div>';
echo '</div>';
// Load own javascript file.
echo $this->loadJS();
}
@ -1255,6 +1256,8 @@ class SatelliteAgent extends HTML
$(document).ready(function() {
$('body').append('<div id="dialog"></div>');
$("#submit-create").on('click', function() {
show_form();
});
@ -1267,61 +1270,140 @@ class SatelliteAgent extends HTML
$('#submit-submit_satellite_action').click(function() {
const checks = $('input[name*=check_]:checked');
const action = $('#satellite_action').val();
$.each(checks, function(i, val) {
const params = val.value.split(",");
if (action === '0') {
if (params[2] === '0') {
$.ajax({
method: 'post',
async: false,
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'enterprise/godmode/servers/agents_satellite',
method: 'disableAgent',
address: params[0],
disable: params[3],
id: params[4],
name: params[1],
no_msg: 1,
server_remote: <?php echo $this->satellite_server; ?>,
},
datatype: "json",
success: function (data) {
},
error: function(e) {
console.error(e);
}
});
}
} else {
if (params[3] === '0') {
$.ajax({
method: 'post',
async: false,
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'enterprise/godmode/servers/agents_satellite',
method: 'deleteAgent',
address: params[0],
name: params[1],
id: params[4],
delete: params[2],
no_msg: 1,
server_remote: <?php echo $this->satellite_server; ?>,
},
datatype: "json",
success: function (data) {
},
error: function(e) {
console.error(e);
}
});
}
}
});
let agent_delete_error = [];
let agent_disable_error = [];
$('#aux').empty();
$('#aux').text('<?php echo __('Are you sure?'); ?>');
$('#aux').dialog({
title: (action === '0') ? '<?php echo __('Disable / Enable Agents'); ?>' : '<?php echo __('Delete / create Agents'); ?>',
buttons: [
{
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
text: '<?php echo __('Cancel'); ?>',
click: function(e) {
$(this).dialog('close');
cleanupDOM();
var dt_satellite_agents = $("#satellite_agents").DataTable();
dt_satellite_agents.draw();
}
},
{
text: '<?php echo __('Ok'); ?>',
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
click: function(e) {
$(this).dialog('close');
$.each(checks, function(i, val) {
const params = val.value.split(",");
if (action === '0') {
if (params[2] === '0') {
$.ajax({
method: 'post',
async: false,
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'enterprise/godmode/servers/agents_satellite',
method: 'disableAgent',
address: params[0],
disable: params[3],
id: params[4],
name: params[1],
no_msg: 1,
server_remote: <?php echo $this->satellite_server; ?>,
},
datatype: "json",
success: function (data) {
},
error: function(e) {
console.error(e);
}
});
} else {
agent_disable_error.push(params[0]);
}
} else {
if (params[3] === '0') {
$.ajax({
method: 'post',
async: false,
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'enterprise/godmode/servers/agents_satellite',
method: 'deleteAgent',
address: params[0],
name: params[1],
id: params[4],
delete: params[2],
no_msg: 1,
server_remote: <?php echo $this->satellite_server; ?>,
},
datatype: "json",
success: function (data) {
},
error: function(e) {
console.error(e);
}
});
} else {
agent_delete_error.push(params[0]);
}
}
});
if (agent_delete_error.length > 0) {
$("#dialog").dialog({
resizable: true,
draggable: true,
modal: true,
height: 240,
width: 600,
title: '<?php echo __('Warning'); ?>',
open: function(){
let text = '<?php echo __('These agents could not be deleted. They must first be enabled'); ?>';
text += ` (${agent_delete_error.join()})`;
$('#dialog').html(`<br><table><tr><td><img src="images/icono-warning-triangulo.png" class="float-left mrgn_lft_25px"></td><td><p id="p_configurar_agente" >${text}</p></td></tr></table>`);
},
buttons: [
{
text: "Ok",
click: function() {
$( this ).dialog( "close" );
return false;
}
}
]
});
}
if (agent_disable_error.length > 0) {
$("#dialog").dialog({
resizable: true,
draggable: true,
modal: true,
height: 240,
width: 600,
title: '<?php echo __('Warning'); ?>',
open: function(){
let text = '<?php echo __('These agents could not be disabled. They must first be created'); ?>';
text += ` (${agent_disable_error.join()})`;
$('#dialog').html(`<br><table><tr><td><img src="images/icono-warning-triangulo.png" class="float-left mrgn_lft_25px"></td><td><p id="p_configurar_agente" >${text}</p></td></tr></table>`);
},
buttons: [
{
text: "Ok",
click: function() {
$( this ).dialog( "close" );
return false;
}
}
]
});
}
var dt_satellite_agents = $("#satellite_agents").DataTable();
dt_satellite_agents.draw();
}
}
]
});
});
});

View File

@ -20,7 +20,7 @@
/**
* Pandora build version and version
*/
$build_version = 'PC221021';
$build_version = 'PC221102';
$pandora_version = 'v7.0NG.765';
// Do not overwrite default timezone set if defined.

View File

@ -45,6 +45,11 @@ define('EVENT_VALIDATE', 1);
define('EVENT_PROCESS', 2);
define('EVENT_NO_VALIDATED', 3);
// Events group by constants.
define('EVENT_GROUP_REP_ALL', 0);
define('EVENT_GROUP_REP_EVENTS', 1);
define('EVENT_GROUP_REP_AGENTS', 2);
define('EVENT_GROUP_REP_EXTRAIDS', 3);
// Agents disabled status.
define('AGENT_ENABLED', 0);

View File

@ -359,10 +359,12 @@ function mysql_db_get_all_rows_in_table($table, $order_field='', $order='ASC')
*
* @return mixed False in case of error or invalid values passed. Affected rows otherwise
*/
function mysql_db_process_sql_insert($table, $values)
function mysql_db_process_sql_insert($table, $values, $sqltostring=false)
{
// Empty rows or values not processed
if (empty($values)) {
global $config;
// Empty rows or values not processed.
if (empty($values) === true) {
return false;
}
@ -374,7 +376,7 @@ function mysql_db_process_sql_insert($table, $values)
$i = 1;
$max = count($values);
foreach ($values as $field => $value) {
// Add the correct escaping to values
// Add the correct escaping to values.
if ($field[0] != '`') {
$field = '`'.$field.'`';
}
@ -402,7 +404,30 @@ function mysql_db_process_sql_insert($table, $values)
$query .= ' VALUES ('.$values_str.')';
return db_process_sql($query, 'insert_id');
$values_insert = [];
if (enterprise_hook('is_metaconsole') === true
&& isset($config['centralized_management']) === true
&& (bool) $config['centralized_management'] === true
) {
$values_insert = [
'table' => $table,
'values' => $values,
];
}
if ($sqltostring === true) {
return $query;
}
return db_process_sql(
$query,
'insert_id',
'',
true,
$status,
true,
$values_insert
);
}

View File

@ -11246,7 +11246,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
$id_user_ack = 0;
$event_view_hr = 0;
$tag = '';
$group_rep = 0;
$group_rep = EVENT_GROUP_REP_ALL;
$utimestamp_upper = 0;
$utimestamp_bottom = 0;
$id_alert_template = -1;
@ -11449,7 +11449,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
$alert_join = ' INNER JOIN talert_template_modules ON '.$table_events.'.id_alert_am=talert_template_modules.id';
}
if ($group_rep == 0) {
if ($group_rep == EVENT_GROUP_REP_ALL) {
if ($filter['total']) {
$sql = 'SELECT COUNT(*)
FROM '.$table_events.'
@ -13171,7 +13171,7 @@ function api_set_create_event($id, $trash1, $other, $returnType)
if ($other['data'][7] != '') {
$values['id_agentmodule'] = $other['data'][7];
} else {
$value['id_agentmodule'] = 0;
$values['id_agentmodule'] = 0;
}
if ($other['data'][8] != '') {
@ -15922,7 +15922,7 @@ function api_set_create_event_filter($name, $thrash1, $other, $thrash3)
$id_user_ack = (in_array($other['data'][9], $users)) ? $other['data'][9] : 0;
$group_rep = ($other['data'][10] == 0 || $other['data'][10] == 1) ? $other['data'][10] : 0;
$group_rep = ($other['data'][10] == EVENT_GROUP_REP_ALL || $other['data'][10] == EVENT_GROUP_REP_EVENTS) ? $other['data'][10] : EVENT_GROUP_REP_ALL;
$date_from = (preg_match('/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/', $other['data'][11])) ? $other['data'][11] : '0000-00-00';
@ -16149,7 +16149,7 @@ function api_set_update_event_filter($id_event_filter, $thrash1, $other, $thrash
break;
case 11:
$values['group_rep'] = ($other['data'][11] == 0 || $other['data'][11] == 1) ? $other['data'][11] : 0;
$values['group_rep'] = ($other['data'][11] == EVENT_GROUP_REP_ALL || $other['data'][11] == EVENT_GROUP_REP_EVENTS) ? $other['data'][11] : EVENT_GROUP_REP_ALL;
break;
case 12:

View File

@ -515,6 +515,10 @@ function config_update_config()
if (config_update_value('reset_pass_option', (bool) get_parameter('reset_pass_option'), true) === false) {
$error_update[] = __('Activate reset password');
}
if (config_update_value('exclusion_word_list', (string) get_parameter('exclusion_word_list'), true) === false) {
$error_update[] = __('Exclusion word list for passwords');
}
}
break;
@ -608,7 +612,7 @@ function config_update_config()
$error_update[] = __('Admin LDAP login');
}
if (config_update_value('ldap_admin_pass', io_input_password(io_safe_output(get_parameter('ldap_admin_pass'))), true) === false) {
if (config_update_value('ldap_admin_pass', io_input_password(get_parameter('ldap_admin_pass')), true) === false) {
$error_update[] = __('Admin LDAP password');
}
@ -644,7 +648,7 @@ function config_update_config()
$error_update[] = __('Admin secondary LDAP login');
}
if (config_update_value('ldap_admin_pass_secondary', io_input_password(io_safe_output(get_parameter('ldap_admin_pass_secondary'))), true) === false) {
if (config_update_value('ldap_admin_pass_secondary', io_input_password(get_parameter('ldap_admin_pass_secondary')), true) === false) {
$error_update[] = __('Admin secondary LDAP password');
}
@ -1563,6 +1567,10 @@ function config_update_config()
$error_update[] = __('Enable history event');
}
if (config_update_value('history_trap_enabled', get_parameter('history_trap_enabled'), true) === false) {
$error_update[] = __('Enable history trap');
}
if (config_update_value('history_db_user', get_parameter('history_db_user'), true) === false) {
$error_update[] = __('Database user');
}
@ -1600,6 +1608,22 @@ function config_update_config()
$error_update[] = __('Event Days');
}
$history_trap_days = get_parameter('history_trap_days');
if (is_numeric($history_trap_days) === false
|| $history_trap_days <= 0
|| config_update_value('history_trap_days', $history_trap_days) === false
) {
$error_update[] = __('Trap Days');
}
$trap_history_purge = get_parameter('history_traps_days_purge');
if (is_numeric($trap_history_purge) === false
|| $trap_history_purge <= 0
|| config_update_value('trap_history_purge', $trap_history_purge) === false
) {
$error_update[] = __('Trap history purge');
}
$history_db_step = get_parameter('history_db_step');
if (!is_numeric($history_db_step)
|| $history_db_step <= 0
@ -1664,6 +1688,14 @@ function config_update_config()
$error_update[] = __('Historical database events purge');
}
if ($dbm->setConfigToken(
'trap_history_purge',
get_parameter('history_traps_days_purge')
) !== true
) {
$error_update[] = __('Historical database traps purge');
}
if ($dbm->setConfigToken(
'string_purge',
get_parameter('history_dbh_string_purge')
@ -2199,6 +2231,10 @@ function config_process_config()
config_update_value('reset_pass_option', 0);
}
if (isset($config['exclusion_word_list']) === false) {
config_update_value('exclusion_word_list', '');
}
if (!isset($config['include_agents'])) {
config_update_value('include_agents', 0);
}
@ -2520,6 +2556,10 @@ function config_process_config()
config_update_value('history_event_enabled', false);
}
if (!isset($config['history_trap_enabled'])) {
config_update_value('history_trap_enabled', false);
}
if (!isset($config['history_db_host'])) {
config_update_value('history_db_host', '');
}
@ -2556,6 +2596,14 @@ function config_process_config()
config_update_value('history_event_days', 90);
}
if (!isset($config['history_trap_days'])) {
config_update_value('history_trap_days', 90);
}
if (!isset($config['trap_history_purge'])) {
config_update_value('trap_history_purge', 180);
}
if (!isset($config['history_db_step'])) {
config_update_value('history_db_step', 0);
}

View File

@ -1338,30 +1338,42 @@ function db_get_cached_queries()
* This function comes back with an array in case of SELECT
* in case of UPDATE, DELETE etc. with affected rows
* an empty array in case of SELECT without results
* Queries that return data will be cached so queries don't get repeated
* Queries that return data will be cached so queries don't get repeated.
*
* @param string SQL statement to execute
* @param string $sql SQL statement to execute.
* @param string $rettype What type of info to return in case of INSERT/UPDATE.
* 'affected_rows' will return mysql_affected_rows (default value)
* 'insert_id' will return the ID of an autoincrement value
* 'info' will return the full (debug) information of a query.
* @param string $dbconnection Info conecction.
* @param boolean $cache Cache.
* @param string $status The status and type of query (support only postgreSQL).
* @param boolean $autocommit Set autocommit transaction mode true/false (Only oracle).
* @param array $values Values (Only type insert).
*
* @param string What type of info to return in case of INSERT/UPDATE.
* 'affected_rows' will return mysql_affected_rows (default value)
* 'insert_id' will return the ID of an autoincrement value
* 'info' will return the full (debug) information of a query
*
* @param string $status The status and type of query (support only postgreSQL).
*
* @param boolean $autocommit (Only oracle) Set autocommit transaction mode true/false
*
* @return mixed An array with the rows, columns and values in a multidimensional array or false in error
* @return mixed An array with the rows, columns and values in a multidimensional array or false in error.
*/
function db_process_sql($sql, $rettype='affected_rows', $dbconnection='', $cache=true, &$status=null, $autocommit=true)
{
function db_process_sql(
$sql,
$rettype='affected_rows',
$dbconnection='',
$cache=true,
&$status=null,
$autocommit=true,
$values_insert=[]
) {
global $config;
$rc = false;
switch ($config['dbtype']) {
case 'mysql':
default:
$rc = @mysql_db_process_sql($sql, $rettype, $dbconnection, $cache);
$rc = @mysql_db_process_sql(
$sql,
$rettype,
$dbconnection,
$cache
);
break;
case 'postgresql':
@ -1373,7 +1385,13 @@ function db_process_sql($sql, $rettype='affected_rows', $dbconnection='', $cache
break;
}
db_sync($dbconnection, $sql, $rc);
db_sync(
$dbconnection,
$sql,
$rc,
$rettype,
$values_insert
);
return $rc;
}
@ -1388,8 +1406,13 @@ function db_process_sql($sql, $rettype='affected_rows', $dbconnection='', $cache
*
* @return void
*/
function db_sync($dbconnection, $sql, $rc)
{
function db_sync(
$dbconnection,
$sql,
$rc,
$rettype='affected_rows',
$values_insert=[]
) {
global $config;
if (enterprise_hook('is_metaconsole') === true
&& isset($config['centralized_management']) === true
@ -1401,6 +1424,16 @@ function db_sync($dbconnection, $sql, $rc)
// Synchronize changes to nodes if needed.
$sync = new Synchronizer();
if ($sync !== null) {
if ($rettype === 'insert_id') {
$forceSql = $sync->updateInsertQueryAddPrimaryKey(
$values_insert,
$rc
);
if (empty($forceSql) === false) {
$sql = $forceSql;
}
}
if ($sync->queue($sql, $rc) === false) {
// Launch events per failed query.
$errors = $sync->getLatestErrors();
@ -1696,13 +1729,13 @@ function db_process_delete_temp($table, $row, $value, $custom_value=false)
*
* @return mixed False in case of error or invalid values passed. Affected rows otherwise
*/
function db_process_sql_insert($table, $values, $autocommit=true)
function db_process_sql_insert($table, $values, $autocommit=true, $sqltostring=false)
{
global $config;
switch ($config['dbtype']) {
case 'mysql':
return mysql_db_process_sql_insert($table, $values);
return mysql_db_process_sql_insert($table, $values, $sqltostring);
break;
case 'postgresql':

View File

@ -382,14 +382,14 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
}
if (isset($filter) === false
|| is_array($filter) === true
|| is_array($filter) === false
) {
$filter = ['group_rep' => 0];
$filter = ['group_rep' => EVENT_GROUP_REP_ALL];
}
switch ($filter['group_rep']) {
case '0':
case '2':
case EVENT_GROUP_REP_ALL:
case EVENT_GROUP_REP_AGENTS:
default:
// No groups option direct update.
$delete_sql = sprintf(
@ -399,7 +399,8 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
);
break;
case '1':
case EVENT_GROUP_REP_EVENTS:
case EVENT_GROUP_REP_EXTRAIDS:
// Group by events.
$sql = events_get_all(
['te.*'],
@ -418,8 +419,16 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
true
);
$target_ids = db_get_all_rows_sql(
sprintf(
if ((int) $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS) {
$sql = sprintf(
'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf
ON tu.id_extra = tf.id_extra
AND tf.max_id_evento = %d',
$sql,
$id_evento
);
} else {
$sql = sprintf(
'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf
ON tu.estado = tf.estado
AND tu.evento = tf.evento
@ -428,8 +437,10 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
AND tf.max_id_evento = %d',
$sql,
$id_evento
)
);
);
}
$target_ids = db_get_all_rows_sql($sql);
// Try to avoid deadlock while updating full set.
if ($target_ids !== false && count($target_ids) > 0) {
@ -475,12 +486,12 @@ function events_update_status($id_evento, $status, $filter=null)
}
if (isset($filter) === false || is_array($filter) === false) {
$filter = ['group_rep' => 0];
$filter = ['group_rep' => EVENT_GROUP_REP_ALL];
}
switch ($filter['group_rep']) {
case '0':
case '2':
case EVENT_GROUP_REP_ALL:
case EVENT_GROUP_REP_AGENTS:
default:
// No groups option direct update.
$update_sql = sprintf(
@ -492,7 +503,8 @@ function events_update_status($id_evento, $status, $filter=null)
);
break;
case '1':
case EVENT_GROUP_REP_EVENTS:
case EVENT_GROUP_REP_EXTRAIDS:
// Group by events.
$sql = events_get_all(
['te.*'],
@ -511,8 +523,16 @@ function events_update_status($id_evento, $status, $filter=null)
true
);
$target_ids = db_get_all_rows_sql(
sprintf(
if ((int) $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS) {
$sql = sprintf(
'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf
ON tu.id_extra = tf.id_extra
AND tf.max_id_evento = %d',
$sql,
$id_evento
);
} else {
$sql = sprintf(
'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf
ON tu.estado = tf.estado
AND tu.evento = tf.evento
@ -521,8 +541,10 @@ function events_update_status($id_evento, $status, $filter=null)
AND tf.max_id_evento = %d',
$sql,
$id_evento
)
);
);
}
$target_ids = db_get_all_rows_sql($sql);
// Try to avoid deadlock while updating full set.
if ($target_ids !== false && count($target_ids) > 0) {
@ -1367,7 +1389,10 @@ function events_get_all(
// Order.
$order_by = '';
if (isset($order, $sort_field) === true) {
if (isset($filter['group_rep']) === true && $filter['group_rep'] == 1) {
if (isset($filter['group_rep']) === true
&& $filter['group_rep'] === EVENT_GROUP_REP_EVENTS
&& $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS
) {
$order_by = events_get_sql_order('MAX('.$sort_field.')', $order);
} else {
$order_by = events_get_sql_order($sort_field, $order);
@ -1401,22 +1426,22 @@ function events_get_all(
$group_by = 'GROUP BY ';
$tagente_join = 'LEFT';
if (isset($filter['group_rep']) === false) {
$filter['group_rep'] = 0;
$filter['group_rep'] = EVENT_GROUP_REP_ALL;
}
switch ($filter['group_rep']) {
case '0':
case EVENT_GROUP_REP_ALL:
default:
// All events.
$group_by = '';
break;
case '1':
case EVENT_GROUP_REP_EVENTS:
// Group by events.
$group_by .= 'te.evento, te.id_agente, te.id_agentmodule';
break;
case '2':
case EVENT_GROUP_REP_AGENTS:
// Group by agents.
$tagente_join = 'INNER';
$group_by = '';
@ -1430,6 +1455,11 @@ function events_get_all(
);
}
break;
case EVENT_GROUP_REP_EXTRAIDS:
// Group by events.
$group_by .= 'te.id_extra';
break;
}
$tgrupo_join = 'LEFT';
@ -1516,7 +1546,9 @@ function events_get_all(
}
}
if ((int) $filter['group_rep'] === 1 && $count === false) {
if (((int) $filter['group_rep'] === EVENT_GROUP_REP_EVENTS
|| (int) $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS) && $count === false
) {
$sql = sprintf(
'SELECT %s
%s
@ -1547,7 +1579,9 @@ function events_get_all(
%s
%s
%s JOIN tgrupo tg
ON %s',
ON %s
%s
%s',
join(',', $fields),
$group_selects_trans,
$tevento,
@ -1576,7 +1610,8 @@ function events_get_all(
join(' ', $agent_join_filters),
$tgrupo_join,
join(' ', $tgrupo_join_filters),
join(' ', $sql_filters)
join(' ', $sql_filters),
$order_by
);
} else {
$sql = sprintf(
@ -2900,9 +2935,9 @@ function events_get_agent(
// Group by agent.
if ((bool) $show_summary_group === true) {
$filters['group_rep'] = 1;
$filters['group_rep'] = EVENT_GROUP_REP_EVENTS;
} else {
$filters['group_rep'] = 2;
$filters['group_rep'] = EVENT_GROUP_REP_AGENTS;
}
$events = Event::search(
@ -5153,7 +5188,7 @@ function events_get_count_events_validated_by_user($data)
*
* @return string SQL.
*/
function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=0, $only_fields=false)
function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=EVENT_GROUP_REP_ALL, $only_fields=false)
{
$sort_field_translated = $sort_field;
switch ($sort_field) {
@ -5174,7 +5209,7 @@ function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=
break;
case 'timestamp':
$sort_field_translated = ($group_rep == 0) ? 'timestamp' : 'timestamp_last';
$sort_field_translated = ($group_rep == EVENT_GROUP_REP_ALL) ? 'timestamp' : 'timestamp_last';
break;
case 'user_id':
@ -5201,6 +5236,14 @@ function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=
$sort_field_translated = 'id_extra';
break;
case 'agent_name':
$sort_field_translated = 'ta.nombre';
break;
case 'module_custom_id':
$sort_field_translated = 'am.custom_id';
break;
default:
$sort_field_translated = $sort_field;
break;

View File

@ -4735,12 +4735,12 @@ function html_print_autocomplete_modules(
*
* @return string HTML code
*/
function html_print_timezone_select($name, $selected='')
function html_print_timezone_select($name, $selected='', $nothing='', $nothing_value='')
{
$timezones_index = timezone_identifiers_list();
$timezones = timezone_identifiers_list();
$timezones = array_combine($timezones_index, $timezones);
return html_print_select($timezones, $name, $selected, '', __('None'), '', true, false, false);
$timezones = array_combine($timezones, $timezones);
$timezones = (['' => __('none')] + $timezones);
return html_print_select($timezones, $name, $selected, '', $nothing, $nothing_value, true, false, false);
}

View File

@ -4011,7 +4011,7 @@ function reporting_groups_nodes($content)
}
// Grouped.
$filters['group_rep'] = 1;
$filters['group_rep'] = EVENT_GROUP_REP_EVENTS;
$events = Event::search(
[

View File

@ -6513,7 +6513,7 @@ function ui_print_breadcrums($tab_name)
/**
* Show last comment
*
* @param array $comments array with comments
* @param string $comments String with comments.
*
* @return string HTML string with the last comment of the events.
*/
@ -6537,31 +6537,45 @@ function ui_print_comments($comments)
foreach ($comments_array as $comm) {
// Show the comments more recent first.
if (is_array($comm)) {
$last_comment[] = array_reverse($comm);
$order_utimestamp = array_reduce(
$comm,
function ($carry, $item) {
$carry[$item['utimestamp']] = $item;
return $carry;
}
);
$key_max_utimestamp = max(array_keys($order_utimestamp));
$last_comment = $order_utimestamp[$key_max_utimestamp];
}
}
if (empty($last_comment) === true) {
return '';
}
// Only show the last comment. If commment its too long,the comment will short with ...
// If $config['prominent_time'] is timestamp the date show Month, day, hour and minutes.
// Else show comments hours ago
if ($last_comment[0][0]['action'] != 'Added comment') {
$last_comment[0][0]['comment'] = $last_comment[0][0]['action'];
if ($last_comment['action'] != 'Added comment') {
$last_comment['comment'] = $last_comment['action'];
}
$short_comment = substr($last_comment[0][0]['comment'], 0, 20);
$short_comment = substr($last_comment['comment'], 0, 20);
if ($config['prominent_time'] == 'timestamp') {
$comentario = '<i>'.date($config['date_format'], $last_comment[0][0]['utimestamp']).'&nbsp;('.$last_comment[0][0]['id_user'].'):&nbsp;'.$last_comment[0][0]['comment'].'';
$comentario = '<i>'.date($config['date_format'], $last_comment['utimestamp']).'&nbsp;('.$last_comment['id_user'].'):&nbsp;'.$last_comment['comment'].'';
if (strlen($comentario) > '200px') {
$comentario = '<i>'.date($config['date_format'], $last_comment[0][0]['utimestamp']).'&nbsp;('.$last_comment[0][0]['id_user'].'):&nbsp;'.$short_comment.'...';
$comentario = '<i>'.date($config['date_format'], $last_comment['utimestamp']).'&nbsp;('.$last_comment['id_user'].'):&nbsp;'.$short_comment.'...';
}
} else {
$rest_time = (time() - $last_comment[0][0]['utimestamp']);
$rest_time = (time() - $last_comment['utimestamp']);
$time_last = (($rest_time / 60) / 60);
$comentario = '<i>'.number_format($time_last, 0).'&nbsp; Hours &nbsp;('.$last_comment[0][0]['id_user'].'):&nbsp;'.$last_comment[0][0]['comment'].'';
$comentario = '<i>'.number_format($time_last, 0).'&nbsp; Hours &nbsp;('.$last_comment['id_user'].'):&nbsp;'.$last_comment['comment'].'';
if (strlen($comentario) > '200px') {
$comentario = '<i>'.number_format($time_last, 0).'&nbsp; Hours &nbsp;('.$last_comment[0][0]['id_user'].'):&nbsp;'.$short_comment.'...';
$comentario = '<i>'.number_format($time_last, 0).'&nbsp; Hours &nbsp;('.$last_comment['id_user'].'):&nbsp;'.$short_comment.'...';
}
}

View File

@ -3708,6 +3708,8 @@ function visual_map_print_visual_map(
// End function
// Start function
/**
* Get a list with the layouts for a user.
*
@ -3719,8 +3721,6 @@ function visual_map_print_visual_map(
*
* @return array A list of layouts the user can see.
*/
function visual_map_get_user_layouts(
$id_user=0,
$only_names=false,
@ -3729,6 +3729,7 @@ function visual_map_get_user_layouts(
$favourite=false,
$check_user_groups=true
) {
$where = '';
if (! is_array($filter)) {
$filter = [];
} else {
@ -3819,17 +3820,19 @@ function visual_map_get_user_layouts(
$retval[$layout['id']] = $layout;
}
// add_perms
if (isset($groups[$layout['id_group']]['vconsole_view'])) {
$retval[$layout['id']]['vr'] = $groups[$layout['id_group']]['vconsole_view'];
}
if ($only_names === false) {
// Aad_perms.
if (isset($groups[$layout['id_group']]['vconsole_view'])) {
$retval[$layout['id']]['vr'] = $groups[$layout['id_group']]['vconsole_view'];
}
if (isset($groups[$layout['id_group']]['vconsole_edit'])) {
$retval[$layout['id']]['vw'] = $groups[$layout['id_group']]['vconsole_edit'];
}
if (isset($groups[$layout['id_group']]['vconsole_edit'])) {
$retval[$layout['id']]['vw'] = $groups[$layout['id_group']]['vconsole_edit'];
}
if (isset($groups[$layout['id_group']]['vconsole_management'])) {
$retval[$layout['id']]['vm'] = $groups[$layout['id_group']]['vconsole_management'];
if (isset($groups[$layout['id_group']]['vconsole_management'])) {
$retval[$layout['id']]['vm'] = $groups[$layout['id_group']]['vconsole_management'];
}
}
}

View File

@ -154,8 +154,10 @@ $(document).ready(function() {
if (selector == "search") {
$("#search_title_result h2").append(
"<span class='pandora_green_text'>" + search_modules + "</span>"
"<span class='pandora_green_text' id='search_string'></span>"
);
$("#search_string").text(search_modules);
}
if (total_posts < 1) {

View File

@ -1386,6 +1386,12 @@ function dashboardLoadVC(settings) {
: "dashboard"
);
if (settings.props.maintenanceMode != null) {
if (settings.props.maintenanceMode.user !== settings.id_user) {
visualConsoleManager.visualConsole.enableMaintenanceMode();
}
}
if (settings.mobile_view_orientation_vc === true) {
$(window).on("orientationchange", function() {
$(container).width($(window).height());

View File

@ -707,7 +707,7 @@ function execute_event_response(event_list_btn) {
}
in_process_event(
"events",
"table_events",
event_id,
$(this).attr("event_rep"),
this.parentElement.parentElement,
@ -727,7 +727,7 @@ function execute_event_response(event_list_btn) {
}
validate_event(
"events",
"table_events",
event_id,
$(this).attr("event_rep"),
this.parentElement.parentElement,
@ -747,7 +747,7 @@ function execute_event_response(event_list_btn) {
}
execute_delete_event_reponse(
"events",
"table_events",
event_id,
$(this).attr("event_rep"),
this.parentElement.parentElement,

View File

@ -13,20 +13,26 @@ function configure_modules_form() {
$("#id_module_type").change(function() {
if (id_modules_icmp.in_array(this.value)) {
$(
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-tcp_send, tr#simple-tcp_receive"
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-snmp_credentials, tr#simple-tcp_send, tr#simple-tcp_receive"
).hide();
$("#text-tcp_port").attr("disabled", "1");
} else if (id_modules_snmp.in_array(this.value)) {
$("tr#simple-snmp_1, tr#simple-snmp_2").show();
$(
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-snmp_credentials"
).show();
$("tr#simple-tcp_send, tr#simple-tcp_receive").hide();
$("#text-tcp_port").removeAttr("disabled");
} else if (id_modules_tcp.in_array(this.value)) {
$("tr#simple-snmp_1, tr#simple-snmp_2").hide();
$(
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-snmp_credentials"
).hide();
$("tr#simple-tcp_send, tr#simple-tcp_receive").show();
$("#text-tcp_port").removeAttr("disabled");
} else if (id_modules_exec.in_array(this.value)) {
$("tr#simple-tcp_send, tr#simple-tcp_receive").hide();
$("tr#simple-snmp_1, tr#simple-snmp_2").hide();
$(
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-snmp_credentials"
).hide();
$("#text-tcp_port").attr("disabled", false);
}
});

View File

@ -117,6 +117,15 @@ function createVisualConsole(
visualConsole.updateElements(items);
}
if (
visualConsole.props.maintenanceMode != null &&
visualConsole.props.maintenanceMode.user !== id_user
) {
visualConsole.enableMaintenanceMode();
} else {
visualConsole.disableMaintenanceMode();
}
// Emit the VC update event.
if (onUpdate) onUpdate(prevProps, visualConsole.props);
} catch (ignored) {} // eslint-disable-line no-empty
@ -159,6 +168,7 @@ function createVisualConsole(
// Initialize the Visual Console.
try {
visualConsole = new VisualConsole(container, props, items);
// VC Item clicked.
visualConsole.onItemClick(function(e) {
var data = e.item.props || {};
@ -357,7 +367,6 @@ function createVisualConsole(
})
.init();
});
// VC Item resized.
visualConsole.onItemResized(function(e) {
var item = e.item;
@ -473,6 +482,11 @@ function createVisualConsole(
updateVisualConsole(visualConsole.props.id, interval, null, dimensions);
}
},
forceUpdateVisualConsole: function() {
asyncTaskManager.cancel("visual-console");
asyncTaskManager.cancel("visual-console-start");
updateVisualConsole(visualConsole.props.id);
},
createItem: function(typeString) {
var type;
switch (typeString) {

File diff suppressed because it is too large Load Diff

View File

@ -126,21 +126,21 @@ class GroupedMeterGraphs extends Widget
*
* @var array
*/
private array $size;
private $size;
/**
* Number of boxes.
*
* @var float
*/
private float $boxNumber;
private $boxNumber;
/**
* Thresholds.
*
* @var array
*/
private array $thresholds;
private $thresholds;
/**

View File

@ -90,6 +90,7 @@ final class Container extends Model
'backgroundURL' => static::extractBackgroundUrl($data),
'relationLineWidth' => (int) $data['relationLineWidth'],
'hash' => static::extractHash($data),
'maintenanceMode' => static::extractMaintenanceMode($data),
];
}
@ -238,6 +239,45 @@ final class Container extends Model
}
/**
* Extract a background color value.
*
* @param array $data Unknown input data structure.
*
* @return mixed String representing the color (not empty) or null.
*/
private static function extractMaintenanceMode(array $data)
{
global $config;
$maintenance_mode = static::notEmptyStringOr(
static::issetInArray(
$data,
[
'maintenanceMode',
'maintenance_mode',
]
),
null
);
$result = null;
if ($maintenance_mode !== null) {
$result = json_decode($maintenance_mode, true);
$result['date'] = date(
$config['date_format'],
$result['timestamp']
);
$result['timestamp'] = human_time_description_raw(
(time() - $result['timestamp'])
);
}
return $result;
}
/**
* Extract the "is favorite" switch value.
*

View File

@ -398,7 +398,6 @@ li > input[type="email"],
border: none;
border-radius: 0;
border-bottom: 1px solid #ccc;
font-weight: lighter;
padding: 0px 0px 2px 0px;
box-sizing: border-box;
margin-bottom: 4px;

View File

@ -9119,3 +9119,37 @@ div#err_msg_centralised {
margin-right: -110px;
margin-top: 13px;
}
.tag-editor {
padding: 0.5em !important;
}
.tag-editor div {
float: right !important;
}
.tag-editor .tag-editor-tag {
padding: 5px !important;
color: #fff !important;
background: #82b92e !important;
border-radius: 0 2px 2px 0 !important;
}
.tag-editor .tag-editor-delete {
padding: 5px !important;
line-height: 16px !important;
background: #82b92e !important;
border-radius: 2px 0 0 2px !important;
}
.tag-editor .tag-editor-delete i {
line-height: 16pt !important;
}
.tag-editor .tag-editor-delete i:before {
color: #fff !important;
}
.tag-editor .tag-editor-delete:hover i:before {
color: #ccc !important;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

View File

@ -7,6 +7,14 @@
margin-top: 5px;
}
.is-maintenance {
background-image: url(maintenanceMode.png) !important;
}
.is-maintenance :nth-child(1) {
display: none;
}
.visual-console-item {
position: absolute;
display: flex;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -546,6 +546,7 @@ if (isset($config['id_user']) === false) {
if ((!isset($double_auth_success)
|| !$double_auth_success)
&& is_double_auth_enabled($nick_in_db)
&& (bool) $config['double_auth_enabled'] === true
) {
// Store this values in the session to know if the user login
// was correct.

View File

@ -129,7 +129,7 @@
<div style='height: 10px'>
<?php
$version = '7.0NG.765';
$build = '221021';
$build = '221102';
$banner = "v$version Build $build";
error_reporting(0);

View File

@ -357,10 +357,10 @@ class Events
);
if (isset($group_rep) === false) {
$group_rep = 0;
$group_rep = EVENT_GROUP_REP_ALL;
}
if ((int) $group_rep !== 0) {
if ((int) $group_rep !== EVENT_GROUP_REP_ALL) {
if ($event['event_rep'] <= 1) {
$event['event_repeated'] = '<i>'.__('No').'</i>';
} else {
@ -1068,7 +1068,7 @@ class Events
$filters['id_agent'] = $this->id_agent;
}
$filters['group_rep'] = 1;
$filters['group_rep'] = EVENT_GROUP_REP_EVENTS;
if (isset($this->limit) === true
&& $this->limit !== -1

View File

@ -358,6 +358,7 @@ class Visualmap
'uniq' => $uniq,
'mobile' => true,
'vcId' => $visualConsoleId,
'id_user' => $config['id_user'],
'mobile_view_orientation_vc' => (bool) !$config['mobile_view_orientation_vc'],
]
);

View File

@ -84,7 +84,7 @@ ui_require_javascript_file('pandora_events');
$default_filter = [
'status' => EVENT_NO_VALIDATED,
'event_view_hr' => $config['event_view_hr'],
'group_rep' => 1,
'group_rep' => EVENT_GROUP_REP_EVENTS,
'tag_with' => [],
'tag_without' => [],
'history' => false,
@ -360,6 +360,10 @@ if (is_ajax() === true) {
$order['field'] = 'agent_name';
break;
case 'if(te.ack_utimestamp > 0, from_unixtime(te.ack_utimestamp),"") as ack_utimestamp':
$order['field'] = 'ack_utimestamp';
break;
default:
$order['field'] = $field;
break;
@ -1445,7 +1449,7 @@ if ($pure) {
).'</a>';
// If the user has administrator permission display manage tab.
if ($event_w || $event_m) {
if ($event_w === true || $event_m === true) {
// Manage events.
$manage_events['active'] = false;
$manage_events['text'] = '<a href="index.php?sec=eventos&sec2=godmode/events/events&amp;section=filter&amp;pure='.$config['pure'].'">'.html_print_image(
@ -1665,9 +1669,10 @@ $inputs[] = $in;
// Duplicates group { events | agents }.
$data = html_print_select(
[
0 => __('All events'),
1 => __('Group events'),
2 => __('Group agents'),
EVENT_GROUP_REP_ALL => __('All events'),
EVENT_GROUP_REP_EVENTS => __('Group events'),
EVENT_GROUP_REP_AGENTS => __('Group agents'),
EVENT_GROUP_REP_EXTRAIDS => __('Group extra id'),
],
'group_rep',
$group_rep,
@ -1771,7 +1776,7 @@ $buttons[] = [
'onclick' => '',
];
if ($event_w || $event_m) {
if ($event_w === true || $event_m === true) {
$buttons[] = [
'id' => 'save-filter',
'class' => 'float-left margin-right-2 sub wand',
@ -2300,12 +2305,14 @@ try {
$active_filters_div .= '<div>';
$active_filters_div .= '<div class="label box-shadow">'.__('Duplicated').'</div>';
$active_filters_div .= '<div id="summary_duplicates" class="content">';
if ($group_rep == 0) {
if ($group_rep == EVENT_GROUP_REP_ALL) {
$active_filters_div .= __('All events.');
} else if ($group_rep == 1) {
} else if ($group_rep == EVENT_GROUP_REP_EVENTS) {
$active_filters_div .= __('Group events');
} else if ($group_rep == 2) {
} else if ($group_rep == EVENT_GROUP_REP_AGENTS) {
$active_filters_div .= __('Group agents.');
} else if ($group_rep == EVENT_GROUP_REP_EXTRAIDS) {
$active_filters_div .= __('Group extra id.');
}
$active_filters_div .= '</div>';
@ -2395,6 +2402,16 @@ if (is_user_admin($config['id_user'])) {
);
}
$array_events_actions = [];
if ($event_w === true && $readonly === false) {
$array_events_actions['in_progress_selected'] = __('In progress selected');
$array_events_actions['validate_selected'] = __('Validate selected');
}
if ($event_m === true && $readonly === false) {
$array_events_actions['delete_selected'] = __('Delete selected');
}
foreach ($event_responses as $val) {
$array_events_actions[$val['id']] = $val['name'];
}

View File

@ -410,7 +410,7 @@ if ($access_console_node === true) {
$user_event_filter = [
'status' => EVENT_NO_VALIDATED,
'event_view_hr' => $config['event_view_hr'],
'group_rep' => 1,
'group_rep' => EVENT_GROUP_REP_EVENTS,
'tag_with' => [],
'tag_without' => [],
'history' => false,

View File

@ -211,7 +211,7 @@ if (isset($_GET['modified']) && !$view_mode) {
$user_info = $upd_info;
} else {
if (!$error_msg) {
$error_msg = __('Error updating passwords: ');
$error_msg = __('Error updating passwords: ').($config['auth_error'] ?? '');
}
$user_auth_error = $config['auth_error'];
@ -425,7 +425,7 @@ $timezone .= html_print_timezone_select('timezone', $user_info['timezone']).'</d
// Double auth.
$double_auth_enabled = (bool) db_get_value('id', 'tuser_double_auth', 'id_user', $config['id_user']);
if ($config['double_auth_enabled'] || ($config['double_auth_enabled'] == '' && $double_auth_enabled)) {
if ((bool) $config['double_auth_enabled'] === true) {
$double_authentication = '<div class="label_select_simple"><p class="edit_user_labels">'.__('Double authentication').'</p>';
if (($config['2FA_all_users'] == '' && !$double_auth_enabled)
|| ($config['2FA_all_users'] != '' && !$double_auth_enabled)
@ -437,9 +437,6 @@ if ($config['double_auth_enabled'] || ($config['double_auth_enabled'] == '' && $
// Dialog.
$double_authentication .= '<div id="dialog-double_auth"class="invisible"><div id="dialog-double_auth-container"></div></div>';
}
if ($double_auth_enabled && $config['double_auth_enabled']) {
$double_authentication .= html_print_button(__('Show information'), 'show_info', false, 'javascript:show_double_auth_info();', '', true);
}
@ -1166,7 +1163,7 @@ function show_double_auth_activation () {
resizable: true,
draggable: true,
modal: true,
title: "<?php echo __('Double autentication activation'); ?>",
title: "<?php echo __('Double authentication activation'); ?>",
overlay: {
opacity: 0.5,
background: "black"
@ -1242,7 +1239,7 @@ function show_double_auth_deactivation () {
resizable: true,
draggable: true,
modal: true,
title: "<?php echo __('Double autentication activation'); ?>",
title: "<?php echo __('Double authentication activation'); ?>",
overlay: {
opacity: 0.5,
background: "black"

View File

@ -281,6 +281,12 @@ $visualConsoleItems = VisualConsole::getItemsFromDB(
"<?php echo get_parameter('hash', ''); ?>"
);
if(props.maintenanceMode != null) {
if(props.maintenanceMode.user !== '<?php echo $config['id_user']; ?>') {
visualConsoleManager.visualConsole.enableMaintenanceMode();
}
}
var controls = document.getElementById('vc-controls');
autoHideElement(controls, 1000);

View File

@ -33,7 +33,6 @@ global $config;
check_login();
require_once $config['homedir'].'/vendor/autoload.php';
// TODO: include file functions.
require_once $config['homedir'].'/include/functions_visual_map.php';
@ -103,6 +102,9 @@ $aclRead = (bool) check_acl_restricted_all($config['id_user'], $groupId, 'VR')
$aclWrite = (bool) check_acl_restricted_all($config['id_user'], $groupId, 'VW');
$aclManage = (bool) check_acl_restricted_all($config['id_user'], $groupId, 'VM');
// Maintenance Mode.
$maintenanceMode = $visualConsoleData['maintenanceMode'];
if ($aclRead === false && $aclWrite === false && $aclManage === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
@ -398,18 +400,54 @@ if ($pure === false) {
echo '</div>';
if ($aclWrite === true || $aclManage === true) {
if (!is_metaconsole()) {
echo '<a id ="force_check" href="" style="margin-right: 25px;">'.html_print_image(
echo '<div class="flex-row" style="width:220px;">';
if (is_metaconsole() === false) {
echo '<div id="force_check_control" class="flex-column">';
echo html_print_label(__('Force'), 'force-mode', true);
echo '<a id ="force_check" href="">';
echo html_print_image(
'images/target.png',
true,
[
'title' => __('Force remote checks'),
'class' => 'invert_filter',
]
).'</a>';
);
echo '</a>';
echo '</div>';
}
echo html_print_checkbox_switch('edit-mode', 1, false, true);
$disabled_edit_mode = false;
if ($aclManage === true) {
$value_maintenance_mode = true;
if ($maintenanceMode === null) {
$value_maintenance_mode = false;
} else {
if ($maintenanceMode['user'] !== $config['id_user']) {
$disabled_edit_mode = true;
}
}
echo '<div id="maintenance-mode-control" class="flex-column">';
echo html_print_label(
__('Maintenance'),
'maintenance-mode',
true
);
echo html_print_checkbox_switch(
'maintenance-mode',
1,
$value_maintenance_mode,
true
);
echo '</div>';
}
echo '<div id="edit-mode-control" class="flex-column">';
echo html_print_label(__('Edit'), 'edit-mode', true);
echo html_print_checkbox_switch('edit-mode', 1, false, true, $disabled_edit_mode);
echo '</div>';
echo '</div>';
}
echo '</div>';
@ -661,6 +699,18 @@ ui_require_css_file('form');
window.history.replaceState({}, document.title, href);
}
}
if(newProps.maintenanceMode != null) {
$('input[name=maintenance-mode]').prop('checked', true);
if(newProps.maintenanceMode.user !== '<?php echo $config['id_user']; ?>') {
$('input[name=edit-mode]').prop('disabled', true);
} else {
$('input[name=edit-mode]').prop('disabled', false);
}
} else {
$('input[name=maintenance-mode]').prop('checked', false);
$('input[name=edit-mode]').prop('disabled', false);
}
}
// Add the datetime when the item was received.
@ -676,26 +726,88 @@ ui_require_css_file('form');
items,
baseUrl,
<?php echo ($refr * 1000); ?>,
handleUpdate
handleUpdate,
false,
undefined,
'<?php echo $config['id_user']; ?>',
);
if(props.maintenanceMode != null) {
if(props.maintenanceMode.user !== '<?php echo $config['id_user']; ?>') {
visualConsoleManager.visualConsole.enableMaintenanceMode();
}
}
<?php
if ($edit_capable === true) {
?>
// Enable/disable the edition mode.
$('input[name=edit-mode]').change(function(event) {
var maintenanceMode = visualConsoleManager.visualConsole.props.maintenanceMode;
if ($(this).prop('checked')) {
visualConsoleManager.visualConsole.enableEditMode();
visualConsoleManager.changeUpdateInterval(0);
$('#force_check').hide();
$('#edit-controls').css('visibility', '');
} else {
visualConsoleManager.visualConsole.disableEditMode();
visualConsoleManager.visualConsole.unSelectItems();
visualConsoleManager.changeUpdateInterval(<?php echo ($refr * 1000); ?>); // To ms.
$('#edit-controls').css('visibility', 'hidden');
$('#force_check').show();
}
resetInterval();
});
// Enable/disable the maintenance mode.
$('input[name=maintenance-mode]').click(function(event) {
event.preventDefault();
const idVisualConsole = '<?php echo $visualConsoleId; ?>';
const mode = ($(this).prop('checked') === true) ? 1 : 0;
var maintenanceMode = visualConsoleManager.visualConsole.props.maintenanceMode;
var msg = '';
if(maintenanceMode == null) {
msg = '<?php echo __('Are you sure you wish to set the visual console in maintenance mode'); ?>';
msg += '?';
} else if (maintenanceMode.user === '<?php echo $config['id_user']; ?>') {
msg += '<?php echo __('Are you sure you wish to disable maintenance mode'); ?>';
msg += '?';
} else {
msg = '<?php echo __('The visual console was set to maintenance mode'); ?>';
msg += ' ' + '<span title="'+maintenanceMode.date+'">' + maintenanceMode.timestamp + '</span>';
msg += ' ' + '<?php echo __('ago by user'); ?>';
msg += ' ' + maintenanceMode.user;
msg += '. ' + '<?php echo __('Are you sure you wish to disable maintenance mode'); ?>';
msg += '?';
}
confirmDialog({
title: '<?php echo __('Maintenance mode'); ?>',
message: msg,
onAccept: function() {
$.ajax({
type: "POST",
url: "ajax.php",
dataType: "json",
data: {
page: "include/ajax/visual_console.ajax",
update_maintanance_mode: true,
idVisualConsole: idVisualConsole,
mode: mode
},
success: function (data) {
if(data.result) {
$('input[name=maintenance-mode]').prop('checked', mode);
$('input[name=maintenance-mode]').trigger('change');
resetInterval();
}
},
error: function (err) {
console.error(err);
}
});
}
});
});
<?php
}
@ -797,6 +909,7 @@ if ($edit_capable === true) {
function resetInterval() {
visualConsoleManager.changeUpdateInterval(<?php echo ($refr * 1000); ?>);
visualConsoleManager.forceUpdateVisualConsole();
}
/**

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.765
%define release 221021
%define release 221102
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.765
%define release 221021
%define release 221102
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.765
%define release 221021
%define release 221102
%define httpd_name httpd
# User and Group under which Apache is running
%define httpd_name apache2

View File

@ -766,7 +766,7 @@ CREATE TABLE IF NOT EXISTS `tgrupo` (
CREATE TABLE IF NOT EXISTS `tcredential_store` (
`identifier` VARCHAR(100) NOT NULL,
`id_group` MEDIUMINT UNSIGNED NOT NULL DEFAULT 0,
`product` ENUM('CUSTOM', 'AWS', 'AZURE', 'GOOGLE', 'SAP') DEFAULT 'CUSTOM',
`product` ENUM('CUSTOM', 'AWS', 'AZURE', 'GOOGLE', 'SAP', 'WMI', 'SNMP') DEFAULT 'CUSTOM',
`username` TEXT,
`password` TEXT,
`extra_1` TEXT,
@ -876,6 +876,7 @@ CREATE TABLE IF NOT EXISTS `trecon_task` (
`summary` TEXT,
`type` INT NOT NULL DEFAULT 0,
`subnet_csv` TINYINT UNSIGNED DEFAULT 0,
`snmp_skip_non_enabled_ifs` TINYINT UNSIGNED DEFAULT 1,
PRIMARY KEY (`id_rt`),
KEY `recon_task_daemon` (`id_recon_server`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
@ -1681,6 +1682,7 @@ CREATE TABLE IF NOT EXISTS `tlayout` (
`background_color` VARCHAR(50) NOT NULL DEFAULT '#FFF',
`is_favourite` INT UNSIGNED NOT NULL DEFAULT 0,
`auto_adjust` INT UNSIGNED NOT NULL DEFAULT 0,
`maintenance_mode` TEXT,
PRIMARY KEY(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;

View File

@ -1335,18 +1335,18 @@ UPDATE `tnotification_source` SET `enabled`=1 WHERE `description` = 'System&#x20
--
INSERT INTO `tlayout`
VALUES
(1, 'Demo&#x20;visual console', 0, 'fondo.jpg', 1080, 1920, 'white', 0, 0),
(2,'Demo&#x20;visual console 2',0,'fondo-keep-alive.jpg',1080,1920,'#FFF',0, 0),
(3,'Worldmap',0,'map_world.jpg',1080,1920,'white',0, 0),
(4,'Europe',0,'map_europe_1.jpg',1080,1920,'white',0, 0),
(5,'USA',0,'map_USA.jpg',1080,1920,'white',0, 0),
(6,'Spain',0,'map_spain.jpg',1080,1920,'white',0, 0),
(7,'Madrid',0,'map_madrid.jpg',1080,1920,'white',0, 0),
(8,'Germany',0,'map_germany_1.jpg',1080,1920,'white',0, 0),
(9,'France',0,'map_france.jpg',1080,1920,'white',0, 0),
(10,'Catalonia',0,'map_catalonia.jpg',1080,1920,'white',0, 0),
(11,'Basque&#x20;Country',0,'map_basque-country.jpg',1080,1920,'white',0, 0),
(12,'Andalusia',0,'map_andalusia.jpg',1080,1920,'white',0, 0)
(1, 'Demo&#x20;visual console', 0, 'fondo.jpg', 1080, 1920, 'white', 0, 0, null),
(2,'Demo&#x20;visual console 2',0,'fondo-keep-alive.jpg',1080,1920,'#FFF',0, 0, null),
(3,'Worldmap',0,'map_world.jpg',1080,1920,'white',0, 0, null),
(4,'Europe',0,'map_europe_1.jpg',1080,1920,'white',0, 0, null),
(5,'USA',0,'map_USA.jpg',1080,1920,'white',0, 0, null),
(6,'Spain',0,'map_spain.jpg',1080,1920,'white',0, 0, null),
(7,'Madrid',0,'map_madrid.jpg',1080,1920,'white',0, 0, null),
(8,'Germany',0,'map_germany_1.jpg',1080,1920,'white',0, 0, null),
(9,'France',0,'map_france.jpg',1080,1920,'white',0, 0, null),
(10,'Catalonia',0,'map_catalonia.jpg',1080,1920,'white',0, 0, null),
(11,'Basque&#x20;Country',0,'map_basque-country.jpg',1080,1920,'white',0, 0, null),
(12,'Andalusia',0,'map_andalusia.jpg',1080,1920,'white',0, 0, null)
;
--

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 7.0NG.765-221021
Version: 7.0NG.765-221102
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.765-221021"
pandora_version="7.0NG.765-221102"
package_cpan=0
package_pandora=1

View File

@ -5,7 +5,7 @@
# Tentacle have IANA assigned port tpc/41121 as official port.
##########################################################################
# Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es>
# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L
# Copyright (c) 2005-2022 Artica Soluciones Tecnologicas S.L
#
# tentacle_server.pl Tentacle Server. See https://pandorafms.com/docs/ for
# protocol description.
@ -1740,6 +1740,19 @@ sub callback_stop {
Win32::Daemon::StopService();
}
################################################################################
## SUB check_ssleay_version
## Print a message if the installed version of Net::SSLeay may leak memory.
################################################################################
sub check_ssleay_version {
eval {
require Net::SSLeay;
return unless defined($Net::SSLeay::VERSION) && $Net::SSLeay::VERSION =~ m/^(\d+)\.(\d+)/ && $1 <= 1 && $2 < 88;
print_log ("Net::SSLeay version $Net::SSLeay::VERSION detected. Versions prior to 1.88 may leak memory. To upgrade it see: https://metacpan.org/pod/Net::SSLeay");
};
}
################################################################################
# Main
################################################################################
@ -1753,12 +1766,20 @@ if ($> == 0 && $^O ne 'MSWin32') {
# Parse command line options
parse_options ();
# Try to open the log file.
if (defined($log_file)) {
open(my $fh, ">>", $log_file) || die("Error opening the log file '$log_file': $!.\n");
close($fh);
}
# Check command line arguments
if ($#ARGV != -1) {
print_help ();
exit 1;
}
check_ssleay_version() if $t_ssl == 1;
# Show IPv6 status
if ($SOCKET_MODULE eq 'IO::Socket::INET') {
print_log ("IO::Socket::INET6 is not found. IPv6 is disabled.");

View File

@ -5,7 +5,7 @@
# Tentacle have IANA assigned port tpc/41121 as official port.
##########################################################################
# Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es>
# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L
# Copyright (c) 2005-2022 Artica Soluciones Tecnologicas S.L
#
# tentacle_server.pl Tentacle Server. See https://pandorafms.com/docs/ for
# protocol description.
@ -1766,6 +1766,12 @@ if ($> == 0 && $^O ne 'MSWin32') {
# Parse command line options
parse_options ();
# Try to open the log file.
if (defined($log_file)) {
open(my $fh, ">>", $log_file) || die("Error opening the log file '$log_file': $!.\n");
close($fh);
}
# Check command line arguments
if ($#ARGV != -1) {
print_help ();

View File

@ -46,7 +46,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.765";
my $pandora_build = "221021";
my $pandora_build = "221102";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash

View File

@ -113,6 +113,10 @@ our @EXPORT = qw(
get_agentmodule_status_str
get_agentmodule_data
set_ssl_opts
db_synch_insert
db_synch_update
db_synch_delete
db_synch
$RDBMS
$RDBMS_QUOTE
$RDBMS_QUOTE_STRING
@ -1672,6 +1676,78 @@ sub set_ssl_opts($) {
}
}
########################################################################
## Synch insert query with nodes.
########################################################################
sub db_synch_insert ($$$$$@) {
my ($dbh, $pa_config, $table, $query, $result, @values) = @_;
my $substr = "\"\%s\"";
$query =~ s/\?/$substr/g;
my $query_string = sprintf($query, @values);
db_synch($dbh, $pa_config, 'INSERT INTO', $table, $query_string, $result);
}
########################################################################
## Synch update query with nodes.
########################################################################
sub db_synch_update ($$$$$@) {
my ($dbh, $pa_config, $table, $query, $result, @values) = @_;
my $substr = "\"\%s\"";
$query =~ s/\?/$substr/g;
my $query_string = sprintf($query, @values);
db_synch($dbh, $pa_config, 'UPDATE', $table, $query_string, $result);
}
########################################################################
## Synch delete query with nodes.
########################################################################
sub db_synch_delete ($$$$@) {
my ($dbh, $pa_config, $table, $result, @parameters) = @_;
#Build query string.
my $query = $dbh->{Statement};
my $substr = "\"\%s\"";
$query =~ s/\?/$substr/g;
my $query_string = sprintf($query, @parameters);
db_synch($dbh, $pa_config, 'DELETE FROM', $table, $query_string, $result);
}
########################################################################
## Synch queries with nodes.
########################################################################
sub db_synch ($$$$$$) {
my ($dbh, $pa_config, $type, $table, $query, $result) = @_;
my @nodes = get_db_rows($dbh, 'SELECT * FROM tmetaconsole_setup');
foreach my $node (@nodes) {
eval {
local $SIG{__DIE__};
my @values_queue = (
safe_input($query),
$node->{'id'},
time(),
$type,
$table,
'',
$result
);
my $query_queue = 'INSERT INTO tsync_queue (`sql`, `target`, `utimestamp`, `operation`, `table`, `error`, `result`) VALUES (?, ?, ?, ?, ?, ?, ?)';
db_insert ($dbh, 'id', $query_queue, @values_queue);
};
if ($@) {
logger($pa_config, "Error add sync_queue: $@", 10);
return;
}
}
}
# End of function declaration
# End of defined Code

View File

@ -273,6 +273,7 @@ sub data_consumer ($$) {
snmp_security_level => $task->{'snmp_security_level'},
snmp_timeout => $task->{'snmp_timeout'},
snmp_version => $task->{'snmp_version'},
snmp_skip_non_enabled_ifs => $task->{'snmp_skip_non_enabled_ifs'},
subnets => \@subnets,
task_id => $task->{'id_rt'},
vlan_cache_enabled => $task->{'vlan_enabled'},
@ -723,9 +724,12 @@ sub PandoraFMS::Recon::Base::create_interface_modules($$) {
foreach my $if_index (@output) {
next unless ($if_index =~ /^[0-9]+$/);
# Check the status of the interface.
my $if_status = $self->snmp_get_value($device, "$PandoraFMS::Recon::Base::IFOPERSTATUS.$if_index");
next unless $if_status == 1;
if ($self->{'task_data'}{'snmp_skip_non_enabled_ifs'} == 1) {
# Check the status of the interface.
my $if_status = $self->snmp_get_value($device, "$PandoraFMS::Recon::Base::IFOPERSTATUS.$if_index");
next unless $if_status == 1;
}
# Fill the module description with the IP and MAC addresses.
my $mac = $self->get_if_mac($device, $if_index);

View File

@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.765";
my $pandora_build = "221021";
my $pandora_build = "221102";
our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -215,6 +215,7 @@ sub new {
snmp_security_level => '',
snmp_timeout => 2,
snmp_version => 1,
snmp_skip_non_enabled_ifs => 1,
subnets => [],
autoconfiguration_enabled => 0,
@ -312,6 +313,7 @@ sub new {
$self->{'snmp_privacy_method'} = '';
$self->{'snmp_privacy_pass'} = '';
$self->{'snmp_security_level'} = '';
$self->{'snmp_skip_non_enabled_ifs'} = '';
}
return $self;

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 7.0NG.765
%define release 221021
%define release 221102
Summary: Pandora FMS Server
Name: %{name}

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 7.0NG.765
%define release 221021
%define release 221102
Summary: Pandora FMS Server
Name: %{name}

View File

@ -9,7 +9,7 @@
# **********************************************************************
PI_VERSION="7.0NG.765"
PI_BUILD="221021"
PI_BUILD="221102"
MODE=$1
if [ $# -gt 1 ]; then

View File

@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB;
# version: define current version
my $version = "7.0NG.765 Build 221021";
my $version = "7.0NG.765 Build 221102";
# Pandora server configuration
my %conf;
@ -344,7 +344,7 @@ sub pandora_purgedb ($$$) {
log_message ('!', "Cannot execute " . $conf->{'_netflow_nfexpire'} . ", skipping.");
}
else {
`yes 2>/dev/null | $conf->{'_netflow_nfexpire'} -e "$conf->{'_netflow_path'}" -t $conf->{'_netflow_max_lifetime'}d`;
`yes 2>/dev/null | $conf->{'_netflow_nfexpire'} -r "$conf->{'_netflow_path'}" -t $conf->{'_netflow_max_lifetime'}d`;
}
}
else {
@ -631,6 +631,7 @@ sub pandora_load_config_pdb ($) {
$conf->{'_event_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'event_purge'");
$conf->{'_trap_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'trap_purge'");
$conf->{'_trap_history_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'trap_purge'");
$conf->{'_audit_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'audit_purge'");
$conf->{'_string_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'string_purge'");
$conf->{'_gis_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'gis_purge'");
@ -641,6 +642,7 @@ sub pandora_load_config_pdb ($) {
$conf->{'_step_compact'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'step_compact'");
$conf->{'_history_db_enabled'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_enabled'");
$conf->{'_history_event_enabled'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_event_enabled'");
$conf->{'_history_trap_enabled'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_trap_enabled'");
$conf->{'_history_db_host'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_host'");
$conf->{'_history_db_port'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_port'");
$conf->{'_history_db_name'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_name'");
@ -650,6 +652,7 @@ sub pandora_load_config_pdb ($) {
$conf->{'_history_db_adv'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_adv'");
$conf->{'_history_db_string_days'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_string_days'");
$conf->{'_history_event_days'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_event_days'");
$conf->{'_history_trap_days'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_trap_days'");
$conf->{'_history_db_step'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_step'");
$conf->{'_history_db_delay'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_delay'");
$conf->{'_days_delete_unknown'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'days_delete_unknown'");
@ -897,18 +900,11 @@ sub pandora_checkdb_consistency {
log_message ('CHECKDB',
"Checking database consistency (Missing status).");
my @modules = get_db_rows ($dbh, 'SELECT * FROM tagente_modulo');
my @modules = get_db_rows ($dbh, 'SELECT m.id_agente, m.id_agente_modulo, e.id_agente_estado FROM tagente_modulo AS m LEFT JOIN tagente_estado AS e ON m.id_agente_modulo = e.id_agente_modulo WHERE e.id_agente_estado IS NULL');
foreach my $module (@modules) {
my $id_agente_modulo = $module->{'id_agente_modulo'};
my $id_agente = $module->{'id_agente'};
# check if exist in tagente_estado and create if not
my $count = get_db_value ($dbh,
'SELECT COUNT(*)
FROM tagente_estado
WHERE id_agente_modulo = ?', $id_agente_modulo);
next if (defined ($count) && $count > 0);
db_do ($dbh,
'INSERT INTO tagente_estado (id_agente_modulo, datos, timestamp, estado, id_agente, last_try, utimestamp, current_interval, running_by, last_execution_try) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente_modulo, 0, '1970-01-01 00:00:00', 1, $id_agente, '1970-01-01 00:00:00', 0, 0, 0, 0);
log_message ('CHECKDB',
@ -923,17 +919,10 @@ sub pandora_checkdb_consistency {
# tagente_modulo, if there is any, delete it
#-------------------------------------------------------------------
@modules = get_db_rows ($dbh, 'SELECT * FROM tagente_estado');
@modules = get_db_rows ($dbh, 'SELECT e.id_agente_modulo, m.id_agente FROM tagente_estado AS e LEFT JOIN tagente_modulo AS m ON e.id_agente_modulo = m.id_agente_modulo WHERE m.id_agente IS NULL');
foreach my $module (@modules) {
my $id_agente_modulo = $module->{'id_agente_modulo'};
# check if exist in tagente_estado and create if not
my $count = get_db_value ($dbh,
'SELECT COUNT(*)
FROM tagente_modulo
WHERE id_agente_modulo = ?', $id_agente_modulo);
next if (defined ($count) && $count > 0);
db_do ($dbh, 'DELETE FROM tagente_estado
WHERE id_agente_modulo = ?', $id_agente_modulo);
@ -1133,6 +1122,26 @@ sub pandoradb_history ($$) {
log_message ('', "\n");
}
# Delete old traps.
if ($conf->{'_trap_history_purge'} > 0) {
log_message ('PURGE', "Deleting traps older than " . $conf->{'_trap_history_purge'} . " days from ttrap (history).", '');
my $trap_limit = strftime ("%Y-%m-%d %H:%M:%S", localtime(time() - 86400 * $conf->{'_trap_history_purge'}));
my $traps_to_delete = get_db_value ($dbh, "SELECT COUNT(*) FROM ttrap WHERE timestamp < ?", $trap_limit);
while($traps_to_delete > 0) {
db_delete_limit($dbh, 'ttrap', "timestamp < ?", $BIG_OPERATION_STEP, $trap_limit);
$traps_to_delete = $traps_to_delete - $BIG_OPERATION_STEP;
# Mark the progress.
log_message ('', ".");
# Do not overload the MySQL server.
usleep (10000);
}
log_message ('', "\n");
}
# Update tconfig with last time of database maintance time (now)
db_do ($dbh, "DELETE FROM tconfig WHERE token = 'db_maintance'");
db_do ($dbh, "INSERT INTO tconfig (token, value) VALUES ('db_maintance', '".time()."')");
@ -1163,6 +1172,9 @@ sub pandoradb_main {
if (defined($conf{'_history_event_enabled'}) && $conf->{'_history_event_enabled'} ne "" && $conf->{'_history_event_enabled'} == 1) {
undef ($history_dbh) unless defined (enterprise_hook ('pandora_history_event', [$dbh, $history_dbh, $conf->{'_history_event_days'}, $conf->{'_history_db_step'}, $conf->{'_history_db_delay'}]));
}
if (defined($conf{'_history_trap_enabled'}) && $conf->{'_history_trap_enabled'} ne "" && $conf->{'_history_trap_enabled'} == 1) {
undef ($history_dbh) unless defined (enterprise_hook ('pandora_history_trap', [$dbh, $history_dbh, $conf->{'_history_trap_days'}, $conf->{'_history_db_step'}, $conf->{'_history_db_delay'}]));
}
}
# Only active database should be compacted. Disabled for historical database.
@ -1270,13 +1282,20 @@ if ($conf{'_force'} == 0 && pandora_is_master(\%conf) == 0) {
exit 1;
}
# Set the lock name for pandora_db.
my $lock_name = $conf{'dbname'};
# Get a lock on the main database.
my $db_lock = db_get_lock ($dbh, $conf{'dbname'} . '_pandora_db', $LOCK_TIMEOUT, 1);
if ($db_lock == 0) {
log_message ('', " [*] Another instance of DB Tool seems to be running on the main database.\n\n");
exit 1;
}
# Release the database lock in forced mode.
if ($conf{'_force'} == 1) {
log_message ('', " [*] Releasing database lock.\n\n");
db_release_pandora_lock($dbh, $lock_name, $LOCK_TIMEOUT);
# Get a lock on the history database.
if (defined($history_dbh)) {
my $history_lock = db_get_lock ($history_dbh, $conf{'_history_db_name'} . '_pandora_db', $LOCK_TIMEOUT, 1);
if ($history_lock == 0) {
log_message ('', " [*] Another instance of DB Tool seems to be running on the history database.\n\n");
exit 1;
}
}
# Get a lock merging.
@ -1293,13 +1312,6 @@ if ($lock_merge_events == 0) {
exit 1;
}
# Get a lock on dbname.
my $lock = db_get_pandora_lock ($dbh, $lock_name, $LOCK_TIMEOUT);
if ($lock == 0) {
log_message ('', " [*] Another instance of DB Tool seems to be running.\n\n");
exit 1;
}
# Main
pandoradb_main(\%conf, $dbh, $h_conf, $history_dbh);
@ -1336,9 +1348,6 @@ if (scalar(@types) != 0) {
db_do($dbh, "UPDATE talert_commands SET fields_values='[\"\", \"\", \"\",\"\",\"" . $query_string . "\",\"\",\"\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\"]' WHERE name=\"Integria&#x20;IMS&#x20;Ticket\"");
}
# Release the lock
db_release_pandora_lock ($dbh, $lock_name);
# Cleanup and exit
db_disconnect ($history_dbh) if defined ($history_dbh);
db_disconnect ($dbh);

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
my $version = "7.0NG.765 Build 221021";
my $version = "7.0NG.765 Build 221102";
# save program name for logging
my $progname = basename($0);
@ -539,8 +539,27 @@ sub pandora_add_profile_to_user ($$$;$) {
$group_id = 0 unless defined($group_id);
db_do ($dbh, 'INSERT INTO tusuario_perfil (id_usuario, id_perfil, id_grupo)
VALUES (?, ?, ?)', safe_input($user_id), $profile_id, $group_id);
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
if(is_metaconsole($conf) != 1 && $centralized) {
print_log "[ERROR] This node is configured with centralized mode. To create a user go to metaconsole. \n\n";
exit;
}
my $query = 'INSERT INTO tusuario_perfil (id_usuario, id_perfil, id_grupo) VALUES (?, ?, ?)';
my @values = (
safe_input($user_id),
$profile_id,
$group_id
);
my $res = db_do ($dbh, $query, @values);
if(is_metaconsole($conf) == 1 && $centralized) {
db_synch_insert($dbh, $conf, 'tusuario_perfil', $query, $res, @values);
}
return $res;
}
@ -568,13 +587,29 @@ sub cli_create_snmp_trap ($$) {
sub pandora_create_user ($$$$$) {
my ($dbh, $name, $password, $is_admin, $comments) = @_;
if(is_metaconsole($conf) != 1 && pandora_get_tconfig_token ($dbh, 'centralized_management', '')) {
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
if(is_metaconsole($conf) != 1 && $centralized) {
print_log "[ERROR] This node is configured with centralized mode. To create a user go to metaconsole. \n\n";
exit;
}
my $query = 'INSERT INTO tusuario (id_user, fullname, password, comments, is_admin) VALUES (?, ?, ?, ?, ?)';
my @values = (
safe_input($name),
safe_input($name),
$password,
decode_entities($comments),
$is_admin ? '1' : '0'
);
return db_insert ($dbh, 'id_user', 'INSERT INTO tusuario (id_user, fullname, password, is_admin, comments)
VALUES (?, ?, ?, ?, ?)', safe_input($name), safe_input($name), $password, $is_admin ? '1' : '0', decode_entities($comments));
my $res = db_insert($dbh, 'id_user', $query, @values);
if(is_metaconsole($conf) == 1 && $centralized) {
db_synch_insert($dbh, $conf, 'tusuario', $query, $res, @values);
}
return $res;
}
##########################################################################
@ -583,17 +618,27 @@ sub pandora_create_user ($$$$$) {
sub pandora_delete_user ($$) {
my ($dbh, $name) = @_;
if(is_metaconsole($conf) != 1 && pandora_get_tconfig_token ($dbh, 'centralized_management', '')) {
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
if(is_metaconsole($conf) != 1 && $centralized) {
print_log "[ERROR] This node is configured with centralized mode. To delete a user go to metaconsole. \n\n";
exit;
}
# Delete user profiles
db_do ($dbh, 'DELETE FROM tusuario_perfil WHERE id_usuario = ?', $name);
my $result_profile = db_do ($dbh, 'DELETE FROM tusuario_perfil WHERE id_usuario = ?', $name);
if(is_metaconsole($conf) == 1 && $centralized) {
db_synch_delete($dbh, $conf, 'tusuario_perfil', $result_profile, $name);
}
# Delete the user
my $return = db_do ($dbh, 'DELETE FROM tusuario WHERE id_user = ?', $name);
if(is_metaconsole($conf) == 1 && $centralized) {
db_synch_delete($dbh, $conf, 'tusuario', $return, $name);
}
if($return eq '0E0') {
return -1;
}
@ -623,25 +668,79 @@ else {
## Assign a profile to the given user/group.
##########################################################################
sub pandora_create_user_profile ($$$$) {
my ($dbh, $user_id, $profile_id, $group_id) = @_;
return db_insert ($dbh, 'id_up', 'INSERT INTO tusuario_perfil (id_usuario, id_perfil, id_grupo) VALUES (?, ?, ?)', $user_id, $profile_id, $group_id);
my ($dbh, $user_id, $profile_id, $group_id) = @_;
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
if(is_metaconsole($conf) != 1 && $centralized) {
print_log "[ERROR] This node is configured with centralized mode. To create a user go to metaconsole. \n\n";
exit;
}
my $query = 'INSERT INTO tusuario_perfil (id_usuario, id_perfil, id_grupo) VALUES (?, ?, ?)';
my @values = (
safe_input($user_id),
$profile_id,
$group_id
);
my $res = db_insert ($dbh, 'id_up', $query, @values);
if(is_metaconsole($conf) == 1 && $centralized) {
db_synch_insert($dbh, $conf, 'tusuario_perfil', $query, $res, @values);
}
return $res;
}
##########################################################################
## Create profile.
##########################################################################
sub pandora_create_profile ($$$$$$$$$$$$$$$$$$$$$$) {
my ($dbh, $profile_name, $agent_view,
my ($dbh, $profile_name, $agent_view,
$agent_edit, $agent_disable, $alert_edit, $alert_management, $user_management, $db_management,
$event_view, $event_edit, $event_management, $report_view, $report_edit, $report_management,
$map_view, $map_edit, $map_management, $vconsole_view, $vconsole_edit, $vconsole_management, $pandora_management) = @_;
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
return db_insert ($dbh, 'id_up', 'INSERT INTO tperfil (name,agent_view,agent_edit,agent_disable,alert_edit,alert_management,user_management,db_management,event_view,event_edit,event_management,report_view,report_edit,report_management,map_view,map_edit,map_management,vconsole_view,vconsole_edit,vconsole_management,pandora_management) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);',
safe_input($profile_name), $agent_view,
$agent_edit, $agent_disable, $alert_edit, $alert_management, $user_management, $db_management,
$event_view, $event_edit, $event_management, $report_view, $report_edit, $report_management,
$map_view, $map_edit, $map_management, $vconsole_view, $vconsole_edit, $vconsole_management, $pandora_management);
if(is_metaconsole($conf) != 1 && $centralized) {
print_log "[ERROR] This node is configured with centralized mode. To create a user go to metaconsole. \n\n";
exit;
}
my $query = 'INSERT INTO tperfil (name,agent_view,agent_edit,agent_disable,alert_edit,alert_management,user_management,db_management,event_view,event_edit,event_management,report_view,report_edit,report_management,map_view,map_edit,map_management,vconsole_view,vconsole_edit,vconsole_management,pandora_management) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);';
my @values = (
safe_input($profile_name),
$agent_view,
$agent_edit,
$agent_disable,
$alert_edit,
$alert_management,
$user_management,
$db_management,
$event_view,
$event_edit,
$event_management,
$report_view,
$report_edit,
$report_management,
$map_view,
$map_edit,
$map_management,
$vconsole_view,
$vconsole_edit,
$vconsole_management,
$pandora_management
);
my $res = db_insert ($dbh, 'id_perfil', $query, @values);
if(is_metaconsole($conf) == 1 && $centralized) {
db_synch_insert($dbh, $conf, 'tperfil', $query, $res, @values);
}
return $res;
}
##########################################################################
@ -653,11 +752,33 @@ sub pandora_update_profile ($$$$$$$$$$$$$$$$$$$$$$) {
$event_view, $event_edit, $event_management, $report_view, $report_edit, $report_management,
$map_view, $map_edit, $map_management, $vconsole_view, $vconsole_edit, $vconsole_management, $pandora_management) = @_;
return db_update ($dbh, 'UPDATE tperfil SET agent_view = ?, agent_edit = ?, agent_disable = ?, alert_edit = ?, alert_management = ?, user_management = ?, db_management = ?, event_view = ?, event_edit = ?, event_management = ?, report_view = ?, report_edit = ?, report_management = ?, map_view = ?, map_edit = ?, map_management = ?, vconsole_view = ?, vconsole_edit = ?, vconsole_management = ?, pandora_management = ? WHERE name=?;',
$agent_view,
$agent_edit, $agent_disable, $alert_edit, $alert_management, $user_management, $db_management,
$event_view, $event_edit, $event_management, $report_view, $report_edit, $report_management,
$map_view, $map_edit, $map_management, $vconsole_view, $vconsole_edit, $vconsole_management, $pandora_management, safe_input($profile_name));
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
if(is_metaconsole($conf) != 1 && $centralized) {
print_log "[ERROR] This node is configured with centralized mode. To create a user go to metaconsole. \n\n";
exit;
}
my @parameters = (
$agent_view, $agent_edit, $agent_disable,
$alert_edit, $alert_management,
$user_management, $db_management,
$event_view, $event_edit, $event_management,
$report_view, $report_edit, $report_management,
$map_view, $map_edit, $map_management,
$vconsole_view, $vconsole_edit, $vconsole_management,
$pandora_management, safe_input($profile_name)
);
my $query = 'UPDATE tperfil SET agent_view = ?, agent_edit = ?, agent_disable = ?, alert_edit = ?, alert_management = ?, user_management = ?, db_management = ?, event_view = ?, event_edit = ?, event_management = ?, report_view = ?, report_edit = ?, report_management = ?, map_view = ?, map_edit = ?, map_management = ?, vconsole_view = ?, vconsole_edit = ?, vconsole_management = ?, pandora_management = ? WHERE name=?;';
my $result = db_update ($dbh, $query, @parameters);
if(is_metaconsole($conf) == 1 && $centralized) {
db_synch_update($dbh, $conf, 'tperfil', $query, $result, @parameters);
}
return $result;
}
##########################################################################
@ -665,8 +786,28 @@ sub pandora_update_profile ($$$$$$$$$$$$$$$$$$$$$$) {
##########################################################################
sub pandora_delete_user_profile ($$$$) {
my ($dbh, $user_id, $profile_id, $group_id) = @_;
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
if(is_metaconsole($conf) != 1 && $centralized) {
print_log "[ERROR] This node is configured with centralized mode. To delete a user go to metaconsole. \n\n";
exit;
}
my @parameters = (
$user_id,
$profile_id,
$group_id
);
# Delete the user
my $return = db_do ($dbh, 'DELETE FROM tusuario_perfil WHERE id_usuario=? AND id_perfil=? AND id_grupo=?', @parameters);
if(is_metaconsole($conf) == 1 && $centralized) {
db_synch_delete($dbh, $conf, 'tusuario_perfil', $return, @parameters);
}
return db_do ($dbh, 'DELETE FROM tusuario_perfil WHERE id_usuario=? AND id_perfil=? AND id_grupo=?', $user_id, $profile_id, $group_id);
return $return;
}
##########################################################################
@ -816,9 +957,18 @@ sub pandora_validate_event_id ($$$) {
##########################################################################
sub pandora_update_user_from_hash ($$$$) {
my ($parameters, $where_column, $where_value, $dbh) = @_;
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
my $result = db_process_update($dbh, 'tusuario', $parameters, {$where_column => $where_value});
if(is_metaconsole($conf) == 1 && $centralized) {
my @values = (
values %$parameters,
$where_value
);
my $user_id = db_process_update($dbh, 'tusuario', $parameters, {$where_column => $where_value});
return $user_id;
db_synch_update($dbh, $conf, 'tusuario', $dbh->{Statement}, $result, @values);
}
return $result;
}
##########################################################################
@ -6235,8 +6385,10 @@ sub cli_disable_double_auth () {
sub cli_user_enable () {
my $user_id = @ARGV[2];
if(is_metaconsole($conf) != 1 && pandora_get_tconfig_token ($dbh, 'centralized_management', '')) {
print_log "[ERROR] This node is configured with centralized mode. To enable a user go to metaconsole. \n\n";
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
if(is_metaconsole($conf) != 1 && $centralized) {
print_log "[ERROR] This node is configured with centralized mode. To create a user go to metaconsole. \n\n";
exit;
}
@ -6253,9 +6405,14 @@ sub cli_user_enable () {
$user_id = safe_input($user_id);
db_do ($dbh, "UPDATE tusuario SET disabled = '0' WHERE id_user = '$user_id'");
exit;
my $result = db_do ($dbh, "UPDATE tusuario SET disabled = '0' WHERE id_user = '$user_id'");
if(is_metaconsole($conf) == 1 && $centralized) {
my @values;
db_synch_update($dbh, $conf, 'tusuario', $dbh->{Statement}, $result, @values);
}
exit;
}
###############################################################################
@ -6265,8 +6422,10 @@ sub cli_user_enable () {
sub cli_user_disable () {
my $user_id = @ARGV[2];
if(is_metaconsole($conf) != 1 && pandora_get_tconfig_token ($dbh, 'centralized_management', '')) {
print_log "[ERROR] This node is configured with centralized mode. To disable a user go to metaconsole. \n\n";
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
if(is_metaconsole($conf) != 1 && $centralized) {
print_log "[ERROR] This node is configured with centralized mode. To create a user go to metaconsole. \n\n";
exit;
}
@ -6283,9 +6442,14 @@ sub cli_user_disable () {
$user_id = safe_input($user_id);
db_do ($dbh, "UPDATE tusuario SET disabled = '1' WHERE id_user = '$user_id'");
my $result = db_do ($dbh, "UPDATE tusuario SET disabled = '1' WHERE id_user = '$user_id'");
if(is_metaconsole($conf) == 1 && $centralized) {
my @values;
db_synch_update($dbh, $conf, 'tusuario', $dbh->{Statement}, $result, @values);
}
exit;
exit;
}
###############################################################################

View File

@ -119,7 +119,6 @@ case "$1" in
rc_status -v
else
echo "Tentacle Server could not be started."
echo "Verify that Tentacle port is not used."
rc_failed 7 # program not running
fi

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
# Tentacle have IANA assigned port tpc/41121 as official port.
##########################################################################
# Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es>
# Copyright (c) 2005-2021 Artica Soluciones Tecnologicas S.L
# Copyright (c) 2005-2022 Artica Soluciones Tecnologicas S.L
#
# tentacle_server.pl Tentacle Server. See https://pandorafms.com/docs/ for
# protocol description.
@ -230,7 +230,6 @@ sub print_help {
print ("\t-p port\t\tPort to listen on (default $t_port).\n");
print ("\t-q\t\tQuiet. Do now print error messages.\n");
print ("\t-r number\tNumber of retries for network opertions (default $t_retries).\n");
print ("\t-s Storage directory\n");
print ("\t-S (install|uninstall|run) Manage the win32 service.\n");
print ("\t-t time\t\tTime-out for network operations in seconds (default ${t_timeout}s).\n");
print ("\t-v\t\tBe verbose (display errors).\n");
@ -1767,6 +1766,12 @@ if ($> == 0 && $^O ne 'MSWin32') {
# Parse command line options
parse_options ();
# Try to open the log file.
if (defined($log_file)) {
open(my $fh, ">>", $log_file) || die("Error opening the log file '$log_file': $!.\n");
close($fh);
}
# Check command line arguments
if ($#ARGV != -1) {
print_help ();

View File

@ -119,7 +119,6 @@ case "$1" in
rc_status -v
else
echo "Tentacle Server could not be started."
echo "Verify that Tentacle port is not used."
rc_failed 7 # program not running
fi

View File

@ -591,6 +591,9 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
});
// Metadata state.
if (this.meta.maintenanceMode) {
box.classList.add("is-maintenance");
}
if (this.meta.editMode) {
box.classList.add("is-editing");
}
@ -877,8 +880,12 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
}
// Change metadata related things.
if (!prevMeta || prevMeta.editMode !== this.meta.editMode) {
if (this.meta.editMode) {
if (
!prevMeta ||
prevMeta.editMode !== this.meta.editMode ||
prevMeta.maintenanceMode !== this.meta.maintenanceMode
) {
if (this.meta.editMode && this.meta.maintenanceMode === false) {
this.elementRef.classList.add("is-editing");
} else {
this.elementRef.classList.remove("is-editing");

View File

@ -159,6 +159,12 @@ export interface VisualConsoleProps extends Size {
backgroundColor: string | null;
isFavorite: boolean;
relationLineWidth: number;
maintenanceMode: MaintenanceModeInterface | null;
}
export interface MaintenanceModeInterface {
user: string;
timestamp: number;
}
/**
@ -181,7 +187,8 @@ export function visualConsolePropsDecoder(
backgroundURL,
backgroundColor,
isFavorite,
relationLineWidth
relationLineWidth,
maintenanceMode
} = data;
if (id == null || isNaN(parseInt(id))) {
@ -202,6 +209,7 @@ export function visualConsolePropsDecoder(
backgroundColor: notEmptyStringOr(backgroundColor, null),
isFavorite: parseBoolean(isFavorite),
relationLineWidth: parseIntOr(relationLineWidth, 0),
maintenanceMode: maintenanceMode,
...sizePropsDecoder(data)
};
}
@ -1222,6 +1230,28 @@ export default class VisualConsole {
this.containerRef.classList.remove("is-editing");
}
/**
* Enable the maintenance mode.
*/
public enableMaintenanceMode(): void {
this.elements.forEach(item => {
item.meta = { ...item.meta, maintenanceMode: true };
});
this.containerRef.classList.add("is-maintenance");
this.containerRef.classList.remove("is-editing");
}
/**
* Disable the maintenance mode.
*/
public disableMaintenanceMode(): void {
this.elements.forEach(item => {
item.meta = { ...item.meta, maintenanceMode: false };
});
this.containerRef.classList.remove("is-maintenance");
this.containerRef.classList.add("is-editing");
}
/**
* Select an item.
* @param itemId Item Id.

View File

@ -275,6 +275,7 @@ export function itemMetaDecoder(data: UnknownObject): ItemMeta | never {
receivedAt,
error,
editMode: parseBoolean(data.editMode),
maintenanceMode: parseBoolean(data.maintenanceMode),
isFromCache: parseBoolean(data.isFromCache),
isFetching: false,
isUpdating: false,

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

View File

@ -133,6 +133,7 @@ describe("itemMetaDecoder function", () => {
isFetching: false,
isUpdating: false,
editMode: false,
maintenanceMode: false,
isBeingMoved: false,
isBeingResized: false,
isSelected: false,
@ -154,6 +155,7 @@ describe("itemMetaDecoder function", () => {
isFetching: false,
isUpdating: false,
editMode: true,
maintenanceMode: false,
isBeingMoved: false,
isBeingResized: false,
isSelected: false,

View File

@ -61,5 +61,6 @@ export interface ItemMeta {
isBeingMoved: boolean;
isBeingResized: boolean;
editMode: boolean;
maintenanceMode: boolean;
lineMode: boolean;
}

View File

@ -7,6 +7,14 @@
margin-top: 5px;
}
.is-maintenance {
background-image: url(./lib/maintenanceMode.png) !important;
}
.is-maintenance :nth-child(1) {
display: none;
}
.visual-console-item {
position: absolute;
display: flex;