[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
more verbose error reporting
I would like to see more diagnostic information sent back to the client when
things fail. The protocol allows arbitrary error message text to accompany
each result, but slapd code rarely uses this feature. Why is that?
As an example, I've changed oc_schema_check to return the reason for the
failure. It's not so nice, using a fixed size error message buffer, but
that's the best we can do without creating a new mechanism for status
reporting. (I also show the corresponding change in back-ldbm/add.c; the
same change would be needed in modify.c and back-bdb2/{add,modify}.c)
Index: proto-slap.h
===================================================================
RCS file: /var/CVSROOT/ldap/servers/slapd/proto-slap.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 proto-slap.h
--- proto-slap.h 1999/08/03 23:02:56 1.1.1.1
+++ proto-slap.h 1999/08/04 08:09:47
@@ -329,7 +329,7 @@
* schema.c
*/
-int oc_schema_check LDAP_P(( Entry *e ));
+int oc_schema_check LDAP_P(( Entry *e, char *err ));
int oc_check_operational_attr LDAP_P(( char *type ));
int oc_check_usermod_attr LDAP_P(( char *type ));
int oc_check_no_usermod_attr LDAP_P(( char *type ));
Index: schema.c
===================================================================
RCS file: /var/CVSROOT/ldap/servers/slapd/schema.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 schema.c
--- schema.c 1999/08/03 23:02:56 1.1.1.1
+++ schema.c 1999/08/04 08:23:30
@@ -21,16 +21,20 @@
*/
int
-oc_schema_check( Entry *e )
+oc_schema_check( Entry *e, char *err )
{
Attribute *a, *aoc;
int i;
int ret = 0;
+ char errbuf[BUFSIZ];
+ if (!err)
+ err = errbuf;
+
/* find the object class attribute - could error out here */
if ( (aoc = attr_find( e->e_attrs, "objectclass" )) == NULL ) {
- Debug( LDAP_DEBUG_ANY, "No object class for entry (%s)\n",
- e->e_dn, 0, 0 );
+ sprintf( err, "Entry (%s), object class missing", e->e_dn );
+ Debug( LDAP_DEBUG_ANY, "%s\n", err, 0, 0);
return( 1 );
}
@@ -39,9 +43,9 @@
char *s = oc_check_required( e, aoc->a_vals[i]->bv_val );
if (s != NULL) {
- Debug( LDAP_DEBUG_ANY,
- "Entry (%s), oc \"%s\" requires attr \"%s\"\n",
+ sprintf( err, "Entry (%s), oc \"%s\" requires attr
\"%s\"",
e->e_dn, aoc->a_vals[i]->bv_val, s );
+ Debug( LDAP_DEBUG_ANY, "%s\n", err, 0, 0);
ret = 1;
}
}
@@ -53,9 +57,9 @@
/* check that each attr in the entry is allowed by some oc */
for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
if ( oc_check_allowed( a->a_type, aoc->a_vals ) != 0 ) {
- Debug( LDAP_DEBUG_ANY,
- "Entry (%s), attr \"%s\" not allowed\n",
- e->e_dn, a->a_type, 0 );
+ sprintf( err, "Entry (%s), attr \"%s\" not allowed",
+ e->e_dn, a->a_type );
+ Debug( LDAP_DEBUG_ANY, "%s\n", err, 0, 0);
ret = 1;
}
}
Index: back-ldbm/add.c
===================================================================
RCS file: /var/CVSROOT/ldap/servers/slapd/back-ldbm/add.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 add.c
--- back-ldbm/add.c 1999/08/03 23:02:56 1.1.1.1
+++ back-ldbm/add.c 1999/08/04 08:25:19
@@ -20,7 +20,7 @@
)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
- char *pdn;
+ char *pdn, errbuf[BUFSIZ];
Entry *p = NULL;
int rootlock = 0;
int rc;
@@ -38,7 +38,7 @@
return( -1 );
}
- if ( global_schemacheck && oc_schema_check( e ) != 0 ) {
+ if ( global_schemacheck && oc_schema_check( e, errbuf ) != 0 ) {
ldap_pvt_thread_mutex_unlock(&li->li_add_mutex);
Debug( LDAP_DEBUG_TRACE, "entry failed schema check\n",
@@ -46,7 +46,7 @@
entry_free( e );
send_ldap_result( conn, op, LDAP_OBJECT_CLASS_VIOLATION,
- NULL, NULL, NULL, NULL );
+ NULL, errbuf, NULL, NULL );
return( -1 );
}