Merge remote-tracking branch 'origin/develop' into ent-7074-Command-Center

Conflicts:
	pandora_console/ajax.php
	pandora_console/extras/delete_files/delete_files.txt
This commit is contained in:
Daniel Barbero Martin 2021-05-24 17:41:28 +02:00
commit 337450a1f8
46 changed files with 303 additions and 409 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.754-210521 Version: 7.0NG.754-210524
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

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

View File

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

View File

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

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.754" PI_VERSION="7.0NG.754"
PI_BUILD="210521" PI_BUILD="210524"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{210521} {210524}
ViewReadme ViewReadme
{Yes} {Yes}

View File

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

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.754-210521 Version: 7.0NG.754-210524
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -31,18 +31,18 @@ require 'vendor/autoload.php';
define('AJAX', true); define('AJAX', true);
if (!defined('__PAN_XHPROF__')) { if (defined('__PAN_XHPROF__') === false) {
define('__PAN_XHPROF__', 0); define('__PAN_XHPROF__', 0);
} }
if (__PAN_XHPROF__ === 1) { if (__PAN_XHPROF__ === 1) {
if (function_exists('tideways_xhprof_enable')) { if (function_exists('tideways_xhprof_enable') === true) {
tideways_xhprof_enable(); tideways_xhprof_enable();
} }
} }
if ((! file_exists('include/config.php')) if (file_exists('include/config.php') === false
|| (! is_readable('include/config.php')) || is_readable('include/config.php') === false
) { ) {
exit; exit;
} }
@ -57,11 +57,11 @@ require_once 'include/auth/mysql.php';
if (isset($config['console_log_enabled']) === true if (isset($config['console_log_enabled']) === true
&& $config['console_log_enabled'] == 1 && $config['console_log_enabled'] == 1
) { ) {
ini_set('log_errors', 1); ini_set('log_errors', true);
ini_set('error_log', $config['homedir'].'/log/console.log'); ini_set('error_log', $config['homedir'].'/log/console.log');
} else { } else {
ini_set('log_errors', 0); ini_set('log_errors', false);
ini_set('error_log', null); ini_set('error_log', '');
} }
// Sometimes input is badly retrieved from caller... // Sometimes input is badly retrieved from caller...
@ -98,8 +98,11 @@ if (isset($_GET['loginhash']) === true) {
} }
} }
// Auth class example: PandoraFMS\Dashboard\Manager. // Another auth class example: PandoraFMS\Dashboard\Manager.
$auth_class = io_safe_output(get_parameter('auth_class', null)); $auth_class = io_safe_output(
get_parameter('auth_class', 'PandoraFMS\User')
);
$public_hash = get_parameter('auth_hash', false); $public_hash = get_parameter('auth_hash', false);
$public_login = false; $public_login = false;
// Check user. // Check user.
@ -123,7 +126,7 @@ if (class_exists($auth_class) === false || $public_hash === false) {
ob_start(); ob_start();
// Enterprise support. // Enterprise support.
if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) { if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php') === true) {
include_once ENTERPRISE_DIR.'/load_enterprise.php'; include_once ENTERPRISE_DIR.'/load_enterprise.php';
} }
@ -141,12 +144,12 @@ if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) {
); );
} }
if (is_metaconsole()) { if (is_metaconsole() === true) {
// Backward compatibility. // Backward compatibility.
define('METACONSOLE', true); define('METACONSOLE', true);
} }
if (file_exists($page)) { if (file_exists($page) === true) {
include_once $page; include_once $page;
} else { } else {
echo '<br /><b class="error">Sorry! I can\'t find the page '.$page.'!</b>'; echo '<br /><b class="error">Sorry! I can\'t find the page '.$page.'!</b>';
@ -171,7 +174,7 @@ if (isset($config['force_instant_logout']) === true
header_remove('Set-Cookie'); header_remove('Set-Cookie');
setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/'); setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/');
if ($config['auth'] == 'saml') { if ($config['auth'] === 'saml') {
include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php'; include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML_Auth_Simple('PandoraFMS'); $as = new SimpleSAML_Auth_Simple('PandoraFMS');
$as->logout(); $as->logout();

View File

@ -90,3 +90,4 @@ enterprise/meta/advanced/synchronizing.alert.php
enterprise/meta/advanced/synchronizing.user.php enterprise/meta/advanced/synchronizing.user.php
enterprise/meta/advanced/synchronizing.tag.php enterprise/meta/advanced/synchronizing.tag.php
enterprise/meta/advanced/synchronizing.group.php enterprise/meta/advanced/synchronizing.group.php
operation/visual_console/pure_ajax.php

View File

@ -14,6 +14,8 @@
global $config; global $config;
global $statusProcessInDB; global $statusProcessInDB;
use PandoraFMS\User;
check_login(); check_login();
require_once $config['homedir'].'/include/functions_visual_map.php'; require_once $config['homedir'].'/include/functions_visual_map.php';
@ -753,8 +755,8 @@ if (!defined('METACONSOLE')) {
$url_view = 'index.php?sec=screen&sec2=screens/screens&action=visualmap&pure=0&id_visualmap='.$idVisualConsole.'&refr='.$view_refresh; $url_view = 'index.php?sec=screen&sec2=screens/screens&action=visualmap&pure=0&id_visualmap='.$idVisualConsole.'&refr='.$view_refresh;
} }
// Hash for auto-auth in public link // Hash for auto-auth in public link.
$hash = md5($config['dbpass'].$idVisualConsole.$config['id_user']); $hash = User::generatePublicHash();
$buttons = []; $buttons = [];

View File

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

View File

@ -3152,10 +3152,6 @@ function events_get_agent(
} }
} }
if (is_metaconsole() === true && empty($id_server) === false) {
$sql_where .= ' AND server_id = '.$id_server;
}
if ($show_summary_group) { if ($show_summary_group) {
return events_get_events_grouped( return events_get_events_grouped(
$sql_where, $sql_where,
@ -3169,7 +3165,7 @@ function events_get_agent(
} else { } else {
return events_get_events_no_grouped( return events_get_events_no_grouped(
$sql_where, $sql_where,
(is_metaconsole() === true && empty($id_server) === false) ? true : false, (is_metaconsole() === true && (int) $id_server === 0) ? true : false,
$history $history
); );
} }

View File

@ -1837,6 +1837,7 @@ function reporting_event_report_group(
$content['name'] = __('Event Report Group'); $content['name'] = __('Event Report Group');
} }
$id_meta = 0;
if (is_metaconsole() === true && empty($content['server_name']) === false) { if (is_metaconsole() === true && empty($content['server_name']) === false) {
$id_meta = metaconsole_get_id_server($content['server_name']); $id_meta = metaconsole_get_id_server($content['server_name']);
$server = metaconsole_get_connection_by_id($id_meta); $server = metaconsole_get_connection_by_id($id_meta);
@ -1928,7 +1929,7 @@ function reporting_event_report_group(
true, true,
false, false,
false, false,
false, $id_meta,
$filter_event_filter_exclude $filter_event_filter_exclude
); );
@ -2176,10 +2177,6 @@ function reporting_event_report_module(
); );
} }
if (is_metaconsole()) {
metaconsole_restore_db();
}
$return['description'] = $content['description']; $return['description'] = $content['description'];
$return['show_extended_events'] = $content['show_extended_events']; $return['show_extended_events'] = $content['show_extended_events'];
$return['date'] = reporting_get_date_text($report, $content); $return['date'] = reporting_get_date_text($report, $content);
@ -2241,7 +2238,7 @@ function reporting_event_report_module(
$return['data'] = array_reverse($data); $return['data'] = array_reverse($data);
} }
if ($config['metaconsole']) { if (is_metaconsole() === true) {
metaconsole_restore_db(); metaconsole_restore_db();
} }
@ -3242,10 +3239,6 @@ function reporting_event_report_agent(
); );
} }
if ($config['metaconsole']) {
metaconsole_restore_db();
}
$label = (isset($content['style']['label'])) ? $content['style']['label'] : ''; $label = (isset($content['style']['label'])) ? $content['style']['label'] : '';
if ($label != '') { if ($label != '') {
$label = reporting_label_macro( $label = reporting_label_macro(
@ -3292,9 +3285,14 @@ function reporting_event_report_agent(
$filter_event_type, $filter_event_type,
$filter_event_status, $filter_event_status,
$filter_event_filter_search, $filter_event_filter_search,
$filter_event_filter_exclude $filter_event_filter_exclude,
$id_server
); );
if (is_metaconsole() === true) {
metaconsole_restore_db();
}
reporting_set_conf_charts( reporting_set_conf_charts(
$width, $width,
$height, $height,
@ -9580,12 +9578,21 @@ function reporting_get_module_detailed_event(
* It construct a table object with all the grouped events happened in an agent * It construct a table object with all the grouped events happened in an agent
* during a period of time. * during a period of time.
* *
* @param mixed Agent id(s) to get the report from. * @param mixed $id_agents Agent id(s) to get the report from.
* @param int Period of time (in seconds) to get the report. * @param integer $period Period of time (in seconds) to get the report.
* @param int Beginning date (unixtime) of the report * @param integer $date Beginning date (unixtime) of the report.
* @param bool Flag to return or echo the report table (echo by default). * @param boolean $return Flag to return or echo the report table (echo by default).
* @param boolean $only_data Only data.
* @param boolean $history History.
* @param boolean $show_summary_group Show summary group.
* @param boolean $filter_event_severity Filter.
* @param boolean $filter_event_type Filter.
* @param boolean $filter_event_status Filter.
* @param boolean $filter_event_filter_search Filter.
* @param boolean $filter_event_filter_exclude Filter.
* @param integer $id_server Id server.
* *
* @return A table object (XHTML) * @return array table object (XHTML)
*/ */
function reporting_get_agents_detailed_event( function reporting_get_agents_detailed_event(
$id_agents, $id_agents,
@ -9599,7 +9606,8 @@ function reporting_get_agents_detailed_event(
$filter_event_type=false, $filter_event_type=false,
$filter_event_status=false, $filter_event_status=false,
$filter_event_filter_search=false, $filter_event_filter_search=false,
$filter_event_filter_exclude=false $filter_event_filter_exclude=false,
$id_server=0
) { ) {
global $config; global $config;
@ -9634,7 +9642,7 @@ function reporting_get_agents_detailed_event(
false, false,
false, false,
false, false,
false, $id_server,
$filter_event_filter_exclude $filter_event_filter_exclude
); );

View File

@ -1151,7 +1151,9 @@ function dashboardLoadVC(settings) {
300 * 1000, 300 * 1000,
handleUpdate, handleUpdate,
beforeUpdate, beforeUpdate,
settings.size settings.size,
settings.id_user,
settings.hash
); );
} }

View File

@ -17,6 +17,9 @@
* @param {function | null} onUpdate Callback which will be execuded when the Visual Console. * @param {function | null} onUpdate Callback which will be execuded when the Visual Console.
* is updated. It will receive two arguments with the old and the new Visual Console's * is updated. It will receive two arguments with the old and the new Visual Console's
* data structure. * data structure.
* @param {string|null} id_user User id given for public access.
* @param {string|null} hash Authorization hash given for public access.
*
* @return {VisualConsole | null} The Visual Console instance or a null value. * @return {VisualConsole | null} The Visual Console instance or a null value.
*/ */
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
@ -28,7 +31,9 @@ function createVisualConsole(
updateInterval, updateInterval,
onUpdate, onUpdate,
beforeUpdate, beforeUpdate,
size size,
id_user,
hash
) { ) {
if (container == null || props == null || items == null) return null; if (container == null || props == null || items == null) return null;
if (baseUrl == null) baseUrl = ""; if (baseUrl == null) baseUrl = "";
@ -46,6 +51,8 @@ function createVisualConsole(
baseUrl, baseUrl,
visualConsoleId, visualConsoleId,
size, size,
id_user,
hash,
function(error, data) { function(error, data) {
if (error) { if (error) {
//Remove spinner change VC. //Remove spinner change VC.
@ -69,7 +76,7 @@ function createVisualConsole(
"[API]", "[API]",
error.message error.message
); );
done(); abortable.abort();
return; return;
} }
@ -651,6 +658,8 @@ function createVisualConsole(
* Fetch a Visual Console's structure and its items. * Fetch a Visual Console's structure and its items.
* @param {string} baseUrl Base URL to build the API path. * @param {string} baseUrl Base URL to build the API path.
* @param {number} vcId Identifier of the Visual Console. * @param {number} vcId Identifier of the Visual Console.
* @param {string|null} id_user User id given for public access.
* @param {string|null} hash Authorization hash given for public access.
* @param {function} callback Function to be executed on request success or fail. * @param {function} callback Function to be executed on request success or fail.
* On success, the function will receive an object with the next properties: * On success, the function will receive an object with the next properties:
* - `props`: object with the Visual Console's data structure. * - `props`: object with the Visual Console's data structure.
@ -658,7 +667,7 @@ function createVisualConsole(
* @return {Object} Cancellable. Object which include and .abort([statusText]) function. * @return {Object} Cancellable. Object which include and .abort([statusText]) function.
*/ */
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
function loadVisualConsoleData(baseUrl, vcId, size, callback) { function loadVisualConsoleData(baseUrl, vcId, size, id_user, hash, callback) {
// var apiPath = baseUrl + "/include/rest-api"; // var apiPath = baseUrl + "/include/rest-api";
var apiPath = baseUrl + "/ajax.php"; var apiPath = baseUrl + "/ajax.php";
var vcJqXHR = null; var vcJqXHR = null;
@ -720,7 +729,9 @@ function loadVisualConsoleData(baseUrl, vcId, size, callback) {
{ {
page: "include/rest-api/index", page: "include/rest-api/index",
getVisualConsole: 1, getVisualConsole: 1,
visualConsoleId: vcId visualConsoleId: vcId,
id_user: typeof id_user == undefined ? id_user : null,
auth_hash: typeof hash == undefined ? hash : null
}, },
"json" "json"
) )
@ -735,7 +746,9 @@ function loadVisualConsoleData(baseUrl, vcId, size, callback) {
page: "include/rest-api/index", page: "include/rest-api/index",
getVisualConsoleItems: 1, getVisualConsoleItems: 1,
size: size, size: size,
visualConsoleId: vcId visualConsoleId: vcId,
id_user: typeof id_user == undefined ? id_user : null,
auth_hash: typeof hash == undefined ? hash : null
}, },
"json" "json"
) )

View File

@ -5,11 +5,12 @@ namespace PandoraFMS\Dashboard;
use PandoraFMS\View; use PandoraFMS\View;
use PandoraFMS\Dashboard\Cell; use PandoraFMS\Dashboard\Cell;
use PandoraFMS\PublicLogin;
/** /**
* Dashboard manager. * Dashboard manager.
*/ */
class Manager class Manager implements PublicLogin
{ {
/** /**

View File

@ -29,7 +29,7 @@
namespace PandoraFMS\Dashboard; namespace PandoraFMS\Dashboard;
// Load Visual Console. // Load Visual Console.
use Models\VisualConsole\Container as VisualConsole; use Models\VisualConsole\Container as VisualConsole;
use PandoraFMS\User;
/** /**
* Maps by users Widgets. * Maps by users Widgets.
*/ */
@ -498,6 +498,8 @@ class MapsMadeByUser extends Widget
'ratio' => $ratio_t, 'ratio' => $ratio_t,
'size' => $size, 'size' => $size,
'cellId' => $this->cellId, 'cellId' => $this->cellId,
'hash' => User::generatePublicHash(),
'id_user' => $config['id_user'],
] ]
); );

View File

@ -0,0 +1,61 @@
<?php
/**
* Public access interface to provide access using hash and id_user.
*
* @category Interfaces
* @package Pandora FMS
* @subpackage Login
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 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.
namespace PandoraFMS;
interface PublicLogin
{
/**
* Generates a hash to authenticate in public views.
*
* @param string|null $other_secret If you need to authenticate using a
* varable string, use this 'other_secret' to customize the hash.
*
* @return string Returns a hash with the authenticaction.
*/
public static function generatePublicHash(?string $other_secret=''):string;
/**
* Validates a hash to authenticate in public view.
*
* @param string $hash Hash to be checked.
* @param string $other_secret Any custom string needed for you.
*
* @return boolean Returns true if hash is valid.
*/
public static function validatePublicHash(
string $hash,
string $other_secret=''
):bool;
}

View File

@ -32,7 +32,7 @@ namespace PandoraFMS;
/** /**
* Object user. * Object user.
*/ */
class User class User implements PublicLogin
{ {
/** /**
@ -53,11 +53,11 @@ class User
/** /**
* Initializes a user object. * Initializes a user object.
* *
* @param array $data User information * @param array|null $data User information.
* - Username * - Username
* - PHP session ID. * - PHP session ID.
*/ */
public function __construct($data) public function __construct(?array $data)
{ {
global $config; global $config;
@ -88,17 +88,20 @@ class User
if (isset($data['id_usuario']) === true if (isset($data['id_usuario']) === true
&& isset($data['password']) === true && isset($data['password']) === true
) { ) {
$user_in_db = process_user_login($user, $password, true); $user_in_db = process_user_login(
$data['id_usuario'],
$data['password'],
true
);
if ($user_in_db !== false) { if ($user_in_db !== false) {
$config['id_usuario'] = $user_in_db; $config['id_usuario'] = $user_in_db;
$correctLogin = true;
// Originally at api.php. // Originally at api.php.
if (session_status() === PHP_SESSION_NONE) { if (session_status() === PHP_SESSION_NONE) {
session_start(); session_start();
} }
$_SESSION['id_usuario'] = $user; $_SESSION['id_usuario'] = $data['id_usuario'];
session_write_close(); session_write_close();
$this->idUser = $data['id_usuario']; $this->idUser = $data['id_usuario'];
@ -113,4 +116,81 @@ class User
} }
/**
* Generates a hash to authenticate in public views.
*
* @param string|null $other_secret If you need to authenticate using a
* varable string, use this 'other_secret' to customize the hash.
*
* @return string Returns a hash with the authenticaction.
*/
public static function generatePublicHash(?string $other_secret=''):string
{
global $config;
$str = $config['dbpass'];
$str .= $config['id_user'];
$str .= $other_secret;
return hash('sha256', $str);
}
/**
* Validates a hash to authenticate in public view.
*
* @param string $hash Hash to be checked.
* @param string $other_secret Any custom string needed for you.
*
* @return boolean Returns true if hash is valid.
*/
public static function validatePublicHash(
string $hash,
string $other_secret=''
):bool {
global $config;
if (isset($config['id_user']) === true) {
// Already logged in.
return true;
}
$userFromParams = false;
// Try to get id_user from parameters if it is missing.
if (isset($config['id_user']) === false) {
$userFromParams = true;
$config['id_user'] = get_parameter('id_user', false);
// It is impossible to authenticate without an id user.
if ($config['id_user'] === false) {
unset($config['id_user']);
return false;
}
} else {
$config['public_access'] = false;
}
// Build a hash to check.
$hashCheck = self::generatePublicHash($other_secret);
if ($hashCheck === $hash) {
// "Log" user in.
if (session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
$_SESSION['id_usuario'] = $config['id_user'];
session_write_close();
$config['public_access'] = true;
$config['force_instant_logout'] = true;
return true;
}
// Remove id user from config array if authentication has failed.
if ($userFromParams === true) {
unset($config['id_user']);
}
return false;
}
} }

View File

@ -147,8 +147,8 @@ class WebSocketUser
/** /**
* Initializes a websocket user. * Initializes a websocket user.
* *
* @param string $id Id of the new user. * @param string $id Id of the new user.
* @param Socket $socket Socket where communication is stablished. * @param \Socket $socket Socket where communication is stablished.
*/ */
public function __construct($id, $socket) public function __construct($id, $socket)
{ {

View File

@ -1071,9 +1071,8 @@ class Item extends CachedModel
$mobile_navigation = false; $mobile_navigation = false;
if (isset($_SERVER['PHP_SELF']) === true if (strstr(($_SERVER['PHP_SELF'] ?? ''), 'mobile/') !== false
&& (strstr($_SERVER['PHP_SELF'], 'mobile/') !== false || strstr(($_SERVER['HTTP_REFERER'] ?? ''), 'mobile/') !== false
|| strstr($_SERVER['HTTP_REFERER'], 'mobile/') !== false)
) { ) {
$mobile_navigation = true; $mobile_navigation = true;
} }

View File

@ -2,6 +2,10 @@
display: inline-block; display: inline-block;
} }
#rules {
display: block;
}
li#li-buttons-alert-list > div { li#li-buttons-alert-list > div {
margin-left: 10px; margin-left: 10px;
} }
@ -132,11 +136,14 @@ div.target {
width: 100%; width: 100%;
} }
div.target.flex { div.target.flex {
display: block;
border: 2px dashed #ddd; border: 2px dashed #ddd;
margin-left: 0em; margin-left: 0em;
margin-top: 10px; margin-top: 10px;
padding: 1em; padding: 1em;
display: flex;
flex-direction: row;
flex-wrap: wrap;
height: fit-content;
} }
.fields, .fields,
@ -190,6 +197,8 @@ div#rules.show {
font-weight: 600; font-weight: 600;
background-color: #333; background-color: #333;
word-break: break-all; word-break: break-all;
height: fit-content;
min-height: 2.3em;
} }
.field.opacityElements { .field.opacityElements {
@ -215,6 +224,11 @@ div#rules.show {
background-color: #82b92e; background-color: #82b92e;
} }
.variable:empty::before {
content: "empty";
font-style: italic;
}
.modifier { .modifier {
background-color: #cba9d2; background-color: #cba9d2;
} }

View File

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

View File

@ -153,7 +153,7 @@ if (is_ajax()) {
// Case. // Case.
'lower', 'lower',
// NoACL. // NoACL.
true, false,
// ChildGroups. // ChildGroups.
$recursion, $recursion,
// Serialized. // Serialized.

View File

@ -15,7 +15,11 @@
// The session is configured and started inside the config process. // The session is configured and started inside the config process.
require_once '../../include/config.php'; require_once '../../include/config.php';
// Set root on homedir, as defined in setup require_once $config['homedir'].'/vendor/autoload.php';
use PandoraFMS\User;
// Set root on homedir, as defined in setup.
chdir($config['homedir']); chdir($config['homedir']);
ob_start(); ob_start();
@ -61,10 +65,13 @@ $id_layout = (int) get_parameter('id_layout');
$graph_javascript = (bool) get_parameter('graph_javascript'); $graph_javascript = (bool) get_parameter('graph_javascript');
$config['id_user'] = get_parameter('id_user'); $config['id_user'] = get_parameter('id_user');
$myhash = md5($config['dbpass'].$id_layout.$config['id_user']); // Check input hash.
if (User::validatePublicHash($hash) !== true) {
// Check input hash db_pandora_audit(
if ($myhash != $hash) { 'Invalid public visual console',
'Trying to access public visual console'
);
include 'general/noaccess.php';
exit; exit;
} }

View File

@ -13,6 +13,8 @@
// GNU General Public License for more details. // GNU General Public License for more details.
global $config; global $config;
use PandoraFMS\User;
// Login check // Login check
require_once $config['homedir'].'/include/functions_visual_map.php'; require_once $config['homedir'].'/include/functions_visual_map.php';
ui_require_css_file('visual_maps'); ui_require_css_file('visual_maps');
@ -122,7 +124,9 @@ $options['consoles_list']['text'] = '<a href="index.php?sec=network&sec2=godmode
if ($vconsole_write || $vconsole_manage) { if ($vconsole_write || $vconsole_manage) {
$url_base = 'index.php?sec=network&sec2=godmode/reporting/visual_console_builder&action='; $url_base = 'index.php?sec=network&sec2=godmode/reporting/visual_console_builder&action=';
$hash = md5($config['dbpass'].$id_layout.$config['id_user']); // Hash for auto-auth in public link.
$hash = User::generatePublicHash();
$options['public_link']['text'] = '<a href="'.ui_get_full_url( $options['public_link']['text'] = '<a href="'.ui_get_full_url(
'operation/visual_console/public_console.php?hash='.$hash.'&id_layout='.$id_layout.'&id_user='.$config['id_user'] 'operation/visual_console/public_console.php?hash='.$hash.'&id_layout='.$id_layout.'&id_user='.$config['id_user']

View File

@ -13,6 +13,8 @@
// GNU General Public License for more details. // GNU General Public License for more details.
require_once '../../include/config.php'; require_once '../../include/config.php';
use PandoraFMS\User;
// Set root on homedir, as defined in setup. // Set root on homedir, as defined in setup.
chdir($config['homedir']); chdir($config['homedir']);
@ -67,10 +69,13 @@ if (!isset($config['pure'])) {
$config['pure'] = 0; $config['pure'] = 0;
} }
$myhash = md5($config['dbpass'].$visualConsoleId.$config['id_user']);
// Check input hash. // Check input hash.
if ($myhash != $hash) { if (User::validatePublicHash($hash) !== true) {
db_pandora_audit(
'Invalid public visual console',
'Trying to access public visual console'
);
include 'general/noaccess.php';
exit; exit;
} }
@ -259,7 +264,15 @@ $visualConsoleItems = VisualConsole::getItemsFromDB(
items, items,
baseUrl, baseUrl,
<?php echo ($refr * 1000); ?>, <?php echo ($refr * 1000); ?>,
handleUpdate handleUpdate,
// BeforeUpdate.
null,
// Size.
null,
// User id.
"<?php echo get_parameter('id_user', ''); ?>",
// Hash.
"<?php echo get_parameter('hash', ''); ?>"
); );
var controls = document.getElementById('vc-controls'); var controls = document.getElementById('vc-controls');

View File

@ -1,314 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2021 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.
global $config;
// Login check
require_once $config['homedir'].'/include/functions_visual_map.php';
check_login();
if (!defined('METACONSOLE')) {
$id_layout = (int) get_parameter('id');
} else {
$id_layout = (int) get_parameter('id_visualmap');
}
if ($id_layout) {
$default_action = 'edit';
} else {
$default_action = 'new';
}
if (!defined('METACONSOLE')) {
$action = get_parameterBetweenListValues(
'action',
[
'new',
'save',
'edit',
'update',
'delete',
],
$default_action
);
} else {
$action = get_parameterBetweenListValues(
'action2',
[
'new',
'save',
'edit',
'update',
'delete',
],
$default_action
);
}
$refr = (int) get_parameter('refr', $config['vc_refr']);
$graph_javascript = (bool) get_parameter('graph_javascript', false);
$vc_refr = false;
if (isset($config['vc_refr']) and $config['vc_refr'] != 0) {
$view_refresh = $config['vc_refr'];
} else {
$view_refresh = '300';
}
// Get input parameter for layout id
if (! $id_layout) {
db_pandora_audit(
'ACL Violation',
'Trying to access visual console without id layout'
);
include 'general/noaccess.php';
exit;
}
$layout = db_get_row('tlayout', 'id', $id_layout);
if (! $layout) {
db_pandora_audit(
'ACL Violation',
'Trying to access visual console without id layout'
);
include 'general/noaccess.php';
exit;
}
$id_group = $layout['id_group'];
$layout_name = $layout['name'];
$background = $layout['background'];
$bwidth = $layout['width'];
$bheight = $layout['height'];
$pure_url = '&pure='.$config['pure'];
// ACL
$vconsole_read = check_acl($config['id_user'], $id_group, 'VR');
$vconsole_write = check_acl($config['id_user'], $id_group, 'VW');
$vconsole_manage = check_acl($config['id_user'], $id_group, 'VM');
if (! $vconsole_read && !$vconsole_write && !$vconsole_manage) {
db_pandora_audit(
'ACL Violation',
'Trying to access visual console without group access'
);
include 'general/noaccess.php';
exit;
}
// Render map
$options = [];
$options['consoles_list']['text'] = '<a href="index.php?sec=network&sec2=godmode/reporting/map_builder&refr='.$refr.'">'.html_print_image(
'images/visual_console.png',
true,
['title' => __('Visual consoles list')]
).'</a>';
if ($vconsole_write || $vconsole_manage) {
$url_base = 'index.php?sec=network&sec2=godmode/reporting/visual_console_builder&action=';
$hash = md5($config['dbpass'].$id_layout.$config['id_user']);
$options['public_link']['text'] = '<a href="'.ui_get_full_url('operation/visual_console/public_console.php?hash='.$hash.'&id_layout='.$id_layout.'&id_user='.$config['id_user']).'" target="_blank">'.html_print_image(
'images/camera_mc.png',
true,
[
'title' => __('Show link to public Visual Console'),
'class' => 'invert_filter',
]
).'</a>';
$options['public_link']['active'] = false;
$options['data']['text'] = '<a href="'.$url_base.$action.'&tab=data&id_visual_console='.$id_layout.'">'.html_print_image(
'images/op_reporting.png',
true,
[
'title' => __('Main data'),
'class' => 'invert_filter',
]
).'</a>';
$options['list_elements']['text'] = '<a href="'.$url_base.$action.'&tab=list_elements&id_visual_console='.$id_layout.'">'.html_print_image(
'images/list.png',
true,
[
'title' => __('List elements'),
'class' => 'invert_filter',
]
).'</a>';
if (enterprise_installed()) {
$options['wizard_services']['text'] = '<a href="'.$url_base.$action.'&tab=wizard_services&id_visual_console='.$id_layout.'">'.html_print_image(
'images/wand_services.png',
true,
[
'title' => __('Services wizard'),
'class' => 'invert_filter',
]
).'</a>';
}
$options['wizard']['text'] = '<a href="'.$url_base.$action.'&tab=wizard&id_visual_console='.$id_layout.'">'.html_print_image(
'images/wand.png',
true,
[
'title' => __('Wizard'),
'class' => 'invert_filter',
]
).'</a>';
$options['editor']['text'] = '<a href="'.$url_base.$action.'&tab=editor&id_visual_console='.$id_layout.'">'.html_print_image(
'images/builder.png',
true,
[
'title' => __('Builder'),
'class' => 'invert_filter',
]
).'</a>';
}
$options['view']['text'] = '<a href="index.php?sec=network&sec2=operation/visual_console/render_view&id='.$id_layout.'&refr='.$view_refresh.'">'.html_print_image(
'images/eye.png',
true,
[
'title' => __('View'),
'class' => 'invert_filter',
]
).'</a>';
$options['view']['active'] = true;
if (!is_metaconsole()) {
if (!$config['pure']) {
$options['pure']['text'] = '<a href="index.php?sec=network&sec2=operation/visual_console/render_view&id='.$id_layout.'&refr='.$refr.'&pure=1">'.html_print_image(
'images/full_screen.png',
true,
[
'title' => __('Full screen mode'),
'class' => 'invert_filter',
]
).'</a>';
ui_print_page_header($layout_name, 'images/visual_console.png', false, '', false, $options);
}
// Set the hidden value for the javascript
html_print_input_hidden('metaconsole', 0);
} else {
// Set the hidden value for the javascript
html_print_input_hidden('metaconsole', 1);
}
visual_map_print_visual_map(
$id_layout,
true,
true,
null,
null,
'',
false,
$graph_javascript
);
?>
<style type="text/css">
/* Avoid the main_pure container 1000px height */
body.pure {
min-height: 100px;
}
div#main_pure {
height: 100%;
margin: 0px;
}
</style>
<?php
ui_require_javascript_file('wz_jsgraphics');
ui_require_javascript_file('pandora_visual_console');
$ignored_params['refr'] = '';
?>
<script language="javascript" type="text/javascript">
$(document).ready (function () {
var refr = <?php echo (int) $refr; ?>;
var pure = <?php echo (int) $config['pure']; ?>;
var href = "<?php echo ui_get_url_refresh($ignored_params); ?>";
$(".module_graph .menu_graph").css('display','none');
$(".parent_graph").each(function(){
if($(this).css('background-color') != 'rgb(255, 255, 255)'){
$(this).css('color', '#999');
}
});
$(".overlay").removeClass("overlay").addClass("overlaydisabled");
});
$(window).on('load', function () {
$('.item:not(.icon) img').each(function(){
if($(this).css('float')=='left' || $(this).css('float')=='right'){
$(this).css('margin-top',(parseInt($(this).parent().parent().css('height'))/2-parseInt($(this).css('height'))/2)+'px');
$(this).css('margin-left','');
}
else{
$(this).css('margin-left',(parseInt($(this).parent().parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px');
$(this).css('margin-top','');
}
});
$('.item > div').each( function() {
if ($(this).css('float')=='left' || $(this).css('float')=='right') {
if($(this).attr('id').indexOf('clock') || $(this).attr('id').indexOf('overlay')){
$(this).css('margin-top',(parseInt($(this).parent().css('height'))/2-parseInt($(this).css('height'))/2)+'px');
}
else{
$(this).css('margin-top',(parseInt($(this).parent().css('height'))/2-parseInt($(this).css('height'))/2-15)+'px');
}
$(this).css('margin-left','');
}
else {
$(this).css('margin-left',(parseInt($(this).parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px');
$(this).css('margin-top','');
}
});
$('.item > a > div').each(function(){
if($(this).css('float')=='left' || $(this).css('float')=='right'){
$(this).css('margin-top',(parseInt($(this).parent().parent().css('height'))/2-parseInt($(this).css('height'))/2-5)+'px');
$(this).css('margin-left','');
}
else{
$(this).css('margin-left',(parseInt($(this).parent().parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px');
$(this).css('margin-top','');
}
});
$(".graph:not([class~='noresizevc'])").each(function(){
height = parseInt($(this).css("height")) - 30;
$(this).css('height', height);
});
});
</script>

View File

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

View File

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

View File

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

View File

@ -321,6 +321,7 @@ return array(
'PandoraFMS\\Module' => $baseDir . '/include/lib/Module.php', 'PandoraFMS\\Module' => $baseDir . '/include/lib/Module.php',
'PandoraFMS\\ModuleStatus' => $baseDir . '/include/lib/ModuleStatus.php', 'PandoraFMS\\ModuleStatus' => $baseDir . '/include/lib/ModuleStatus.php',
'PandoraFMS\\ModuleType' => $baseDir . '/include/lib/ModuleType.php', 'PandoraFMS\\ModuleType' => $baseDir . '/include/lib/ModuleType.php',
'PandoraFMS\\PublicLogin' => $baseDir . '/include/lib/PublicLogin.php',
'PandoraFMS\\User' => $baseDir . '/include/lib/User.php', 'PandoraFMS\\User' => $baseDir . '/include/lib/User.php',
'PandoraFMS\\View' => $baseDir . '/include/lib/View.php', 'PandoraFMS\\View' => $baseDir . '/include/lib/View.php',
'PandoraFMS\\Websockets\\WSManager' => $baseDir . '/include/lib/Websockets/WSManager.php', 'PandoraFMS\\Websockets\\WSManager' => $baseDir . '/include/lib/Websockets/WSManager.php',

View File

@ -403,6 +403,7 @@ class ComposerStaticInitfdecadadce22e6dde51e9535fe4ad7aa
'PandoraFMS\\Module' => __DIR__ . '/../..' . '/include/lib/Module.php', 'PandoraFMS\\Module' => __DIR__ . '/../..' . '/include/lib/Module.php',
'PandoraFMS\\ModuleStatus' => __DIR__ . '/../..' . '/include/lib/ModuleStatus.php', 'PandoraFMS\\ModuleStatus' => __DIR__ . '/../..' . '/include/lib/ModuleStatus.php',
'PandoraFMS\\ModuleType' => __DIR__ . '/../..' . '/include/lib/ModuleType.php', 'PandoraFMS\\ModuleType' => __DIR__ . '/../..' . '/include/lib/ModuleType.php',
'PandoraFMS\\PublicLogin' => __DIR__ . '/../..' . '/include/lib/PublicLogin.php',
'PandoraFMS\\User' => __DIR__ . '/../..' . '/include/lib/User.php', 'PandoraFMS\\User' => __DIR__ . '/../..' . '/include/lib/User.php',
'PandoraFMS\\View' => __DIR__ . '/../..' . '/include/lib/View.php', 'PandoraFMS\\View' => __DIR__ . '/../..' . '/include/lib/View.php',
'PandoraFMS\\Websockets\\WSManager' => __DIR__ . '/../..' . '/include/lib/Websockets/WSManager.php', 'PandoraFMS\\Websockets\\WSManager' => __DIR__ . '/../..' . '/include/lib/Websockets/WSManager.php',

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0NG.754-210521 Version: 7.0NG.754-210524
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "7.0NG.754 Build 210521"; my $version = "7.0NG.754 Build 210524";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "7.0NG.754 Build 210521"; my $version = "7.0NG.754 Build 210524";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);