summaryrefslogtreecommitdiffstats
path: root/src/responder/ifp
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2014-05-11 16:18:06 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-05-22 17:16:13 +0200
commit78f2f0bbb999d40782f8beb940f79bc522cdcb2d (patch)
treead606bd7a72a5d67d990b77619e45d08dd9bd1b4 /src/responder/ifp
parent1a546ae8250c6dbcff0ce775fc811529e02c360c (diff)
downloadsssd-78f2f0bbb999d40782f8beb940f79bc522cdcb2d.tar.gz
sssd-78f2f0bbb999d40782f8beb940f79bc522cdcb2d.tar.xz
sssd-78f2f0bbb999d40782f8beb940f79bc522cdcb2d.zip
IFP: Add a utility function to reply with an object path
Reviewed-by: Stef Walter <stefw@redhat.com> Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Diffstat (limited to 'src/responder/ifp')
-rw-r--r--src/responder/ifp/ifp_private.h6
-rw-r--r--src/responder/ifp/ifpsrv_util.c42
2 files changed, 48 insertions, 0 deletions
diff --git a/src/responder/ifp/ifp_private.h b/src/responder/ifp/ifp_private.h
index 75be038e4..bf2015a97 100644
--- a/src/responder/ifp/ifp_private.h
+++ b/src/responder/ifp/ifp_private.h
@@ -73,6 +73,12 @@ const char *ifp_path_strip_prefix(const char *path, const char *prefix);
char *ifp_bus_path_unescape(TALLOC_CTX *mem_ctx, const char *path);
char *ifp_bus_path_escape(TALLOC_CTX *mem_ctx, const char *path);
+char *_ifp_reply_objpath(TALLOC_CTX *mem_ctx, const char *base,
+ const char *part, ...);
+
+#define ifp_reply_objpath(mem_ctx, base, ...) \
+ _ifp_reply_objpath(mem_ctx, base, ##__VA_ARGS__, NULL)
+
errno_t ifp_add_ldb_el_to_dict(DBusMessageIter *iter_dict,
struct ldb_message_element *el);
const char **ifp_parse_attr_list(TALLOC_CTX *mem_ctx, const char *conf_str);
diff --git a/src/responder/ifp/ifpsrv_util.c b/src/responder/ifp/ifpsrv_util.c
index 6fcd22479..c0ab686e4 100644
--- a/src/responder/ifp/ifpsrv_util.c
+++ b/src/responder/ifp/ifpsrv_util.c
@@ -236,6 +236,48 @@ done:
return safe_path;
}
+char *
+_ifp_reply_objpath(TALLOC_CTX *mem_ctx, const char *base,
+ const char *part, ...)
+{
+ char *safe_part;
+ char *path = NULL;
+ va_list va;
+
+ if (base == NULL) {
+ DEBUG(SSSDBG_OP_FAILURE, "Wrong object path base!\n");
+ return NULL;
+ }
+
+ path = talloc_strdup(mem_ctx, base);
+ if (path == NULL) return NULL;
+
+ va_start(va, part);
+ while (part != NULL) {
+ safe_part = ifp_bus_path_escape(mem_ctx, part);
+ if (safe_part == NULL) {
+ DEBUG(SSSDBG_OP_FAILURE, "Could not add [%s] to objpath\n", part);
+ goto fail;
+ }
+
+ path = talloc_asprintf_append(path, "/%s", safe_part);
+ talloc_free(safe_part);
+ if (path == NULL) {
+ goto fail;
+ }
+
+ part = va_arg(va, const char *);
+ }
+ va_end(va);
+
+ return path;
+
+fail:
+ va_end(va);
+ talloc_free(path);
+ return NULL;
+}
+
errno_t ifp_add_ldb_el_to_dict(DBusMessageIter *iter_dict,
struct ldb_message_element *el)
{