[SSSD] [PATCH] sysdb_set_entry_attr: dump attributes and values on error

Lukas Slebodnik lslebodn at redhat.com
Wed Mar 11 08:45:41 UTC 2015


On (11/03/15 08:31), Sumit Bose wrote:
>On Tue, Mar 10, 2015 at 06:47:44PM +0100, Lukas Slebodnik wrote:
>> On (10/03/15 16:30), Sumit Bose wrote:
>> >On Mon, Mar 09, 2015 at 06:36:51PM +0100, Lukas Slebodnik wrote:
>> >> On (09/03/15 12:03), Sumit Bose wrote:
>> >> >On Mon, Mar 09, 2015 at 11:24:31AM +0100, Pavel Reichl wrote:
>> >> >> 
>> >> >> 
>> >> >> On 03/09/2015 10:13 AM, Sumit Bose wrote:
>> >> >> >Hi,
>> >> >> >
>> >> >> >this is a patch I have in my tree for some time for debugging purposes.
>> >> >> >Recently I've seen some bug reports with "ldb_modify failed" messages in
>> >> >> >the logs and I think this patch might help in those cases.
>> >> >> >
>> >> >> >Additionally I wonder if SSSDBG_MINOR_FAILURE is a suitable debug level
>> >> >> >here. In most cases an error here prevents a user or group object to be
>> >> >> >written to the cache, so maybe SSSDBG_CRIT_FAILURE is justified here?
>> >> >> >
>> >> >> >bye,
>> >> >> >Sumit
>> >> >> >
>> >> >> >
>> >> >> Hello Sumit,
>> >> >> 
>> >> >> when compiling at my environment, I'm seeing this warning:
>> >> >> 
>> >> >> ../src/db/sysdb_ops.c: In function 'sysdb_set_entry_attr':
>> >> >> ../src/db/sysdb_ops.c:717:21: warning: format '%u' expects argument of type
>> >> >> 'unsigned int', but argument 6 has type 'size_t' [-Wformat=]
>> >> >>                      DEBUG(SSSDBG_MINOR_FAILURE, "   Value[%u]: [%s].\n",
>> >> >> 
>> >> >> 
>> >> >> Would you consider amending the patch?
>> >> >> -                    DEBUG(SSSDBG_MINOR_FAILURE, "   Value[%u]: [%s].\n",
>> >> >> +                    DEBUG(SSSDBG_MINOR_FAILURE, "   Value[%zu]: [%s].\n",
>> >> >
>> >> >Of course, thank you for catching this, new version attached.
>> >> >
>> >> >bye,
>> >> >Sumit
>> >> >
>> >> >> 
>> >> >> This seem to remove the warning for me.
>> >> >> 
>> >> >> Thanks!
>> >> >> 
>> >> 
>> >> >From eaa3bbdea943dd509632e4ccb97c9278bd1208a3 Mon Sep 17 00:00:00 2001
>> >> >From: Sumit Bose <sbose at redhat.com>
>> >> >Date: Wed, 21 Jan 2015 11:05:23 +0100
>> >> >Subject: [PATCH] sysdb_set_entry_attr: dump attributes and values on error
>> >> >
>> >> >---
>> >> > src/db/sysdb_ops.c | 11 +++++++++++
>> >> > 1 file changed, 11 insertions(+)
>> >> >
>> >> >diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
>> >> >index 6085762dcc5585114dd3049dd3a365856cb6b190..5d25d11f0cc10ab3e59420231e8acfa0e58fbf4b 100644
>> >> >--- a/src/db/sysdb_ops.c
>> >> >+++ b/src/db/sysdb_ops.c
>> >> >@@ -671,6 +671,7 @@ int sysdb_set_entry_attr(struct sysdb_ctx *sysdb,
>> >> >     struct ldb_message *msg;
>> >> >     int i, ret;
>> >> >     int lret;
>> >> >+    size_t c;
>> >> >     TALLOC_CTX *tmp_ctx;
>> >> > 
>> >> >     tmp_ctx = talloc_new(NULL);
>> >> >@@ -708,6 +709,16 @@ int sysdb_set_entry_attr(struct sysdb_ctx *sysdb,
>> >> >     if (lret != LDB_SUCCESS) {
>> >> >         DEBUG(SSSDBG_MINOR_FAILURE,
>> >> >               "ldb_modify failed: [%s]\n", ldb_strerror(lret));
>> >> >+        if (DEBUG_IS_SET(SSSDBG_MINOR_FAILURE)) {
>> >> >+            for (i = 0; i < msg->num_elements; i++) {
>> >> >+                DEBUG(SSSDBG_MINOR_FAILURE, "Name: [%s].\n",
>> >> >+                      msg->elements[i].name);
>> >> >+                for (c = 0; c < msg->elements[i].num_values; c++) {
>> >> >+                    DEBUG(SSSDBG_MINOR_FAILURE, "   Value[%zu]: [%s].\n",
>> >> >+                          c, msg->elements[i].values[c].data);
>> >> >+                }
>> >> >+            }
>> >> >+        }
>> >> 
>> >> I'm sorry but this patch isn't very useful
>> >> I am debugging bug #2576 and it didn't help me with anything
>> >> and I really got a message "ldb_modify failed"
>> >> 
>> >> It seems to be some issue with ghost attributes which are not present
>> >> in stored msg. They are generated by memberof plug-in.
>> >
>> >yes, this does not help with 'internal' errors. It would be possible to
>> >print the list only on LDB_ERR_CONSTRAINT_VIOLATION,
>> >LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS, LDB_ERR_INVALID_ATTRIBUTE_SYNTAX or
>> >any other error code related to the input attributes. But I thought
>> >chances are high to miss an error code and so dump the stuff on all
>> >errors.
>> >
>> As I already mention it will not help.
>> In my case, LDB_ERR_CONSTRAINT_VIOLATION was returned.
>> The error from ldb said:
>> attribute 'ghost': attribute on 'name=groupA,cn=groups,cn=LDAP,cn=sysdb'
>> specified, but with 0 values (illegal)
>
>ah, now I see your point, I didn't realize that libldb returns such
>useful error messages.
>
You didn't know but you have already used it in sysdb_views :-)

src/db/sysdb_views.c:585:                  ldb_strerror(ret), ret, ldb_errstring(domain->sysdb->ldb));
src/db/sysdb_views.c:619:                  ldb_strerror(ret), ret, ldb_errstring(domain->sysdb->ldb));

>> 
>> But with your patch I could see that ghost attribute was present in msg.
>
>But I would assume that the value was empty, or was the value remove
>during memberOf processing?
Yes, memberof plug-in remove that attribute.

LS



More information about the sssd-devel mailing list