diff options
author | Sumit Bose <sbose@redhat.com> | 2013-04-22 16:26:56 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2013-05-02 19:33:56 +0200 |
commit | b5afbc39c09baaef57b5300b636307e277c59d66 (patch) | |
tree | a5b4174241eadc11785a37a9400a38e7966364c3 /src | |
parent | 1e72a17f6527d47968032fc928f489dad10705ea (diff) | |
download | sssd-b5afbc39c09baaef57b5300b636307e277c59d66.tar.gz sssd-b5afbc39c09baaef57b5300b636307e277c59d66.tar.bz2 sssd-b5afbc39c09baaef57b5300b636307e277c59d66.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/responder/common/negcache.c | 29 | ||||
-rw-r--r-- | 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 2e1c0af2..76934637 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 b2e6a7a9..0b7e00b0 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); |