From b6a5905c5258cb644c95c786cca3d8014c77b128 Mon Sep 17 00:00:00 2001 From: Vanessa Gil Date: Tue, 27 Jan 2015 16:58:30 +0100 Subject: [PATCH 1/2] Fixed bug #1679. --- pandora_console/include/functions_events.php | 24 ++++++++ pandora_console/include/functions_tags.php | 58 ++++++++++++++++++- .../operation/events/events_list.php | 12 ++++ 3 files changed, 92 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 8bac07fbfc..f7d6f403ae 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -2679,4 +2679,28 @@ function events_get_count_events_validated ($filter, $period, $date, return $return; } + +function events_checks_event_tags($event_data, $acltags) { + global $config; + + if (empty($acltags[$event_data['id_grupo']])) { + return true; + } else { + $tags_arr_acl = explode(',',$acltags[$event_data['id_grupo']]); + $tags_arr_event = explode(',',$event_data['tags']); + + foreach ($tags_arr_acl as $tag) { + $tag_name = tags_get_name($tag); + if (in_array($tag_name, $tags_arr_event)) { + return true; + } else { + $has_tag = false; + } + } + if (!$has_tag) { + return false; + } + } + return false; +} ?> diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index 5ca76dc190..9a716eadf4 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -901,7 +901,8 @@ function tags_get_acl_tags_event_condition($acltags, $meta = false, $force_group if ($force_group_and_tag) { if (!empty($all_tags[$tag])) { - $tags_condition .= sprintf('(tags = "%s"',io_safe_input($all_tags[$tag])); + //~ $tags_condition .= sprintf('(tags = "%s"',io_safe_input($all_tags[$tag])); + $tags_condition .= "(tags LIKE '%".io_safe_input($all_tags[$tag])."%'"; $childrens = groups_get_childrens($group_id, null, true); if (empty($childrens)) { @@ -919,7 +920,8 @@ function tags_get_acl_tags_event_condition($acltags, $meta = false, $force_group $tags_condition .= "id_grupo = ".$group_id; } } else { - $tags_condition .= sprintf('tags = "%s"',io_safe_input($all_tags[$tag])); + //~ $tags_condition .= sprintf('tags = "%s"',io_safe_input($all_tags[$tag])); + $tags_condition .= "tags LIKE '%".io_safe_input($all_tags[$tag])."%'"; } } } @@ -1338,4 +1340,56 @@ function tags_checks_event_acl($id_user, $id_group, $access, $tags = array(), $c return false; } + +/* Return array with groups and their tags */ +function tags_get_user_module_and_tags ($id_user = false, $access = 'AR') { + global $config; + + if ($id_user == false) { + $id_user = $config['id_user']; + } + + $acl_column = get_acl_column($access); + + $query = sprintf("SELECT tags, id_grupo + FROM tusuario_perfil, tperfil + WHERE tperfil.id_perfil = tusuario_perfil.id_perfil AND + tusuario_perfil.id_usuario = '%s' AND + tperfil.%s = 1 + ORDER BY id_grupo", $id_user, $acl_column); + $tags_and_groups = db_get_all_rows_sql($query); + + if ($tags_and_groups == false) { + $tags_and_groups = array(); + } + + $acltags = array(); + + if ((count($tags_and_groups) == 1) && ($tags_and_groups[0]['id_grupo'] == 0) && ($tags_and_groups[0]['tags'] == '')){ //user with all groups without tags + $all_groups = groups_get_all(); + + foreach ($all_groups as $id => $name) { + $acltags[$id] = ''; + } + } else { + foreach ($tags_and_groups as $group_tag) { + $acltags[$group_tag['id_grupo']] = $group_tag['tags']; + $propagate = db_get_value('propagate', 'tgrupo', 'id_grupo', $group_tag['id_grupo']); + + if ($propagate) { + $sql = "SELECT id_grupo FROM tgrupo WHERE parent = " .$group_tag['id_grupo']; + $children = db_get_all_rows_sql($sql); + + if ($children == false) { + $children = array(); + } + foreach ($children as $group) { + $acltags[$group['id_grupo']] = $group_tag['tags']; + } + } + } + } + + return $acltags; +} ?> diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index b5936fd105..cdedf5f4c6 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -564,6 +564,18 @@ else { $history); } +if (!empty($result)) { + //~ Checking the event tags exactly. The event query filters approximated tags to keep events + //~ with several tags + $acltags = tags_get_user_module_and_tags ($config['id_user'],'ER', true); + + foreach ($result as $key=>$event_data) { + $has_tags = events_checks_event_tags($event_data, $acltags); + if (!$has_tags) { + unset($result[$key]); + } + } +} if (!empty($result)) { $graph = '
' . From e6c8b2866bf837a18a13e246d82e16c8c059133d Mon Sep 17 00:00:00 2001 From: artica Date: Wed, 28 Jan 2015 00:01:21 +0100 Subject: [PATCH 2/2] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_console/pandoradb_data.sql | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 474e730ecf..b906747a2a 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 5.1SP2-150127 +Version: 5.1SP2-150128 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index a93444e1aa..340eb8d6ef 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="5.1SP2-150127" +pandora_version="5.1SP2-150128" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 1106b4988c..536edde38b 100644 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,7 +41,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '5.1SP2'; -use constant AGENT_BUILD => '150127'; +use constant AGENT_BUILD => '150128'; # Commands to retrieve total memory information in kB use constant TOTALMEMORY_CMDS => { diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 379454ec41..a1d1e9f3dc 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 5.1SP2 -%define release 150127 +%define release 150128 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 78593098a6..6c6d17900d 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 5.1SP2 -%define release 150127 +%define release 150128 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 3179480f10..b096e7e8d5 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{150127} +{150128} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 09a38decca..485d9a6c2c 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("5.1SP2(Build 150127)") +#define PANDORA_VERSION ("5.1SP2(Build 150128)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 4f598029e5..7c0fea1f62 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(5.1SP2(Build 150127))" + VALUE "ProductVersion", "(5.1SP2(Build 150128))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 59b086baf2..f45fe145ac 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 5.1SP2-150127 +Version: 5.1SP2-150128 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 49dac9708c..6c2311b9cb 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="5.1SP2-150127" +pandora_version="5.1SP2-150128" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 251ab70c0e..7e86b020a1 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC150127'; +$build_version = 'PC150128'; $pandora_version = 'v5.1SP2'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index d7205e5c12..daa1f4e0b1 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -63,7 +63,7 @@