Still not usable.
}
if ( b->a_dn_at != NULL && op->o_ndn != NULL ) {
+ char *dn_at;
Attribute *at;
struct berval bv;
bv.bv_val = op->o_ndn;
bv.bv_len = strlen( bv.bv_val );
+#ifdef SLAPD_SCHEMA_COMPAT
+ dn_at = b->a_dn_at;
+#else
+ dn_at = at_canonical_name( b->a_dn_at );
+#endif
+
/* see if asker is listed in dnattr */
- if ( (at = attr_find( e->e_attrs, b->a_dn_at )) != NULL
+ if ( (at = attr_find( e->e_attrs, dn_at )) != NULL
#ifdef SLAPD_SCHEMA_COMPAT
&& value_find( at->a_vals, &bv, at->a_syntax, 3 ) == 0
#endif
if ( strcasecmp( left, "dnattr" ) == 0 ) {
if( b->a_dn_pat != NULL ) {
fprintf( stderr,
- "%s: line %d: dnaddr already specified.\n",
+ "%s: line %d: dnattr already specified.\n",
fname, lineno );
acl_usage();
}
+#ifdef SLAPD_SCHEMA_COMPAT
b->a_dn_at = ch_strdup( right );
+#else
+ b->a_dn_at = at_find( right );
+
+ if( b->a_dn_at == NULL ) {
+ fprintf( stderr,
+ "%s: line %d: dnattr attribute type undefined.\n",
+ fname, lineno );
+ acl_usage();
+ }
+
+#ifdef SLAPD_OID_DN_SYNTAX
+ if( strcmp( b->a_dn_at->sat_syntax_oid,
+ SLAPD_OID_DN_SYNTAX ) != 0 )
+ {
+ fprintf( stderr,
+ "%s: line %d: dnattr attribute type not of DN syntax.\n",
+ fname, lineno );
+ acl_usage();
+ }
+#endif
+#endif
continue;
}
}
if (name && *name) {
+#ifdef SLAPD_SCHEMA_COMPAT
b->a_group_at = ch_strdup(name);
+#else
+ b->a_group_at = at_find( name );
+#endif
*--name = '/';
} else {
+#ifdef SLAPD_SCHEMA_COMPAT
b->a_group_at = ch_strdup("member");
+#else
+ b->a_group_at = at_find("member");
+#endif
+ }
+
+#ifndef SLAPD_SCHEMA_COMPAT
+ if( b->a_group_at == NULL ) {
+ fprintf( stderr,
+ "%s: line %d: group attribute type undefined.\n",
+ fname, lineno );
+ acl_usage();
+ }
+
+#ifdef SLAPD_OID_DN_SYNTAX
+ if( strcmp( b->a_group_at->sat_syntax_oid,
+ SLAPD_OID_DN_SYNTAX ) != 0 )
+ {
+ fprintf( stderr,
+ "%s: line %d: group attribute type not of DN syntax.\n",
+ fname, lineno );
+ acl_usage();
}
+#endif /* SLAPD_OID_DN_SYNTAX */
+#endif /* !SLAPD_SCHEMA_COMPAT */
continue;
}
acl_usage();
}
- if ( right != NULL && *right != '\0' )
+ if ( right != NULL && *right != '\0' ) {
+#ifdef SLAPD_SCHEMA_COMPAT
b->a_aci_at = ch_strdup( right );
- else
+#else
+ b->a_aci_at = at_find( right );
+#endif
+ } else {
+#ifdef SLAPD_SCHEMA_COMPAT
b->a_aci_at = ch_strdup( SLAPD_ACI_DEFAULT_ATTR );
+#else
+ b->a_aci_at = at_find( SLAPD_ACI_DEFAULT_ATTR );
+#endif
+ }
+
+#ifdef SLAPD_SCHEMA_COMPAT
+ if( b->a_aci_at == NULL ) {
+ fprintf( stderr,
+ "%s: line %d: aci attribute type undefined.\n",
+ fname, lineno );
+ acl_usage();
+ }
+
+#ifdef SLAPD_OID_DN_SYNTAX
+ if( strcmp( b->a_aci_at->sat_syntax_oid,
+ SLAPD_OID_DN_SYNTAX ) != 0 )
+ {
+ fprintf( stderr,
+ "%s: line %d: aci attribute type not of DN syntax.\n",
+ fname, lineno );
+ acl_usage();
+ }
+#endif /* SLAPD_OID_DN_SYNTAX */
+#endif /* SLAPD_SCHEMA_COMPAT */
continue;
}
-#endif
+#endif /* SLAPD_ACI_ENABLED */
if( right != NULL ) {
/* unsplit */
return( DEFAULT_SYNTAX );
}
-#endif
/*
* attr_syntax_config - process an attribute syntax config line
char **argv
)
{
-#ifdef SLAPD_SCHEMA_COMPAT
char *save;
LDAP_ATTRIBUTE_TYPE *at;
int lasti;
#define SYNTAX_DSCE_OID "2.5.13.5"
#define SYNTAX_IA5_OID "1.3.6.1.4.1.1466.115.121.1.26"
#define SYNTAX_IA5CE_OID "1.3.6.1.4.1.1466.109.114.1"
-#define SYNTAX_DN_OID "1.3.6.1.4.1.1466.115.121.1.12"
+#define SYNTAX_DN_OID SLAPD_OID_DN_SYNTAX
#define SYNTAX_TEL_OID "1.3.6.1.4.1.1466.115.121.1.50"
#define SYNTAX_BIN_OID "1.3.6.1.4.1.1466.115.121.1.40" /* octetString */
fname, lineno, scherr2str(code), err);
exit( EXIT_FAILURE );
}
+
ldap_memfree(at);
-#else
- fprintf( stderr, "%s: line %d: %s\n",
- fname, lineno, "not built with -DSLAPD_SCHEMA_COMPAT\n");
- exit( EXIT_FAILURE );
-#endif
}
-#ifdef SLAPD_SCHEMA_COMPAT
int
at_fake_if_needed(
char *name
char *
+#ifdef SLAPD_SCHEMA_COMPAT
at_canonical_name( char * a_type )
+#else
+at_canonical_name( AttributeType * atp )
+#endif
{
+#ifdef SLAPD_SCHEMA_COMPAT
AttributeType *atp;
- if ( (atp=at_find(a_type)) == NULL ) {
+ atp=at_find(a_type);
+#endif
+
+ if ( atp == NULL ) {
+#ifdef SLAPD_SCHEMA_COMPAT
return a_type;
+#else
+ return NULL;
+#endif
} else if ( atp->sat_names
&& atp->sat_names[0] && (*(atp->sat_names[0]) != '\0') )
} else if (atp->sat_oid && (*atp->sat_oid != '\0')) {
return atp->sat_oid;
-
- } else {
- return a_type;
}
+
+#ifdef SLAPD_SCHEMA_COMPAT
+ return a_type;
+#else
+ return NULL;
+#endif
}
#if defined( SLAPD_SCHEMA_DN )
Debug( LDAP_DEBUG_ANY, " get_ava ber_scanf\n", 0, 0, 0 );
return( -1 );
}
+
attr_normalize( ava->ava_type );
+
#ifdef SLAPD_SCHEMA_COMPAT
value_normalize( ava->ava_value.bv_val, attr_syntax( ava->ava_type ) );
#endif
extern int ldbm_back_abandon LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op, ber_int_t msgid ));
+#ifdef SLAPD_SCHEMA_COMPAT
extern int ldbm_back_group LDAP_P(( BackendDB *bd,
Entry *target, const char* gr_ndn, const char* op_ndn,
- const char* objectclassValue, const char* groupattrName));
+ const char* objectclassValue, const char* group_at));
+#else
+extern int ldbm_back_group LDAP_P(( BackendDB *bd,
+ Entry *target, const char* gr_ndn, const char* op_ndn,
+ const char* objectclassValue, AttributeType* group_at));
+#endif
/* hooks for slap tools */
const char *gr_ndn,
const char *op_ndn,
const char *objectclassValue,
+#ifdef SLAPD_SCHEMA_COMPAT
const char *groupattrName
+#else
+ AttributeType *group_at
+#endif
)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
Attribute *attr;
struct berval bv;
+#ifndef SLAPD_SCHEMA_COMPAT
+ char *groupattrName = at_canonical_name( group_at );
+#endif
+
Debug( LDAP_DEBUG_ARGS,
"=> ldbm_back_group: gr dn: \"%s\"\n",
gr_ndn, 0, 0 );
return( idl );
}
+#ifdef SLAPD_SCHEMA_COMPAT
attr_normalize( type );
at_cn = at_canonical_name( type );
+#else
+ at_cn = at_canonical_name( at_find( type ) );
+#endif
if ( at_cn == NULL ) {
Debug( LDAP_DEBUG_ANY,
return( 0 );
}
+#ifdef SLAPD_SCHEMA_COMPAT
at_cn = at_canonical_name( type );
+#else
+ at_cn = at_canonical_name( at_find( type ) );
+#endif
if ( at_cn == NULL ) {
Debug( LDAP_DEBUG_ANY,
return( -1 );
}
-#ifdef SLAPD_SCHEMA_COMPAT
if ( (db = ldbm_cache_open( be, at_cn, LDBM_SUFFIX, mode ))
== NULL ) {
Debug( LDAP_DEBUG_ANY,
}
+#ifdef SLAPD_SCHEMA_COMPAT
for ( i = 0; vals[i] != NULL; i++ ) {
/*
* presence index entry
free( bigbuf );
}
}
+#endif
ldbm_cache_close( be, db );
-#endif
return( 0 );
attr_masks( be->be_private, type, &indexmask, &syntaxmask );
+#ifdef SLAPD_SCHEMA_COMPAT
attr_normalize( type );
at_cn = at_canonical_name( type );
+ if( at_cn ) {
+ Debug( LDAP_DEBUG_ANY, "<= index_attr NULL (attribute type %s has no canonical name)\n",
+ type, 0, 0 );
+ return 0;
+ }
+#else
+ {
+ AttributeType *at = at_find( type );
+
+ if( at == NULL ) {
+ Debug( LDAP_DEBUG_ANY,
+ "<= index_attr NULL (could not find attribute type %s)\n",
+ type, 0, 0 );
+ return 0;
+ }
+
+ at_cn = at_canonical_name( at );
+ }
+
+ if( at_cn ) {
+ Debug( LDAP_DEBUG_ANY, "<= index_attr NULL (attribute type %s (%s) has no canonical name)\n",
+ at->sat_oid, type, 0 );
+ return 0;
+ }
+#endif
+
if ( (db = ldbm_cache_open( be, at_cn, LDBM_SUFFIX, LDBM_NEWDB ))
- == NULL ) {
+ == NULL )
+ {
Debug( LDAP_DEBUG_ANY,
- "<= index_read NULL (could not open %s%s)\n", at_cn,
+ "<= index_attr NULL (could not open %s%s)\n", at_cn,
LDBM_SUFFIX, 0 );
return 0;
}
const char *gr_ndn,
const char *op_ndn,
const char *objectclassValue,
- const char *groupattrName
+#ifdef SLAPD_SCHEMA_COMPAT
+ const char *group_at
+#else
+ AttributeType *group_at
+#endif
)
{
if (be->be_group)
return( be->be_group(be, target, gr_ndn, op_ndn,
- objectclassValue, groupattrName) );
+ objectclassValue, group_at) );
else
return(1);
}
p = strchr(saveline,'(');
parse_oc( fname, lineno, p, cargv );
} else {
+#ifdef SLAPD_SCHEMA_COMPAT
parse_oc_old( be, fname, lineno, cargc, cargv );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "%s: line %d: old objectclass format not supported.\n",
+ fname, lineno, 0 );
+#endif
}
/* specify an attribute type */
p = strchr(saveline,'(');
parse_at( fname, lineno, p, cargv );
} else {
+#ifdef SLAPD_SCHEMA_COMPAT
attr_syntax_config( fname, lineno, cargc - 1,
&cargv[1] );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "%s: line %d: old attribute type format not supported.\n",
+ fname, lineno, 0 );
+#endif
}
/* turn on/off schema checking */
{
rc = ber_scanf( ber, "O", &val );
if ( rc == LBER_ERROR ) {
- return( -1 );
+ rc = -1;
+ goto return_error;
}
+
if ( val == NULL || val->bv_len == 0 ) {
ber_bvfree( val );
- return( LDAP_INVALID_SYNTAX );
- }
+ rc = LDAP_INVALID_SYNTAX;
+ goto return_error;
+ }
+
+ rc = LDAP_PROTOCOL_ERROR;
#ifdef SLAPD_SCHEMA_COMPAT
/* we should call a substring syntax normalization routine */
default:
Debug( LDAP_DEBUG_FILTER, " unknown type\n", tag, 0,
0 );
+
+ ber_bvfree( val );
+
return_error:
+ Debug( LDAP_DEBUG_FILTER, " error=%d\n", rc, 0, 0 );
+
if( fstr ) {
free( *fstr );
*fstr = NULL;
ber_bvfree( f->f_sub_initial );
ber_bvecfree( f->f_sub_any );
ber_bvfree( f->f_sub_final );
- return( LDAP_PROTOCOL_ERROR );
+ return rc;
}
}
LIBSLAPD_F (char *) attr_normalize LDAP_P(( char *s ));
LIBSLAPD_F (int) attr_merge_fast LDAP_P(( Entry *e, char *type, struct berval **vals, int nvals, int naddvals, int *maxvals, Attribute ***a ));
LIBSLAPD_F (int) attr_merge LDAP_P(( Entry *e, char *type, struct berval **vals ));
+
LIBSLAPD_F (Attribute *) attr_find LDAP_P(( Attribute *a, const char *type ));
LIBSLAPD_F (int) attr_delete LDAP_P(( Attribute **attrs, const char *type ));
LIBSLAPD_F (int) attr_syntax LDAP_P(( char *type ));
+
LIBSLAPD_F (void) attr_syntax_config LDAP_P(( const char *fname, int lineno, int argc, char **argv ));
LIBSLAPD_F (AttributeType *) at_find LDAP_P(( const char *name ));
LIBSLAPD_F (int) at_find_in_list LDAP_P(( AttributeType *sat, AttributeType **list ));
LIBSLAPD_F (int) at_fake_if_needed LDAP_P(( char *name ));
LIBSLAPD_F (int) at_schema_info LDAP_P(( Entry *e ));
LIBSLAPD_F (int) at_add LDAP_P(( LDAP_ATTRIBUTE_TYPE *at, const char **err ));
+
+#ifdef SLAPD_SCHEMA_COMPAT
LIBSLAPD_F (char *) at_canonical_name LDAP_P(( char * a_type ));
+#else
+LIBSLAPD_F (char *) at_canonical_name LDAP_P(( AttributeType *a_type ));
+#endif
LIBSLAPD_F (void) attrs_free LDAP_P(( Attribute *a ));
LIBSLAPD_F (Attribute *) attrs_dup LDAP_P(( Attribute *a ));
LIBSLAPD_F (int) backend_connection_init LDAP_P((Connection *conn));
LIBSLAPD_F (int) backend_connection_destroy LDAP_P((Connection *conn));
+#ifdef SLAPD_SCHEMA_COMPAT
+LIBSLAPD_F (int) backend_group LDAP_P((Backend *be,
+ Entry *target,
+ const char *gr_ndn,
+ const char *op_ndn,
+ const char *objectclassValue,
+ const char *groupattrName
+));
+#else
LIBSLAPD_F (int) backend_group LDAP_P((Backend *be,
Entry *target,
const char *gr_ndn,
const char *op_ndn,
const char *objectclassValue,
- const char *groupattrName));
+ AttributeType *groupAttrType
+));
+#endif
#ifdef SLAPD_SCHEMA_DN
/* temporary extern for temporary routine*/
int global_schemacheck = 1; /* schemacheck on is default */
+#ifdef SLAPD_SCHEMA_COMPAT
static void oc_usage_old(void) LDAP_GCCATTR((noreturn));
+#endif
static void oc_usage(void) LDAP_GCCATTR((noreturn));
static void at_usage(void) LDAP_GCCATTR((noreturn));
}
}
+#ifdef SLAPD_SCHEMA_COMPAT
void
parse_oc_old(
Backend *be,
char **argv
)
{
-#ifdef SLAPD_SCHEMA_COMPAT
int i;
char last;
LDAP_OBJECT_CLASS *oc;
exit( EXIT_FAILURE );
}
ldap_memfree(oc);
-
-#else
- fprintf( stderr, "%s: line %d: %s %s\n",
- fname, lineno, "not built with -DSLAPD_SCHEMA_COMPAT\n");
- exit( EXIT_FAILURE );
-#endif
}
+#endif
/* OID Macros */
exit( EXIT_FAILURE );
}
+#ifdef SLAPD_SCHEMA_COMPAT
static void
oc_usage_old( void )
{
fprintf( stderr, " [ allows <attrlist> ]\n" );
exit( EXIT_FAILURE );
}
+#endif
static void
at_usage( void )
#ifndef _SLDAPD_H_
#define _SLDAPD_H_
+#ifndef SLAPD_SCHEMA_NOT_COMPAT
#define SLAPD_SCHEMA_COMPAT 1
+#endif
#include "ldap_defaults.h"
#define SLAPD_ACI_DEFAULT_ATTR "aci"
+/* schema needed by slapd */
+#define SLAPD_OID_DN_SYNTAX "1.3.6.1.4.1.1466.115.121.1.12"
+
LIBSLAPD_F (int) slap_debug;
* represents an matching rule assertion
*/
typedef struct slap_mra {
- char *mra_rule;
- char *mra_type; /* attribute description */
+ char *mra_rule; /* optional */
+ char *mra_type; /* attribute description -- optional */
int mra_dnattrs;
struct berval *mra_value;
} Mra;
slap_access_mask_t a_mask;
char *a_dn_pat;
+#ifdef SLAPD_SCHEMA_COMPAT
char *a_dn_at;
+#else
+ AttributeType *a_dn_at;
+#endif
int a_dn_self;
char *a_peername_pat;
char *a_sockurl_pat;
#ifdef SLAPD_ACI_ENABLED
+#ifdef SLAPD_SCHEMA_COMPAT
char *a_aci_at;
+#else
+ AttributeType *a_aci_at;
+#endif
#endif
/* ACL Groups */
char *a_group_pat;
char *a_group_oc;
+#ifdef SLAPD_SCHEMA_COMPAT
char *a_group_at;
+#else
+ AttributeType *a_group_at;
+#endif
struct slap_access *a_next;
} Access;
int (*bi_acl_group) LDAP_P((Backend *bd,
Entry *e, const char *bdn, const char *edn,
- const char *objectclassValue, const char *groupattrName ));
+ const char *objectclassValue,
+ AttributeType *group_at ));
int (*bi_connection_init) LDAP_P((BackendDB *bd,
struct slap_conn *c));