From db97470a4820983676b9851f061c13287a47d25f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 20 Mar 2020 09:09:00 +0100 Subject: [PATCH] Fix host templates not usable with hostgroup restrictions Before, for new hosts the code checked whether the host is part of any restricted hostgroup only if the host's groups got modified directly. I honestly don't know how that should be possible, since one can't add host groups directly if restricted. Now, for new hosts the code checks whether the resolved host groups match at least one of the restricted host groups. --- library/Director/Restriction/HostgroupRestriction.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/library/Director/Restriction/HostgroupRestriction.php b/library/Director/Restriction/HostgroupRestriction.php index 0d88b919..f77066a0 100644 --- a/library/Director/Restriction/HostgroupRestriction.php +++ b/library/Director/Restriction/HostgroupRestriction.php @@ -57,11 +57,9 @@ class HostgroupRestriction extends ObjectRestriction } if (! $host->hasBeenLoadedFromDb()) { - if ($host->hasModifiedGroups()) { - foreach ($this->listRestrictedHostgroups() as $group) { - if ($host->hasGroup($group)) { - return true; - } + foreach ($this->listRestrictedHostgroups() as $group) { + if ($host->hasGroup($group)) { + return true; } }