diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/Makefile.in | 10 | ||||
-rw-r--r-- | server/conf_macros.m4 | 14 | ||||
-rw-r--r-- | server/configure.ac | 1 | ||||
-rw-r--r-- | server/infopipe/infopipe.c | 14 | ||||
-rw-r--r-- | server/infopipe/infopipe.h | 1 | ||||
-rw-r--r-- | server/infopipe/org.freeipa.sssd.infopipe.conf | 22 | ||||
-rw-r--r-- | server/infopipe/sysbus.c | 89 | ||||
-rw-r--r-- | server/infopipe/sysbus.h | 33 | ||||
-rw-r--r-- | server/server.mk | 3 |
9 files changed, 183 insertions, 4 deletions
diff --git a/server/Makefile.in b/server/Makefile.in index 656be8a6..0206b372 100644 --- a/server/Makefile.in +++ b/server/Makefile.in @@ -61,7 +61,10 @@ OBJS = $(SERVER_OBJ) @LIBREPLACEOBJ@ $(EXTRA_OBJ) headers = +DBUS_SYSBUS_POLICY_DIR = @sysbuspath@ + LIBEXECBINS = sbin/sssd_nss sbin/sssd_dp sbin/sssd_be sbin/sssd_info sbin/sssd_pk +DBUS_SYSBUS_POLICIES = infopipe/org.freeipa.sssd.infopipe.conf BINS = sbin/sssd $(LIBEXECBINS) SOLIBS = lib/libsss_proxy.$(SHLIBEXT) @@ -90,10 +93,10 @@ distclean:: clean realdistclean:: distclean rm -f configure config.h.in -install:: all installdirs installheaders installlibs installbin +install:: all installdirs installheaders installlibs installbin installsupport installdirs:: - mkdir -p $(DESTDIR)$(includedir) $(DESTDIR)$(libdir) $(DESTDIR)$(sbindir) + mkdir -p $(DESTDIR)$(includedir) $(DESTDIR)$(libdir) $(DESTDIR)$(sbindir) $(DBUS_SYSBUS_POLICY_DIR) installheaders:: installdirs ifneq (x$(headers), x) @@ -107,4 +110,7 @@ endif installbin:: installdirs +installsupport:: installdirs + cp $(DBUS_SYSBUS_POLICIES) $(DBUS_SYSBUS_POLICY_DIR) + include $(srvdir)/server.mk diff --git a/server/conf_macros.m4 b/server/conf_macros.m4 index 9aac02c5..33290d89 100644 --- a/server/conf_macros.m4 +++ b/server/conf_macros.m4 @@ -57,3 +57,17 @@ AC_DEFUN(WITH_PIPE_PATH, AC_SUBST(pipepath) AC_DEFINE_UNQUOTED(PIPE_PATH, "$pipepath", [Where to store pipe files for the SSSD interconnects]) ]) + +AC_DEFUN(WITH_DBUS_SYSBUS_PATH, + [ AC_ARG_WITH([dbus-sysbus-path], + [AC_HELP_STRING([--with-dbus-sysbus-path=PATH], + [Where to store policy files for the D-BUS system bus [/etc/dbus-1/system.d]] + ) + ] + ) + sysbuspath="/etc/dbus-1/system.d" + if test x"$with_dbus_sysbus_path" != x; then + sysbuspath=$with_dbus_sysbus_path + fi + AC_SUBST(sysbuspath) + ]) diff --git a/server/configure.ac b/server/configure.ac index 94c057f4..54dedd9d 100644 --- a/server/configure.ac +++ b/server/configure.ac @@ -37,6 +37,7 @@ WITH_DB_PATH WITH_PLUGIN_PATH WITH_PID_PATH WITH_PIPE_PATH +WITH_DBUS_SYSBUS_PATH m4_include(pkg.m4) m4_include(libpopt.m4) 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_ */ diff --git a/server/server.mk b/server/server.mk index 54f9629a..58a49e59 100644 --- a/server/server.mk +++ b/server/server.mk @@ -32,7 +32,8 @@ NSSSRV_OBJ = \ nss/nsssrv_dp.o INFOPIPE_OBJ = \ - infopipe/infopipe.o + infopipe/infopipe.o \ + infopipe/sysbus.o POLKIT_OBJ = \ polkit/sssd_polkit.o |