diff options
-rw-r--r-- | src/responder/common/negcache.c | 35 | ||||
-rw-r--r-- | src/responder/common/negcache.h | 4 |
2 files changed, 39 insertions, 0 deletions
diff --git a/src/responder/common/negcache.c b/src/responder/common/negcache.c index 9ba24c811..5f85df25d 100644 --- a/src/responder/common/negcache.c +++ b/src/responder/common/negcache.c @@ -28,6 +28,7 @@ #define NC_ENTRY_PREFIX "NCE/" #define NC_USER_PREFIX NC_ENTRY_PREFIX"USER" #define NC_GROUP_PREFIX NC_ENTRY_PREFIX"GROUP" +#define NC_NETGROUP_PREFIX NC_ENTRY_PREFIX"NETGR" #define NC_UID_PREFIX NC_ENTRY_PREFIX"UID" #define NC_GID_PREFIX NC_ENTRY_PREFIX"GID" @@ -186,6 +187,23 @@ int sss_ncache_check_group(struct sss_nc_ctx *ctx, int ttl, return ret; } +int sss_ncache_check_netgr(struct sss_nc_ctx *ctx, int ttl, + const char *domain, const char *name) +{ + char *str; + int ret; + + if (!name || !*name) return EINVAL; + + str = talloc_asprintf(ctx, "%s/%s/%s", NC_NETGROUP_PREFIX, domain, name); + if (!str) return ENOMEM; + + ret = sss_ncache_check_str(ctx, str, ttl); + + talloc_free(str); + return ret; +} + int sss_ncache_check_uid(struct sss_nc_ctx *ctx, int ttl, uid_t uid) { char *str; @@ -248,6 +266,23 @@ int sss_ncache_set_group(struct sss_nc_ctx *ctx, bool permanent, return ret; } +int sss_ncache_set_netgr(struct sss_nc_ctx *ctx, bool permanent, + const char *domain, const char *name) +{ + char *str; + int ret; + + if (!name || !*name) return EINVAL; + + str = talloc_asprintf(ctx, "%s/%s/%s", NC_NETGROUP_PREFIX, domain, name); + if (!str) return ENOMEM; + + ret = sss_ncache_set_str(ctx, str, permanent); + + talloc_free(str); + return ret; +} + int sss_ncache_set_uid(struct sss_nc_ctx *ctx, bool permanent, uid_t uid) { char *str; diff --git a/src/responder/common/negcache.h b/src/responder/common/negcache.h index 68be9f02e..fc857fce1 100644 --- a/src/responder/common/negcache.h +++ b/src/responder/common/negcache.h @@ -32,6 +32,8 @@ int sss_ncache_check_user(struct sss_nc_ctx *ctx, int ttl, const char *domain, const char *name); int sss_ncache_check_group(struct sss_nc_ctx *ctx, int ttl, const char *domain, const char *name); +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); @@ -43,6 +45,8 @@ int sss_ncache_set_user(struct sss_nc_ctx *ctx, bool permanent, const char *domain, const char *name); int sss_ncache_set_group(struct sss_nc_ctx *ctx, bool permanent, const char *domain, const char *name); +int sss_ncache_set_netgr(struct sss_nc_ctx *ctx, bool permanent, + const char *domain, 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); |