sssd/0010-SYSDB-Rework-sysdb_cache_connect.patch
Lukas Slebodnik 2b61bbee11 Backport important patches from upstream 1.14.2 prerelease
- Resolves: upstream #3154 - sssd exits if clock is adjusted backwards after
                             boot
- Resolves: upstream #3163 - resolving IPA nested user group is broken in 1.14
2016-09-01 18:13:49 +02:00

125 lines
5.3 KiB
Diff

From 3258fa9d328f364fa41fd1a5bc5fc3250e87df8e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
Date: Tue, 16 Aug 2016 11:20:49 +0200
Subject: [PATCH 10/39] SYSDB: Rework sysdb_cache_connect()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
As sysdb_cache_connect() has two very specific use cases (connect to the
cache and connect to the timestamp cache) and each of those calls have a
predetermined/fixed sets of values for a few parameters, let's try to
make the code a bit simpler to follow by having explicit functions for
connecting to the cache and connecting to the timestamp cache.
Macros could be used as well, but I have a slightly preference for
having two new functions instead of macros accessing internal parameters
of the macro's parameter.
Related:
https://fedorahosted.org/sssd/ticket/3128
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
(cherry picked from commit b6d1cd5eaab4c7c73df8ee041944ec05630a9630)
---
src/db/sysdb_init.c | 53 ++++++++++++++++++++++++++++++++++-------------------
1 file changed, 34 insertions(+), 19 deletions(-)
diff --git a/src/db/sysdb_init.c b/src/db/sysdb_init.c
index 9e3646bfeb9a494ebff2d348ab1c53336f8a5c03..59934701c4d2b9d770385a202af058404a6d3eb9 100644
--- a/src/db/sysdb_init.c
+++ b/src/db/sysdb_init.c
@@ -511,14 +511,14 @@ done:
return ret;
}
-static errno_t sysdb_cache_connect(TALLOC_CTX *mem_ctx,
- struct sss_domain_info *domain,
- const char *ldb_file,
- int flags,
- const char *exp_version,
- const char *base_ldif,
- struct ldb_context **_ldb,
- const char **_version)
+static errno_t sysdb_cache_connect_helper(TALLOC_CTX *mem_ctx,
+ struct sss_domain_info *domain,
+ const char *ldb_file,
+ int flags,
+ const char *exp_version,
+ const char *base_ldif,
+ struct ldb_context **_ldb,
+ const char **_version)
{
TALLOC_CTX *tmp_ctx = NULL;
struct ldb_message_element *el;
@@ -619,6 +619,29 @@ done:
return ret;
}
+static errno_t sysdb_cache_connect(TALLOC_CTX *mem_ctx,
+ struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
+ struct ldb_context **ldb,
+ const char **version)
+{
+ return sysdb_cache_connect_helper(mem_ctx, domain, sysdb->ldb_file,
+ 0, SYSDB_VERSION, SYSDB_BASE_LDIF,
+ ldb, version);
+}
+
+static errno_t sysdb_ts_cache_connect(TALLOC_CTX *mem_ctx,
+ struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
+ struct ldb_context **ldb,
+ const char **version)
+{
+ return sysdb_cache_connect_helper(mem_ctx, domain, sysdb->ldb_ts_file,
+ LDB_FLG_NOSYNC, SYSDB_TS_VERSION,
+ SYSDB_TS_BASE_LDIF,
+ ldb, version);
+}
+
static errno_t remove_ts_cache(struct sysdb_ctx *sysdb)
{
errno_t ret;
@@ -649,9 +672,7 @@ static int sysdb_domain_cache_connect(struct sysdb_ctx *sysdb,
return ENOMEM;
}
- ret = sysdb_cache_connect(tmp_ctx, domain, sysdb->ldb_file, 0,
- SYSDB_VERSION, SYSDB_BASE_LDIF,
- &ldb, &version);
+ ret = sysdb_cache_connect(tmp_ctx, sysdb, domain, &ldb, &version);
switch (ret) {
case ERR_SYSDB_VERSION_TOO_OLD:
if (upgrade_ctx == NULL) {
@@ -731,10 +752,7 @@ static int sysdb_timestamp_cache_connect(struct sysdb_ctx *sysdb,
return ENOMEM;
}
- ret = sysdb_cache_connect(tmp_ctx, domain,
- sysdb->ldb_ts_file, LDB_FLG_NOSYNC,
- SYSDB_TS_VERSION, SYSDB_TS_BASE_LDIF,
- &ldb, &version);
+ ret = sysdb_ts_cache_connect(tmp_ctx, sysdb, domain, &ldb, &version);
switch (ret) {
case ERR_SYSDB_VERSION_TOO_OLD:
if (upgrade_ctx == NULL) {
@@ -801,10 +819,7 @@ static int sysdb_timestamp_cache_connect(struct sysdb_ctx *sysdb,
/* Now the connect must succeed because the previous cache doesn't
* exist anymore.
*/
- ret = sysdb_cache_connect(tmp_ctx, domain,
- sysdb->ldb_ts_file, LDB_FLG_NOSYNC,
- SYSDB_TS_VERSION, SYSDB_TS_BASE_LDIF,
- &ldb, &version);
+ ret = sysdb_ts_cache_connect(tmp_ctx, sysdb, domain, &ldb, &version);
if (ret != EOK) {
DEBUG(SSSDBG_MINOR_FAILURE,
"Could not delete the timestamp ldb file (%d) (%s)\n",
--
2.9.3