|
|
5fca41 |
From 58f3d546954d7c2298a0b57865f7d5ad51f69aec Mon Sep 17 00:00:00 2001
|
|
|
5fca41 |
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
|
|
|
5fca41 |
Date: Thu, 5 Sep 2019 11:32:11 +0200
|
|
|
5fca41 |
Subject: [PATCH 89/90] sysdb: invalidate also autofs entries
|
|
|
5fca41 |
MIME-Version: 1.0
|
|
|
5fca41 |
Content-Type: text/plain; charset=UTF-8
|
|
|
5fca41 |
Content-Transfer-Encoding: 8bit
|
|
|
5fca41 |
|
|
|
5fca41 |
Autofs entries got data expiration attribute so we must
|
|
|
5fca41 |
make sure it is invalidated as well.
|
|
|
5fca41 |
|
|
|
5fca41 |
Resolves:
|
|
|
5fca41 |
https://pagure.io/SSSD/sssd/issue/2607
|
|
|
5fca41 |
|
|
|
5fca41 |
Reviewed-by: Tomáš Halman <thalman@redhat.com>
|
|
|
5fca41 |
---
|
|
|
5fca41 |
src/db/sysdb_autofs.c | 131 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
5fca41 |
src/db/sysdb_autofs.h | 4 ++
|
|
|
5fca41 |
2 files changed, 135 insertions(+)
|
|
|
5fca41 |
|
|
|
5fca41 |
diff --git a/src/db/sysdb_autofs.c b/src/db/sysdb_autofs.c
|
|
|
5fca41 |
index 11841d50d..413b00722 100644
|
|
|
5fca41 |
--- a/src/db/sysdb_autofs.c
|
|
|
5fca41 |
+++ b/src/db/sysdb_autofs.c
|
|
|
5fca41 |
@@ -530,6 +530,37 @@ done:
|
|
|
5fca41 |
return ret;
|
|
|
5fca41 |
}
|
|
|
5fca41 |
|
|
|
5fca41 |
+errno_t
|
|
|
5fca41 |
+sysdb_set_autofsentry_attr(struct sss_domain_info *domain,
|
|
|
5fca41 |
+ const char *mapname,
|
|
|
5fca41 |
+ const char *key,
|
|
|
5fca41 |
+ const char *value,
|
|
|
5fca41 |
+ struct sysdb_attrs *attrs,
|
|
|
5fca41 |
+ int mod_op)
|
|
|
5fca41 |
+{
|
|
|
5fca41 |
+ TALLOC_CTX *tmp_ctx;
|
|
|
5fca41 |
+ struct ldb_dn *dn;
|
|
|
5fca41 |
+ errno_t ret;
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ tmp_ctx = talloc_new(NULL);
|
|
|
5fca41 |
+ if (tmp_ctx == NULL) {
|
|
|
5fca41 |
+ DEBUG(SSSDBG_FATAL_FAILURE, "Out of memory!\n");
|
|
|
5fca41 |
+ return ENOMEM;
|
|
|
5fca41 |
+ }
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ dn = sysdb_autofsentry_dn(tmp_ctx, domain, mapname, key, value);
|
|
|
5fca41 |
+ if (dn == NULL) {
|
|
|
5fca41 |
+ ret = ENOMEM;
|
|
|
5fca41 |
+ goto done;
|
|
|
5fca41 |
+ }
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ ret = sysdb_set_entry_attr(domain->sysdb, dn, attrs, mod_op);
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+done:
|
|
|
5fca41 |
+ talloc_free(tmp_ctx);
|
|
|
5fca41 |
+ return ret;
|
|
|
5fca41 |
+}
|
|
|
5fca41 |
+
|
|
|
5fca41 |
errno_t
|
|
|
5fca41 |
sysdb_set_autofsmap_attr(struct sss_domain_info *domain,
|
|
|
5fca41 |
const char *name,
|
|
|
5fca41 |
@@ -558,6 +589,99 @@ done:
|
|
|
5fca41 |
return ret;
|
|
|
5fca41 |
}
|
|
|
5fca41 |
|
|
|
5fca41 |
+errno_t
|
|
|
5fca41 |
+sysdb_invalidate_autofs_entries(struct sss_domain_info *domain,
|
|
|
5fca41 |
+ const char *mapname)
|
|
|
5fca41 |
+{
|
|
|
5fca41 |
+ TALLOC_CTX *tmp_ctx;
|
|
|
5fca41 |
+ bool in_transaction = false;
|
|
|
5fca41 |
+ struct ldb_message **entries;
|
|
|
5fca41 |
+ struct sysdb_attrs *attrs;
|
|
|
5fca41 |
+ const char *value;
|
|
|
5fca41 |
+ const char *key;
|
|
|
5fca41 |
+ size_t count;
|
|
|
5fca41 |
+ errno_t ret;
|
|
|
5fca41 |
+ size_t i;
|
|
|
5fca41 |
+ int sret;
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ tmp_ctx = talloc_new(NULL);
|
|
|
5fca41 |
+ if (tmp_ctx == NULL) {
|
|
|
5fca41 |
+ DEBUG(SSSDBG_FATAL_FAILURE, "Out of memory!\n");
|
|
|
5fca41 |
+ return ENOMEM;
|
|
|
5fca41 |
+ }
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ ret = sysdb_autofs_entries_by_map(tmp_ctx, domain, mapname,
|
|
|
5fca41 |
+ &count, &entries);
|
|
|
5fca41 |
+ if (ret == ENOENT) {
|
|
|
5fca41 |
+ ret = EOK;
|
|
|
5fca41 |
+ goto done;
|
|
|
5fca41 |
+ } else if (ret != EOK) {
|
|
|
5fca41 |
+ goto done;
|
|
|
5fca41 |
+ }
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ attrs = sysdb_new_attrs(tmp_ctx);
|
|
|
5fca41 |
+ if (attrs == NULL) {
|
|
|
5fca41 |
+ ret = ENOMEM;
|
|
|
5fca41 |
+ goto done;
|
|
|
5fca41 |
+ }
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ ret = sysdb_attrs_add_time_t(attrs, SYSDB_CACHE_EXPIRE, 1);
|
|
|
5fca41 |
+ if (ret != EOK) {
|
|
|
5fca41 |
+ goto done;
|
|
|
5fca41 |
+ }
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ ret = sysdb_transaction_start(domain->sysdb);
|
|
|
5fca41 |
+ if (ret != EOK) {
|
|
|
5fca41 |
+ DEBUG(SSSDBG_CRIT_FAILURE, "Failed to start transaction\n");
|
|
|
5fca41 |
+ goto done;
|
|
|
5fca41 |
+ }
|
|
|
5fca41 |
+ in_transaction = true;
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ for (i = 0; i < count; i++) {
|
|
|
5fca41 |
+ key = ldb_msg_find_attr_as_string(entries[i], SYSDB_AUTOFS_ENTRY_KEY,
|
|
|
5fca41 |
+ NULL);
|
|
|
5fca41 |
+ if (key == NULL) {
|
|
|
5fca41 |
+ DEBUG(SSSDBG_MINOR_FAILURE, "An entry with no key?\n");
|
|
|
5fca41 |
+ continue;
|
|
|
5fca41 |
+ }
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ value = ldb_msg_find_attr_as_string(entries[i],
|
|
|
5fca41 |
+ SYSDB_AUTOFS_ENTRY_VALUE,
|
|
|
5fca41 |
+ NULL);
|
|
|
5fca41 |
+ if (value == NULL) {
|
|
|
5fca41 |
+ DEBUG(SSSDBG_MINOR_FAILURE, "An entry with no value?\n");
|
|
|
5fca41 |
+ continue;
|
|
|
5fca41 |
+ }
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ ret = sysdb_set_autofsentry_attr(domain, mapname, key, value,
|
|
|
5fca41 |
+ attrs, SYSDB_MOD_REP);
|
|
|
5fca41 |
+ if (ret != EOK) {
|
|
|
5fca41 |
+ DEBUG(SSSDBG_MINOR_FAILURE, "Could not expire entry %s\n", key);
|
|
|
5fca41 |
+ continue;
|
|
|
5fca41 |
+ }
|
|
|
5fca41 |
+ }
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ ret = sysdb_transaction_commit(domain->sysdb);
|
|
|
5fca41 |
+ if (ret != EOK) {
|
|
|
5fca41 |
+ DEBUG(SSSDBG_OP_FAILURE, "Could not commit transaction\n");
|
|
|
5fca41 |
+ goto done;
|
|
|
5fca41 |
+ }
|
|
|
5fca41 |
+ in_transaction = false;
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ ret = EOK;
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+done:
|
|
|
5fca41 |
+ if (in_transaction) {
|
|
|
5fca41 |
+ sret = sysdb_transaction_cancel(domain->sysdb);
|
|
|
5fca41 |
+ if (sret != EOK) {
|
|
|
5fca41 |
+ DEBUG(SSSDBG_OP_FAILURE, "Could not cancel transaction\n");
|
|
|
5fca41 |
+ }
|
|
|
5fca41 |
+ }
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ talloc_free(tmp_ctx);
|
|
|
5fca41 |
+ return ret;
|
|
|
5fca41 |
+}
|
|
|
5fca41 |
+
|
|
|
5fca41 |
errno_t
|
|
|
5fca41 |
sysdb_invalidate_autofs_maps(struct sss_domain_info *domain)
|
|
|
5fca41 |
{
|
|
|
5fca41 |
@@ -634,6 +758,13 @@ sysdb_invalidate_autofs_maps(struct sss_domain_info *domain)
|
|
|
5fca41 |
DEBUG(SSSDBG_MINOR_FAILURE, "Could not expire map %s\n", name);
|
|
|
5fca41 |
continue;
|
|
|
5fca41 |
}
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ ret = sysdb_invalidate_autofs_entries(domain, name);
|
|
|
5fca41 |
+ if (ret != EOK) {
|
|
|
5fca41 |
+ DEBUG(SSSDBG_MINOR_FAILURE, "Could not expire map entries %s\n",
|
|
|
5fca41 |
+ name);
|
|
|
5fca41 |
+ continue;
|
|
|
5fca41 |
+ }
|
|
|
5fca41 |
}
|
|
|
5fca41 |
|
|
|
5fca41 |
ret = sysdb_transaction_commit(domain->sysdb);
|
|
|
5fca41 |
diff --git a/src/db/sysdb_autofs.h b/src/db/sysdb_autofs.h
|
|
|
5fca41 |
index 3775e2a17..37489f2e8 100644
|
|
|
5fca41 |
--- a/src/db/sysdb_autofs.h
|
|
|
5fca41 |
+++ b/src/db/sysdb_autofs.h
|
|
|
5fca41 |
@@ -93,6 +93,10 @@ sysdb_set_autofsmap_attr(struct sss_domain_info *domain,
|
|
|
5fca41 |
struct sysdb_attrs *attrs,
|
|
|
5fca41 |
int mod_op);
|
|
|
5fca41 |
|
|
|
5fca41 |
+errno_t
|
|
|
5fca41 |
+sysdb_invalidate_autofs_entries(struct sss_domain_info *domain,
|
|
|
5fca41 |
+ const char *mapname);
|
|
|
5fca41 |
+
|
|
|
5fca41 |
errno_t
|
|
|
5fca41 |
sysdb_invalidate_autofs_maps(struct sss_domain_info *domain);
|
|
|
5fca41 |
|
|
|
5fca41 |
--
|
|
|
5fca41 |
2.20.1
|
|
|
5fca41 |
|