From 054321c995958ecc7f8e5a92f8d35c6a6bd6e809 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 6 Jan 2009 18:30:04 -0500 Subject: Add initial support to connect nss to the data provider as a frontend --- server/nss/nsssrv.c | 7 ++++++ server/nss/nsssrv.h | 1 + server/nss/nsssrv_cmd.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) (limited to 'server') diff --git a/server/nss/nsssrv.c b/server/nss/nsssrv.c index e42efacf9..bd9202bdc 100644 --- a/server/nss/nsssrv.c +++ b/server/nss/nsssrv.c @@ -40,6 +40,7 @@ #include "sbus_interfaces.h" #include "util/btreemap.h" #include "util/service_helpers.h" +#include "providers/data_provider.h" #define SSS_NSS_PIPE_NAME "nss" @@ -403,6 +404,12 @@ int nss_process_init(TALLOC_CTX *mem_ctx, return ret; } + ret = nss_cmd_init(nctx); + if (ret != EOK) { + DEBUG(0, ("fatal error setting up backend connector\n")); + return ret; + } + ret = nss_ldb_init(nctx, ev, cdb, &nctx->lctx); if (ret != EOK) { DEBUG(0, ("fatal error initializing nss_ctx\n")); diff --git a/server/nss/nsssrv.h b/server/nss/nsssrv.h index e032ae85c..223066f3d 100644 --- a/server/nss/nsssrv.h +++ b/server/nss/nsssrv.h @@ -80,6 +80,7 @@ void nss_packet_get_body(struct nss_packet *packet, uint8_t **body, size_t *blen void nss_packet_set_error(struct nss_packet *packet, int error); /* from nsssrv_cmd.c */ +int nss_cmd_init(struct nss_ctx *nctx); int nss_cmd_execute(struct cli_ctx *cctx); #endif /* __NSSSRV_H__ */ diff --git a/server/nss/nsssrv_cmd.c b/server/nss/nsssrv_cmd.c index f688b2835..a345c3a31 100644 --- a/server/nss/nsssrv_cmd.c +++ b/server/nss/nsssrv_cmd.c @@ -24,6 +24,7 @@ #include "util/util.h" #include "nss/nsssrv.h" #include "nss/nsssrv_ldb.h" +#include "providers/data_provider.h" struct nss_cmd_ctx { struct cli_ctx *cctx; @@ -207,6 +208,12 @@ done: return EOK; } +static int nss_dispatch_getpwnam(struct cli_ctx *cctx) +{ + + return EOK; +} + static int nss_cmd_getpwnam(struct cli_ctx *cctx) { struct nss_cmd_ctx *nctx; @@ -999,3 +1006,53 @@ int nss_cmd_execute(struct cli_ctx *cctx) return EINVAL; } + +static int cmd_identity(DBusMessage *message, void *data, DBusMessage **r) +{ + dbus_uint16_t version = DATA_PROVIDER_VERSION; + dbus_uint16_t clitype = DP_CLI_FRONTEND; + const char *cliname = "NSS"; + const char *nullname = ""; + DBusMessage *reply; + dbus_bool_t ret; + + DEBUG(4,("Sending ID reply: (%d,%d,%s)\n", + clitype, version, cliname)); + + reply = dbus_message_new_method_return(message); + ret = dbus_message_append_args(reply, + DBUS_TYPE_UINT16, &clitype, + DBUS_TYPE_UINT16, &version, + DBUS_TYPE_STRING, &cliname, + DBUS_TYPE_STRING, &nullname, + DBUS_TYPE_INVALID); + if (!ret) { + return EIO; + } + + *r = reply; + return EOK; +} + +struct sbus_method nss_dp_methods[] = { + { DP_CLI_METHOD_IDENTITY, cmd_identity }, + { NULL, NULL } +}; + +int nss_cmd_init(struct nss_ctx *nctx) +{ + int ret; + + /* Set up SBUS connection to the data provider */ + ret = dp_sbus_cli_init(nctx, nctx->ev, nctx->cdb, + nss_dp_methods, &nctx->dp_ctx); + if (ret != EOK) { + return ret; + } + + /* attach context to the connection */ + sbus_conn_set_private_data(nctx->dp_ctx->scon_ctx, nctx); + + return EOK; +} + -- cgit