X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fschema.c;h=f4fab6022c3403ff5e94d6b2a5c05cf38754ba2e;hb=fc49135a367e90d8fccbe9ad43c07c61340a74c7;hp=05dbd557776223c31098cd61c1172c32576a0653;hpb=3952bc8e95a2b21aced14f890028f12d00e191fa;p=openldap diff --git a/servers/slapd/schema.c b/servers/slapd/schema.c index 05dbd55777..f4fab6022c 100644 --- a/servers/slapd/schema.c +++ b/servers/slapd/schema.c @@ -10,7 +10,7 @@ #include "slap.h" static struct objclass *oc_find(char *ocname); -static int oc_check_required(Entry *e, char *ocname); +static char * oc_check_required(Entry *e, char *ocname); static int oc_check_allowed(char *type, struct berval **ocl); /* @@ -35,10 +35,12 @@ oc_schema_check( Entry *e ) /* check that the entry has required attrs for each oc */ for ( i = 0; aoc->a_vals[i] != NULL; i++ ) { - if ( oc_check_required( e, aoc->a_vals[i]->bv_val ) != 0 ) { + char *s = oc_check_required( e, aoc->a_vals[i]->bv_val ); + + if (s != NULL) { Debug( LDAP_DEBUG_ANY, - "Entry (%s), required attr (%s) missing\n", - e->e_dn, aoc->a_vals[i]->bv_val, 0 ); + "Entry (%s), oc \"%s\" requires attr \"%s\"\n", + e->e_dn, aoc->a_vals[i]->bv_val, s ); ret = 1; } } @@ -51,7 +53,7 @@ oc_schema_check( Entry *e ) 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", + "Entry (%s), attr \"%s\" not allowed\n", e->e_dn, a->a_type, 0 ); ret = 1; } @@ -60,7 +62,7 @@ oc_schema_check( Entry *e ) return( ret ); } -static int +static char * oc_check_required( Entry *e, char *ocname ) { struct objclass *oc; @@ -89,11 +91,25 @@ oc_check_required( Entry *e, char *ocname ) /* not there => schema violation */ if ( a == NULL ) { - return( 1 ); + return oc->oc_required[i]; } } - return( 0 ); + return( NULL ); +} + +/* + * check to see if attribute is 'operational' or not. + * this function should be externalized... + */ +static int +oc_check_operational( char *type ) +{ + return ( strcasecmp( type, "modifiersname" ) == 0 || + strcasecmp( type, "modifytimestamp" ) == 0 || + strcasecmp( type, "creatorsname" ) == 0 || + strcasecmp( type, "createtimestamp" ) == 0 ) + ? 1 : 0; } static int @@ -107,6 +123,10 @@ oc_check_allowed( char *type, struct berval **ocl ) return( 0 ); } + if ( oc_check_operational( type ) ) { + return( 0 ); + } + /* check that the type appears as req or opt in at least one oc */ for ( i = 0; ocl[i] != NULL; i++ ) { /* if we know about the oc */