From 7d401aae4c9794c9fbc711b21fa8b35ca7ad11b4 Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Mon, 22 Apr 2013 16:26:56 +0200 Subject: [PATCH 10/12] Add sss_ncache_set_sid() and sss_ncache_check_sid() Two new calls are added to allow to add SID based lookups to the negative cache. --- src/responder/common/negcache.c | 29 +++++++++++++++++++++++++++++ src/responder/common/negcache.h | 2 ++ 2 files changed, 31 insertions(+), 0 deletions(-) diff --git a/src/responder/common/negcache.c b/src/responder/common/negcache.c index 2e1c0af..7693463 100644 --- a/src/responder/common/negcache.c +++ b/src/responder/common/negcache.c @@ -33,6 +33,7 @@ #define NC_SERVICE_PREFIX NC_ENTRY_PREFIX"SERVICE" #define NC_UID_PREFIX NC_ENTRY_PREFIX"UID" #define NC_GID_PREFIX NC_ENTRY_PREFIX"GID" +#define NC_SID_PREFIX NC_ENTRY_PREFIX"SID" struct sss_nc_ctx { struct tdb_context *tdb; @@ -401,6 +402,20 @@ int sss_ncache_check_gid(struct sss_nc_ctx *ctx, int ttl, gid_t gid) return ret; } +int sss_ncache_check_sid(struct sss_nc_ctx *ctx, int ttl, const char *sid) +{ + char *str; + int ret; + + str = talloc_asprintf(ctx, "%s/%s", NC_SID_PREFIX, sid); + if (!str) return ENOMEM; + + ret = sss_ncache_check_str(ctx, str, ttl); + + talloc_free(str); + return ret; +} + static int sss_ncache_set_user_int(struct sss_nc_ctx *ctx, bool permanent, const char *domain, const char *name) { @@ -518,6 +533,20 @@ int sss_ncache_set_gid(struct sss_nc_ctx *ctx, bool permanent, gid_t gid) return ret; } +int sss_ncache_set_sid(struct sss_nc_ctx *ctx, bool permanent, const char *sid) +{ + char *str; + int ret; + + str = talloc_asprintf(ctx, "%s/%s", NC_SID_PREFIX, sid); + if (!str) return ENOMEM; + + ret = sss_ncache_set_str(ctx, str, permanent); + + talloc_free(str); + return ret; +} + static int delete_permanent(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *state) { diff --git a/src/responder/common/negcache.h b/src/responder/common/negcache.h index b2e6a7a..0b7e00b 100644 --- a/src/responder/common/negcache.h +++ b/src/responder/common/negcache.h @@ -36,6 +36,7 @@ int sss_ncache_check_netgr(struct sss_nc_ctx *ctx, int ttl, const char *domain, const char *name); int sss_ncache_check_uid(struct sss_nc_ctx *ctx, int ttl, uid_t uid); int sss_ncache_check_gid(struct sss_nc_ctx *ctx, int ttl, gid_t gid); +int sss_ncache_check_sid(struct sss_nc_ctx *ctx, int ttl, const char *sid); int sss_ncache_check_service(struct sss_nc_ctx *ctx, int ttl, struct sss_domain_info *dom, @@ -58,6 +59,7 @@ int sss_ncache_set_netgr(struct sss_nc_ctx *ctx, bool permanent, struct sss_domain_info *dom, const char *name); int sss_ncache_set_uid(struct sss_nc_ctx *ctx, bool permanent, uid_t uid); int sss_ncache_set_gid(struct sss_nc_ctx *ctx, bool permanent, gid_t gid); +int sss_ncache_set_sid(struct sss_nc_ctx *ctx, bool permanent, const char *sid); int sss_ncache_set_service_name(struct sss_nc_ctx *ctx, bool permanent, struct sss_domain_info *dom, const char *name, const char *proto); -- 1.7.7.6