Hi all,
after chat with Lukas I attached only first two patches. Author of the
third one is Lukas and I am not sure if he is finished. (There was
question of LD_PRELOAD.)
Regards
--
Petr^4 Čech
>From c67ccc872eb5dacc98f626c10740424cef205334 Mon Sep 17 00:00:00 2001
From: Petr Cech <pc...@redhat.com>
Date: Tue, 16 Aug 2016 09:32:18 +0200
Subject: [PATCH 1/3] SYSDB: Adding message to inform which cache is used
Resolves:
https://fedorahosted.org/sssd/ticket/3060
---
src/db/sysdb_ops.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index 29f4b1d1597bd98541a152dd6462caa864fbf2fd..8b194e3db48870aecd54b21bd3d0b77dc342f9e5 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -27,6 +27,11 @@
#include "util/cert.h"
#include <time.h>
+
+#define SSS_SYSDB_NO_CACHE 0x0
+#define SSS_SYSDB_CACHE 0x1
+#define SSS_SYSDB_TS_CACHE 0x2
+
static uint32_t get_attr_as_uint32(struct ldb_message *msg, const char *attr)
{
const struct ldb_val *v = ldb_msg_find_ldb_val(msg, attr);
@@ -1176,6 +1181,21 @@ done:
return ret;
}
+static const char *get_attr_storage(int state_mask)
+{
+ const char *storage = "unknown";
+
+ if (state_mask == (SSS_SYSDB_CACHE | SSS_SYSDB_TS_CACHE)) {
+ storage = "cache, ts_cache";
+ } else if (state_mask == SSS_SYSDB_TS_CACHE) {
+ storage = "ts_cache";
+ } else if (state_mask == SSS_SYSDB_CACHE) {
+ storage = "cache";
+ }
+
+ return storage;
+}
+
int sysdb_set_entry_attr(struct sysdb_ctx *sysdb,
struct ldb_dn *entry_dn,
struct sysdb_attrs *attrs,
@@ -1184,6 +1204,7 @@ int sysdb_set_entry_attr(struct sysdb_ctx *sysdb,
bool sysdb_write = true;
errno_t ret = EOK;
errno_t tret = EOK;
+ int state_mask = SSS_SYSDB_NO_CACHE;
sysdb_write = sysdb_entry_attrs_diff(sysdb, entry_dn, attrs, mod_op);
if (sysdb_write == true) {
@@ -1192,6 +1213,8 @@ int sysdb_set_entry_attr(struct sysdb_ctx *sysdb,
DEBUG(SSSDBG_MINOR_FAILURE,
"Cannot set attrs for %s, %d [%s]\n",
ldb_dn_get_linearized(entry_dn), ret, sss_strerror(ret));
+ } else {
+ state_mask |= SSS_SYSDB_CACHE;
}
}
@@ -1201,9 +1224,17 @@ int sysdb_set_entry_attr(struct sysdb_ctx *sysdb,
DEBUG(SSSDBG_MINOR_FAILURE,
"Cannot set ts attrs for %s\n", ldb_dn_get_linearized(entry_dn));
/* Not fatal */
+ } else {
+ state_mask |= SSS_SYSDB_TS_CACHE;
}
}
+ if (state_mask != SSS_SYSDB_NO_CACHE) {
+ DEBUG(SSSDBG_FUNC_DATA, "Entry [%s] has set [%s] attrs.\n",
+ ldb_dn_get_linearized(entry_dn),
+ get_attr_storage(state_mask));
+ }
+
return ret;
}
--
2.7.4
>From 1f4e5b03442ea87a117c54a30550fbc357ff10a7 Mon Sep 17 00:00:00 2001
From: Petr Cech <pc...@redhat.com>
Date: Tue, 16 Aug 2016 09:33:46 +0200
Subject: [PATCH 2/3] SYSDB: Adding message about reason why cache changed
Resolves:
https://fedorahosted.org/sssd/ticket/3060
---
src/db/sysdb.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index 6f0b1b9e9b52bede68f03cb5674f65b91cc28c98..b67769ed11fc0796d1987f09aa568c2db4a0ffab 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -1821,7 +1821,8 @@ bool sysdb_msg_attrs_modts_differs(struct ldb_message *old_entry,
return true;
}
-static bool sysdb_ldb_msg_difference(struct ldb_message *db_msg,
+static bool sysdb_ldb_msg_difference(struct ldb_dn *entry_dn,
+ struct ldb_message *db_msg,
struct ldb_message *mod_msg)
{
struct ldb_message_element *mod_msg_el;
@@ -1848,6 +1849,9 @@ static bool sysdb_ldb_msg_difference(struct ldb_message *db_msg,
*/
if (mod_msg_el->num_values > 0) {
/* We can ignore additions of timestamp attributes */
+ DEBUG(SSSDBG_TRACE_INTERNAL,
+ "Added attr [%s] to entry [%s]\n",
+ mod_msg_el->name, ldb_dn_get_linearized(entry_dn));
return true;
}
break;
@@ -1855,12 +1859,15 @@ static bool sysdb_ldb_msg_difference(struct ldb_message *db_msg,
el_differs = ldb_msg_element_compare(db_msg_el, mod_msg_el);
if (el_differs) {
- /* We are replacing or extending element, there is a difference. If
- * some values already exist and ldb_add is not permissive,
+ /* We are replacing or extending element, there is a difference.
+ * If some values already exist and ldb_add is not permissive,
* ldb will throw an error, but that's not our job to check..
*/
if (is_ts_cache_attr(mod_msg_el->name) == false) {
/* We can ignore changes to timestamp attributes */
+ DEBUG(SSSDBG_TRACE_INTERNAL,
+ "Replaced/extended attr [%s] of entry [%s]\n",
+ mod_msg_el->name, ldb_dn_get_linearized(entry_dn) );
return true;
}
}
@@ -1869,6 +1876,9 @@ static bool sysdb_ldb_msg_difference(struct ldb_message *db_msg,
db_msg_el = ldb_msg_find_element(db_msg, mod_msg_el->name);
if (db_msg_el != NULL) {
/* We are deleting a valid element, there is a difference */
+ DEBUG(SSSDBG_TRACE_INTERNAL,
+ "Deleted attr [%s] of entry [%s].\n",
+ mod_msg_el->name, ldb_dn_get_linearized(entry_dn));
return true;
}
break;
@@ -1892,10 +1902,16 @@ bool sysdb_entry_attrs_diff(struct sysdb_ctx *sysdb,
const char *attrnames[attrs->num+1];
if (sysdb->ldb_ts == NULL) {
+ DEBUG(SSSDBG_TRACE_FUNC,
+ "Entry [%s] differs, reason: there is no ts_cache yet.\n",
+ ldb_dn_get_linearized(entry_dn));
return true;
}
if (is_ts_ldb_dn(entry_dn) == false) {
+ DEBUG(SSSDBG_TRACE_FUNC,
+ "Entry [%s] differs, reason: ts_cache doesn't trace this type of entry.\n",
+ ldb_dn_get_linearized(entry_dn));
return true;
}
@@ -1930,7 +1946,7 @@ bool sysdb_entry_attrs_diff(struct sysdb_ctx *sysdb,
goto done;
}
- differs = sysdb_ldb_msg_difference(res->msgs[0], new_entry_msg);
+ differs = sysdb_ldb_msg_difference(entry_dn, res->msgs[0], new_entry_msg);
done:
talloc_free(tmp_ctx);
return differs;
--
2.7.4
_______________________________________________
sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org
To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org