summaryrefslogtreecommitdiffstats
path: root/server/sbus
diff options
context:
space:
mode:
Diffstat (limited to 'server/sbus')
-rw-r--r--server/sbus/sssd_dbus.h11
-rw-r--r--server/sbus/sssd_dbus_connection.c23
-rw-r--r--server/sbus/sssd_dbus_server.c1
3 files changed, 19 insertions, 16 deletions
diff --git a/server/sbus/sssd_dbus.h b/server/sbus/sssd_dbus.h
index 5fec9c80a..a05d229a1 100644
--- a/server/sbus/sssd_dbus.h
+++ b/server/sbus/sssd_dbus.h
@@ -27,7 +27,7 @@ struct sbus_srv_ctx;
#include "dbus/dbus.h"
-typedef int (*sbus_msg_handler_fn)(DBusMessage *, void *, DBusMessage **);
+typedef int (*sbus_msg_handler_fn)(DBusMessage *, struct sbus_conn_ctx *);
/*
* sbus_conn_destructor_fn
@@ -66,12 +66,6 @@ struct sbus_method_ctx {
sbus_msg_handler_fn introspect_fn;
};
-struct sbus_message_handler_ctx {
- struct sbus_conn_ctx *conn_ctx;
- struct sbus_method_ctx *method_ctx;
- char *introspection_xml;
-};
-
/* Server Functions */
int sbus_new_server(TALLOC_CTX *mem_ctx,
struct event_context *ev, struct sbus_method_ctx *ctx,
@@ -129,4 +123,7 @@ DBusHandlerResult sbus_message_handler(DBusConnection *conn,
DBusMessage *message,
void *user_data);
+void sbus_conn_send_reply(struct sbus_conn_ctx *conn_ctx,
+ DBusMessage *reply);
+
#endif /* _SSSD_DBUS_H_*/
diff --git a/server/sbus/sssd_dbus_connection.c b/server/sbus/sssd_dbus_connection.c
index d02dc6c85..9b3da9cc1 100644
--- a/server/sbus/sssd_dbus_connection.c
+++ b/server/sbus/sssd_dbus_connection.c
@@ -18,6 +18,11 @@ struct sbus_conn_ctx {
void *pvt_data; /* Private data for this connection */
};
+struct sbus_message_handler_ctx {
+ struct sbus_conn_ctx *conn_ctx;
+ struct sbus_method_ctx *method_ctx;
+};
+
struct sbus_conn_watch_ctx {
DBusWatch *watch;
int fd;
@@ -354,6 +359,7 @@ int sbus_new_connection(TALLOC_CTX *ctx, struct event_context *ev,
if (!dbus_conn) {
DEBUG(1, ("Failed to open connection: name=%s, message=%s\n",
dbus_error.name, dbus_error.message));
+ if (dbus_error_is_set(&dbus_error)) dbus_error_free(&dbus_error);
return EIO;
}
@@ -509,7 +515,7 @@ DBusHandlerResult sbus_message_handler(DBusConnection *conn,
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, ctx, &reply);
+ ret = ctx->method_ctx->methods[i].fn(message, ctx->conn_ctx);
if (ret != EOK) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
break;
}
@@ -532,7 +538,7 @@ 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, ctx, &reply);
+ ret = ctx->method_ctx->introspect_fn(message, ctx->conn_ctx);
if (ret != EOK) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
}
@@ -540,13 +546,6 @@ DBusHandlerResult sbus_message_handler(DBusConnection *conn,
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
- DEBUG(5, ("Method %s complete. Reply was %ssent.\n", method, reply?"":"not "));
-
- if (reply) {
- dbus_connection_send(conn, reply, NULL);
- dbus_message_unref(reply);
- }
-
return DBUS_HANDLER_RESULT_HANDLED;
}
@@ -654,3 +653,9 @@ bool sbus_conn_disconnecting(struct sbus_conn_ctx *conn_ctx)
if (conn_ctx->disconnect == 1) return true;
return false;
}
+
+void sbus_conn_send_reply(struct sbus_conn_ctx *conn_ctx, DBusMessage *reply)
+{
+ dbus_connection_send(conn_ctx->conn, reply, NULL);
+}
+
diff --git a/server/sbus/sssd_dbus_server.c b/server/sbus/sssd_dbus_server.c
index 03cd6524f..eae1ce67c 100644
--- a/server/sbus/sssd_dbus_server.c
+++ b/server/sbus/sssd_dbus_server.c
@@ -272,6 +272,7 @@ int sbus_new_server(TALLOC_CTX *mem_ctx,
if (!dbus_server) {
DEBUG(1,("dbus_server_listen failed! (name=%s, message=%s)\n",
dbus_error.name, dbus_error.message));
+ if (dbus_error_is_set(&dbus_error)) dbus_error_free(&dbus_error);
return EIO;
}