summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/infopipe/infopipe.c61
-rw-r--r--server/infopipe/infopipe.h26
-rw-r--r--server/infopipe/infopipe_groups.c20
-rw-r--r--server/infopipe/infopipe_users.c24
-rw-r--r--server/monitor/monitor.c9
-rw-r--r--server/nss/nsssrv.c28
-rw-r--r--server/nss/nsssrv_dp.c8
-rw-r--r--server/polkit/sssd_polkit.c20
-rw-r--r--server/providers/data_provider.c46
-rw-r--r--server/providers/data_provider_be.c71
-rw-r--r--server/sbus/sssd_dbus.h8
-rw-r--r--server/sbus/sssd_dbus_connection.c32
12 files changed, 186 insertions, 167 deletions
diff --git a/server/infopipe/infopipe.c b/server/infopipe/infopipe.c
index 80b1bef0..dc7abc54 100644
--- a/server/infopipe/infopipe.c
+++ b/server/infopipe/infopipe.c
@@ -39,16 +39,17 @@ struct infp_ctx {
struct sysbus_ctx *sysbus;
};
-static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply)
+static int service_identity(DBusMessage *message, void *data, DBusMessage **r)
{
dbus_uint16_t version = INFOPIPE_VERSION;
const char *name = INFOPIPE_SERVICE_NAME;
+ DBusMessage *reply;
dbus_bool_t ret;
DEBUG(4, ("Sending identity data [%s,%d]\n", name, version));
- reply->reply_message = dbus_message_new_method_return(message);
- ret = dbus_message_append_args(reply->reply_message,
+ reply = dbus_message_new_method_return(message);
+ ret = dbus_message_append_args(reply,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_UINT16, &version,
DBUS_TYPE_INVALID);
@@ -56,30 +57,33 @@ static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply
return EIO;
}
+ *r = reply;
return EOK;
}
-static int service_pong(DBusMessage *message, struct sbus_message_ctx *reply)
+static int service_pong(DBusMessage *message, void *data, DBusMessage **r)
{
+ DBusMessage *reply;
dbus_bool_t ret;
- reply->reply_message = dbus_message_new_method_return(message);
- ret = dbus_message_append_args(reply->reply_message, DBUS_TYPE_INVALID);
+ reply = dbus_message_new_method_return(message);
+ ret = dbus_message_append_args(reply, DBUS_TYPE_INVALID);
if (!ret) {
return EIO;
}
+ *r = reply;
return EOK;
}
-static int service_reload(DBusMessage *message, struct sbus_message_ctx *reply) {
+static int service_reload(DBusMessage *message, void *data, DBusMessage **r) {
/* Monitor calls this function when we need to reload
* our configuration information. Perform whatever steps
* are needed to update the configuration objects.
*/
/* Send an empty reply to acknowledge receipt */
- return service_pong(message, reply);
+ return service_pong(message, data, r);
}
struct sbus_method mon_sbus_methods[] = {
@@ -136,8 +140,10 @@ struct sbus_method infp_methods[] = {
#define INTROSPECT_CHUNK_SIZE 4096 /* Read in one memory page at a time */
-int infp_introspect(DBusMessage *message, struct sbus_message_ctx *reply)
+int infp_introspect(DBusMessage *message, void *data, DBusMessage **r)
{
+ struct sbus_message_handler_ctx *mh_ctx;
+ DBusMessage *reply;
FILE *xml_stream;
char *introspect_xml;
char *chunk;
@@ -147,12 +153,14 @@ int infp_introspect(DBusMessage *message, struct sbus_message_ctx *reply)
int ret;
dbus_bool_t dbret;
- tmp_ctx = talloc_new(reply);
+ mh_ctx = talloc_get_type(data, struct sbus_message_handler_ctx);
+
+ tmp_ctx = talloc_new(NULL);
if(tmp_ctx == NULL) {
return ENOMEM;
}
- if (reply->mh_ctx->introspection_xml == NULL) {
+ if (mh_ctx->introspection_xml == NULL) {
/* Read in the Introspection XML the first time */
xml_stream = fopen(SSSD_INTROSPECT_PATH"/"INFP_INTROSPECT_XML, "r");
if(xml_stream == NULL) {
@@ -182,21 +190,20 @@ int infp_introspect(DBusMessage *message, struct sbus_message_ctx *reply)
talloc_free(chunk);
/* Store the instrospection XML for future calls */
- reply->mh_ctx->introspection_xml = introspect_xml;
- talloc_steal(reply->mh_ctx, introspect_xml);
+ mh_ctx->introspection_xml = introspect_xml;
}
else {
/* Subsequent calls should just reuse the saved value */
- introspect_xml = reply->mh_ctx->introspection_xml;
+ introspect_xml = mh_ctx->introspection_xml;
}
/* Return the Introspection XML */
- reply->reply_message = dbus_message_new_method_return(message);
- if (reply->reply_message == NULL) {
+ reply = dbus_message_new_method_return(message);
+ if (reply == NULL) {
ret = ENOMEM;
goto done;
}
- dbret = dbus_message_append_args(reply->reply_message,
+ dbret = dbus_message_append_args(reply,
DBUS_TYPE_STRING, &introspect_xml,
DBUS_TYPE_INVALID);
if (!dbret) {
@@ -339,8 +346,10 @@ bool infp_get_permissions(const char *username,
/* CheckPermissions(STRING domain, STRING object, STRING instance
* ARRAY(STRING action_type, STRING attribute) actions)
*/
-int infp_check_permissions(DBusMessage *message, struct sbus_message_ctx *reply)
+int infp_check_permissions(DBusMessage *message, void *data, DBusMessage **r)
{
+ struct sbus_message_handler_ctx *mh_ctx;
+ DBusMessage *reply;
TALLOC_CTX *tmp_ctx;
int current_type;
DBusConnection *conn;
@@ -362,13 +371,15 @@ int infp_check_permissions(DBusMessage *message, struct sbus_message_ctx *reply)
dbus_bool_t *permissions;
size_t count;
- tmp_ctx = talloc_new(reply);
+ mh_ctx = talloc_get_type(data, struct sbus_message_handler_ctx);
+
+ tmp_ctx = talloc_new(NULL);
if(tmp_ctx == NULL) {
return ENOMEM;
}
/* Get the connection UID */
- conn = sbus_get_connection(reply->mh_ctx->conn_ctx);
+ conn = sbus_get_connection(mh_ctx->conn_ctx);
conn_name = dbus_message_get_sender(message);
if (conn_name == NULL) {
DEBUG(0, ("Critical error: D-BUS client has no unique name\n"));
@@ -488,11 +499,10 @@ int infp_check_permissions(DBusMessage *message, struct sbus_message_ctx *reply)
}
/* Create response message */
- reply->reply_message = dbus_message_new_method_return(message);
- if (reply->reply_message == NULL) return ENOMEM;
+ reply = dbus_message_new_method_return(message);
+ if (reply == NULL) return ENOMEM;
- talloc_steal(reply, permissions);
- dbus_message_append_args(reply->reply_message,
+ dbus_message_append_args(reply,
DBUS_TYPE_ARRAY, DBUS_TYPE_BOOLEAN, &permissions, count,
DBUS_TYPE_INVALID);
@@ -500,8 +510,7 @@ int infp_check_permissions(DBusMessage *message, struct sbus_message_ctx *reply)
return EOK;
einval:
- talloc_steal(reply, einval_msg);
- reply->reply_message = dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS, einval_msg);
+ reply = dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS, einval_msg);
talloc_free(tmp_ctx);
return EOK;
}
diff --git a/server/infopipe/infopipe.h b/server/infopipe/infopipe.h
index 9db5c0d1..ed5092ed 100644
--- a/server/infopipe/infopipe.h
+++ b/server/infopipe/infopipe.h
@@ -47,13 +47,13 @@
* org.freedesktop.DBus.Introspectable interface
*/
#define INFP_INTROSPECT "Introspect"
-int infp_introspect(DBusMessage *message, struct sbus_message_ctx *reply);
+int infp_introspect(DBusMessage *message, void *data, DBusMessage **r);
/**********************************************************
* Permission Methods (from infopipe.c) *
**********************************************************/
#define INFP_CHECK_PERMISSIONS "CheckPermissions1"
-int infp_check_permissions(DBusMessage *message, struct sbus_message_ctx *reply);
+int infp_check_permissions(DBusMessage *message, void *data, DBusMessage **r);
#define INFP_PERMISSION_METHODS \
{INFP_CHECK_PERMISSIONS,infp_check_permissions},
@@ -62,22 +62,22 @@ int infp_check_permissions(DBusMessage *message, struct sbus_message_ctx *reply)
* User Methods (from infopipe_users.c) *
**********************************************************/
#define INFP_USERS_GET_CACHED "GetCachedUsers1"
-int infp_users_get_cached(DBusMessage *message, struct sbus_message_ctx *reply);
+int infp_users_get_cached(DBusMessage *message, void *data, DBusMessage **r);
#define INFP_USERS_CREATE "CreateUser1"
-int infp_users_create(DBusMessage *message, struct sbus_message_ctx *reply);
+int infp_users_create(DBusMessage *message, void *data, DBusMessage **r);
#define INFP_USERS_DELETE "DeleteUser1"
-int infp_users_delete(DBusMessage *message, struct sbus_message_ctx *reply);
+int infp_users_delete(DBusMessage *message, void *data, DBusMessage **r);
#define INFP_USERS_GET_ATTR "GetUserAttributes1"
-int infp_users_get_attr(DBusMessage *message, struct sbus_message_ctx *reply);
+int infp_users_get_attr(DBusMessage *message, void *data, DBusMessage **r);
#define INFP_USERS_SET_ATTR "SetUserAttributes1"
-int infp_users_set_attr(DBusMessage *message, struct sbus_message_ctx *reply);
+int infp_users_set_attr(DBusMessage *message, void *data, DBusMessage **r);
#define INFP_USERS_SET_UID "Set_YouReallyDoNotWantToUseThisFunction_UserUID1"
-int infp_users_set_uid(DBusMessage *message, struct sbus_message_ctx *reply);
+int infp_users_set_uid(DBusMessage *message, void *data, DBusMessage **r);
#define INFP_USER_METHODS \
{INFP_USERS_GET_CACHED, infp_users_get_cached}, \
@@ -92,19 +92,19 @@ int infp_users_set_uid(DBusMessage *message, struct sbus_message_ctx *reply);
**********************************************************/
#define INFP_GROUPS_CREATE "CreateGroup1"
-int infp_groups_create(DBusMessage *message, struct sbus_message_ctx *reply);
+int infp_groups_create(DBusMessage *message, void *data, DBusMessage **r);
#define INFP_GROUPS_DELETE "DeleteGroup1"
-int infp_groups_delete(DBusMessage *message, struct sbus_message_ctx *reply);
+int infp_groups_delete(DBusMessage *message, void *data, DBusMessage **r);
#define INFP_GROUPS_ADD_MEMBERS "AddGroupMembers1"
-int infp_groups_add_members(DBusMessage *message, struct sbus_message_ctx *reply);
+int infp_groups_add_members(DBusMessage *message, void *data, DBusMessage **r);
#define INFP_GROUPS_REMOVE_MEMBERS "RemoveGroupMembers1"
-int infp_groups_remove_members(DBusMessage *message, struct sbus_message_ctx *reply);
+int infp_groups_remove_members(DBusMessage *message, void *data, DBusMessage **r);
#define INFP_GROUPS_SET_GID "Set_YouReallyDoNotWantToUseThisFunction_GroupGID1"
-int infp_groups_set_gid(DBusMessage *message, struct sbus_message_ctx *reply);
+int infp_groups_set_gid(DBusMessage *message, void *data, DBusMessage **r);
#define INFP_GROUP_METHODS \
{INFP_GROUPS_CREATE, infp_groups_create}, \
diff --git a/server/infopipe/infopipe_groups.c b/server/infopipe/infopipe_groups.c
index 6aa115f8..4b9cfc22 100644
--- a/server/infopipe/infopipe_groups.c
+++ b/server/infopipe/infopipe_groups.c
@@ -23,32 +23,32 @@
#include "util/util.h"
#include "infopipe.h"
-int infp_groups_create(DBusMessage *message, struct sbus_message_ctx *reply)
+int infp_groups_create(DBusMessage *message, void *data, DBusMessage **r)
{
- reply->reply_message = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
+ *r = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
return EOK;
}
-int infp_groups_delete(DBusMessage *message, struct sbus_message_ctx *reply)
+int infp_groups_delete(DBusMessage *message, void *data, DBusMessage **r)
{
- reply->reply_message = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
+ *r = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
return EOK;
}
-int infp_groups_add_members(DBusMessage *message, struct sbus_message_ctx *reply)
+int infp_groups_add_members(DBusMessage *message, void *data, DBusMessage **r)
{
- reply->reply_message = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
+ *r = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
return EOK;
}
-int infp_groups_remove_members(DBusMessage *message, struct sbus_message_ctx *reply)
+int infp_groups_remove_members(DBusMessage *message, void *data, DBusMessage **r)
{
- reply->reply_message = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
+ *r = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
return EOK;
}
-int infp_groups_set_gid(DBusMessage *message, struct sbus_message_ctx *reply)
+int infp_groups_set_gid(DBusMessage *message, void *data, DBusMessage **r)
{
- reply->reply_message = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
+ *r = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
return EOK;
}
diff --git a/server/infopipe/infopipe_users.c b/server/infopipe/infopipe_users.c
index 566d5e16..632e624f 100644
--- a/server/infopipe/infopipe_users.c
+++ b/server/infopipe/infopipe_users.c
@@ -22,38 +22,38 @@
#include "util/util.h"
#include "infopipe.h"
-int infp_users_get_cached(DBusMessage *message, struct sbus_message_ctx *reply)
+int infp_users_get_cached(DBusMessage *message, void *data, DBusMessage **r)
{
- reply->reply_message = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
+ *r = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
return EOK;
}
-int infp_users_create(DBusMessage *message, struct sbus_message_ctx *reply)
+int infp_users_create(DBusMessage *message, void *data, DBusMessage **r)
{
- reply->reply_message = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
+ *r = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
return EOK;
}
-int infp_users_delete(DBusMessage *message, struct sbus_message_ctx *reply)
+int infp_users_delete(DBusMessage *message, void *data, DBusMessage **r)
{
- reply->reply_message = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
+ *r = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
return EOK;
}
-int infp_users_get_attr(DBusMessage *message, struct sbus_message_ctx *reply)
+int infp_users_get_attr(DBusMessage *message, void *data, DBusMessage **r)
{
- reply->reply_message = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
+ *r = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
return EOK;
}
-int infp_users_set_attr(DBusMessage *message, struct sbus_message_ctx *reply)
+int infp_users_set_attr(DBusMessage *message, void *data, DBusMessage **r)
{
- reply->reply_message = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
+ *r = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
return EOK;
}
-int infp_users_set_uid(DBusMessage *message, struct sbus_message_ctx *reply)
+int infp_users_set_uid(DBusMessage *message, void *data, DBusMessage **r)
{
- reply->reply_message = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
+ *r = dbus_message_new_error(message, DBUS_ERROR_NOT_SUPPORTED, "Not yet implemented");
return EOK;
}
diff --git a/server/monitor/monitor.c b/server/monitor/monitor.c
index 45191a68..166cf3cd 100644
--- a/server/monitor/monitor.c
+++ b/server/monitor/monitor.c
@@ -88,19 +88,22 @@ static void set_global_checker(struct mt_ctx *ctx);
/* dbus_get_monitor_version
* Return the monitor version over D-BUS */
static int dbus_get_monitor_version(DBusMessage *message,
- struct sbus_message_ctx *reply)
+ void *data,
+ DBusMessage **r)
{
const char *version = MONITOR_VERSION;
+ DBusMessage *reply;
dbus_bool_t ret;
- reply->reply_message = dbus_message_new_method_return(message);
- ret = dbus_message_append_args(reply->reply_message, DBUS_TYPE_STRING,
+ reply = dbus_message_new_method_return(message);
+ ret = dbus_message_append_args(reply, DBUS_TYPE_STRING,
&version, DBUS_TYPE_INVALID);
if (!ret) {
return EIO;
}
+ *r = reply;
return EOK;
}
diff --git a/server/nss/nsssrv.c b/server/nss/nsssrv.c
index 0909f629..b6191cce 100644
--- a/server/nss/nsssrv.c
+++ b/server/nss/nsssrv.c
@@ -44,9 +44,9 @@
#define SSS_NSS_PIPE_NAME "nss"
-static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply);
-static int service_pong(DBusMessage *message, struct sbus_message_ctx *reply);
-static int service_reload(DBusMessage *message, struct sbus_message_ctx *reply);
+static int service_identity(DBusMessage *message, void *data, DBusMessage **r);
+static int service_pong(DBusMessage *message, void *data, DBusMessage **r);
+static int service_reload(DBusMessage *message, void *data, DBusMessage **r);
static int nss_init_domains(struct nss_ctx *nctx);
static int _domain_comparator(const void *key1, const void *key2);
@@ -227,17 +227,18 @@ static void accept_fd_handler(struct event_context *ev,
return;
}
-static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply)
+static int service_identity(DBusMessage *message, void *data, DBusMessage **r)
{
dbus_uint16_t version = NSS_SBUS_SERVICE_VERSION;
- const char *name = NSS_SBUS_SERVICE_NAME;\
+ const char *name = NSS_SBUS_SERVICE_NAME;
+ DBusMessage *reply;
dbus_bool_t ret;
DEBUG(4,("Sending ID reply: (%s,%d)\n",
name, version));
- reply->reply_message = dbus_message_new_method_return(message);
- ret = dbus_message_append_args(reply->reply_message,
+ reply = dbus_message_new_method_return(message);
+ ret = dbus_message_append_args(reply,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_UINT16, &version,
DBUS_TYPE_INVALID);
@@ -245,30 +246,33 @@ static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply
return EIO;
}
+ *r = reply;
return EOK;
}
-static int service_pong(DBusMessage *message, struct sbus_message_ctx *reply)
+static int service_pong(DBusMessage *message, void *data, DBusMessage **r)
{
+ DBusMessage *reply;
dbus_bool_t ret;
- reply->reply_message = dbus_message_new_method_return(message);
- ret = dbus_message_append_args(reply->reply_message, DBUS_TYPE_INVALID);
+ reply = dbus_message_new_method_return(message);
+ ret = dbus_message_append_args(reply, DBUS_TYPE_INVALID);
if (!ret) {
return EIO;
}
+ *r = reply;
return EOK;
}
-static int service_reload(DBusMessage *message, struct sbus_message_ctx *reply) {
+static int service_reload(DBusMessage *message, void *data, DBusMessage **r) {
/* Monitor calls this function when we need to reload
* our configuration information. Perform whatever steps
* are needed to update the configuration objects.
*/
/* Send an empty reply to acknowledge receipt */
- return service_pong(message, reply);
+ return service_pong(message, data, r);
}
static int nss_sbus_init(struct nss_ctx *nctx)
diff --git a/server/nss/nsssrv_dp.c b/server/nss/nsssrv_dp.c
index b5746e86..487ac285 100644
--- a/server/nss/nsssrv_dp.c
+++ b/server/nss/nsssrv_dp.c
@@ -281,19 +281,20 @@ done:
return err;
}
-static int nss_dp_identity(DBusMessage *message, struct sbus_message_ctx *reply)
+static int nss_dp_identity(DBusMessage *message, void *data, DBusMessage **r)
{
dbus_uint16_t version = DATA_PROVIDER_VERSION;
dbus_uint16_t clitype = DP_CLI_FRONTEND;
const char *cliname = "NSS";
const char *nullname = "";
+ DBusMessage *reply;
dbus_bool_t ret;
DEBUG(4,("Sending ID reply: (%d,%d,%s)\n",
clitype, version, cliname));
- reply->reply_message = dbus_message_new_method_return(message);
- ret = dbus_message_append_args(reply->reply_message,
+ reply = dbus_message_new_method_return(message);
+ ret = dbus_message_append_args(reply,
DBUS_TYPE_UINT16, &clitype,
DBUS_TYPE_UINT16, &version,
DBUS_TYPE_STRING, &cliname,
@@ -303,6 +304,7 @@ static int nss_dp_identity(DBusMessage *message, struct sbus_message_ctx *reply)
return EIO;
}
+ *r = reply;
return EOK;
}
diff --git a/server/polkit/sssd_polkit.c b/server/polkit/sssd_polkit.c
index 9eda5373..6c7d0e1e 100644
--- a/server/polkit/sssd_polkit.c
+++ b/server/polkit/sssd_polkit.c
@@ -35,16 +35,17 @@ struct spk_ctx {
struct sbus_srv_ctx *sbus_srv;
};
-static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply)
+static int service_identity(DBusMessage *message, void *data, DBusMessage **r)
{
dbus_uint16_t version = POLKIT_VERSION;
const char *name = POLKIT_SERVICE_NAME;
+ DBusMessage *reply;
dbus_bool_t ret;
DEBUG(4, ("Sending identity data [%s,%d]\n", name, version));
- reply->reply_message = dbus_message_new_method_return(message);
- ret = dbus_message_append_args(reply->reply_message,
+ reply = dbus_message_new_method_return(message);
+ ret = dbus_message_append_args(reply,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_UINT16, &version,
DBUS_TYPE_INVALID);
@@ -52,30 +53,33 @@ static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply
return EIO;
}
+ *r = reply;
return EOK;
}
-static int service_pong(DBusMessage *message, struct sbus_message_ctx *reply)
+static int service_pong(DBusMessage *message, void *data, DBusMessage **r)
{
+ DBusMessage *reply;
dbus_bool_t ret;
- reply->reply_message = dbus_message_new_method_return(message);
- ret = dbus_message_append_args(reply->reply_message, DBUS_TYPE_INVALID);
+ reply = dbus_message_new_method_return(message);
+ ret = dbus_message_append_args(reply, DBUS_TYPE_INVALID);
if (!ret) {
return EIO;
}
+ *r = reply;
return EOK;
}
-static int service_reload(DBusMessage *message, struct sbus_message_ctx *reply) {
+static int service_reload(DBusMessage *message, void *data, DBusMessage **r) {
/* Monitor calls this function when we need to reload
* our configuration information. Perform whatever steps
* are needed to update the configuration objects.
*/
/* Send an empty reply to acknowledge receipt */
- return service_pong(message, reply);
+ return service_pong(message, data, r);
}
struct sbus_method mon_sbus_methods[] = {
diff --git a/server/providers/data_provider.c b/server/providers/data_provider.c
index c1dc2801..aa66c8e5 100644
--- a/server/providers/data_provider.c
+++ b/server/providers/data_provider.c
@@ -76,9 +76,9 @@ struct dp_frontend {
static int dp_backend_destructor(void *ctx);
static int dp_frontend_destructor(void *ctx);
-static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply);
-static int service_pong(DBusMessage *message, struct sbus_message_ctx *reply);
-static int service_reload(DBusMessage *message, struct sbus_message_ctx *reply);
+static int service_identity(DBusMessage *message, void *data, DBusMessage **r);
+static int service_pong(DBusMessage *message, void *data, DBusMessage **r);
+static int service_reload(DBusMessage *message, void *data, DBusMessage **r);
struct sbus_method mon_sbus_methods[] = {
{ SERVICE_METHOD_IDENTITY, service_identity },
@@ -87,7 +87,7 @@ struct sbus_method mon_sbus_methods[] = {
{ NULL, NULL }
};
-static int dp_get_account_info(DBusMessage *message, struct sbus_message_ctx *reply);
+static int dp_get_account_info(DBusMessage *message, void *data, DBusMessage **r);
struct sbus_method dp_sbus_methods[] = {
{ DP_SRV_METHOD_GETACCTINFO, dp_get_account_info },
@@ -108,16 +108,17 @@ struct dp_be_request {
struct dp_backend *be;
};
-static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply)
+static int service_identity(DBusMessage *message, void *data, DBusMessage **r)
{
dbus_uint16_t version = DATA_PROVIDER_VERSION;
const char *name = DATA_PROVIDER_SERVICE_NAME;
+ DBusMessage *reply;
dbus_bool_t ret;
DEBUG(4, ("Sending identity data [%s,%d]\n", name, version));
- reply->reply_message = dbus_message_new_method_return(message);
- ret = dbus_message_append_args(reply->reply_message,
+ reply = dbus_message_new_method_return(message);
+ ret = dbus_message_append_args(reply,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_UINT16, &version,
DBUS_TYPE_INVALID);
@@ -125,30 +126,33 @@ static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply
return EIO;
}
+ *r = reply;
return EOK;
}
-static int service_pong(DBusMessage *message, struct sbus_message_ctx *reply)
+static int service_pong(DBusMessage *message, void *data, DBusMessage **r)
{
+ DBusMessage *reply;
dbus_bool_t ret;
- reply->reply_message = dbus_message_new_method_return(message);
- ret = dbus_message_append_args(reply->reply_message, DBUS_TYPE_INVALID);
+ reply = dbus_message_new_method_return(message);
+ ret = dbus_message_append_args(reply, DBUS_TYPE_INVALID);
if (!ret) {
return EIO;
}
+ *r = reply;
return EOK;
}
-static int service_reload(DBusMessage *message, struct sbus_message_ctx *reply) {
+static int service_reload(DBusMessage *message, void *data, DBusMessage **r) {
/* Monitor calls this function when we need to reload
* our configuration information. Perform whatever steps
* are needed to update the configuration objects.
*/
/* Send an empty reply to acknowledge receipt */
- return service_pong(message, reply);
+ return service_pong(message, data, r);
}
static int dp_monitor_init(struct dp_ctx *dpctx)
@@ -534,13 +538,14 @@ static int dp_send_acct_req(struct dp_be_request *bereq,
return EOK;
}
-static int dp_get_account_info(DBusMessage *message, struct sbus_message_ctx *reply)
+static int dp_get_account_info(DBusMessage *message, void *data, DBusMessage **r)
{
struct sbus_message_handler_ctx *smh_ctx;
struct dp_client *dpcli;
struct dp_be_request *bereq;
struct dp_request *dpreq = NULL;
struct dp_backend *dpbe;
+ DBusMessage *reply;
DBusError dbus_error;
dbus_bool_t dbret;
void *user_data;
@@ -549,11 +554,9 @@ static int dp_get_account_info(DBusMessage *message, struct sbus_message_ctx *re
const char *errmsg = NULL;
int dpret = 0, ret = 0;
- if (!reply) return EINVAL;
-
- smh_ctx = reply->mh_ctx;
+ if (!data) return EINVAL;
+ smh_ctx = talloc_get_type(data, struct sbus_message_handler_ctx);
if (!smh_ctx) return EINVAL;
-
user_data = sbus_conn_get_private_data(smh_ctx->conn_ctx);
if (!user_data) return EINVAL;
dpcli = talloc_get_type(user_data, struct dp_client);
@@ -575,7 +578,7 @@ static int dp_get_account_info(DBusMessage *message, struct sbus_message_ctx *re
DEBUG(4, ("Got request for [%s][%u][%s][%s]\n",
domain, type, attrs, filter));
- reply->reply_message = dbus_message_new_method_return(message);
+ reply = dbus_message_new_method_return(message);
/* search for domain */
if (!domain) {
@@ -603,7 +606,7 @@ static int dp_get_account_info(DBusMessage *message, struct sbus_message_ctx *re
goto respond;
}
- dpreq->reply = reply->reply_message;
+ dpreq->reply = reply;
dpreq->src_cli = dpcli;
dpreq->pending_replies = 0;
@@ -659,7 +662,7 @@ static int dp_get_account_info(DBusMessage *message, struct sbus_message_ctx *re
goto respond;
}
- dpreq->reply = reply->reply_message;
+ dpreq->reply = reply;
dpreq->src_cli = dpcli;
dpreq->pending_replies = 1;
@@ -695,13 +698,14 @@ static int dp_get_account_info(DBusMessage *message, struct sbus_message_ctx *re
return EOK;
respond:
- dbret = dbus_message_append_args(reply->reply_message,
+ dbret = dbus_message_append_args(reply,
DBUS_TYPE_UINT16, &dpret,
DBUS_TYPE_UINT32, &ret,
DBUS_TYPE_STRING, &errmsg,
DBUS_TYPE_INVALID);
if (!dbret) return EIO;
+ *r = reply;
return EOK;
}
diff --git a/server/providers/data_provider_be.c b/server/providers/data_provider_be.c
index c12e2b2f..7b491ce7 100644
--- a/server/providers/data_provider_be.c
+++ b/server/providers/data_provider_be.c
@@ -44,8 +44,8 @@
typedef int (*be_init_fn_t)(TALLOC_CTX *, struct be_mod_ops **, void **);
-static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply);
-static int service_pong(DBusMessage *message, struct sbus_message_ctx *reply);
+static int service_identity(DBusMessage *message, void *data, DBusMessage **r);
+static int service_pong(DBusMessage *message, void *data, DBusMessage **r);
struct sbus_method mon_sbus_methods[] = {
{ SERVICE_METHOD_IDENTITY, service_identity },
@@ -53,9 +53,9 @@ struct sbus_method mon_sbus_methods[] = {
{ NULL, NULL }
};
-static int be_identity(DBusMessage *message, struct sbus_message_ctx *reply);
-static int be_check_online(DBusMessage *message, struct sbus_message_ctx *reply);
-static int be_get_account_info(DBusMessage *message, struct sbus_message_ctx *reply);
+static int be_identity(DBusMessage *message, void *data, DBusMessage **r);
+static int be_check_online(DBusMessage *message, void *data, DBusMessage **r);
+static int be_get_account_info(DBusMessage *message, void *data, DBusMessage **r);
struct sbus_method be_methods[] = {
{ DP_CLI_METHOD_IDENTITY, be_identity },
@@ -64,16 +64,17 @@ struct sbus_method be_methods[] = {
{ NULL, NULL }
};
-static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply)
+static int service_identity(DBusMessage *message, void *data, DBusMessage **r)
{
dbus_uint16_t version = DATA_PROVIDER_VERSION;
struct sbus_message_handler_ctx *smh_ctx;
struct be_ctx *ctx;
+ DBusMessage *reply;
dbus_bool_t ret;
void *user_data;
- if (!reply) return EINVAL;
- smh_ctx = reply->mh_ctx;
+ if (!data) return EINVAL;
+ smh_ctx = talloc_get_type(data, struct sbus_message_handler_ctx);
if (!smh_ctx) return EINVAL;
user_data = sbus_conn_get_private_data(smh_ctx->conn_ctx);
if (!user_data) return EINVAL;
@@ -82,8 +83,8 @@ static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply
DEBUG(4,("Sending ID reply: (%s,%d)\n", ctx->identity, version));
- reply->reply_message = dbus_message_new_method_return(message);
- ret = dbus_message_append_args(reply->reply_message,
+ reply = dbus_message_new_method_return(message);
+ ret = dbus_message_append_args(reply,
DBUS_TYPE_STRING, &ctx->identity,
DBUS_TYPE_UINT16, &version,
DBUS_TYPE_INVALID);
@@ -91,33 +92,37 @@ static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply
return EIO;
}
+ *r = reply;
return EOK;
}
-static int service_pong(DBusMessage *message, struct sbus_message_ctx *reply)
+static int service_pong(DBusMessage *message, void *data, DBusMessage **r)
{
+ DBusMessage *reply;
dbus_bool_t ret;
- reply->reply_message = dbus_message_new_method_return(message);
- ret = dbus_message_append_args(reply->reply_message, DBUS_TYPE_INVALID);
+ reply = dbus_message_new_method_return(message);
+ ret = dbus_message_append_args(reply, DBUS_TYPE_INVALID);
if (!ret) {
return EIO;
}
+ *r = reply;
return EOK;
}
-static int be_identity(DBusMessage *message, struct sbus_message_ctx *reply)
+static int be_identity(DBusMessage *message, void *data, DBusMessage **r)
{
dbus_uint16_t version = DATA_PROVIDER_VERSION;
dbus_uint16_t clitype = DP_CLI_BACKEND;
struct sbus_message_handler_ctx *smh_ctx;
struct be_ctx *ctx;
+ DBusMessage *reply;
dbus_bool_t ret;
void *user_data;
- if (!reply) return EINVAL;
- smh_ctx = reply->mh_ctx;
+ if (!data) return EINVAL;
+ smh_ctx = talloc_get_type(data, struct sbus_message_handler_ctx);
if (!smh_ctx) return EINVAL;
user_data = sbus_conn_get_private_data(smh_ctx->conn_ctx);
if (!user_data) return EINVAL;
@@ -127,8 +132,8 @@ static int be_identity(DBusMessage *message, struct sbus_message_ctx *reply)
DEBUG(4,("Sending ID reply: (%d,%d,%s,%s)\n",
clitype, version, ctx->name, ctx->domain));
- reply->reply_message = dbus_message_new_method_return(message);
- ret = dbus_message_append_args(reply->reply_message,
+ reply = dbus_message_new_method_return(message);
+ ret = dbus_message_append_args(reply,
DBUS_TYPE_UINT16, &clitype,
DBUS_TYPE_UINT16, &version,
DBUS_TYPE_STRING, &ctx->name,
@@ -138,6 +143,7 @@ static int be_identity(DBusMessage *message, struct sbus_message_ctx *reply)
return EIO;
}
+ *r = reply;
return EOK;
}
@@ -231,12 +237,13 @@ static void online_chk_callback(struct be_req *req, int status,
}
-static int be_check_online(DBusMessage *message, struct sbus_message_ctx *reply)
+static int be_check_online(DBusMessage *message, void *data, DBusMessage **r)
{
struct sbus_message_handler_ctx *smh_ctx;
struct be_online_req *req;
struct be_req *be_req;
struct be_ctx *ctx;
+ DBusMessage *reply;
dbus_bool_t dbret;
void *user_data;
int ret;
@@ -245,15 +252,15 @@ static int be_check_online(DBusMessage *message, struct sbus_message_ctx *reply)
dbus_uint32_t err_min;
const char *err_msg;
- if (!reply) return EINVAL;
- smh_ctx = reply->mh_ctx;
+ if (!data) return EINVAL;
+ smh_ctx = talloc_get_type(data, struct sbus_message_handler_ctx);
if (!smh_ctx) return EINVAL;
user_data = sbus_conn_get_private_data(smh_ctx->conn_ctx);
if (!user_data) return EINVAL;
ctx = talloc_get_type(user_data, struct be_ctx);
if (!ctx) return EINVAL;
- reply->reply_message = dbus_message_new_method_return(message);
+ reply = dbus_message_new_method_return(message);
/* process request */
be_req = talloc(ctx, struct be_req);
@@ -266,7 +273,7 @@ static int be_check_online(DBusMessage *message, struct sbus_message_ctx *reply)
}
be_req->be_ctx = ctx;
be_req->fn = online_chk_callback;
- be_req->pvt = reply->reply_message;
+ be_req->pvt = reply;
req = talloc(be_req, struct be_online_req);
if (!req) {
@@ -296,7 +303,7 @@ done:
talloc_free(be_req);
}
- dbret = dbus_message_append_args(reply->reply_message,
+ dbret = dbus_message_append_args(reply,
DBUS_TYPE_UINT16, &online,
DBUS_TYPE_UINT16, &err_maj,
DBUS_TYPE_UINT32, &err_min,
@@ -304,6 +311,7 @@ done:
DBUS_TYPE_INVALID);
if (!dbret) return EIO;
+ *r = reply;
return EOK;
}
@@ -347,12 +355,13 @@ static void acctinfo_callback(struct be_req *req, int status,
talloc_free(req);
}
-static int be_get_account_info(DBusMessage *message, struct sbus_message_ctx *reply)
+static int be_get_account_info(DBusMessage *message, void *data, DBusMessage **r)
{
struct sbus_message_handler_ctx *smh_ctx;
struct be_acct_req *req;
struct be_req *be_req;
struct be_ctx *ctx;
+ DBusMessage *reply;
DBusError dbus_error;
dbus_bool_t dbret;
void *user_data;
@@ -366,9 +375,10 @@ static int be_get_account_info(DBusMessage *message, struct sbus_message_ctx *re
const char *err_msg;
be_req = NULL;
+ *r = NULL;
- if (!reply) return EINVAL;
- smh_ctx = reply->mh_ctx;
+ if (!data) return EINVAL;
+ smh_ctx = talloc_get_type(data, struct sbus_message_handler_ctx);
if (!smh_ctx) return EINVAL;
user_data = sbus_conn_get_private_data(smh_ctx->conn_ctx);
if (!user_data) return EINVAL;
@@ -389,7 +399,7 @@ static int be_get_account_info(DBusMessage *message, struct sbus_message_ctx *re
DEBUG(4, ("Got request for [%u][%s][%s]\n", type, attrs, filter));
- reply->reply_message = dbus_message_new_method_return(message);
+ reply = dbus_message_new_method_return(message);
if (attrs) {
if (strcmp(attrs, "core") == 0) attr_type = BE_ATTR_CORE;
@@ -438,7 +448,7 @@ static int be_get_account_info(DBusMessage *message, struct sbus_message_ctx *re
}
be_req->be_ctx = ctx;
be_req->fn = acctinfo_callback;
- be_req->pvt = reply->reply_message;
+ be_req->pvt = reply;
req = talloc(be_req, struct be_acct_req);
if (!req) {
@@ -469,7 +479,7 @@ done:
talloc_free(be_req);
}
- dbret = dbus_message_append_args(reply->reply_message,
+ dbret = dbus_message_append_args(reply,
DBUS_TYPE_UINT16, &err_maj,
DBUS_TYPE_UINT32, &err_min,
DBUS_TYPE_STRING, &err_msg,
@@ -479,6 +489,7 @@ done:
DEBUG(4, ("Request processed. Returned %d,%d,%s\n",
err_maj, err_min, err_msg));
+ *r = reply;
return EOK;
}
diff --git a/server/sbus/sssd_dbus.h b/server/sbus/sssd_dbus.h
index 20165ffb..5fec9c80 100644
--- a/server/sbus/sssd_dbus.h
+++ b/server/sbus/sssd_dbus.h
@@ -27,8 +27,7 @@ struct sbus_srv_ctx;
#include "dbus/dbus.h"
-struct sbus_message_ctx;
-typedef int (*sbus_msg_handler_fn)(DBusMessage *, struct sbus_message_ctx *);
+typedef int (*sbus_msg_handler_fn)(DBusMessage *, void *, DBusMessage **);
/*
* sbus_conn_destructor_fn
@@ -73,11 +72,6 @@ struct sbus_message_handler_ctx {
char *introspection_xml;
};
-struct sbus_message_ctx {
- struct sbus_message_handler_ctx *mh_ctx;
- DBusMessage *reply_message;
-};
-
/* Server Functions */
int sbus_new_server(TALLOC_CTX *mem_ctx,
struct event_context *ev, struct sbus_method_ctx *ctx,
diff --git a/server/sbus/sssd_dbus_connection.c b/server/sbus/sssd_dbus_connection.c
index 186df356..d02dc6c8 100644
--- a/server/sbus/sssd_dbus_connection.c
+++ b/server/sbus/sssd_dbus_connection.c
@@ -483,7 +483,7 @@ DBusHandlerResult sbus_message_handler(DBusConnection *conn,
const char *method;
const char *path;
const char *msg_interface;
- struct sbus_message_ctx *reply = NULL;
+ DBusMessage *reply = NULL;
int i, ret;
int found;
@@ -503,22 +503,14 @@ DBusHandlerResult sbus_message_handler(DBusConnection *conn,
if (strcmp(path, ctx->method_ctx->path) != 0)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- reply = talloc_zero(ctx, struct sbus_message_ctx);
- if (!reply) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- reply->mh_ctx = ctx;
- reply->reply_message = NULL;
-
/* Validate the method interface */
if (strcmp(msg_interface, ctx->method_ctx->interface) == 0) {
found = 0;
for (i = 0; ctx->method_ctx->methods[i].method != NULL; i++) {
if (strcmp(method, ctx->method_ctx->methods[i].method) == 0) {
found = 1;
- ret = ctx->method_ctx->methods[i].fn(message, reply);
- if (ret != EOK) {
- talloc_free(reply);
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
+ ret = ctx->method_ctx->methods[i].fn(message, ctx, &reply);
+ if (ret != EOK) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
break;
}
}
@@ -526,7 +518,7 @@ DBusHandlerResult sbus_message_handler(DBusConnection *conn,
if (!found) {
/* Reply DBUS_ERROR_UNKNOWN_METHOD */
DEBUG(1, ("No matching method found for %s.\n", method));
- reply->reply_message = dbus_message_new_error(message, DBUS_ERROR_UNKNOWN_METHOD, NULL);
+ reply = dbus_message_new_error(message, DBUS_ERROR_UNKNOWN_METHOD, NULL);
}
}
else {
@@ -540,24 +532,20 @@ DBusHandlerResult sbus_message_handler(DBusConnection *conn,
/* If we have been asked for introspection data and we have
* an introspection function registered, user that.
*/
- ret = ctx->method_ctx->introspect_fn(message, reply);
- if (ret != EOK) {
- talloc_free(reply);
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
+ ret = ctx->method_ctx->introspect_fn(message, ctx, &reply);
+ if (ret != EOK) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
}
else
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
- DEBUG(5, ("Method %s complete. Reply was %ssent.\n", method, reply->reply_message?"":"not "));
+ DEBUG(5, ("Method %s complete. Reply was %ssent.\n", method, reply?"":"not "));
- if (reply->reply_message) {
- dbus_connection_send(conn, reply->reply_message, NULL);
- dbus_message_unref(reply->reply_message);
+ if (reply) {
+ dbus_connection_send(conn, reply, NULL);
+ dbus_message_unref(reply);
}
- talloc_free(reply);
return DBUS_HANDLER_RESULT_HANDLED;
}