';
@@ -265,13 +291,6 @@ if ($moduleFilter != 0) {
$where .= ' AND id_agent_module = '.$moduleFilter;
}
-// Filter report items created from metaconsole in normal console list and the opposite
-if (defined('METACONSOLE') and $config['metaconsole'] == 1) {
- $where .= ' AND ((server_name IS NOT NULL AND length(server_name) != 0) '.'OR '.$type_escaped.' IN (\'general\', \'SLA\', \'exception\', \'availability\', \'availability_graph\', \'top_n\',\'SLA_monthly\',\'SLA_weekly\',\'SLA_hourly\',\'text\'))';
-} else {
- $where .= ' AND ((server_name IS NULL OR length(server_name) = 0) '.'OR '.$type_escaped.' IN (\'general\', \'SLA\', \'exception\', \'availability\', \'top_n\'))';
-}
-
switch ($config['dbtype']) {
case 'mysql':
$items = db_get_all_rows_sql(
@@ -306,13 +325,17 @@ switch ($config['dbtype']) {
'AND',
false
);
- // Delete rnum row generated by oracle_recode_query() function
+ // Delete rnum row generated by oracle_recode_query() function.
if ($items !== false) {
for ($i = 0; $i < count($items); $i++) {
unset($items[$i]['rnum']);
}
}
break;
+
+ default:
+ // Default.
+ break;
}
$countItems = db_get_sql(
@@ -421,29 +444,30 @@ foreach ($items as $item) {
$row[1] = get_report_name($item['type']);
- if ($item['type'] == 'custom_graph') {
- $custom_graph_name = db_get_row_sql('select name from tgraph where id_graph = '.$item['id_gs']);
- $row[1] = get_report_name($item['type']).' ('.$custom_graph_name['name'].')';
- }
-
$server_name = $item['server_name'];
- if (($config['metaconsole'] == 1) && ($server_name != '') && defined('METACONSOLE')) {
+ if (is_metaconsole()) {
$connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) != NOERR) {
// ui_print_error_message ("Error connecting to ".$server_name);
}
}
+ if ($item['type'] == 'custom_graph') {
+ $custom_graph_name = db_get_row_sql('SELECT name FROM tgraph WHERE id_graph = '.$item['id_gs']);
+ $row[1] = get_report_name($item['type']).' ('.$custom_graph_name['name'].')';
+ }
+
+
if ($item['id_agent'] == 0) {
$is_inventory_item = $item['type'] == 'inventory' || $item['type'] == 'inventory_changes';
- // Due to SLA or top N or general report items
+ // Due to SLA or top N or general report items.
if (!$is_inventory_item && ($item['id_agent_module'] == '' || $item['id_agent_module'] == 0)) {
$row[2] = '';
$row[3] = '';
} else {
- // The inventory items have the agents and modules in json format in the field external_source
+ // The inventory items have the agents and modules in json format in the field external_source.
if ($is_inventory_item) {
$external_source = json_decode($item['external_source'], true);
$agents = $external_source['id_agents'];
@@ -522,7 +546,7 @@ foreach ($items as $item) {
$table->data[] = $row;
$count++;
- // Restore db connection
+ // Restore db connection.
if (($config['metaconsole'] == 1) && ($server_name != '') && defined('METACONSOLE')) {
metaconsole_restore_db();
}
diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php
index 45993ec38e..40ce45b5bb 100755
--- a/pandora_console/godmode/reporting/reporting_builder.php
+++ b/pandora_console/godmode/reporting/reporting_builder.php
@@ -3144,17 +3144,19 @@ if ($enterpriseEnable && defined('METACONSOLE')) {
break;
}
- ui_print_page_header(
- $textReportName,
- 'images/op_reporting.png',
- false,
- $helpers,
- false,
- $buttons,
- false,
- '',
- 60
- );
+ if ($action !== 'update' && !is_metaconsole()) {
+ ui_print_page_header(
+ $textReportName,
+ 'images/op_reporting.png',
+ false,
+ $helpers,
+ false,
+ $buttons,
+ false,
+ '',
+ 60
+ );
+ }
}
if ($resultOperationDB !== null) {
@@ -3176,6 +3178,26 @@ if ($resultOperationDB !== null) {
__('Successfull action'),
__('Unsuccessful action
'.$err)
);
+
+ if ($action == 'update') {
+ $buttons[$activeTab]['active'] = false;
+ $activeTab = 'list_items';
+ $buttons[$activeTab]['active'] = true;
+
+ if (!is_metaconsole()) {
+ ui_print_page_header(
+ $textReportName,
+ 'images/op_reporting.png',
+ false,
+ $helpers,
+ false,
+ $buttons,
+ false,
+ '',
+ 60
+ );
+ }
+ }
}
switch ($activeTab) {
diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php
index 3f2166bb39..2d0fcec8a1 100755
--- a/pandora_console/godmode/servers/discovery.php
+++ b/pandora_console/godmode/servers/discovery.php
@@ -4,7 +4,14 @@ global $config;
check_login();
-if (! check_acl($config['id_user'], 0, 'AW')) {
+if (! check_acl($config['id_user'], 0, 'AR')
+ && ! check_acl($config['id_user'], 0, 'AW')
+ && ! check_acl($config['id_user'], 0, 'AM')
+ && ! check_acl($config['id_user'], 0, 'RR')
+ && ! check_acl($config['id_user'], 0, 'RW')
+ && ! check_acl($config['id_user'], 0, 'RM')
+ && ! check_acl($config['id_user'], 0, 'PM')
+) {
db_pandora_audit(
'ACL Violation',
'Trying to access Server Management'
@@ -134,11 +141,18 @@ if ($classname_selected === null) {
$classname = basename($classpath, '.class.php');
$obj = new $classname();
+ $button = $obj->load();
+
+ if ($button === false) {
+ // No acess, skip.
+ continue;
+ }
+
// DiscoveryTaskList must be first button.
if ($classname == 'DiscoveryTaskList') {
- array_unshift($wiz_data, $obj->load());
+ array_unshift($wiz_data, $button);
} else {
- $wiz_data[] = $obj->load();
+ $wiz_data[] = $button;
}
}
diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php
index 3eb385332c..79fcfc61a2 100644
--- a/pandora_console/godmode/servers/plugin.php
+++ b/pandora_console/godmode/servers/plugin.php
@@ -928,10 +928,10 @@ if (($create != '') || ($view != '')) {
$other['plugin_type'] = $plugin_meta['plugin_type'];
$other['macros'] = urlencode($plugin_meta['macros']);
$other['parameters'] = urlencode($plugin_meta['parameters']);
- $other = implode('%7C', $other);
+ $other = implode('%7E', $other);
$auth_token = json_decode($value['auth_token']);
- $url = $value['server_url'].'include/api.php?op=set&op2=push_plugin'.'&id='.$pluginid.'&other_mode=url_encode_separator_%7C&other='.$other."&apipass=$auth_token->api_password"."&user=$auth_token->console_user&pass=$auth_token->console_password";
+ $url = $value['server_url'].'include/api.php?op=set&op2=push_plugin'.'&id='.$pluginid.'&other_mode=url_encode_separator_%7E&other='.$other."&apipass=$auth_token->api_password"."&user=$auth_token->console_user&pass=$auth_token->console_password";
$file_path = realpath($plugin_meta['execute']);
$post = '';
if (file_exists($file_path)) {
diff --git a/pandora_console/godmode/users/configure_profile.php b/pandora_console/godmode/users/configure_profile.php
index 418add8aa8..8c69c0e0a9 100644
--- a/pandora_console/godmode/users/configure_profile.php
+++ b/pandora_console/godmode/users/configure_profile.php
@@ -18,7 +18,7 @@ check_login();
enterprise_hook('open_meta_frame');
-if (! check_acl($config['id_user'], 0, 'PM')) {
+if (! check_acl($config['id_user'], 0, 'UM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access Profile Management'
@@ -320,24 +320,29 @@ if ($id_profile || $new_profile) {
$table->data['IM'] = $row;
$table->data[] = '
';
+ $disable_option = 'javascript: return false;';
+ if (check_acl($config['id_user'], 0, 'PM') || users_is_admin()) {
+ $disable_option = '';
+ }
+
// Users
$row = [];
$row['name'] = __('Manage users');
- $row['input'] = html_print_checkbox('user_management', 1, $user_management, true);
+ $row['input'] = html_print_checkbox('user_management', 1, $user_management, true, false, $disable_option);
$table->data['UM'] = $row;
$table->data[] = '
';
// DB
$row = [];
$row['name'] = __('Manage database');
- $row['input'] = html_print_checkbox('db_management', 1, $db_management, true);
+ $row['input'] = html_print_checkbox('db_management', 1, $db_management, true, false, $disable_option);
$table->data['DM'] = $row;
$table->data[] = '
';
// Pandora
$row = [];
$row['name'] = __('%s management', get_product_name());
- $row['input'] = html_print_checkbox('pandora_management', 1, $pandora_management, true);
+ $row['input'] = html_print_checkbox('pandora_management', 1, $pandora_management, true, false, $disable_option);
$table->data['PM'] = $row;
$table->data[] = '
';
@@ -359,3 +364,18 @@ if ($id_profile || $new_profile) {
}
enterprise_hook('close_meta_frame');
+
+?>
+
+
diff --git a/pandora_console/godmode/users/profile_list.php b/pandora_console/godmode/users/profile_list.php
index da77dffd9f..a87323f0f8 100644
--- a/pandora_console/godmode/users/profile_list.php
+++ b/pandora_console/godmode/users/profile_list.php
@@ -362,7 +362,10 @@ foreach ($profiles as $profile) {
$data['PM'] = ($profile['pandora_management'] ? $img : '');
$table->cellclass[]['operations'] = 'action_buttons';
$data['operations'] = '
'.html_print_image('images/config.png', true, ['title' => __('Edit')]).'';
- $data['operations'] .= '
'.html_print_image('images/cross.png', true).'';
+ if (check_acl($config['id_user'], 0, 'PM') || users_is_admin()) {
+ $data['operations'] .= '
'.html_print_image('images/cross.png', true).'';
+ }
+
array_push($table->data, $data);
}
diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php
index 4e8cfbb2c1..6a02f4bb57 100644
--- a/pandora_console/godmode/users/user_list.php
+++ b/pandora_console/godmode/users/user_list.php
@@ -420,7 +420,9 @@ else {
$u = get_user_info($key);
$g = users_get_groups($key, 'AR', $u['is_admin']);
$result = array_intersect($g, $own_groups);
- if (!$usr['is_admin'] && !empty($result)) {
+
+ // Show users without profile too.
+ if (!$usr['is_admin'] && !empty($result) || (!$usr['is_admin'] && db_get_all_rows_field_filter('tusuario_perfil', 'id_usuario', $usr['id_user']) === false)) {
$info[$key] = $usr;
}
diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php
index ed7e1f3b10..ed523d0b82 100644
--- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php
+++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php
@@ -200,7 +200,7 @@ class DiscoveryTaskList extends Wizard
{
global $config;
- if (! check_acl($config['id_user'], 0, 'PM')) {
+ if (! check_acl($config['id_user'], 0, 'AW')) {
db_pandora_audit(
'ACL Violation',
'Trying to access recon task viewer'
@@ -241,7 +241,7 @@ class DiscoveryTaskList extends Wizard
{
global $config;
- if (! check_acl($config['id_user'], 0, 'PM')) {
+ if (!$this->aclMulticheck('RR|RW|RM|PM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access recon task viewer'
@@ -270,7 +270,7 @@ class DiscoveryTaskList extends Wizard
{
global $config;
- if (! check_acl($config['id_user'], 0, 'PM')) {
+ if (! check_acl($config['id_user'], 0, 'RM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access recon task viewer'
@@ -313,13 +313,9 @@ class DiscoveryTaskList extends Wizard
check_login();
- if (! check_acl($config['id_user'], 0, 'PM')) {
- db_pandora_audit(
- 'ACL Violation',
- 'Trying to access recon task viewer'
- );
- include 'general/noaccess.php';
- return false;
+ if (!$this->aclMulticheck('AR|AW|AM')) {
+ // Tasklist are allowed only of agent managers.
+ return '';
}
// Get all discovery servers.
@@ -341,7 +337,7 @@ class DiscoveryTaskList extends Wizard
// --------------------------------
// FORCE A RECON TASK
// --------------------------------
- if (check_acl($config['id_user'], 0, 'PM')) {
+ if (check_acl($config['id_user'], 0, 'AW')) {
if (isset($_GET['force'])) {
$id = (int) get_parameter_get('force', 0);
servers_force_recon_task($id);
@@ -387,8 +383,10 @@ class DiscoveryTaskList extends Wizard
// Operations.
$table->headstyle[9] .= 'min-width: 150px; width: 150px;';
- $table->head[0] = __('Force');
- $table->align[0] = 'left';
+ if (check_acl($config['id_user'], 0, 'AW')) {
+ $table->head[0] = __('Force');
+ $table->align[0] = 'left';
+ }
$table->head[1] = __('Task name');
$table->align[1] = 'left';
@@ -455,11 +453,13 @@ class DiscoveryTaskList extends Wizard
}
if ($task['disabled'] == 0 && $server_name !== '') {
- $data[0] = '
';
- $data[0] .= html_print_image('images/target.png', true, ['title' => __('Force')]);
- $data[0] .= '';
+ if (check_acl($config['id_user'], 0, 'AW')) {
+ $data[0] = '
';
+ $data[0] .= html_print_image('images/target.png', true, ['title' => __('Force')]);
+ $data[0] .= '';
+ }
} else if ($task['disabled'] == 2) {
$data[0] = ui_print_help_tip(
__('This task has not been completely defined, please edit it'),
@@ -622,18 +622,20 @@ class DiscoveryTaskList extends Wizard
&& $task['type'] != DISCOVERY_APP_ORACLE
&& $task['type'] != DISCOVERY_CLOUD_AWS_RDS
) {
- $data[9] .= '
';
- $data[9] .= html_print_image(
- 'images/dynamic_network_icon.png',
- true
- );
- $data[9] .= '';
+ if (check_acl($config['id_user'], 0, 'MR')) {
+ $data[9] .= '
';
+ $data[9] .= html_print_image(
+ 'images/dynamic_network_icon.png',
+ true
+ );
+ $data[9] .= '';
+ }
}
if (check_acl(
$config['id_user'],
$task['id_group'],
- 'PM'
+ 'AW'
)
) {
if ($ipam === true) {
@@ -733,6 +735,16 @@ class DiscoveryTaskList extends Wizard
{
if ($script !== false) {
switch ($script['type']) {
+ case DISCOVERY_SCRIPT_APP_VMWARE:
+ return 'wiz=app&mode=vmware&page=0';
+
+ case DISCOVERY_SCRIPT_IPAM_RECON:
+ return '';
+
+ case DISCOVERY_SCRIPT_IPMI_RECON:
+ default:
+ return 'wiz=hd&mode=customnetscan';
+
case DISCOVERY_SCRIPT_CLOUD_AWS:
switch ($task['type']) {
case DISCOVERY_CLOUD_AWS_EC2:
@@ -744,16 +756,6 @@ class DiscoveryTaskList extends Wizard
default:
return 'wiz=cloud';
}
-
- case DISCOVERY_SCRIPT_APP_VMWARE:
- return 'wiz=app&mode=vmware&page=0';
-
- case DISCOVERY_SCRIPT_IPAM_RECON:
- return '';
-
- case DISCOVERY_SCRIPT_IPMI_RECON:
- default:
- return 'wiz=hd&mode=customnetscan';
}
}
diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php
index fb9fba2cdd..fd7811f2e9 100755
--- a/pandora_console/godmode/wizards/HostDevices.class.php
+++ b/pandora_console/godmode/wizards/HostDevices.class.php
@@ -87,6 +87,7 @@ class HostDevices extends Wizard
) {
$this->setBreadcrum([]);
+ $this->access = 'AW';
$this->task = [];
$this->msg = $msg;
$this->icon = $icon;
@@ -100,6 +101,32 @@ class HostDevices extends Wizard
}
+ /**
+ * Checks if environment is ready,
+ * returns array
+ * icon: icon to be displayed
+ * label: label to be displayed
+ *
+ * @return array With data.
+ **/
+ public function load()
+ {
+ global $config;
+ // Check access.
+ check_login();
+
+ if (! $this->aclMulticheck('AW|PM')) {
+ return false;
+ }
+
+ return [
+ 'icon' => $this->icon,
+ 'label' => $this->label,
+ 'url' => $this->url,
+ ];
+ }
+
+
/**
* Run wizard manager.
*
@@ -116,37 +143,42 @@ class HostDevices extends Wizard
if ($mode === null) {
$buttons = [];
- $buttons[] = [
- 'url' => $this->url.'&mode=netscan',
- 'icon' => 'images/wizard/netscan.png',
- 'label' => __('Net Scan'),
- ];
- if (enterprise_installed()) {
+ if (check_acl($config['id_user'], 0, $this->access)) {
$buttons[] = [
- 'url' => $this->url.'&mode=importcsv',
- 'icon' => ENTERPRISE_DIR.'/images/wizard/csv.png',
- 'label' => __('Import CSV'),
+ 'url' => $this->url.'&mode=netscan',
+ 'icon' => 'images/wizard/netscan.png',
+ 'label' => __('Net Scan'),
];
+ if (enterprise_installed()) {
+ $buttons[] = [
+ 'url' => $this->url.'&mode=importcsv',
+ 'icon' => ENTERPRISE_DIR.'/images/wizard/csv.png',
+ 'label' => __('Import CSV'),
+ ];
+
+ $buttons[] = [
+ 'url' => $this->url.'&mode=deploy',
+ 'icon' => ENTERPRISE_DIR.'/images/wizard/deployment.png',
+ 'label' => __('Agent deployment'),
+ ];
+ }
+
$buttons[] = [
- 'url' => $this->url.'&mode=deploy',
- 'icon' => ENTERPRISE_DIR.'/images/wizard/deployment.png',
- 'label' => __('Agent deployment'),
+ 'url' => $this->url.'&mode=customnetscan',
+ 'icon' => '/images/wizard/customnetscan.png',
+ 'label' => __('Custom NetScan'),
];
}
- $buttons[] = [
- 'url' => $this->url.'&mode=customnetscan',
- 'icon' => '/images/wizard/customnetscan.png',
- 'label' => __('Custom NetScan'),
- ];
-
- $buttons[] = [
- 'url' => $this->url.'&mode=managenetscanscripts',
- 'icon' => '/images/wizard/managenetscanscripts.png',
- 'label' => __('Manage NetScan scripts'),
- ];
+ if (check_acl($config['id_user'], 0, 'PM')) {
+ $buttons[] = [
+ 'url' => $this->url.'&mode=managenetscanscripts',
+ 'icon' => '/images/wizard/managenetscanscripts.png',
+ 'label' => __('Manage NetScan scripts'),
+ ];
+ }
$this->prepareBreadcrum(
[
@@ -311,11 +343,11 @@ class HostDevices extends Wizard
) {
// Default values, no data received.
// User is accesing directly to this page.
- if (users_is_admin() !== true && check_acl(
+ if (check_acl(
$config['id_usuario'],
$this->task['id_group'],
- 'PM'
- ) !== true
+ $this->access
+ ) != true
) {
$this->msg = __('You have no access to edit this task.');
return false;
@@ -487,7 +519,7 @@ class HostDevices extends Wizard
check_login();
- if (! check_acl($config['id_user'], 0, 'PM')) {
+ if (! check_acl($config['id_user'], 0, $this->access)) {
db_pandora_audit(
'ACL Violation',
'Trying to access Agent Management'
@@ -529,11 +561,11 @@ class HostDevices extends Wizard
// Check ACL. If user is not able to manage target task,
// redirect him to main page.
- if (users_is_admin() !== true && check_acl(
+ if (check_acl(
$config['id_usuario'],
$this->task['id_group'],
- 'PM'
- ) !== true
+ $this->access
+ ) != true
) {
$form['form']['action'] = $this->url.'&mode=netscan&page='.($this->page - 1);
}
@@ -750,7 +782,7 @@ class HostDevices extends Wizard
[
'name' => 'id_group',
'returnAllGroup' => false,
- 'privilege' => 'PM',
+ 'privilege' => $this->access,
'type' => 'select_groups',
'selected' => $this->task['id_group'],
'return' => true,
diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php
index 3a65560285..cb29d78c06 100644
--- a/pandora_console/godmode/wizards/Wizard.main.php
+++ b/pandora_console/godmode/wizards/Wizard.main.php
@@ -87,6 +87,13 @@ class Wizard
*/
public $msg;
+ /**
+ * Defines access level to use this util.
+ *
+ * @var string
+ */
+ public $access = 'AR';
+
/**
* Setter for breadcrum
@@ -234,6 +241,42 @@ class Wizard
public function run()
{
ui_require_css_file('wizard');
+ // Check access.
+ check_login();
+
+ if (! $this->aclMulticheck()) {
+ return;
+ }
+ }
+
+
+ /**
+ * Check multiple acl perms.
+ *
+ * @param string $access Access in PM|AR|RR format. Optional.
+ *
+ * @return boolean Alowed or not.
+ */
+ public function aclMulticheck($access=null)
+ {
+ global $config;
+
+ if (isset($access)) {
+ $perms = explode('|', $access);
+ } else {
+ $perms = explode('|', $this->access);
+ }
+
+ $allowed = false;
+ foreach ($perms as $perm) {
+ $allowed = $allowed || (bool) check_acl(
+ $config['id_user'],
+ 0,
+ $perm
+ );
+ }
+
+ return $allowed;
}
@@ -247,6 +290,14 @@ class Wizard
**/
public function load()
{
+ global $config;
+ // Check access.
+ check_login();
+
+ if (! $this->aclMulticheck()) {
+ return false;
+ }
+
return [
'icon' => $this->icon,
'label' => $this->label,
diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php
index e34d287da5..bf528cbaca 100755
--- a/pandora_console/include/ajax/module.php
+++ b/pandora_console/include/ajax/module.php
@@ -1113,7 +1113,7 @@ if (check_login()) {
}
if ($module['id_tipo_modulo'] != 25) {
- $data[6] = ui_print_module_warn_value($module['max_warning'], $module['min_warning'], $module['str_warning'], $module['max_critical'], $module['min_critical'], $module['str_critical']);
+ $data[6] = ui_print_module_warn_value($module['max_warning'], $module['min_warning'], $module['str_warning'], $module['max_critical'], $module['min_critical'], $module['str_critical'], $module['warning_inverse'], $module['critical_inverse']);
} else {
$data[6] = '';
}
diff --git a/pandora_console/include/api.php b/pandora_console/include/api.php
index e4977bb614..f263350685 100644
--- a/pandora_console/include/api.php
+++ b/pandora_console/include/api.php
@@ -1,15 +1,32 @@
'api_password']));
+$apiPassword = io_output_password(
+ db_get_value_filter(
+ 'value',
+ 'tconfig',
+ ['token' => 'api_password']
+ )
+);
$correctLogin = false;
$no_login_msg = '';
-// Clean unwanted output
+// Clean unwanted output.
ob_clean();
// READ THIS:
// Special call without checks to retrieve version and build of the Pandora FMS
// This info is avalable from the web console without login
-// Don't change the format, it is parsed by applications
-switch ($info) {
- case 'version':
- if (!$config['MR']) {
- $config['MR'] = 0;
- }
-
- echo 'Pandora FMS '.$pandora_version.' - '.$build_version.' MR'.$config['MR'];
+// Don't change the format, it is parsed by applications.
+if ($info == 'version') {
+ if (!$config['MR']) {
+ $config['MR'] = 0;
+ }
+ echo 'Pandora FMS '.$pandora_version.' - '.$build_version.' MR'.$config['MR'];
exit;
}
@@ -68,14 +89,19 @@ if (isInACL($ipOrigin)) {
if (empty($apiPassword) || (!empty($apiPassword) && $api_password === $apiPassword)) {
$user_in_db = process_user_login($user, $password, true);
if ($user_in_db !== false) {
+ $config['id_usuario'] = $user_in_db;
+ // Compat.
$config['id_user'] = $user_in_db;
$correctLogin = true;
if (session_status() === PHP_SESSION_NONE) {
session_start();
+ $_SESSION = [];
}
$_SESSION['id_usuario'] = $user;
+
+ config_prepare_session();
session_write_close();
} else {
$no_login_msg = 'Incorrect user credentials';
@@ -84,7 +110,7 @@ if (isInACL($ipOrigin)) {
$no_login_msg = 'Incorrect given API password';
}
} else {
- $no_login_msg = "IP $ipOrigin is not in ACL list";
+ $no_login_msg = 'IP '.$ipOrigin.' is not in ACL list';
}
if ($correctLogin) {
@@ -93,11 +119,14 @@ if ($correctLogin) {
} else {
$function_name = '';
- // Check if is an extension function and get the function name
+ // Check if is an extension function and get the function name.
if ($op2 == 'extension') {
- $extension_api_url = $config['homedir'].'/'.EXTENSIONS_DIR."/$ext_name/$ext_name.api.php";
- // The extension API file must exist and the extension must be enabled
- if (file_exists($extension_api_url) && !in_array($ext_name, extensions_get_disabled_extensions())) {
+ $extension_api_url = $config['homedir'].'/'.EXTENSIONS_DIR.'/'.$ext_name.'/'.$ext_name.'.api.php';
+ // The extension API file must exist and the extension must be
+ // enabled.
+ if (file_exists($extension_api_url)
+ && !in_array($ext_name, extensions_get_disabled_extensions())
+ ) {
include_once $extension_api_url;
$function_name = 'apiextension_'.$op.'_'.$ext_function;
}
@@ -107,16 +136,19 @@ if ($correctLogin) {
if ($op == 'set' && $id) {
switch ($op2) {
case 'update_agent':
-
case 'add_module_in_conf':
case 'update_module_in_conf':
case 'delete_module_in_conf':
-
- $id_os = db_get_value_sql('select id_os from tagente where id_agente = '.$id);
-
- if ($id_os == 100) {
- returnError('not_allowed_operation_cluster', $returnType);
- return false;
+ $agent = agents_locate_agent($id);
+ if ($agent !== false) {
+ $id_os = $agent['id_os'];
+ if ($id_os == 100) {
+ returnError(
+ 'not_allowed_operation_cluster',
+ $returnType
+ );
+ return false;
+ }
}
break;
@@ -127,12 +159,16 @@ if ($correctLogin) {
case 'create_snmp_module':
case 'delete_module':
case 'delete_agent':
-
- $id_os = db_get_value_sql('select id_os from tagente where nombre = "'.$id.'"');
-
- if ($id_os == 100) {
- returnError('not_allowed_operation_cluster', $returnType);
- return false;
+ $agent = agents_locate_agent($id);
+ if ($agent !== false) {
+ $id_os = $agent['id_os'];
+ if ($id_os == 100) {
+ returnError(
+ 'not_allowed_operation_cluster',
+ $returnType
+ );
+ return false;
+ }
}
break;
@@ -141,60 +177,98 @@ if ($correctLogin) {
case 'update_data_module':
case 'update_snmp_module':
- $id_os = db_get_value_sql('select id_os from tagente where id_agente = (select id_agente from tagente_modulo where id_agente_modulo ='.$id.')');
+ $id_os = db_get_value_sql(
+ sprintf(
+ 'SELECT id_os
+ FROM tagente
+ WHERE id_agente = (
+ SELECT id_agente
+ FROM tagente_modulo
+ WHERE id_agente_modulo = %d
+ )',
+ $id
+ )
+ );
+
if ($id_os == 100) {
- returnError('not_allowed_operation_cluster', $returnType);
+ returnError(
+ 'not_allowed_operation_cluster',
+ $returnType
+ );
return false;
}
break;
case 'delete_user_permission':
-
if ($user_db === '') {
- returnError(__('User or group not specified'), __('User, group not specified'));
+ returnError(
+ __('User or group not specified'),
+ __('User, group not specified')
+ );
return;
}
- $id_os = api_set_delete_user_profiles($thrash1, $thrash2, $other, $returnType);
+ $id_os = api_set_delete_user_profiles(
+ $thrash1,
+ $thrash2,
+ $other,
+ $returnType
+ );
if ($id_os != 100) {
return;
}
if ($id_os == false) {
- returnError('not_allowed_operation_cluster', $returnType);
+ returnError(
+ 'not_allowed_operation_cluster',
+ $returnType
+ );
return false;
}
break;
case 'add_permission_user_to_group':
-
- if ($user_db == null || $group_db == null || $id_up == null) {
- returnError(__('User, group or profile not specified'), __('User, group or profile status not specified'));
+ if ($user_db == null
+ || $group_db == null
+ || $id_up == null
+ ) {
+ returnError(
+ __('User, group or profile not specified'),
+ __('User, group or profile status not specified')
+ );
return;
}
- $id_os = api_set_add_permission_user_to_group($thrash1, $thrash2, $other, $returnType);
+ $id_os = api_set_add_permission_user_to_group(
+ $thrash1,
+ $thrash2,
+ $other,
+ $returnType
+ );
if ($id_os != 100) {
return;
}
if ($id_os == false) {
- returnError('not_allowed_operation_cluster', $returnType);
+ returnError(
+ 'not_allowed_operation_cluster',
+ $returnType
+ );
return false;
}
break;
default:
-
- // break;
+ // Ignore.
+ break;
}
}
}
- // Check if the function exists
+ // Check if the function exists.
if (function_exists($function_name)) {
if (!DEBUG) {
error_reporting(0);
@@ -205,18 +279,37 @@ if ($correctLogin) {
ini_set('display_errors', 1);
}
- call_user_func($function_name, $id, $id2, $other, $returnType, $user_in_db);
+ call_user_func(
+ $function_name,
+ $id,
+ $id2,
+ $other,
+ $returnType,
+ $user_in_db
+ );
} else {
returnError('no_exist_operation', $returnType);
}
}
} else {
- // TODO: Implement a new switch in config to enable / disable
- // ACL auth failure: if enabled and have lots of traffic can produce millions
- // of records and a considerable OVERHEAD in the system :(
- // db_pandora_audit("API access Failed", $no_login_msg, $user, $ipOrigin);
+ /*
+ * //TODO: Implement a new switch in config to enable / disable
+ * ACL auth failure: if enabled and have lots of traffic can produce
+ * millions of records and a considerable OVERHEAD in the system :(
+ * db_pandora_audit("API access Failed", $no_login_msg, $user, $ipOrigin);
+ */
+
sleep(15);
- // Protection on DoS attacks
+ // Protection on DoS attacks.
echo 'auth error';
}
+
+// Logout.
+if (session_status() === PHP_SESSION_ACTIVE) {
+ $_SESSION = [];
+ // Could give a warning if no session file is created. Ignore.
+ @session_destroy();
+ header_remove('Set-Cookie');
+ setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/');
+}
diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php
index 2ae768d4fe..0d1d138ae6 100644
--- a/pandora_console/include/chart_generator.php
+++ b/pandora_console/include/chart_generator.php
@@ -1,22 +1,39 @@
+
+ $_REQUEST['session_id']]);
+if (check_login(false) === false) {
+ // Error handler.
+ ?>
+
+
+
+
+
Access denied
+
+
+
+
+
+
+
+
+
Access is not granted
+
+
+
+
+ ';
- echo '';
- ui_print_error_message(__('There was a problem connecting with the node'));
- echo '';
- echo '