|
|
8d3578 |
From 11ffb775d725172a4247a9826cadecb872c7d0dc Mon Sep 17 00:00:00 2001
|
|
|
8d3578 |
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
|
|
|
8d3578 |
Date: Wed, 14 Aug 2019 12:29:56 +0200
|
|
|
8d3578 |
Subject: [PATCH 71/90] sysdb: store enumeration expiration time in autofs map
|
|
|
8d3578 |
MIME-Version: 1.0
|
|
|
8d3578 |
Content-Type: text/plain; charset=UTF-8
|
|
|
8d3578 |
Content-Transfer-Encoding: 8bit
|
|
|
8d3578 |
|
|
|
8d3578 |
We need to distinguish between 'object expired' when we need
|
|
|
8d3578 |
to obtain only the map entry and 'enumeration expired' when
|
|
|
8d3578 |
we need to enumerated the map entry.
|
|
|
8d3578 |
|
|
|
8d3578 |
Resolves:
|
|
|
8d3578 |
https://pagure.io/SSSD/sssd/issue/2607
|
|
|
8d3578 |
|
|
|
8d3578 |
Reviewed-by: Tomáš Halman <thalman@redhat.com>
|
|
|
8d3578 |
---
|
|
|
8d3578 |
src/db/sysdb_autofs.c | 22 ++++++++++++++++++----
|
|
|
8d3578 |
src/db/sysdb_autofs.h | 3 ++-
|
|
|
8d3578 |
src/providers/ldap/sdap_async_autofs.c | 7 ++++---
|
|
|
8d3578 |
src/tests/sysdb-tests.c | 2 +-
|
|
|
8d3578 |
4 files changed, 25 insertions(+), 9 deletions(-)
|
|
|
8d3578 |
|
|
|
8d3578 |
diff --git a/src/db/sysdb_autofs.c b/src/db/sysdb_autofs.c
|
|
|
8d3578 |
index f5186451e..dc1ea5586 100644
|
|
|
8d3578 |
--- a/src/db/sysdb_autofs.c
|
|
|
8d3578 |
+++ b/src/db/sysdb_autofs.c
|
|
|
8d3578 |
@@ -101,8 +101,10 @@ sysdb_save_autofsmap(struct sss_domain_info *domain,
|
|
|
8d3578 |
const char *autofsmapname,
|
|
|
8d3578 |
struct sysdb_attrs *attrs,
|
|
|
8d3578 |
int cache_timeout,
|
|
|
8d3578 |
- time_t now)
|
|
|
8d3578 |
+ time_t now,
|
|
|
8d3578 |
+ bool enumerated)
|
|
|
8d3578 |
{
|
|
|
8d3578 |
+ time_t expiration = cache_timeout ? now + cache_timeout : 0;
|
|
|
8d3578 |
errno_t ret;
|
|
|
8d3578 |
TALLOC_CTX *tmp_ctx;
|
|
|
8d3578 |
|
|
|
8d3578 |
@@ -150,15 +152,22 @@ sysdb_save_autofsmap(struct sss_domain_info *domain,
|
|
|
8d3578 |
goto done;
|
|
|
8d3578 |
}
|
|
|
8d3578 |
|
|
|
8d3578 |
- ret = sysdb_attrs_add_time_t(attrs, SYSDB_CACHE_EXPIRE,
|
|
|
8d3578 |
- ((cache_timeout) ?
|
|
|
8d3578 |
- (now + cache_timeout) : 0));
|
|
|
8d3578 |
+ ret = sysdb_attrs_add_time_t(attrs, SYSDB_CACHE_EXPIRE, expiration);
|
|
|
8d3578 |
if (ret) {
|
|
|
8d3578 |
DEBUG(SSSDBG_OP_FAILURE, "Could not set sysdb cache expire [%d]: %s\n",
|
|
|
8d3578 |
ret, strerror(ret));
|
|
|
8d3578 |
goto done;
|
|
|
8d3578 |
}
|
|
|
8d3578 |
|
|
|
8d3578 |
+ if (enumerated) {
|
|
|
8d3578 |
+ ret = sysdb_attrs_add_time_t(attrs, SYSDB_ENUM_EXPIRE, expiration);
|
|
|
8d3578 |
+ if (ret) {
|
|
|
8d3578 |
+ DEBUG(SSSDBG_OP_FAILURE, "Could not set sysdb enum expire [%d]: %s\n",
|
|
|
8d3578 |
+ ret, strerror(ret));
|
|
|
8d3578 |
+ goto done;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
ret = sysdb_store_custom(domain, name, AUTOFS_MAP_SUBDIR, attrs);
|
|
|
8d3578 |
if (ret != EOK) {
|
|
|
8d3578 |
DEBUG(SSSDBG_OP_FAILURE, "sysdb_store_custom failed [%d]: %s\n",
|
|
|
8d3578 |
@@ -569,6 +578,11 @@ sysdb_invalidate_autofs_maps(struct sss_domain_info *domain)
|
|
|
8d3578 |
goto done;
|
|
|
8d3578 |
}
|
|
|
8d3578 |
|
|
|
8d3578 |
+ ret = sysdb_attrs_add_time_t(sys_attrs, SYSDB_ENUM_EXPIRE, 1);
|
|
|
8d3578 |
+ if (ret != EOK) {
|
|
|
8d3578 |
+ goto done;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
ret = sysdb_transaction_start(domain->sysdb);
|
|
|
8d3578 |
if (ret != EOK) {
|
|
|
8d3578 |
DEBUG(SSSDBG_CRIT_FAILURE, "Failed to start transaction\n");
|
|
|
8d3578 |
diff --git a/src/db/sysdb_autofs.h b/src/db/sysdb_autofs.h
|
|
|
8d3578 |
index 0cbe6ddbf..7170334c6 100644
|
|
|
8d3578 |
--- a/src/db/sysdb_autofs.h
|
|
|
8d3578 |
+++ b/src/db/sysdb_autofs.h
|
|
|
8d3578 |
@@ -41,7 +41,8 @@ sysdb_save_autofsmap(struct sss_domain_info *domain,
|
|
|
8d3578 |
const char *autofsmapname,
|
|
|
8d3578 |
struct sysdb_attrs *attrs,
|
|
|
8d3578 |
int cache_timeout,
|
|
|
8d3578 |
- time_t now);
|
|
|
8d3578 |
+ time_t now,
|
|
|
8d3578 |
+ bool enumerated);
|
|
|
8d3578 |
|
|
|
8d3578 |
errno_t
|
|
|
8d3578 |
sysdb_get_map_byname(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
diff --git a/src/providers/ldap/sdap_async_autofs.c b/src/providers/ldap/sdap_async_autofs.c
|
|
|
8d3578 |
index 787283872..453e95f7b 100644
|
|
|
8d3578 |
--- a/src/providers/ldap/sdap_async_autofs.c
|
|
|
8d3578 |
+++ b/src/providers/ldap/sdap_async_autofs.c
|
|
|
8d3578 |
@@ -189,7 +189,8 @@ del_autofs_entries(struct sss_domain_info *dom,
|
|
|
8d3578 |
static errno_t
|
|
|
8d3578 |
save_autofs_map(struct sss_domain_info *dom,
|
|
|
8d3578 |
struct sdap_options *opts,
|
|
|
8d3578 |
- struct sysdb_attrs *map)
|
|
|
8d3578 |
+ struct sysdb_attrs *map,
|
|
|
8d3578 |
+ bool enumerated)
|
|
|
8d3578 |
{
|
|
|
8d3578 |
const char *mapname;
|
|
|
8d3578 |
errno_t ret;
|
|
|
8d3578 |
@@ -201,7 +202,7 @@ save_autofs_map(struct sss_domain_info *dom,
|
|
|
8d3578 |
now = time(NULL);
|
|
|
8d3578 |
|
|
|
8d3578 |
ret = sysdb_save_autofsmap(dom, mapname, mapname,
|
|
|
8d3578 |
- NULL, dom->autofsmap_timeout, now);
|
|
|
8d3578 |
+ NULL, dom->autofsmap_timeout, now, enumerated);
|
|
|
8d3578 |
if (ret != EOK) {
|
|
|
8d3578 |
return ret;
|
|
|
8d3578 |
}
|
|
|
8d3578 |
@@ -898,7 +899,7 @@ sdap_autofs_setautomntent_save(struct tevent_req *req)
|
|
|
8d3578 |
in_transaction = true;
|
|
|
8d3578 |
|
|
|
8d3578 |
/* Save the map itself */
|
|
|
8d3578 |
- ret = save_autofs_map(state->dom, state->opts, state->map);
|
|
|
8d3578 |
+ ret = save_autofs_map(state->dom, state->opts, state->map, true);
|
|
|
8d3578 |
if (ret != EOK) {
|
|
|
8d3578 |
DEBUG(SSSDBG_OP_FAILURE,
|
|
|
8d3578 |
"Cannot save autofs map entry [%d]: %s\n",
|
|
|
8d3578 |
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
|
|
|
8d3578 |
index 23f2bd383..108ef8943 100644
|
|
|
8d3578 |
--- a/src/tests/sysdb-tests.c
|
|
|
8d3578 |
+++ b/src/tests/sysdb-tests.c
|
|
|
8d3578 |
@@ -6374,7 +6374,7 @@ START_TEST(test_autofs_create_map)
|
|
|
8d3578 |
fail_if(autofsmapname == NULL, "Out of memory\n");
|
|
|
8d3578 |
|
|
|
8d3578 |
ret = sysdb_save_autofsmap(test_ctx->domain, autofsmapname,
|
|
|
8d3578 |
- autofsmapname, NULL, 0, 0);
|
|
|
8d3578 |
+ autofsmapname, NULL, 0, 0, false);
|
|
|
8d3578 |
fail_if(ret != EOK, "Could not store autofs map %s", autofsmapname);
|
|
|
8d3578 |
talloc_free(test_ctx);
|
|
|
8d3578 |
}
|
|
|
8d3578 |
--
|
|
|
8d3578 |
2.20.1
|
|
|
8d3578 |
|