summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2009-01-06 18:30:04 -0500
committerSimo Sorce <idra@samba.org>2009-01-06 18:30:04 -0500
commit054321c995958ecc7f8e5a92f8d35c6a6bd6e809 (patch)
treeb02fec790d5f2af9b68a4a0cf72278f59b37b719
parent2ef9239a6a33890b4ea077ceee8d3e8d8a18cc3c (diff)
downloadsssd-054321c995958ecc7f8e5a92f8d35c6a6bd6e809.tar.gz
sssd-054321c995958ecc7f8e5a92f8d35c6a6bd6e809.tar.bz2
sssd-054321c995958ecc7f8e5a92f8d35c6a6bd6e809.zip
Add initial support to connect nss to the data provider as a frontend
-rw-r--r--server/nss/nsssrv.c7
-rw-r--r--server/nss/nsssrv.h1
-rw-r--r--server/nss/nsssrv_cmd.c57
3 files changed, 65 insertions, 0 deletions
diff --git a/server/nss/nsssrv.c b/server/nss/nsssrv.c
index e42efacf..bd9202bd 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 e032ae85..223066f3 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 f688b283..a345c3a3 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;
+}
+