summaryrefslogtreecommitdiff
path: root/server/nss
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2008-11-20 15:11:27 -0500
committerSimo Sorce <idra@samba.org>2008-11-20 16:22:21 -0500
commit2671d14d8068f8f0ee43cab529f10163a4b7dee1 (patch)
tree9eb2ba6a6199095d321455b245fd2fdf2cbf7643 /server/nss
parented52202447ff9e80daa64864df271988bc5332ae (diff)
downloadsssd-2671d14d8068f8f0ee43cab529f10163a4b7dee1.tar.gz
sssd-2671d14d8068f8f0ee43cab529f10163a4b7dee1.tar.bz2
sssd-2671d14d8068f8f0ee43cab529f10163a4b7dee1.zip
Created a helper function sssd_service_sbus_init() to simplify creating the initial connection to the monitor service within the child services. It will create the D-BUS connection to the monitor and configure the service to handle the mandatory getIdentity and ping methods.
Diffstat (limited to 'server/nss')
-rw-r--r--server/nss/nsssrv.c57
-rw-r--r--server/nss/nsssrv.h8
2 files changed, 14 insertions, 51 deletions
diff --git a/server/nss/nsssrv.c b/server/nss/nsssrv.c
index d66fe90c..fff563d0 100644
--- a/server/nss/nsssrv.c
+++ b/server/nss/nsssrv.c
@@ -39,6 +39,7 @@
#include "sbus/sssd_dbus.h"
#include "sbus_interfaces.h"
#include "util/btreemap.h"
+#include "util/service_helpers.h"
static int provide_identity(DBusMessage *message, void *data, DBusMessage **r);
static int reply_ping(DBusMessage *message, void *data, DBusMessage **r);
@@ -245,53 +246,21 @@ static int reply_ping(DBusMessage *message, void *data, DBusMessage **r)
static int nss_sbus_init(struct nss_ctx *nctx)
{
- struct nss_sbus_ctx *ns_ctx;
- DBusConnection *dbus_conn;
- char *sbus_address;
- int ret;
-
- ret = confdb_get_string(nctx->cdb, nctx,
- "config/services/monitor", "sbusAddress",
- DEFAULT_SBUS_ADDRESS, &sbus_address);
- if (ret != EOK) {
- return ret;
+ struct service_sbus_ctx *ss_ctx;
+
+ /* Set up SBUS connection to the monitor */
+ ss_ctx = sssd_service_sbus_init(nctx, nctx->ev, nctx->cdb,
+ provide_identity,
+ reply_ping);
+ if (ss_ctx == NULL) {
+ DEBUG(0, ("Could not initialize D-BUS.\n"));
+ return ENOMEM;
}
- ns_ctx = talloc(nctx, struct nss_sbus_ctx);
- if (!ns_ctx) {
- return ENOMEM;
- }
- ns_ctx->ev = nctx->ev;
-
- ret = sbus_new_connection(ns_ctx, ns_ctx->ev,
- sbus_address,
- &ns_ctx->scon_ctx, NULL);
- if (ret != EOK) {
- talloc_free(ns_ctx);
- return ret;
- }
-
- dbus_conn = sbus_get_connection(ns_ctx->scon_ctx);
-
- /* set up handler for service methods */
- ns_ctx->sm_ctx = talloc_zero(ns_ctx, struct sbus_method_ctx);
- if (!ns_ctx->sm_ctx) {
- talloc_free(ns_ctx);
- return ENOMEM;
- }
- ns_ctx->sm_ctx->interface = talloc_strdup(ns_ctx->sm_ctx,
- SERVICE_INTERFACE);
- ns_ctx->sm_ctx->path = talloc_strdup(ns_ctx->sm_ctx,
- SERVICE_PATH);
- if (!ns_ctx->sm_ctx->interface || !ns_ctx->sm_ctx->path) {
- talloc_free(ns_ctx);
- return ENOMEM;
- }
- ns_ctx->sm_ctx->methods = nss_sbus_methods;
- ns_ctx->sm_ctx->message_handler = sbus_message_handler;
- sbus_conn_add_method_ctx(ns_ctx->scon_ctx, ns_ctx->sm_ctx);
+ /* Set up NSS-specific listeners */
+ /* None currently used */
- nctx->ns_ctx = ns_ctx;
+ nctx->ss_ctx = ss_ctx;
return EOK;
}
diff --git a/server/nss/nsssrv.h b/server/nss/nsssrv.h
index cf07ad49..28949879 100644
--- a/server/nss/nsssrv.h
+++ b/server/nss/nsssrv.h
@@ -35,12 +35,6 @@
struct nss_ldb_ctx;
struct getent_ctx;
-struct nss_sbus_ctx {
- struct event_context *ev;
- struct sbus_method_ctx *sm_ctx;
- struct sbus_conn_ctx *scon_ctx;
-};
-
struct nss_ctx {
struct event_context *ev;
struct fd_event *lfde;
@@ -48,7 +42,7 @@ struct nss_ctx {
struct nss_ldb_ctx *lctx;
struct confdb_ctx *cdb;
char *sock_name;
- struct nss_sbus_ctx *ns_ctx;
+ struct service_sbus_ctx *ss_ctx;
struct btreemap *domain_map;
};