summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2014-12-12 15:14:09 +0100
committerJakub Hrozek <jhrozek@redhat.com>2015-01-23 21:29:34 +0100
commit71c9027d4192bf149afa4fcf9fef93bf6e901121 (patch)
tree823982d4ff67ccf906608742b7b73174db413851 /src
parent46ee931314e6a5517f5c6b6b14f759364be119cc (diff)
downloadsssd-71c9027d4192bf149afa4fcf9fef93bf6e901121.tar.gz
sssd-71c9027d4192bf149afa4fcf9fef93bf6e901121.tar.xz
sssd-71c9027d4192bf149afa4fcf9fef93bf6e901121.zip
sbus: add object path to sbus request
Object path is heavily used in implementation of methods from interfaces that are supported on whole subtrees. Although it can be obtained from a D-Bus message, it is nice to have it accessible directly. Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/responder/ifp/ifp_components.c18
-rw-r--r--src/responder/ifp/ifp_domains.c4
-rw-r--r--src/sbus/sssd_dbus.h1
-rw-r--r--src/sbus/sssd_dbus_request.c1
-rw-r--r--src/tests/sbus_tests.c8
5 files changed, 13 insertions, 19 deletions
diff --git a/src/responder/ifp/ifp_components.c b/src/responder/ifp/ifp_components.c
index c8ad7673c..2b76a480d 100644
--- a/src/responder/ifp/ifp_components.c
+++ b/src/responder/ifp/ifp_components.c
@@ -691,7 +691,6 @@ int ifp_component_change_debug_level_tmp(struct sbus_request *dbus_req,
{
struct ifp_ctx *ctx = NULL;
DBusError *error = NULL;
- const char *path = dbus_message_get_path(dbus_req->message);
char *name = NULL;
enum component_type type;
errno_t ret;
@@ -704,7 +703,7 @@ int ifp_component_change_debug_level_tmp(struct sbus_request *dbus_req,
}
ret = check_and_get_component_from_path(dbus_req, ctx->rctx->cdb,
- path, &type, &name);
+ dbus_req->path, &type, &name);
if (ret != EOK) {
goto done;
}
@@ -736,7 +735,6 @@ void ifp_component_get_name(struct sbus_request *dbus_req,
const char **_out)
{
struct ifp_ctx *ctx = NULL;
- const char *path = dbus_message_get_path(dbus_req->message);
char *name = NULL;
errno_t ret;
@@ -749,7 +747,7 @@ void ifp_component_get_name(struct sbus_request *dbus_req,
}
ret = check_and_get_component_from_path(dbus_req, ctx->rctx->cdb,
- path, NULL, &name);
+ dbus_req->path, NULL, &name);
if (ret != EOK) {
DEBUG(SSSDBG_OP_FAILURE, "Unknown object [%d]: %s\n",
ret, strerror(ret));
@@ -764,7 +762,6 @@ void ifp_component_get_debug_level(struct sbus_request *dbus_req,
uint32_t *_out)
{
struct ifp_ctx *ctx = NULL;
- const char *path = dbus_message_get_path(dbus_req->message);
const char *confdb_path = NULL;
char *name = NULL;
enum component_type type;
@@ -780,7 +777,7 @@ void ifp_component_get_debug_level(struct sbus_request *dbus_req,
}
ret = check_and_get_component_from_path(dbus_req, ctx->rctx->cdb,
- path, &type, &name);
+ dbus_req->path, &type, &name);
if (ret != EOK) {
DEBUG(SSSDBG_OP_FAILURE, "Unknown object [%d]: %s\n",
ret, strerror(ret));
@@ -820,7 +817,6 @@ void ifp_component_get_enabled(struct sbus_request *dbus_req,
bool *_out)
{
struct ifp_ctx *ctx = NULL;
- const char *path = dbus_message_get_path(dbus_req->message);
const char *param = NULL;
char **values = NULL;
char *name = NULL;
@@ -837,7 +833,7 @@ void ifp_component_get_enabled(struct sbus_request *dbus_req,
}
ret = check_and_get_component_from_path(dbus_req, ctx->rctx->cdb,
- path, &type, &name);
+ dbus_req->path, &type, &name);
if (ret != EOK) {
DEBUG(SSSDBG_OP_FAILURE, "Unknown object [%d]: %s\n",
ret, strerror(ret));
@@ -877,7 +873,6 @@ void ifp_component_get_type(struct sbus_request *dbus_req,
const char **_out)
{
struct ifp_ctx *ctx = NULL;
- const char *path = dbus_message_get_path(dbus_req->message);
enum component_type type;
errno_t ret;
@@ -890,7 +885,7 @@ void ifp_component_get_type(struct sbus_request *dbus_req,
}
ret = check_and_get_component_from_path(dbus_req, ctx->rctx->cdb,
- path, &type, NULL);
+ dbus_req->path, &type, NULL);
if (ret != EOK) {
DEBUG(SSSDBG_OP_FAILURE, "Unknown object [%d]: %s\n",
ret, strerror(ret));
@@ -917,7 +912,6 @@ void ifp_backend_get_providers(struct sbus_request *dbus_req,
{
TALLOC_CTX *tmp_ctx = NULL;
struct ifp_ctx *ctx = NULL;
- const char *path = dbus_message_get_path(dbus_req->message);
const char *confdb_path = NULL;
char *name = NULL;
enum component_type type;
@@ -952,7 +946,7 @@ void ifp_backend_get_providers(struct sbus_request *dbus_req,
}
ret = check_and_get_component_from_path(tmp_ctx, ctx->rctx->cdb,
- path, &type, &name);
+ dbus_req->path, &type, &name);
if (ret != EOK) {
DEBUG(SSSDBG_OP_FAILURE, "Unknown object [%d]: %s\n",
ret, strerror(ret));
diff --git a/src/responder/ifp/ifp_domains.c b/src/responder/ifp/ifp_domains.c
index 0d50dac32..1841cbe58 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 *path = dbus_message_get_path(dbus_req->message);
const char *raw_name = NULL;
char *name = NULL;
@@ -264,7 +263,8 @@ get_domain_info_from_req(struct sbus_request *dbus_req, void *data)
return NULL;
}
- raw_name = ifp_path_strip_prefix(path, INFOPIPE_DOMAIN_PATH_PFX "/");
+ raw_name = ifp_path_strip_prefix(dbus_req->path,
+ INFOPIPE_DOMAIN_PATH_PFX "/");
if (raw_name == NULL) {
return NULL;
}
diff --git a/src/sbus/sssd_dbus.h b/src/sbus/sssd_dbus.h
index c50b4e9b6..0d021f8fd 100644
--- a/src/sbus/sssd_dbus.h
+++ b/src/sbus/sssd_dbus.h
@@ -219,6 +219,7 @@ struct sbus_request {
DBusMessage *message;
struct sbus_interface *intf;
const struct sbus_method_meta *method;
+ const char *path;
};
/*
diff --git a/src/sbus/sssd_dbus_request.c b/src/sbus/sssd_dbus_request.c
index 2db9513f6..7362f4b79 100644
--- a/src/sbus/sssd_dbus_request.c
+++ b/src/sbus/sssd_dbus_request.c
@@ -49,6 +49,7 @@ sbus_new_request(struct sbus_connection *conn,
dbus_req->intf = intf;
dbus_req->conn = conn;
dbus_req->message = dbus_message_ref(message);
+ dbus_req->path = dbus_message_get_path(message);
talloc_set_destructor(dbus_req, sbus_request_destructor);
return dbus_req;
diff --git a/src/tests/sbus_tests.c b/src/tests/sbus_tests.c
index 6086a42bf..288163d61 100644
--- a/src/tests/sbus_tests.c
+++ b/src/tests/sbus_tests.c
@@ -108,7 +108,6 @@ const struct sbus_interface_meta pilot_meta = {
static int blink_handler(struct sbus_request *req, void *data)
{
DBusError error = DBUS_ERROR_INIT;
- const char *path;
dbus_int32_t duration = 0;
dbus_bool_t crashed;
@@ -116,12 +115,11 @@ static int blink_handler(struct sbus_request *req, void *data)
ck_assert(data != NULL);
ck_assert(data == req->intf->instance_data);
- path = dbus_message_get_path(req->message);
- ck_assert_str_eq(req->intf->path, path);
+ ck_assert_str_eq(req->intf->path, req->path);
- if (strcmp(path, "/test/fry") == 0) {
+ if (strcmp(req->path, "/test/fry") == 0) {
ck_assert_str_eq(data, "Don't crash");
- } else if (strcmp(path, "/test/leela") == 0) {
+ } else if (strcmp(req->path, "/test/leela") == 0) {
ck_assert_str_eq(data, "Crash into the billboard");
} else {
ck_abort();