summaryrefslogtreecommitdiffstats
path: root/server/sbus
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2009-02-23 08:46:46 -0500
committerSimo Sorce <idra@samba.org>2009-02-23 10:26:22 -0500
commitf8469b71247b5a41cfdf0f54c25ceda1552e0ee9 (patch)
treee61b1ab3b30174ea76c05120acfbe02640377b0e /server/sbus
parent70901a109f546b0d5adcbb01430649cddf607e35 (diff)
downloadsssd-f8469b71247b5a41cfdf0f54c25ceda1552e0ee9.tar.gz
sssd-f8469b71247b5a41cfdf0f54c25ceda1552e0ee9.tar.xz
sssd-f8469b71247b5a41cfdf0f54c25ceda1552e0ee9.zip
Attach the InfoPipe to the D-BUS system bus. InfoPipe is now capable of listening for requests to org.freeipa.sssd.infopipe
I made the sbus_add_connection function public so that I could use it for system bus connections. Adding initial framework for the InfoPipe Updating sysdb tests for the refactored sysdb methods.
Diffstat (limited to 'server/sbus')
-rw-r--r--server/sbus/sssd_dbus.h31
-rw-r--r--server/sbus/sssd_dbus_connection.c28
-rw-r--r--server/sbus/sssd_dbus_private.h6
3 files changed, 55 insertions, 10 deletions
diff --git a/server/sbus/sssd_dbus.h b/server/sbus/sssd_dbus.h
index 51a16e203..c75bbc937 100644
--- a/server/sbus/sssd_dbus.h
+++ b/server/sbus/sssd_dbus.h
@@ -48,6 +48,10 @@ enum {
SBUS_CONN_TYPE_SHARED
};
+/* Special interface and method for D-BUS introspection */
+#define DBUS_INTROSPECT_INTERFACE "org.freedesktop.DBus.Introspectable"
+#define DBUS_INTROSPECT_METHOD "Introspect"
+
struct sbus_method {
const char *method;
sbus_msg_handler_fn fn;
@@ -59,6 +63,7 @@ struct sbus_method_ctx {
char *path;
DBusObjectPathMessageFunction message_handler;
struct sbus_method *methods;
+ sbus_msg_handler_fn introspect_fn;
};
struct sbus_message_handler_ctx {
@@ -73,11 +78,37 @@ int sbus_new_server(TALLOC_CTX *mem_ctx,
sbus_server_conn_init_fn init_fn, void *init_pvt_data);
/* Connection Functions */
+
+/* sbus_new_connection
+ * Use this function when connecting a new process to
+ * the standard SSSD interface.
+ * This will connect to the address specified and then
+ * call sbus_add_connection to integrate with the main
+ * loop.
+ */
int sbus_new_connection(TALLOC_CTX *ctx, struct event_context *ev,
const char *address,
struct sbus_conn_ctx **conn_ctx,
sbus_conn_destructor_fn destructor);
+/* sbus_add_connection
+ * Integrates a D-BUS connection with the TEvent main
+ * loop. Use this function when you already have a
+ * DBusConnection object (for example from dbus_bus_get)
+ * Connection type can be either:
+ * SBUS_CONN_TYPE_PRIVATE: Used only from within a D-BUS
+ * server such as the Monitor in the
+ * new_connection_callback
+ * SBUS_CONN_TYPE_SHARED: Used for all D-BUS client
+ * connections, including those retrieved from
+ * dbus_bus_get
+ */
+int sbus_add_connection(TALLOC_CTX *ctx,
+ struct event_context *ev,
+ DBusConnection *dbus_conn,
+ struct sbus_conn_ctx **dct_ctx,
+ int connection_type);
+
void sbus_conn_set_destructor(struct sbus_conn_ctx *conn_ctx,
sbus_conn_destructor_fn destructor);
diff --git a/server/sbus/sssd_dbus_connection.c b/server/sbus/sssd_dbus_connection.c
index 601ca0095..d02dc6c85 100644
--- a/server/sbus/sssd_dbus_connection.c
+++ b/server/sbus/sssd_dbus_connection.c
@@ -499,12 +499,12 @@ DBusHandlerResult sbus_message_handler(DBusConnection *conn,
if (!method || !path || !msg_interface)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- /* Validate the method interface */
- if (strcmp(msg_interface, ctx->method_ctx->interface) != 0)
+ /* Validate the D-BUS path */
+ if (strcmp(path, ctx->method_ctx->path) != 0)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- /* Validate the D-BUS path */
- if (strcmp(path, ctx->method_ctx->path) == 0) {
+ /* 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) {
@@ -521,6 +521,24 @@ DBusHandlerResult sbus_message_handler(DBusConnection *conn,
reply = dbus_message_new_error(message, DBUS_ERROR_UNKNOWN_METHOD, NULL);
}
}
+ else {
+ /* Special case: check for Introspection request
+ * This is usually only useful for system bus connections
+ */
+ if (strcmp(msg_interface, DBUS_INTROSPECT_INTERFACE) == 0 &&
+ strcmp(method, DBUS_INTROSPECT_METHOD) == 0)
+ {
+ if (ctx->method_ctx->introspect_fn) {
+ /* 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);
+ 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?"":"not "));
@@ -548,6 +566,7 @@ int sbus_conn_add_method_ctx(struct sbus_conn_ctx *dct_ctx,
}
if (_method_list_contains_path(dct_ctx->method_ctx_list, method_ctx)) {
+ DEBUG(0, ("Cannot add method context with identical path.\n"));
return EINVAL;
}
@@ -579,6 +598,7 @@ int sbus_conn_add_method_ctx(struct sbus_conn_ctx *dct_ctx,
dbret = dbus_connection_register_object_path(dct_ctx->conn, method_ctx->path,
connection_vtable, msg_handler_ctx);
if (!dbret) {
+ DEBUG(0, ("Could not register object path to the connection.\n"));
return ENOMEM;
}
diff --git a/server/sbus/sssd_dbus_private.h b/server/sbus/sssd_dbus_private.h
index d102c8c9d..bcaee62cd 100644
--- a/server/sbus/sssd_dbus_private.h
+++ b/server/sbus/sssd_dbus_private.h
@@ -1,12 +1,6 @@
#ifndef _SSSD_DBUS_PRIVATE_H_
#define _SSSD_DBUS_PRIVATE_H_
-int sbus_add_connection(TALLOC_CTX *ctx,
- struct event_context *ev,
- DBusConnection *dbus_conn,
- struct sbus_conn_ctx **dct_ctx,
- int connection_type);
-
struct timeval _dbus_timeout_get_interval_tv(int interval);
void sbus_remove_watch(DBusWatch *watch, void *data);
void sbus_remove_timeout(DBusTimeout *timeout, void *data);