diff options
author | sinanmohd <sinan@sinanmohd.com> | 2024-04-28 15:52:38 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2024-04-29 08:03:21 +0530 |
commit | 46d107c270e7d0d00956920c142996ab786ea9a1 (patch) | |
tree | 854d35141574690b40061a40aab3c080ac51ef9c /src/npassd/collection.c | |
parent | cd4036cb63d19296476e1e91056a6524ade9bbbc (diff) |
npassd/collection/aliases: init
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; |