Module: check_mk
Branch: master
Commit: b97548077855a29fe2add921473d1d52edc54cdc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b97548077855a2…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Nov 2 15:22:30 2017 +0100
Push nullptr check into implementation where it belongs. Renaming.
Change-Id: I9b52be420c30cac6ad9ed2258c88ae51afa7f97f
---
livestatus/src/HostGroupsColumn.cc | 3 +--
livestatus/src/ServiceGroupsColumn.cc | 3 +--
livestatus/src/auth.cc | 6 ++++++
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/livestatus/src/HostGroupsColumn.cc b/livestatus/src/HostGroupsColumn.cc
index c70ccf4..22f470c 100644
--- a/livestatus/src/HostGroupsColumn.cc
+++ b/livestatus/src/HostGroupsColumn.cc
@@ -34,8 +34,7 @@ std::vector<std::string> HostGroupsColumn::getValue(
if (auto p = columnData<objectlist *>(row)) {
for (objectlist *list = *p; list != nullptr; list = list->next) {
auto hg = static_cast<hostgroup *>(list->object_ptr);
- if (auth_user == nullptr ||
- is_authorized_for_host_group(_mc, hg, auth_user)) {
+ if (is_authorized_for_host_group(_mc, hg, auth_user)) {
group_names.emplace_back(hg->group_name);
}
}
diff --git a/livestatus/src/ServiceGroupsColumn.cc
b/livestatus/src/ServiceGroupsColumn.cc
index 5213305..a5f6aed 100644
--- a/livestatus/src/ServiceGroupsColumn.cc
+++ b/livestatus/src/ServiceGroupsColumn.cc
@@ -34,8 +34,7 @@ std::vector<std::string> ServiceGroupsColumn::getValue(
if (auto p = columnData<objectlist *>(row)) {
for (objectlist *list = *p; list != nullptr; list = list->next) {
auto sg = static_cast<servicegroup *>(list->object_ptr);
- if (auth_user == nullptr ||
- is_authorized_for_service_group(_mc, sg, auth_user)) {
+ if (is_authorized_for_service_group(_mc, sg, auth_user)) {
group_names.emplace_back(sg->group_name);
}
}
diff --git a/livestatus/src/auth.cc b/livestatus/src/auth.cc
index 867f066..4acbd06 100644
--- a/livestatus/src/auth.cc
+++ b/livestatus/src/auth.cc
@@ -57,6 +57,9 @@ bool is_authorized_for(MonitoringCore *mc, const contact *ctc, const
host *hst,
bool is_authorized_for_host_group(MonitoringCore *mc, const hostgroup *hg,
const contact *ctc) {
+ if (ctc == nullptr) {
+ return true;
+ }
if (ctc == unknown_auth_user()) {
return false;
}
@@ -84,6 +87,9 @@ bool is_authorized_for_host_group(MonitoringCore *mc, const hostgroup
*hg,
bool is_authorized_for_service_group(MonitoringCore *mc, const servicegroup *sg,
const contact *ctc) {
+ if (ctc == nullptr) {
+ return true;
+ }
if (ctc == unknown_auth_user()) {
return false;
}