summaryrefslogtreecommitdiffstats
path: root/src/responder
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2014-12-16 15:25:38 +0100
committerJakub Hrozek <jhrozek@redhat.com>2015-01-23 21:45:46 +0100
commitca6dd8e7ac91c7f8e3b4d55206d4f39791ab7149 (patch)
treec298cebafb9554c1359550bac842f7a5c4036409 /src/responder
parent3a8f6b575f4019f21c9425a26f1b346c08a197ae (diff)
downloadsssd-ca6dd8e7ac91c7f8e3b4d55206d4f39791ab7149.tar.gz
sssd-ca6dd8e7ac91c7f8e3b4d55206d4f39791ab7149.tar.xz
sssd-ca6dd8e7ac91c7f8e3b4d55206d4f39791ab7149.zip
sbus: add sbus_opath_get_object_name()
This function assumes that the last component of the object path is an object name. It will return the part unescaped. Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Diffstat (limited to 'src/responder')
-rw-r--r--src/responder/ifp/ifp_components.c25
-rw-r--r--src/responder/ifp/ifp_domains.c10
2 files changed, 13 insertions, 22 deletions
diff --git a/src/responder/ifp/ifp_components.c b/src/responder/ifp/ifp_components.c
index 5847a767d..fbccc7e4b 100644
--- a/src/responder/ifp/ifp_components.c
+++ b/src/responder/ifp/ifp_components.c
@@ -85,8 +85,7 @@ static errno_t check_and_get_component_from_path(TALLOC_CTX *mem_ctx,
char **_name)
{
enum component_type type;
- const char *name = NULL;
- char *safe_name = NULL;
+ char *name = NULL;
errno_t ret;
if (confdb == NULL || path == NULL) {
@@ -95,13 +94,17 @@ static errno_t check_and_get_component_from_path(TALLOC_CTX *mem_ctx,
if (strcmp(path, PATH_MONITOR) == 0) {
type = COMPONENT_MONITOR;
- name = "monitor";
+ name = talloc_strdup(mem_ctx, "monitor");
+ if (name == NULL) {
+ ret = ENOMEM;
+ goto done;
+ }
} else {
- name = sbus_opath_strip_prefix(path, PATH_RESPONDERS "/");
+ name = sbus_opath_get_object_name(mem_ctx, path, PATH_RESPONDERS);
if (name != NULL) {
type = COMPONENT_RESPONDER;
} else {
- name = sbus_opath_strip_prefix(path, PATH_BACKENDS "/");
+ name = sbus_opath_get_object_name(mem_ctx, path, PATH_BACKENDS);
if (name != NULL) {
type = COMPONENT_BACKEND;
} else {
@@ -116,24 +119,18 @@ static errno_t check_and_get_component_from_path(TALLOC_CTX *mem_ctx,
goto done;
}
- safe_name = sbus_opath_unescape_part(mem_ctx, name);
- if (safe_name == NULL) {
- ret = ENOMEM;
- goto done;
- }
-
switch (type) {
case COMPONENT_MONITOR:
/* noop */
break;
case COMPONENT_RESPONDER:
- if (!responder_exists(safe_name)) {
+ if (!responder_exists(name)) {
ret = ENOENT;
goto done;
}
break;
case COMPONENT_BACKEND:
- if (!backend_exists(confdb, safe_name)) {
+ if (!backend_exists(confdb, name)) {
ret = ENOENT;
goto done;
}
@@ -145,7 +142,7 @@ static errno_t check_and_get_component_from_path(TALLOC_CTX *mem_ctx,
}
if (_name != NULL) {
- *_name = safe_name;
+ *_name = name;
}
ret = EOK;
diff --git a/src/responder/ifp/ifp_domains.c b/src/responder/ifp/ifp_domains.c
index 0af81af81..7cddb2ebc 100644
--- a/src/responder/ifp/ifp_domains.c
+++ b/src/responder/ifp/ifp_domains.c
@@ -254,7 +254,6 @@ get_domain_info_from_req(struct sbus_request *dbus_req, void *data)
struct ifp_ctx *ctx = NULL;
struct sss_domain_info *domains = NULL;
struct sss_domain_info *iter = NULL;
- const char *raw_name = NULL;
char *name = NULL;
ctx = talloc_get_type(data, struct ifp_ctx);
@@ -263,13 +262,8 @@ get_domain_info_from_req(struct sbus_request *dbus_req, void *data)
return NULL;
}
- raw_name = sbus_opath_strip_prefix(dbus_req->path,
- INFOPIPE_DOMAIN_PATH_PFX "/");
- if (raw_name == NULL) {
- return NULL;
- }
-
- name = sbus_opath_unescape_part(dbus_req, raw_name);
+ name = sbus_opath_get_object_name(dbus_req, dbus_req->path,
+ INFOPIPE_DOMAIN_PATH_PFX);
if (name == NULL) {
return NULL;
}