Add support for obsolete attributes.

We don't support collective attributes (yet).
Remove exit() calls from scheme parsers.  Need to do same for acl parser.
This commit is contained in:
Kurt Zeilenga 2001-05-17 07:31:59 +00:00
parent 90766f4d4f
commit 0aef7722e6
6 changed files with 63 additions and 34 deletions

View File

@ -246,6 +246,11 @@ at_add(
cname = ""; cname = "";
return SLAP_SCHERR_ATTR_INCOMPLETE; return SLAP_SCHERR_ATTR_INCOMPLETE;
} }
if ( at->at_collective ) {
return SLAP_SCHERR_NOT_SUPPORTED;
}
sat = (AttributeType *) ch_calloc( 1, sizeof(AttributeType) ); sat = (AttributeType *) ch_calloc( 1, sizeof(AttributeType) );
AC_MEMCPY( &sat->sat_atype, at, sizeof(LDAPAttributeType)); AC_MEMCPY( &sat->sat_atype, at, sizeof(LDAPAttributeType));
@ -323,7 +328,6 @@ at_add(
} }
code = at_insert(sat,err); code = at_insert(sat,err);
return code;
} }
#ifdef LDAP_DEBUG #ifdef LDAP_DEBUG

View File

@ -1368,14 +1368,17 @@ read_config( const char *fname )
lutil_set_debug_level( cargv[1], level ); lutil_set_debug_level( cargv[1], level );
/* specify an Object Identifier macro */ /* specify an Object Identifier macro */
} else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) { } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
parse_oidm( fname, lineno, cargc, cargv ); rc = parse_oidm( fname, lineno, cargc, cargv );
if( rc ) return rc;
/* specify an objectclass */ /* specify an objectclass */
} else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) { } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
if ( *cargv[1] == '(' ) { if ( *cargv[1] == '(' ) {
char * p; char * p;
p = strchr(saveline,'('); p = strchr(saveline,'(');
parse_oc( fname, lineno, p, cargv ); rc = parse_oc( fname, lineno, p, cargv );
if( rc ) return rc;
} else { } else {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_INFO, LDAP_LOG(( "config", LDAP_LEVEL_INFO,
@ -1396,7 +1399,9 @@ read_config( const char *fname )
if ( *cargv[1] == '(' ) { if ( *cargv[1] == '(' ) {
char * p; char * p;
p = strchr(saveline,'('); p = strchr(saveline,'(');
parse_at( fname, lineno, p, cargv ); rc = parse_at( fname, lineno, p, cargv );
if( rc ) return rc;
} else { } else {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_INFO, LDAP_LOG(( "config", LDAP_LEVEL_INFO,

View File

@ -414,6 +414,21 @@ int slap_modlist2mods(
return LDAP_CONSTRAINT_VIOLATION; return LDAP_CONSTRAINT_VIOLATION;
} }
if ( is_at_obsolete( ad->ad_type ) &&
( mod->sml_op == LDAP_MOD_ADD || ml->ml_bvalues != NULL ) )
{
/*
* attribute is obsolete,
* only allow replace/delete with no values
*/
slap_mods_free( mod );
snprintf( textbuf, textlen,
"%s: attribute is obsolete",
ml->ml_type );
*text = textbuf;
return LDAP_CONSTRAINT_VIOLATION;
}
/* /*
* check values * check values
*/ */
@ -423,16 +438,6 @@ int slap_modlist2mods(
ad->ad_type->sat_syntax->ssyn_validate; ad->ad_type->sat_syntax->ssyn_validate;
if( !validate ) { if( !validate ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
"modlist2mods: %s: no validator for syntax %s\n",
ml->ml_type, ad->ad_type->sat_syntax->ssyn_oid ));
#else
Debug( LDAP_DEBUG_TRACE,
"modlist2mods: %s: no validator for syntax %s\n",
ml->ml_type, ad->ad_type->sat_syntax->ssyn_oid, 0 );
#endif
slap_mods_free( mod ); slap_mods_free( mod );
*text = "no validator for syntax"; *text = "no validator for syntax";
snprintf( textbuf, textlen, snprintf( textbuf, textlen,

View File

@ -685,12 +685,17 @@ LDAP_SLAPD_F (int) schema_prep LDAP_P((void));
* schemaparse.c * schemaparse.c
*/ */
LDAP_SLAPD_F (void) parse_oc_old LDAP_P(( Backend *be, const char *fname, int lineno, int argc, char **argv )); LDAP_SLAPD_F (int) parse_oc_old LDAP_P((
LDAP_SLAPD_F (void) parse_oc LDAP_P(( const char *fname, int lineno, char *line, char **argv )); Backend *be, const char *fname, int lineno, int argc, char **argv ));
LDAP_SLAPD_F (void) parse_at LDAP_P(( const char *fname, int lineno, char *line, char **argv )); LDAP_SLAPD_F (int) parse_oc LDAP_P((
LDAP_SLAPD_F (void) parse_oidm LDAP_P(( const char *fname, int lineno, int argc, char **argv )); const char *fname, int lineno, char *line, char **argv ));
LDAP_SLAPD_F (int) parse_at LDAP_P((
const char *fname, int lineno, char *line, char **argv ));
LDAP_SLAPD_F (int) parse_oidm LDAP_P((
const char *fname, int lineno, int argc, char **argv ));
LDAP_SLAPD_F (char *) scherr2str LDAP_P((int code)) LDAP_GCCATTR((const)); LDAP_SLAPD_F (char *) scherr2str LDAP_P((int code)) LDAP_GCCATTR((const));
LDAP_SLAPD_F (int) dscompare LDAP_P(( const char *s1, const char *s2del, char delim )); LDAP_SLAPD_F (int) dscompare LDAP_P(( const char *s1, const char *s2del,
char delim ));
/* /*

View File

@ -18,8 +18,8 @@
int global_schemacheck = 1; /* schemacheck on is default */ int global_schemacheck = 1; /* schemacheck on is default */
static void oc_usage(void) LDAP_GCCATTR((noreturn)); static void oc_usage(void);
static void at_usage(void) LDAP_GCCATTR((noreturn)); static void at_usage(void);
static char *const err2text[] = { static char *const err2text[] = {
"Success", "Success",
@ -36,7 +36,8 @@ static char *const err2text[] = {
"SYNTAX or SUPerior required", "SYNTAX or SUPerior required",
"MatchingRule not found", "MatchingRule not found",
"Syntax not found", "Syntax not found",
"Syntax required" "Syntax required",
"Qualifier not supported"
}; };
char * char *
@ -112,7 +113,7 @@ find_oidm(char *oid)
return NULL; return NULL;
} }
void int
parse_oidm( parse_oidm(
const char *fname, const char *fname,
int lineno, int lineno,
@ -127,7 +128,7 @@ parse_oidm(
fprintf( stderr, "%s: line %d: too many arguments\n", fprintf( stderr, "%s: line %d: too many arguments\n",
fname, lineno ); fname, lineno );
usage: fprintf( stderr, "\tObjectIdentifier <name> <oid>\n"); usage: fprintf( stderr, "\tObjectIdentifier <name> <oid>\n");
exit( EXIT_FAILURE ); return 1;
} }
oid = find_oidm( argv[1] ); oid = find_oidm( argv[1] );
@ -136,7 +137,7 @@ usage: fprintf( stderr, "\tObjectIdentifier <name> <oid>\n");
"%s: line %d: " "%s: line %d: "
"ObjectIdentifier \"%s\" previously defined \"%s\"", "ObjectIdentifier \"%s\" previously defined \"%s\"",
fname, lineno, argv[1], oid ); fname, lineno, argv[1], oid );
exit( EXIT_FAILURE ); return 1;
} }
om = (OidMacro *) ch_malloc( sizeof(OidMacro) ); om = (OidMacro *) ch_malloc( sizeof(OidMacro) );
@ -158,9 +159,11 @@ usage: fprintf( stderr, "\tObjectIdentifier <name> <oid>\n");
om->som_oid.bv_len = strlen( om->som_oid.bv_val ); om->som_oid.bv_len = strlen( om->som_oid.bv_val );
om->som_next = om_list; om->som_next = om_list;
om_list = om; om_list = om;
return 0;
} }
void int
parse_oc( parse_oc(
const char *fname, const char *fname,
int lineno, int lineno,
@ -178,7 +181,9 @@ parse_oc(
fprintf( stderr, "%s: line %d: %s before %s\n", fprintf( stderr, "%s: line %d: %s before %s\n",
fname, lineno, ldap_scherr2str(code), err ); fname, lineno, ldap_scherr2str(code), err );
oc_usage(); oc_usage();
return 1;
} }
if ( oc->oc_oid ) { if ( oc->oc_oid ) {
if ( !OID_LEADCHAR( oc->oc_oid[0] )) { if ( !OID_LEADCHAR( oc->oc_oid[0] )) {
/* Expand OID macros */ /* Expand OID macros */
@ -187,7 +192,7 @@ parse_oc(
fprintf(stderr, fprintf(stderr,
"%s: line %d: OID %s not recognized\n", "%s: line %d: OID %s not recognized\n",
fname, lineno, oc->oc_oid); fname, lineno, oc->oc_oid);
exit( EXIT_FAILURE ); return 1;
} }
if ( oid != oc->oc_oid ) { if ( oid != oc->oc_oid ) {
ldap_memfree( oc->oc_oid ); ldap_memfree( oc->oc_oid );
@ -195,14 +200,17 @@ parse_oc(
} }
} }
} }
/* oc->oc_oid == NULL will be an error someday */ /* oc->oc_oid == NULL will be an error someday */
code = oc_add(oc,&err); code = oc_add(oc,&err);
if ( code ) { if ( code ) {
fprintf( stderr, "%s: line %d: %s: \"%s\"\n", fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
fname, lineno, scherr2str(code), err); fname, lineno, scherr2str(code), err);
exit( EXIT_FAILURE ); return 1;
} }
ldap_memfree(oc); ldap_memfree(oc);
return 0;
} }
static void static void
@ -220,7 +228,6 @@ oc_usage( void )
" [ \"MUST\" oids ] ; AttributeTypes\n" " [ \"MUST\" oids ] ; AttributeTypes\n"
" [ \"MAY\" oids ] ; AttributeTypes\n" " [ \"MAY\" oids ] ; AttributeTypes\n"
" whsp \")\"\n" ); " whsp \")\"\n" );
exit( EXIT_FAILURE );
} }
@ -248,10 +255,9 @@ at_usage( void )
" ; distributedOperation\n" " ; distributedOperation\n"
" ; dSAOperation\n" " ; dSAOperation\n"
" whsp \")\"\n"); " whsp \")\"\n");
exit( EXIT_FAILURE );
} }
void int
parse_at( parse_at(
const char *fname, const char *fname,
int lineno, int lineno,
@ -284,7 +290,7 @@ parse_at(
{ {
fprintf(stderr, "%s: line %d: OID %s not found\n", fprintf(stderr, "%s: line %d: OID %s not found\n",
fname, lineno, argv[4]); fname, lineno, argv[4]);
exit( EXIT_FAILURE ); return 1;
} }
memset(strstr(line, argv[4]), '0', slen); memset(strstr(line, argv[4]), '0', slen);
soid = ch_strdup(syn->ssyn_syn.syn_oid ); soid = ch_strdup(syn->ssyn_syn.syn_oid );
@ -296,6 +302,7 @@ parse_at(
fprintf( stderr, "%s: line %d: %s before %s\n", fprintf( stderr, "%s: line %d: %s before %s\n",
fname, lineno, ldap_scherr2str(code), err ); fname, lineno, ldap_scherr2str(code), err );
at_usage(); at_usage();
return 1;
} }
if ( at->at_oid ) { if ( at->at_oid ) {
if ( !OID_LEADCHAR( at->at_oid[0] )) { if ( !OID_LEADCHAR( at->at_oid[0] )) {
@ -305,7 +312,7 @@ parse_at(
fprintf(stderr, fprintf(stderr,
"%s: line %d: OID %s not recognized\n", "%s: line %d: OID %s not recognized\n",
fname, lineno, at->at_oid); fname, lineno, at->at_oid);
exit( EXIT_FAILURE ); return 1;
} }
if ( oid != at->at_oid ) { if ( oid != at->at_oid ) {
ldap_memfree( at->at_oid ); ldap_memfree( at->at_oid );
@ -322,7 +329,8 @@ parse_at(
if ( code ) { if ( code ) {
fprintf( stderr, "%s: line %d: %s: \"%s\"\n", fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
fname, lineno, scherr2str(code), err); fname, lineno, scherr2str(code), err);
exit( EXIT_FAILURE ); return 1;
} }
ldap_memfree(at); ldap_memfree(at);
return 0;
} }

View File

@ -216,6 +216,7 @@ typedef struct slap_ssf_set {
#define SLAP_SCHERR_MR_NOT_FOUND 12 #define SLAP_SCHERR_MR_NOT_FOUND 12
#define SLAP_SCHERR_SYN_NOT_FOUND 13 #define SLAP_SCHERR_SYN_NOT_FOUND 13
#define SLAP_SCHERR_MR_INCOMPLETE 14 #define SLAP_SCHERR_MR_INCOMPLETE 14
#define SLAP_SCHERR_NOT_SUPPORTED 15
typedef struct slap_oid_macro { typedef struct slap_oid_macro {
struct berval som_oid; struct berval som_oid;
@ -382,6 +383,7 @@ typedef struct slap_attribute_type {
#define is_at_operational(at) ((at)->sat_usage) #define is_at_operational(at) ((at)->sat_usage)
#define is_at_single_value(at) ((at)->sat_single_value) #define is_at_single_value(at) ((at)->sat_single_value)
#define is_at_collective(at) ((at)->sat_collective) #define is_at_collective(at) ((at)->sat_collective)
#define is_at_obsolete(at) ((at)->sat_obsolete)
#define is_at_no_user_mod(at) ((at)->sat_no_user_mod) #define is_at_no_user_mod(at) ((at)->sat_no_user_mod)
typedef struct slap_object_class { typedef struct slap_object_class {