[icinga-checkins] icinga.org: icinga2/master: Disallow colons in user-defined objects. Use colons for auto-generated object names.

git at icinga.org git at icinga.org
Tue May 7 09:22:57 CEST 2013


Module: icinga2
Branch: master
Commit: 08cd495fef41c25549e24ee3383530a7bd870e9e
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=08cd495fef41c25549e24ee3383530a7bd870e9e

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Tue May  7 09:22:39 2013 +0200

Disallow colons in user-defined objects. Use colons for auto-generated object names.

---

 lib/config/config_parser.yy         |    3 +++
 lib/icinga/host.cpp                 |    2 +-
 lib/icinga/service-notification.cpp |    2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/config/config_parser.yy b/lib/config/config_parser.yy
index b00fc12..c962e19 100644
--- a/lib/config/config_parser.yy
+++ b/lib/config/config_parser.yy
@@ -301,6 +301,9 @@ object_declaration identifier T_STRING object_inherits_specifier expressionlist
 		item->SetType($3);
 		free($3);
 
+		if (strchr($4, ':') != NULL)
+			BOOST_THROW_EXCEPTION(std::invalid_argument("Object names may not contain ':'"));
+
 		item->SetName($4);
 		free($4);
 
diff --git a/lib/icinga/host.cpp b/lib/icinga/host.cpp
index 4c486f2..73cc842 100644
--- a/lib/icinga/host.cpp
+++ b/lib/icinga/host.cpp
@@ -192,7 +192,7 @@ void Host::UpdateSlaveServices(void)
 				svcname = svcdesc;
 
 			std::ostringstream namebuf;
-			namebuf << GetName() << "-" << svcname;
+			namebuf << GetName() << ":" << svcname;
 			String name = namebuf.str();
 
 			ConfigItemBuilder::Ptr builder = boost::make_shared<ConfigItemBuilder>(item->GetDebugInfo());
diff --git a/lib/icinga/service-notification.cpp b/lib/icinga/service-notification.cpp
index 65983b1..e7c6eb4 100644
--- a/lib/icinga/service-notification.cpp
+++ b/lib/icinga/service-notification.cpp
@@ -213,7 +213,7 @@ void Service::UpdateSlaveNotifications(void)
 		Value nfcdesc;
 		BOOST_FOREACH(boost::tie(nfcname, nfcdesc), descs) {
 			std::ostringstream namebuf;
-			namebuf << GetName() << "-" << nfcname;
+			namebuf << GetName() << ":" << nfcname;
 			String name = namebuf.str();
 
 			ConfigItemBuilder::Ptr builder = boost::make_shared<ConfigItemBuilder>(item->GetDebugInfo());





More information about the icinga-checkins mailing list