From: Pierangelo Masarati Date: Mon, 8 Sep 2008 00:10:18 +0000 (+0000) Subject: implement X-SUBST substitute syntax extension (ITS#5663) X-Git-Tag: ACLCHECK_0~1371 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0009def716810b2f67f729cedf75942b5d3384c7;p=openldap implement X-SUBST substitute syntax extension (ITS#5663) --- diff --git a/servers/slapd/schemaparse.c b/servers/slapd/schemaparse.c index c02fdea215..fa9cb2ee07 100644 --- a/servers/slapd/schemaparse.c +++ b/servers/slapd/schemaparse.c @@ -50,6 +50,8 @@ static char *const err2text[] = { "Syntax not found", "Duplicate ldapSyntax", "Superior syntax not found", + "Substitute syntax not specified", + "Substitute syntax not found", "OID or name required", "Qualifier not supported", "Invalid NAME", diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 95c4e898ac..4b5e84dfd7 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -300,6 +300,8 @@ enum { SLAP_SCHERR_SYN_NOT_FOUND, SLAP_SCHERR_SYN_DUP, SLAP_SCHERR_SYN_SUP_NOT_FOUND, + SLAP_SCHERR_SYN_SUBST_NOT_SPECIFIED, + SLAP_SCHERR_SYN_SUBST_NOT_FOUND, SLAP_SCHERR_NO_NAME, SLAP_SCHERR_NOT_SUPPORTED, SLAP_SCHERR_BAD_DESCR, diff --git a/servers/slapd/syntax.c b/servers/slapd/syntax.c index 85025683ec..c7089acc45 100644 --- a/servers/slapd/syntax.c +++ b/servers/slapd/syntax.c @@ -190,6 +190,47 @@ syn_add( ssyn->ssyn_str2ber = def->sd_str2ber; #endif + if ( def->sd_validate == NULL && def->sd_pretty == NULL && syn->syn_extensions != NULL ) { + LDAPSchemaExtensionItem **lsei; + Syntax *subst = NULL; + + for ( lsei = syn->syn_extensions; *lsei != NULL; lsei++) { + if ( strcmp( (*lsei)->lsei_name, "X-SUBST" ) != 0 ) { + continue; + } + + assert( (*lsei)->lsei_values != NULL ); + if ( (*lsei)->lsei_values[0] == '\0' + || (*lsei)->lsei_values[1] != '\0' ) + { + Debug( LDAP_DEBUG_ANY, "syn_add(%s): exactly one substitute syntax must be present\n", + ssyn->ssyn_syn.syn_oid, 0, 0 ); + return SLAP_SCHERR_SYN_SUBST_NOT_SPECIFIED; + } + + subst = syn_find( (*lsei)->lsei_values[0] ); + if ( subst == NULL ) { + Debug( LDAP_DEBUG_ANY, "syn_add(%s): substitute syntax %s not found\n", + ssyn->ssyn_syn.syn_oid, (*lsei)->lsei_values[0], 0 ); + return SLAP_SCHERR_SYN_SUBST_NOT_FOUND; + } + break; + } + + if ( subst != NULL ) { + ssyn->ssyn_flags = subst->ssyn_flags; + ssyn->ssyn_validate = subst->ssyn_validate; + ssyn->ssyn_pretty = subst->ssyn_pretty; + + ssyn->ssyn_sups = NULL; + +#ifdef SLAPD_BINARY_CONVERSION + ssyn->ssyn_ber2str = subst->ssyn_ber2str; + ssyn->ssyn_str2ber = subst->ssyn_str2ber; +#endif + } + } + if ( def->sd_sups != NULL ) { int cnt;