summaryrefslogtreecommitdiff
path: root/server/infopipe
diff options
context:
space:
mode:
Diffstat (limited to 'server/infopipe')
-rw-r--r--server/infopipe/infopipe.c14
-rw-r--r--server/infopipe/infopipe.h1
-rw-r--r--server/infopipe/org.freeipa.sssd.infopipe.conf22
-rw-r--r--server/infopipe/sysbus.c89
-rw-r--r--server/infopipe/sysbus.h33
5 files changed, 158 insertions, 1 deletions
diff --git a/server/infopipe/infopipe.c b/server/infopipe/infopipe.c
index 14e0354f..81541d82 100644
--- a/server/infopipe/infopipe.c
+++ b/server/infopipe/infopipe.c
@@ -24,15 +24,22 @@
#include "popt.h"
#include "infopipe.h"
#include "util/util.h"
+#include "sbus/sssd_dbus.h"
#include "sbus/sbus_client.h"
#include "monitor/monitor_sbus.h"
#include "monitor/monitor_interfaces.h"
+#include "infopipe/sysbus.h"
struct infp_ctx {
struct event_context *ev;
struct confdb_ctx *cdb;
struct service_sbus_ctx *ss_ctx;
- struct sbus_srv_ctx *sbus_srv;
+ struct sysbus_ctx *sysbus;
+};
+
+struct sbus_method infp_methods[] = {
+ { SYSBUS_GET_PARAM, sysbus_get_param },
+ { NULL, NULL }
};
static int service_identity(DBusMessage *message, void *data, DBusMessage **r)
@@ -142,10 +149,15 @@ static int infp_process_init(TALLOC_CTX *mem_ctx,
infp_ctx->ev = ev;
infp_ctx->cdb = cdb;
+ /* Connect to the monitor */
ret = infp_monitor_init(infp_ctx);
if (ret != EOK) {
DEBUG(0, ("Fatal error setting up monitor bus\n"));
}
+
+ /* Connect to the D-BUS system bus */
+ ret = sysbus_init(infp_ctx, &infp_ctx->sysbus, infp_methods);
+
return ret;
}
diff --git a/server/infopipe/infopipe.h b/server/infopipe/infopipe.h
index c888b1da..259729aa 100644
--- a/server/infopipe/infopipe.h
+++ b/server/infopipe/infopipe.h
@@ -22,6 +22,7 @@
#ifndef INFOPIPE_H_
#define INFOPIPE_H_
+#define INFOPIPE_DBUS_NAME "org.freeipa.sssd.infopipe"
#define INFOPIPE_VERSION 0x0001
#define INFOPIPE_SERVICE_NAME "infp"
diff --git a/server/infopipe/org.freeipa.sssd.infopipe.conf b/server/infopipe/org.freeipa.sssd.infopipe.conf
new file mode 100644
index 00000000..e33eb30c
--- /dev/null
+++ b/server/infopipe/org.freeipa.sssd.infopipe.conf
@@ -0,0 +1,22 @@
+<!DOCTYPE busconfig PUBLIC
+ "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+
+ <!-- This configuration file specifies the required security policies
+ for the HAL to work. -->
+
+ <!-- Only root can own the SSSD service -->
+ <policy user="root">
+ <allow own="org.freeipa.sssd.infopipe"/>
+ </policy>
+
+ <!-- Allow anyone to invoke methods on the infopipe
+ This is temporary. Real rules will be established
+ later -->
+ <policy context="default">
+ <allow send_interface="org.freeipa.sssd.infopipe"/>
+ </policy>
+
+</busconfig>
+
diff --git a/server/infopipe/sysbus.c b/server/infopipe/sysbus.c
new file mode 100644
index 00000000..2c28bacc
--- /dev/null
+++ b/server/infopipe/sysbus.c
@@ -0,0 +1,89 @@
+/*
+ SSSD
+
+ SystemBus Helpers
+
+ Copyright (C) Stephen Gallagher <sgallagh@redhat.com> 2009
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "talloc.h"
+#include "tevent.h"
+#include "util/util.h"
+#include "dbus/dbus.h"
+#include "sbus/sssd_dbus.h"
+#include "sysbus.h"
+#include "infopipe/infopipe.h"
+
+struct sysbus_ctx {
+ DBusConnection *conn;
+ struct sbus_method_ctx *method_ctx_list;
+ void *pvt_data;
+};
+
+static int sysbus_destructor(TALLOC_CTX *ctx) {
+ struct sysbus_ctx *system_bus = talloc_get_type(ctx, struct sysbus_ctx);
+ dbus_connection_unref(system_bus->conn);
+ return EOK;
+}
+
+int sysbus_init(TALLOC_CTX *mem_ctx, struct sysbus_ctx **sysbus, struct sbus_method *methods)
+{
+ DBusError dbus_error;
+ struct sysbus_ctx *system_bus;
+ int ret;
+
+ system_bus = talloc_zero(mem_ctx, struct sysbus_ctx);
+ if (system_bus == NULL) {
+ return ENOMEM;
+ }
+
+ dbus_error_init(&dbus_error);
+
+ /* Connect to the well-known system bus */
+ system_bus->conn = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error);
+ if (system_bus->conn == NULL) {
+ DEBUG(0, ("Failed to connect to D-BUS system bus.\n"));
+ talloc_free(system_bus);
+ return EIO;
+ }
+ dbus_connection_set_exit_on_disconnect(system_bus->conn, FALSE);
+ talloc_set_destructor((TALLOC_CTX *)system_bus,
+ sysbus_destructor);
+
+ ret = dbus_bus_request_name(system_bus->conn,
+ INFOPIPE_DBUS_NAME,
+ /* We want exclusive access */
+ DBUS_NAME_FLAG_DO_NOT_QUEUE,
+ &dbus_error
+ );
+ if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+ /* We were unable to register on the system bus */
+ DEBUG(0, ("Unable to request name on the system bus. Error: %s\n", dbus_error.message));
+ talloc_free(system_bus);
+ return EIO;
+ }
+
+ DEBUG(1, ("Listening on %s\n", INFOPIPE_DBUS_NAME));
+
+ *sysbus = system_bus;
+ return EOK;
+}
+
+int sysbus_get_param(DBusMessage *message, void *data, DBusMessage **r) {
+ /* TODO: remove this */
+ DEBUG(0, ("Received message. Printing this garbage.\n"));
+ return EOK;
+}
diff --git a/server/infopipe/sysbus.h b/server/infopipe/sysbus.h
new file mode 100644
index 00000000..f47219b7
--- /dev/null
+++ b/server/infopipe/sysbus.h
@@ -0,0 +1,33 @@
+/*
+ SSSD
+
+ SystemBus Helpers
+
+ Copyright (C) Stephen Gallagher <sgallagh@redhat.com> 2009
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef SYSBUS_H_
+#define SYSBUS_H_
+
+#define SYSBUS_GET_PARAM "getParam"
+
+struct sysbus_ctx;
+
+int sysbus_init(TALLOC_CTX *mem_ctx, struct sysbus_ctx **sysbus, struct sbus_method *methods);
+
+int sysbus_get_param(DBusMessage *message, void *data, DBusMessage **r);
+
+#endif /* SYSBUS_H_ */