Hello list, I am solving ticket [1] now. There are three points mentioned. A have prepared patches for the first two. I would like to ask anybody it is right or if I miss something.
The third point is about full LDIFF in special debug level. What does it mean 'special debug level'? Is it new option, for example? [1] https://fedorahosted.org/sssd/ticket/3060 Regards -- Petr^4 Čech
>From 6ac105b6a3ad9e424c5053f05aa1eefd55cafb71 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/2] SYSDB: Adding message to inform which cache is used Resolves: https://fedorahosted.org/sssd/ticket/3060 --- src/db/sysdb_ops.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c index 44fb5b70e6d33fffbca5824f831a3229254ecb57..e199bd946d5d58be2acd3dfda7050c112688d20d 100644 --- a/src/db/sysdb_ops.c +++ b/src/db/sysdb_ops.c @@ -1176,6 +1176,31 @@ done: return ret; } +static const char *get_attr_storage(int state) +{ + const char *storage; + + switch (state) { + case 0: + storage = ""; + break; + case 1: + storage = "cache"; + break; + case 2: + storage = "ts_cache"; + break; + case 3: + storage = "cache, ts_cache"; + break; + default: + storage = ""; + break; + } + + return storage; +} + int sysdb_set_entry_attr(struct sysdb_ctx *sysdb, struct ldb_dn *entry_dn, struct sysdb_attrs *attrs, @@ -1184,6 +1209,7 @@ int sysdb_set_entry_attr(struct sysdb_ctx *sysdb, bool sysdb_write = true; errno_t ret = EOK; errno_t tret = EOK; + int state = 0; sysdb_write = sysdb_entry_attrs_diff(sysdb, entry_dn, attrs, mod_op); if (sysdb_write == true) { @@ -1192,6 +1218,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 += 1; } } @@ -1201,9 +1229,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 += 2; } } + if (state % 4) { + DEBUG(SSSDBG_FUNC_DATA, "Entry [%s] has set [%s] attrs.\n", + ldb_dn_get_linearized(entry_dn), + get_attr_storage(state)); + } + return ret; } -- 2.7.4
>From b24b8dfac99fcee7410ee8f189dd28d8c7c2bd2b 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/2] SYSDB: Adding message about reason why cache changed Resolves: https://fedorahosted.org/sssd/ticket/3060 --- src/db/sysdb.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/db/sysdb.c b/src/db/sysdb.c index 6f0b1b9e9b52bede68f03cb5674f65b91cc28c98..9d1abc2b3dd0ce5db626544673795eebfbc28bcd 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,10 @@ 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_FUNC, "Entry [%s] differs, reason: " \ + "attr [%s] is new.\n", + ldb_dn_get_linearized(entry_dn), + mod_msg_el->name); return true; } break; @@ -1861,6 +1866,11 @@ static bool sysdb_ldb_msg_difference(struct ldb_message *db_msg, */ if (is_ts_cache_attr(mod_msg_el->name) == false) { /* We can ignore changes to timestamp attributes */ + DEBUG(SSSDBG_TRACE_FUNC, "Entry [%s] differs, reason: " \ + "attr [%s] is replaced " \ + "or extended.\n", + ldb_dn_get_linearized(entry_dn), + mod_msg_el->name); return true; } } @@ -1869,6 +1879,10 @@ 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_FUNC, "Entry [%s] differs, reason: " \ + "attr [%s] is deleted.\n", + ldb_dn_get_linearized(entry_dn), + mod_msg_el->name); return true; } break; @@ -1892,10 +1906,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 +1950,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 https://lists.fedorahosted.org/admin/lists/sssd-devel@lists.fedorahosted.org