Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
fix problem with ACL calculation when a group is linked to multiple r…
Browse files Browse the repository at this point in the history
…esource acl group -> to be validate
  • Loading branch information
julienmathis committed Sep 30, 2015
1 parent bba9b85 commit b1ff725
Showing 1 changed file with 40 additions and 39 deletions.
79 changes: 40 additions & 39 deletions cron/centAcl.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,11 @@ function programExit($msg) {
foreach ($tabGroups as $acl_group_id => $acl_res_id) {
$tabElem = array();

/*
* Delete old data for this group
*/
$DBRESULT = $pearDBndo->query("DELETE FROM `centreon_acl` WHERE `group_id` = '" . $acl_group_id . "'");

/** ***********************************************
* Select
*/
Expand Down Expand Up @@ -583,6 +588,41 @@ function programExit($msg) {
$tabElem += $metaServices;
}

$str = "";
if (count($tabElem)) {
$i = 0;
foreach ($tabElem as $host => $svc_list) {
$singleId = array_search($host, $hostCache);
if ($singleId) {
if ($str != "") {
$str .= ", ";
}
$str .= " ('".$pearDBndo->escape($host)."', NULL, {$singleId}, NULL, {$acl_group_id}) ";
}
foreach ($svc_list as $desc => $t) {
if ($str != "") {
$str .= ', ';
}
$id_tmp = preg_split("/\,/", $t);
$str .= "('" . $host . "', '" . addslashes($desc) . "', '" . $id_tmp[0] . "' , '" . $id_tmp[1] . "' , " . $acl_group_id . ") ";
$i++;
if ($i >= 1000) {
$DBRESULTNDO = $pearDBndo->query($strBegin . $str);
$str = "";
$i = 0;
}
}
}

/*
* Insert datas
*/
if ($str != "") {
$DBRESULTNDO = $pearDBndo->query($strBegin . $str);
$str = "";
}
}

/* ------------------------------------------------------------------
* reset Flags
*/
Expand All @@ -596,45 +636,6 @@ function programExit($msg) {
print round($now, 3) . " " . _("seconds") . "\n";
}

/*
* Delete old data for this group
*/
$DBRESULT = $pearDBndo->query("DELETE FROM `centreon_acl` WHERE `group_id` = '" . $acl_group_id . "'");

$str = "";
if (count($tabElem)) {
$i = 0;
foreach ($tabElem as $host => $svc_list) {
$singleId = array_search($host, $hostCache);
if ($singleId) {
if ($str != "") {
$str .= ", ";
}
$str .= " ('".$pearDBndo->escape($host)."', NULL, {$singleId}, NULL, {$acl_group_id}) ";
}
foreach ($svc_list as $desc => $t) {
if ($str != "") {
$str .= ', ';
}
$id_tmp = preg_split("/\,/", $t);
$str .= "('" . $host . "', '" . addslashes($desc) . "', '" . $id_tmp[0] . "' , '" . $id_tmp[1] . "' , " . $acl_group_id . ") ";
$i++;
if ($i >= 1000) {
$DBRESULTNDO = $pearDBndo->query($strBegin . $str);
$str = "";
$i = 0;
}
}
}

/*
* Insert datas
*/
if ($str != "") {
$DBRESULTNDO = $pearDBndo->query($strBegin . $str);
$str = "";
}
}
$cpt++;
$pearDB->query("UPDATE acl_groups SET acl_group_changed = '0' WHERE acl_group_id = " . $pearDB->escape($acl_group_id));
}
Expand Down

2 comments on commit b1ff725

@Sims24
Copy link

@Sims24 Sims24 commented on b1ff725 Sep 30, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me !

I can see all things, even if I've defined several resources group and in theses groups I used host and hostgroup pointing to same servers.

Probably unclear but anyway it works !

Thanks for the quick fix

@julienmathis
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !

Please sign in to comment.