From: Sebastian Harl Date: Sat, 17 Aug 2013 18:10:45 +0000 (+0200) Subject: store: Canonicalize hostname before storing a service. X-Git-Tag: sysdb-0.1.0~383 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4fcb8750b9b34bc012b8ffa1fcf78096a8e61d6f;p=sysdb.git store: Canonicalize hostname before storing a service. Else, host to service mapping is not correct. --- 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 */