diff options
Diffstat (limited to 'src/npassd/collection.c')
-rw-r--r-- | src/npassd/collection.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/npassd/collection.c b/src/npassd/collection.c index 6fecf16..97f1e31 100644 --- a/src/npassd/collection.c +++ b/src/npassd/collection.c @@ -46,6 +46,7 @@ static void collection_free(struct collection *c) return; sd_bus_slot_unref(c->slot); + sd_bus_slot_unref(c->slot); free(c->path); free(c->alias); @@ -177,6 +178,7 @@ static int collection_alloc(sd_bus *bus, struct collection **p, uint64_t modified) { struct collection *collection; + char *alias_path; int ret; *p = malloc(sizeof(**p)); @@ -218,7 +220,7 @@ static int collection_alloc(sd_bus *bus, struct collection **p, collection->root); if (ret < 0) { collection_free(collection); - print_err("%s", "Failed to create collection object path"); + print_err("%s", "Failed to build collection object path"); return -ENOMEM; } ret = dbus_objpath_alnumify(collection->path); @@ -235,6 +237,25 @@ static int collection_alloc(sd_bus *bus, struct collection **p, collection_free(collection); print_err("Failed to connect to bus: %s", strerror(-ret)); return ret; + } else if (alias == NULL) { + return 0; + } + + ret = asprintf(&alias_path, DBUS_OBJECT_PATH "/aliases/%s", alias); + if (ret < 0) { + collection_free(collection); + print_err("%s", "Failed to build collection alias path"); + return -ENOMEM; + } + + ret = sd_bus_add_object_vtable(bus, &collection->slot, alias_path, + COLLECTION_IFACE, collection_vtable, + collection); + free(alias_path); + if (ret < 0) { + collection_free(collection); + print_err("Failed to connect to bus: %s", strerror(-ret)); + return ret; } return 0; |