mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-25 09:09:54 -05:00
Misc cleanup and dn_normalize() zapping
Fix nameAndOptionalIdentifer syntax.
This commit is contained in:
parent
bbcb0f8a7f
commit
21288fbb21
10 changed files with 51 additions and 35 deletions
|
|
@ -1674,7 +1674,7 @@ string_expand(
|
|||
char *match,
|
||||
regmatch_t *matches)
|
||||
{
|
||||
int size;
|
||||
ber_len_t size;
|
||||
char *sp;
|
||||
char *dp;
|
||||
int flag;
|
||||
|
|
|
|||
|
|
@ -83,10 +83,12 @@ passwd_back_search(
|
|||
/* Create an entry corresponding to the base DN */
|
||||
e = (Entry *) ch_calloc(1, sizeof(Entry));
|
||||
e->e_attrs = NULL;
|
||||
e->e_dn = ch_strdup( base );
|
||||
e->e_name.bv_val = ch_strdup( base );
|
||||
e->e_name.bv_len = strlen( e->e_name.bv_val );
|
||||
|
||||
e->e_ndn = ch_strdup( e->e_dn );
|
||||
(void) dn_normalize( e->e_ndn );
|
||||
e->e_nname.bv_val = ch_strdup( base );
|
||||
(void) dn_normalize( e->e_nname.bv_val );
|
||||
e->e_nname.bv_len = strlen( e->e_nname.bv_val );
|
||||
|
||||
/* Use the first attribute of the DN
|
||||
* as an attribute within the entry itself.
|
||||
|
|
|
|||
|
|
@ -44,10 +44,16 @@ config_info(
|
|||
vals[1] = NULL;
|
||||
|
||||
e = (Entry *) ch_calloc( 1, sizeof(Entry) );
|
||||
e->e_private = NULL;
|
||||
e->e_attrs = NULL;
|
||||
|
||||
e->e_name.bv_val = SLAPD_CONFIG_DN;
|
||||
e->e_name.bv_len = sizeof( SLAPD_CONFIG_DN ) - 1;
|
||||
|
||||
|
||||
e->e_attrs = NULL;
|
||||
ber_str2bv( SLAPD_CONFIG_DN, sizeof(SLAPD_CONFIG_DN)-1, 1, &e->e_name );
|
||||
dnNormalize( NULL, &e->e_name, &ndn );
|
||||
(void) dnNormalize( NULL, &e->e_name, &ndn );
|
||||
e->e_nname = *ndn;
|
||||
free( ndn );
|
||||
e->e_private = NULL;
|
||||
|
|
|
|||
|
|
@ -307,8 +307,7 @@ str2entry( char *s )
|
|||
return NULL;
|
||||
}
|
||||
|
||||
e->e_nname.bv_val = ndn->bv_val;
|
||||
e->e_nname.bv_len = ndn->bv_len;
|
||||
e->e_nname = *ndn;
|
||||
free( ndn );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,9 @@ get_limits(
|
|||
}
|
||||
} else {
|
||||
/* check for unescaped rdn separator */
|
||||
if ( !DN_SEPARATOR( ndn->bv_val[d-1] ) || DN_ESCAPE( ndn->bv_val[d-2] ) ) {
|
||||
if ( !DN_SEPARATOR( ndn->bv_val[d-1] )
|
||||
|| DN_ESCAPE( ndn->bv_val[d-2] ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -97,7 +99,9 @@ get_limits(
|
|||
if ( ndn->bv_len == 0 ) {
|
||||
break;
|
||||
}
|
||||
if ( regexec( &lm[0]->lm_dn_regex, ndn->bv_val, 0, NULL, 0 ) == 0 ) {
|
||||
if ( regexec( &lm[0]->lm_dn_regex, ndn->bv_val, 0, NULL, 0 )
|
||||
== 0 )
|
||||
{
|
||||
*limit = &lm[0]->lm_limits;
|
||||
return( 0 );
|
||||
}
|
||||
|
|
@ -126,7 +130,7 @@ get_limits(
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
add_limits(
|
||||
Backend *be,
|
||||
int type,
|
||||
|
|
|
|||
|
|
@ -464,9 +464,6 @@ LDAP_SLAPD_F (int) test_filter LDAP_P((
|
|||
*/
|
||||
LDAP_SLAPD_F (int) get_limits LDAP_P((
|
||||
Backend *be, struct berval *ndn, struct slap_limits_set **limit ));
|
||||
LDAP_SLAPD_F (int) add_limits LDAP_P((
|
||||
Backend *be, int type, const char *pattern,
|
||||
struct slap_limits_set *limit ));
|
||||
LDAP_SLAPD_F (int) parse_limits LDAP_P((
|
||||
Backend *be, const char *fname, int lineno, int argc, char **argv ));
|
||||
LDAP_SLAPD_F (int) parse_limit LDAP_P(( const char *arg,
|
||||
|
|
|
|||
|
|
@ -762,11 +762,12 @@ send_search_entry(
|
|||
|
||||
if ( ! access_allowed( be, conn, op, e, desc, NULL, ACL_READ ) ) {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "acl", LDAP_LEVEL_INFO,
|
||||
"send_search_entry: conn %d access to attribute %s not allowed\n",
|
||||
op->o_connid, desc->ad_cname.bv_val ));
|
||||
LDAP_LOG(( "acl", LDAP_LEVEL_INFO, "send_search_entry: "
|
||||
"conn %d access to attribute %s not allowed\n",
|
||||
op->o_connid, desc->ad_cname.bv_val ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ACL, "acl: access to attribute %s not allowed\n",
|
||||
Debug( LDAP_DEBUG_ACL, "acl: "
|
||||
"access to attribute %s not allowed\n",
|
||||
desc->ad_cname.bv_val, 0, 0 );
|
||||
#endif
|
||||
|
||||
|
|
@ -776,8 +777,8 @@ send_search_entry(
|
|||
if (( rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname )) == -1 ) {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
|
||||
"send_search_entry: conn %d ber_printf failed\n",
|
||||
op->o_connid ));
|
||||
"send_search_entry: conn %d ber_printf failed\n",
|
||||
op->o_connid ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -66,9 +66,16 @@ root_dse_info(
|
|||
e = (Entry *) ch_calloc( 1, sizeof(Entry) );
|
||||
|
||||
e->e_attrs = NULL;
|
||||
e->e_dn = ch_strdup( LDAP_ROOT_DSE );
|
||||
e->e_ndn = ch_strdup( LDAP_ROOT_DSE );
|
||||
/* the DN is an empty string so no normalization needed */
|
||||
e->e_name.bv_val = ch_strdup( LDAP_ROOT_DSE );
|
||||
e->e_name.bv_len = sizeof( LDAP_ROOT_DSE )-1;
|
||||
e->e_nname.bv_val = ch_strdup( LDAP_ROOT_DSE );
|
||||
e->e_nname.bv_len = sizeof( LDAP_ROOT_DSE )-1;
|
||||
|
||||
/* the DN is an empty string so no pretty/normalization is needed */
|
||||
assert( !e->e_name.bv_len );
|
||||
assert( !e->e_nname.bv_len );
|
||||
|
||||
|
||||
e->e_private = NULL;
|
||||
|
||||
val.bv_val = "OpenLDAProotDSE";
|
||||
|
|
@ -191,8 +198,8 @@ int read_root_dse_file( const char *fname )
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* make sure the DN is a valid rootdse(rootdse is a null string) */
|
||||
if( strcmp(e->e_ndn, "") != 0 ) {
|
||||
/* make sure the DN is the empty DN */
|
||||
if( e->e_nname.bv_len ) {
|
||||
fprintf( stderr,
|
||||
"root_dse: invalid rootDSE - dn=\"%s\" (line=%d)\n",
|
||||
e->e_dn, lineno );
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ schema_info( Entry **entry, const char **text )
|
|||
|
||||
e->e_attrs = NULL;
|
||||
ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1, &e->e_name);
|
||||
dnNormalize( NULL, &e->e_name, &ndn );
|
||||
(void) dnNormalize( NULL, &e->e_name, &ndn );
|
||||
e->e_nname = *ndn;
|
||||
free( ndn );
|
||||
e->e_private = NULL;
|
||||
|
|
|
|||
|
|
@ -227,30 +227,31 @@ nameUIDValidate(
|
|||
if( in->bv_len == 0 ) return LDAP_SUCCESS;
|
||||
|
||||
dn = ber_bvdup( in );
|
||||
if( !dn ) return LDAP_OTHER;
|
||||
|
||||
if( dn->bv_val[dn->bv_len-1] == '\'' ) {
|
||||
if( dn->bv_val[dn->bv_len-1] == 'B'
|
||||
&& dn->bv_val[dn->bv_len-2] == '\'' )
|
||||
{
|
||||
/* assume presence of optional UID */
|
||||
ber_len_t i;
|
||||
|
||||
for(i=dn->bv_len-2; i>2; i--) {
|
||||
for(i=dn->bv_len-3; i>1; i--) {
|
||||
if( dn->bv_val[i] != '0' && dn->bv_val[i] != '1' ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( dn->bv_val[i] != '\'' ||
|
||||
dn->bv_val[i-1] != 'B' ||
|
||||
dn->bv_val[i-2] != '#' ) {
|
||||
dn->bv_val[i-1] != '#' ) {
|
||||
ber_bvfree( dn );
|
||||
return LDAP_INVALID_SYNTAX;
|
||||
}
|
||||
|
||||
/* trim the UID to allow use of dn_validate */
|
||||
dn->bv_val[i-2] = '\0';
|
||||
/* trim the UID to allow use of dnValidate */
|
||||
dn->bv_val[i-1] = '\0';
|
||||
dn->bv_len = i-1;
|
||||
}
|
||||
|
||||
/* FIXME: should use dnValidate */
|
||||
rc = dn_validate( dn->bv_val ) == NULL
|
||||
? LDAP_INVALID_SYNTAX : LDAP_SUCCESS;
|
||||
rc = dnValidate( NULL, dn );
|
||||
|
||||
ber_bvfree( dn );
|
||||
return rc;
|
||||
|
|
@ -266,7 +267,6 @@ nameUIDNormalize(
|
|||
int rc;
|
||||
|
||||
if( out->bv_len != 0 ) {
|
||||
char *dn;
|
||||
ber_len_t dnlen;
|
||||
char *uid = NULL;
|
||||
ber_len_t uidlen = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue