From 4fcb8750b9b34bc012b8ffa1fcf78096a8e61d6f Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sat, 17 Aug 2013 20:10:45 +0200 Subject: [PATCH] store: Canonicalize hostname before storing a service. Else, host to service mapping is not correct. --- src/core/store.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/core/store.c b/src/core/store.c index b013dcd..1eb22d6 100644 --- a/src/core/store.c +++ b/src/core/store.c @@ -492,10 +492,22 @@ int sdb_store_service(const char *hostname, const char *name, sdb_time_t last_update) { + char *cname; + int status = 0; + if ((! hostname) || (! name)) return -1; - return store_obj(/* parent = */ SDB_HOST, hostname, + + cname = sdb_plugin_cname(strdup(hostname)); + if (! cname) { + sdb_log(SDB_LOG_ERR, "store: strdup failed"); + return -1; + } + + status = store_obj(/* parent = */ SDB_HOST, cname, /* stored object = */ SDB_SERVICE, name, last_update); + free(cname); + return status; } /* sdb_store_service */ /* TODO: actually support hierarchical data */ -- 2.30.2