accessmask2str( slap_mask_t mask, char *buf )
{
int none=1;
+ char *ptr = buf;
assert( buf != NULL );
if ( ACL_IS_LEVEL( mask ) ) {
if ( ACL_LVL_IS_NONE(mask) ) {
- strcat( buf, "none" );
+ ptr = slap_strcopy( ptr, "none" );
} else if ( ACL_LVL_IS_AUTH(mask) ) {
- strcat( buf, "auth" );
+ ptr = slap_strcopy( ptr, "auth" );
} else if ( ACL_LVL_IS_COMPARE(mask) ) {
- strcat( buf, "compare" );
+ ptr = slap_strcopy( ptr, "compare" );
} else if ( ACL_LVL_IS_SEARCH(mask) ) {
- strcat( buf, "search" );
+ ptr = slap_strcopy( ptr, "search" );
} else if ( ACL_LVL_IS_READ(mask) ) {
- strcat( buf, "read" );
+ ptr = slap_strcopy( ptr, "read" );
} else if ( ACL_LVL_IS_WRITE(mask) ) {
- strcat( buf, "write" );
+ ptr = slap_strcopy( ptr, "write" );
} else {
- strcat( buf, "unknown" );
+ ptr = slap_strcopy( ptr, "unknown" );
}
- strcat(buf, " (");
+ *ptr++ = '(';
}
if( ACL_IS_ADDITIVE( mask ) ) {
- strcat( buf, "+" );
+ *ptr++ = '+';
} else if( ACL_IS_SUBTRACTIVE( mask ) ) {
- strcat( buf, "-" );
+ *ptr++ = '-';
} else {
- strcat( buf, "=" );
+ *ptr++ = '=';
}
if ( ACL_PRIV_ISSET(mask, ACL_PRIV_WRITE) ) {
none = 0;
- strcat( buf, "w" );
+ *ptr++ = 'w';
}
if ( ACL_PRIV_ISSET(mask, ACL_PRIV_READ) ) {
none = 0;
- strcat( buf, "r" );
+ *ptr++ = 'r';
}
if ( ACL_PRIV_ISSET(mask, ACL_PRIV_SEARCH) ) {
none = 0;
- strcat( buf, "s" );
+ *ptr++ = 's';
}
if ( ACL_PRIV_ISSET(mask, ACL_PRIV_COMPARE) ) {
none = 0;
- strcat( buf, "c" );
+ *ptr++ = 'c';
}
if ( ACL_PRIV_ISSET(mask, ACL_PRIV_AUTH) ) {
none = 0;
- strcat( buf, "x" );
+ *ptr++ = 'x';
}
if ( none && ACL_PRIV_ISSET(mask, ACL_PRIV_NONE) ) {
none = 0;
- strcat( buf, "n" );
+ *ptr++ = 'n';
}
if ( none ) {
- strcat( buf, "0" );
+ *ptr++ = '0';
}
if ( ACL_IS_LEVEL( mask ) ) {
- strcat(buf, ")");
+ *ptr = ')';
}
return buf;
}
{
Entry *e;
char buf[BUFSIZ];
- struct berval val;
+ struct berval val, *ndn = NULL;
struct berval *vals[2];
int i, j;
e = (Entry *) ch_calloc( 1, sizeof(Entry) );
e->e_attrs = NULL;
- e->e_dn = ch_strdup( SLAPD_CONFIG_DN );
- e->e_ndn = ch_strdup( SLAPD_CONFIG_DN );
- (void) dn_normalize( e->e_ndn );
+ ber_str2bv( SLAPD_CONFIG_DN, sizeof(SLAPD_CONFIG_DN)-1, 1, &e->e_name );
+ dnNormalize( NULL, &e->e_name, &ndn );
+ e->e_nname = *ndn;
+ free( ndn );
e->e_private = NULL;
val.bv_val = "top";
attr_merge( e, "objectClass", vals );
{
- char *rdn = ch_strdup( SLAPD_CONFIG_DN );
- val.bv_val = strchr( rdn, '=' );
+ val.bv_val = strchr( e->e_dn, '=' );
if( val.bv_val != NULL ) {
- *val.bv_val = '\0';
- val.bv_len = strlen( ++val.bv_val );
+ *val.bv_val++ = '\0';
+ val.bv_len = e->e_name.bv_len - (val.bv_val-e->e_dn);
attr_merge( e, rdn, vals );
+ val.bv_val[-1] = '=';
}
-
- free( rdn );
}
for ( i = 0; i < nbackends; i++ ) {
- strcpy( buf, backends[i].be_type );
+ char *ptr = slap_strcopy( buf, backends[i].be_type );
for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) {
- strcat( buf, " : " );
- strcat( buf, backends[i].be_suffix[j]->bv_val );
+ ptr = slap_strcopy( ptr, " : " );
+ ptr = slap_strcopy( ptr, backends[i].be_suffix[j]->bv_val );
}
val.bv_val = buf;
- val.bv_len = strlen( buf );
+ val.bv_len = ptr - buf;
attr_merge( e, "database", vals );
}
slapd_srvurls[i] = (char *) realloc( slapd_srvurls[i],
strlen( host ) +
sizeof( LDAP_SRVTYPE_PREFIX ) );
- strcpy( slapd_srvurls[i], LDAP_SRVTYPE_PREFIX );
- strcat( slapd_srvurls[i], host );
+ strcpy( slap_strcopy(slapd_srvurls[i],
+ LDAP_SRVTYPE_PREFIX ), host );
ch_free( host );
}
slapd_srvurls[i] = (char *) realloc( slapd_srvurls[i],
strlen( host ) +
sizeof( LDAPS_SRVTYPE_PREFIX ) );
- strcpy( slapd_srvurls[i], LDAPS_SRVTYPE_PREFIX );
- strcat( slapd_srvurls[i], host );
+ strcpy( slap_strcopy(slapd_srvurls[i],
+ LDAPS_SRVTYPE_PREFIX ), host );
ch_free( host );
}
const char * parent_dn,
const char * newrdn )
{
+ char *ptr;
if ( parent_dn == NULL ) {
*new_dn = ch_strdup( newrdn );
*new_dn = (char *) ch_malloc(
strlen( parent_dn ) + strlen( newrdn ) + 2 );
- strcpy( *new_dn, newrdn );
- strcat( *new_dn, "," );
- strcat( *new_dn, parent_dn );
+ ptr = slap_strcopy( *new_dn, newrdn );
+ *ptr++ = ',';
+ strcpy( ptr, parent_dn );
}
#endif /* SLAP_DN_MIGRATION */
char buf[MAXPATHLEN];
/* open the lock file */
- strcpy( buf, fname );
- strcat( buf, ".lock" );
+ strcpy(slap_strcopy( buf, fname ), ".lock" );
if ( (*lfp = fopen( buf, "w" )) == NULL ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ERR,