which should help in debugging schema development for back-config.
The check essentially verifies, when a duplicate attributeType is found,
that the new attributeType definition is an exact duplicate of the
definition already present in the schema.
return (*at != NULL);
}
-
+
+/*
+ * check whether the two attributeTypes actually __are__ identical,
+ * or rather inconsistent
+ */
+static int
+at_check_dup(
+ AttributeType *sat,
+ AttributeType *new_sat )
+{
+ if ( new_sat->sat_oid != NULL ) {
+ if ( sat->sat_oid == NULL ) {
+ return SLAP_SCHERR_ATTR_INCONSISTENT;
+ }
+
+ if ( strcmp( sat->sat_oid, new_sat->sat_oid ) != 0 ) {
+ return SLAP_SCHERR_ATTR_INCONSISTENT;
+ }
+
+ } else {
+ if ( sat->sat_oid != NULL ) {
+ return SLAP_SCHERR_ATTR_INCONSISTENT;
+ }
+ }
+
+ if ( new_sat->sat_names ) {
+ int i;
+
+ if ( sat->sat_names == NULL ) {
+ return SLAP_SCHERR_ATTR_INCONSISTENT;
+ }
+
+ for ( i = 0; new_sat->sat_names[ i ]; i++ ) {
+ if ( sat->sat_names[ i ] == NULL ) {
+ return SLAP_SCHERR_ATTR_INCONSISTENT;
+ }
+
+ if ( strcasecmp( sat->sat_names[ i ],
+ new_sat->sat_names[ i ] ) != 0 )
+ {
+ return SLAP_SCHERR_ATTR_INCONSISTENT;
+ }
+ }
+ } else {
+ if ( sat->sat_names != NULL ) {
+ return SLAP_SCHERR_ATTR_INCONSISTENT;
+ }
+ }
+
+ return SLAP_SCHERR_ATTR_DUP;
+}
static int
struct aindexrec *air;
char **names;
+
if ( sat->sat_oid ) {
air = (struct aindexrec *)
ch_calloc( 1, sizeof(struct aindexrec) );
air->air_name.bv_len = strlen(sat->sat_oid);
air->air_at = sat;
if ( avl_insert( &attr_index, (caddr_t) air,
- attr_index_cmp, avl_dup_error ) ) {
+ attr_index_cmp, avl_dup_error ) )
+ {
+ AttributeType *old_sat;
+ int rc;
+
*err = sat->sat_oid;
- ldap_memfree(air);
- return SLAP_SCHERR_ATTR_DUP;
+
+ old_sat = at_bvfind( &air->air_name );
+ rc = at_check_dup( old_sat, sat );
+
+ ldap_memfree( air );
+
+ return rc;
}
/* FIX: temporal consistency check */
- at_bvfind(&air->air_name);
+ at_bvfind( &air->air_name );
}
- if ( (names = sat->sat_names) ) {
+ names = sat->sat_names;
+ if ( names ) {
while ( *names ) {
air = (struct aindexrec *)
ch_calloc( 1, sizeof(struct aindexrec) );
air->air_name.bv_len = strlen(*names);
air->air_at = sat;
if ( avl_insert( &attr_index, (caddr_t) air,
- attr_index_cmp, avl_dup_error ) ) {
+ attr_index_cmp, avl_dup_error ) )
+ {
+ AttributeType *old_sat;
+ int rc;
+
*err = *names;
+
+ old_sat = at_bvfind( &air->air_name );
+ rc = at_check_dup( old_sat, sat );
+
ldap_memfree(air);
- return SLAP_SCHERR_ATTR_DUP;
+
+ return rc;
}
/* FIX: temporal consistency check */
at_bvfind(&air->air_name);
sat->sat_substr = mr;
}
- code = at_insert(sat,err);
+ code = at_insert( sat, err );
if ( code == 0 && rsat )
*rsat = sat;
return code;
AttributeType *at;
int i, num;
struct berval bv, *bva = NULL, idx;
- char ibuf[32], *ptr;
+ char ibuf[32];
if ( !start )
start = LDAP_STAILQ_FIRST( &attr_list );
"AttributeType inappropriate SUPerior",
"AttributeType SYNTAX or SUPerior required",
"Duplicate attributeType",
+ "Inconsistent attributeType",
"MatchingRule not found",
"MatchingRule incomplete",
"Duplicate matchingRule",
"Duplicate Content Rule",
"Content Rule not for STRUCTURAL object class",
"Content Rule AUX contains inappropriate object class",
- "Content Rule attribute type list contains duplicate"
+ "Content Rule attribute type list contains duplicate",
+ NULL
};
char *
/*
* represents schema information for a database
*/
-#define SLAP_SCHERR_OUTOFMEM 1
-#define SLAP_SCHERR_CLASS_NOT_FOUND 2
-#define SLAP_SCHERR_CLASS_BAD_USAGE 3
-#define SLAP_SCHERR_CLASS_BAD_SUP 4
-#define SLAP_SCHERR_CLASS_DUP 5
-#define SLAP_SCHERR_ATTR_NOT_FOUND 6
-#define SLAP_SCHERR_ATTR_BAD_MR 7
-#define SLAP_SCHERR_ATTR_BAD_USAGE 8
-#define SLAP_SCHERR_ATTR_BAD_SUP 9
-#define SLAP_SCHERR_ATTR_INCOMPLETE 10
-#define SLAP_SCHERR_ATTR_DUP 11
-#define SLAP_SCHERR_MR_NOT_FOUND 12
-#define SLAP_SCHERR_MR_INCOMPLETE 13
-#define SLAP_SCHERR_MR_DUP 14
-#define SLAP_SCHERR_SYN_NOT_FOUND 15
-#define SLAP_SCHERR_SYN_DUP 16
-#define SLAP_SCHERR_NO_NAME 17
-#define SLAP_SCHERR_NOT_SUPPORTED 18
-#define SLAP_SCHERR_BAD_DESCR 19
-#define SLAP_SCHERR_OIDM 20
-#define SLAP_SCHERR_CR_DUP 21
-#define SLAP_SCHERR_CR_BAD_STRUCT 22
-#define SLAP_SCHERR_CR_BAD_AUX 23
-#define SLAP_SCHERR_CR_BAD_AT 24
-#define SLAP_SCHERR_LAST SLAP_SCHERR_CR_BAD_AT
+enum {
+ SLAP_SCHERR_OUTOFMEM = 1,
+ SLAP_SCHERR_CLASS_NOT_FOUND,
+ SLAP_SCHERR_CLASS_BAD_USAGE,
+ SLAP_SCHERR_CLASS_BAD_SUP,
+ SLAP_SCHERR_CLASS_DUP,
+ SLAP_SCHERR_ATTR_NOT_FOUND,
+ SLAP_SCHERR_ATTR_BAD_MR,
+ SLAP_SCHERR_ATTR_BAD_USAGE,
+ SLAP_SCHERR_ATTR_BAD_SUP,
+ SLAP_SCHERR_ATTR_INCOMPLETE,
+ SLAP_SCHERR_ATTR_DUP,
+ SLAP_SCHERR_ATTR_INCONSISTENT,
+ SLAP_SCHERR_MR_NOT_FOUND,
+ SLAP_SCHERR_MR_INCOMPLETE,
+ SLAP_SCHERR_MR_DUP,
+ SLAP_SCHERR_SYN_NOT_FOUND,
+ SLAP_SCHERR_SYN_DUP,
+ SLAP_SCHERR_NO_NAME,
+ SLAP_SCHERR_NOT_SUPPORTED,
+ SLAP_SCHERR_BAD_DESCR,
+ SLAP_SCHERR_OIDM,
+ SLAP_SCHERR_CR_DUP,
+ SLAP_SCHERR_CR_BAD_STRUCT,
+ SLAP_SCHERR_CR_BAD_AUX,
+ SLAP_SCHERR_CR_BAD_AT,
+
+ SLAP_SCHERR_LAST
+};
typedef union slap_sockaddr {
struct sockaddr sa_addr;