From 6d5d337ceaee88e8031a73c10097a2e7b4fa0f25 Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Tue, 16 Apr 2013 10:48:17 +0200 Subject: [PATCH 07/12] Add idmap context to nss context This allows the nss responder to use libsss_idmap to convert between different SID representations. --- Makefile.am | 1 + src/responder/nss/nsssrv.c | 19 +++++++++++++++++++ src/responder/nss/nsssrv.h | 3 +++ 3 files changed, 23 insertions(+), 0 deletions(-) diff --git a/Makefile.am b/Makefile.am index eef1836..e79d95b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -620,6 +620,7 @@ sssd_nss_SOURCES = \ sssd_nss_LDADD = \ $(TDB_LIBS) \ $(SSSD_LIBS) \ + libsss_idmap.la \ libsss_util.la sssd_pam_SOURCES = \ diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c index 709912c..ee8fecb 100644 --- a/src/responder/nss/nsssrv.c +++ b/src/responder/nss/nsssrv.c @@ -391,6 +391,16 @@ static void nss_dp_reconnect_init(struct sbus_connection *conn, /* nss_shutdown(rctx); */ } +static void *idmap_talloc(size_t size, void *pvt) +{ + return talloc_size(pvt, size); +} + +static void idmap_free(void *ptr, void *pvt) +{ + talloc_free(ptr); +} + int nss_process_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct confdb_ctx *cdb) @@ -401,6 +411,7 @@ int nss_process_init(TALLOC_CTX *mem_ctx, struct nss_ctx *nctx; int memcache_timeout; int ret, max_retries; + enum idmap_error_code err; int hret; int fd_limit; @@ -457,6 +468,14 @@ int nss_process_init(TALLOC_CTX *mem_ctx, nss_dp_reconnect_init, iter); } + err = sss_idmap_init(idmap_talloc, nctx, idmap_free, + &nctx->idmap_ctx); + if (err != IDMAP_SUCCESS) { + DEBUG(SSSDBG_FATAL_FAILURE, ("sss_idmap_init failed.\n")); + ret = EFAULT; + goto fail; + } + /* Create the lookup table for netgroup results */ hret = sss_hash_create(nctx, 10, &nctx->netgroups); if (hret != HASH_SUCCESS) { diff --git a/src/responder/nss/nsssrv.h b/src/responder/nss/nsssrv.h index 354782b..b279f8a 100644 --- a/src/responder/nss/nsssrv.h +++ b/src/responder/nss/nsssrv.h @@ -32,6 +32,7 @@ #include "sbus/sssd_dbus.h" #include "responder/common/responder_packet.h" #include "responder/common/responder.h" +#include "lib/idmap/sss_idmap.h" #define NSS_PACKET_MAX_RECV_SIZE 1024 @@ -68,6 +69,8 @@ struct nss_ctx { struct sss_mc_ctx *pwd_mc_ctx; struct sss_mc_ctx *grp_mc_ctx; + + struct sss_idmap_ctx *idmap_ctx; }; struct nss_packet; -- 1.7.7.6