diff options
author | Pavel Březina <pbrezina@redhat.com> | 2012-01-17 15:33:02 +0100 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2012-01-17 11:38:16 -0500 |
commit | 1a542b3698d8c42cf075b722f8838f106eb09fcc (patch) | |
tree | 62c399da0dc3ba08e2bf6194ff12de60004c429b /src | |
parent | 6961025be43141b1d1ca4a6a046ce8f3ac94f508 (diff) | |
download | sssd-1a542b3698d8c42cf075b722f8838f106eb09fcc.tar.gz sssd-1a542b3698d8c42cf075b722f8838f106eb09fcc.tar.bz2 sssd-1a542b3698d8c42cf075b722f8838f106eb09fcc.zip |
SUDO Integration - functions for manipulating with 'refreshed' attribute
https://fedorahosted.org/sssd/ticket/1110
Diffstat (limited to 'src')
-rw-r--r-- | src/db/sysdb_sudo.c | 58 | ||||
-rw-r--r-- | src/db/sysdb_sudo.h | 10 |
2 files changed, 68 insertions, 0 deletions
diff --git a/src/db/sysdb_sudo.c b/src/db/sysdb_sudo.c index 784b642e..f7e87ee4 100644 --- a/src/db/sysdb_sudo.c +++ b/src/db/sysdb_sudo.c @@ -21,6 +21,7 @@ #include <talloc.h> #include "db/sysdb.h" +#include "db/sysdb_private.h" #include "db/sysdb_sudo.h" #define NULL_CHECK(val, rval, label) do { \ @@ -324,3 +325,60 @@ done: talloc_free(tmp_ctx); return ret; } + +errno_t sysdb_sudo_set_refreshed(struct sysdb_ctx *sysdb, + bool refreshed) +{ + errno_t ret; + struct ldb_dn *dn; + TALLOC_CTX *tmp_ctx; + + + tmp_ctx = talloc_new(NULL); + if (!tmp_ctx) { + ret = ENOMEM; + goto done; + } + + dn = ldb_dn_new_fmt(tmp_ctx, sysdb->ldb, SYSDB_TMPL_CUSTOM_SUBTREE, + SUDORULE_SUBDIR, sysdb->domain->name); + if (!dn) { + ret = ENOMEM; + goto done; + } + + ret = sysdb_set_bool(sysdb, dn, SUDORULE_SUBDIR, + SYSDB_SUDO_AT_REFRESHED, refreshed); + +done: + talloc_free(tmp_ctx); + return ret; +} + +errno_t sysdb_sudo_get_refreshed(struct sysdb_ctx *sysdb, + bool *refreshed) +{ + errno_t ret; + struct ldb_dn *dn; + TALLOC_CTX *tmp_ctx; + + + tmp_ctx = talloc_new(NULL); + if (!tmp_ctx) { + ret = ENOMEM; + goto done; + } + + dn = ldb_dn_new_fmt(tmp_ctx, sysdb->ldb, SYSDB_TMPL_CUSTOM_SUBTREE, + SUDORULE_SUBDIR, sysdb->domain->name); + if (!dn) { + ret = ENOMEM; + goto done; + } + + ret = sysdb_get_bool(sysdb, dn, SYSDB_SUDO_AT_REFRESHED, refreshed); + +done: + talloc_free(tmp_ctx); + return ret; +} diff --git a/src/db/sysdb_sudo.h b/src/db/sysdb_sudo.h index 70ee1f4c..67f9e912 100644 --- a/src/db/sysdb_sudo.h +++ b/src/db/sysdb_sudo.h @@ -27,6 +27,10 @@ * b/c it's not name-service-switch data */ #define SUDORULE_SUBDIR "sudorules" +/* attribute of SUDORULE_SUBDIR + * should be true if we have downloaded all rules atleast once */ +#define SYSDB_SUDO_AT_REFRESHED "refreshed" + /* sysdb attributes */ #define SYSDB_SUDO_CACHE_AT_OC "sudoRule" #define SYSDB_SUDO_CACHE_AT_CN "cn" @@ -66,4 +70,10 @@ errno_t sysdb_purge_sudorule_subtree(struct sysdb_ctx *sysdb, struct sss_domain_info *domain, const char *filter); +errno_t sysdb_sudo_set_refreshed(struct sysdb_ctx *sysdb, + bool refreshed); + +errno_t sysdb_sudo_get_refreshed(struct sysdb_ctx *sysdb, + bool *refreshed); + #endif /* _SYSDB_SUDO_H_ */ |