[Date Prev][Date Next] [Chronological] [Thread] [Top]

Patch to improve LDAP error strings

I have made an attempt to improve the textual error messages returned in an
LDAP session from server to client when adding or modifying an entry.

Instead of fixed text strings such as "value contains invalid data", they
now identify which attribute is at fault (e.g. "value for attribute
ipHostNumber contains invalid data").

I found it rather frustrating to submit a new entry with, say, 20
attributes, and have it fail without any indication of where the problem
lay. Since LDAP does provide for these text messages, and they are likely
either to be seen by the client or logged at the client end when debugging,
I think this is a worthwhile improvement.

Two patches are attached:

- One against openldap-devel, which I have not tested except to show that
  it compiles (but note that I am unable to compile the bdb backend anyway,
  since my FreeBSD box does not have DB_ENV, so I may have broken this)

- A backport against openldap-2.0.7; this is the patch I am actually using.
  I have only given it a quick test, but it does seem to function

Instead of just passing back a pointer to a fixed error string, after
applying this patch many functions now take a pointer+length to a buffer
allocated by the caller, into which the result string is written. There are
other functions where this could be done too, for consistency.

I hope this is useful to somebody :-)


Brian Candler.

P.S. One other point. In the original codebase, there are places where *text
appears to be used for debug output before it is assigned. Is there a subtle
reason for this, or is it just a bug? For example, from

        if( err != LDAP_SUCCESS ) {
                Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
                        err, *text, 0);
                *text = "modify: add values failed";

I have swapped these around in the attached patches.

Attachment: openldap-devel20010219-messages.gz
Description: application/gunzip

Attachment: openldap-2.0.7-messages.gz
Description: application/gunzip