diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2010-09-13 09:44:18 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-10-13 09:49:37 -0400 |
commit | a88dba637d6b65b92e0ac23b0e5ecadfe97adaf7 (patch) | |
tree | 992784f378781956c39f5a468898f80dc87fdd75 /src/responder | |
parent | f128b7b865062da662127712935dcc58bd022384 (diff) | |
download | sssd-a88dba637d6b65b92e0ac23b0e5ecadfe97adaf7.tar.gz sssd-a88dba637d6b65b92e0ac23b0e5ecadfe97adaf7.tar.xz sssd-a88dba637d6b65b92e0ac23b0e5ecadfe97adaf7.zip |
Add negative cache features for netgroups
Diffstat (limited to 'src/responder')
-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 9ba24c81..5f85df25 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 68be9f02..fc857fce 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); |