summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/db/sysdb_sudo.c58
-rw-r--r--src/db/sysdb_sudo.h10
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_ */