*/
if ( be->be_add ) {
/* do the update here */
- int repl_user = be_isupdate(be, op->o_ndn.bv_val );
+ int repl_user = be_isupdate(be, &op->o_ndn );
#ifndef SLAPD_MULTIMASTER
- if ( be->be_update_ndn == NULL || repl_user )
+ if ( !be->be_update_ndn.bv_len || repl_user )
#endif
{
- int update = be->be_update_ndn != NULL;
+ int update = be->be_update_ndn.bv_len;
char textbuf[SLAP_TEXT_BUFLEN];
size_t textlen = sizeof textbuf;
* or with parent ""
*/
if ( !be_isroot( be, op->o_ndn.bv_val )) {
- if ( be_issuffix( be, "" ) || be_isupdate( be, op->o_ndn.bv_val ) ) {
-
+ if ( be_issuffix( be, "" ) || be_isupdate( be, &op->o_ndn ) ) {
p = (Entry *)&slap_entry_root;
/* check parent for "children" acl */
} else {
/* no parent, must be root to delete */
if( ! be_isroot( be, op->o_ndn.bv_val ) ) {
- if ( be_issuffix( be, "" ) || be_isupdate( be, op->o_ndn.bv_val ) ) {
+ if ( be_issuffix( be, "" ) || be_isupdate( be, &op->o_ndn ) ) {
p = (Entry *)&slap_entry_root;
/* check parent for "children" acl */
/* no parent, modrdn entry directly under root */
isroot = be_isroot( be, op->o_ndn.bv_val );
if ( ! isroot ) {
- if ( be_issuffix( be, "" ) || be_isupdate( be, op->o_ndn.bv_val ) ) {
+ if ( be_issuffix( be, "" ) || be_isupdate( be, &op->o_ndn ) ) {
p = (Entry *)&slap_entry_root;
/* no parent, modrdn entry directly under root */
if ( ! isroot ) {
- if ( be_issuffix( be, "" ) || be_isupdate( be, op->o_ndn.bv_val ) ) {
-
+ if ( be_issuffix( be, "" ) || be_isupdate( be, &op->o_ndn ) ) {
np = (Entry *)&slap_entry_root;
/* check parent for "children" acl */
/* no parent, must be adding entry to root */
if ( !be_isroot( be, op->o_ndn.bv_val ) ) {
- if ( be_issuffix( be, "" )
- || be_isupdate( be, op->o_ndn.bv_val ) ) {
+ if ( be_issuffix( be, "" ) || be_isupdate( be, &op->o_ndn ) ) {
p = (Entry *)&slap_entry_root;
rc = access_allowed( be, conn, op, p,
} else {
/* no parent, must be root to delete */
if( ! be_isroot( be, op->o_ndn.bv_val ) ) {
- if ( be_issuffix( be, "" )
- || be_isupdate( be, op->o_ndn.bv_val ) ) {
+ if ( be_issuffix( be, "" ) || be_isupdate( be, &op->o_ndn ) ) {
p = (Entry *)&slap_entry_root;
rc = access_allowed( be, conn, op, p,
/* no parent, must be root to modify rdn */
isroot = be_isroot( be, op->o_ndn.bv_val );
if ( ! be_isroot ) {
- if ( be_issuffix( be, "" )
- || be_isupdate( be, op->o_ndn.bv_val ) ) {
+ if ( be_issuffix( be, "" ) || be_isupdate( be, &op->o_ndn ) ) {
p = (Entry *)&slap_entry_root;
rc = access_allowed( be, conn, op, p,
}
if ( ! be_isroot ) {
- if ( be_issuffix( be, "" )
- || be_isupdate( be, op->o_ndn.bv_val ) ) {
+ if ( be_issuffix( be, "" ) || be_isupdate( be, &op->o_ndn ) ) {
np = (Entry *)&slap_entry_root;
rc = access_allowed( be, conn, op, np,
}
charray_free( backendDB[i].be_suffix );
ber_bvecfree( backendDB[i].be_nsuffix );
- free( backendDB[i].be_root_dn );
- free( backendDB[i].be_root_ndn );
- free( backendDB[i].be_root_pw.bv_val );
+ free( backendDB[i].be_rootdn.bv_val );
+ free( backendDB[i].be_rootndn.bv_val );
+ free( backendDB[i].be_rootpw.bv_val );
acl_destroy( backendDB[i].be_acl, global_acl );
}
free( backendDB );
return( 0 );
}
- if ( be->be_root_ndn == NULL || *be->be_root_ndn == '\0' ) {
+ if ( !be->be_rootndn.bv_len ) {
return( 0 );
}
- rc = strcmp( be->be_root_ndn, ndn ) ? 0 : 1;
+ rc = strcmp( be->be_rootndn.bv_val, ndn ) ? 0 : 1;
return(rc);
}
int
-be_isupdate( Backend *be, const char *ndn )
+be_isupdate( Backend *be, struct berval *ndn )
{
- int rc;
-
- if ( ndn == NULL || *ndn == '\0' ) {
+ if ( !ndn->bv_len ) {
return( 0 );
}
- if ( be->be_update_ndn == NULL || *be->be_update_ndn == '\0' ) {
+ if ( !be->be_update_ndn.bv_len ) {
return( 0 );
}
- rc = strcmp( be->be_update_ndn, ndn ) ? 0 : 1;
-
- return(rc);
+ return strcmp( be->be_update_ndn.bv_val, ndn->bv_val ) ? 0 : 1;
}
char *
be_root_dn( Backend *be )
{
- if ( be->be_root_dn == NULL ) {
+ if ( !be->be_rootdn.bv_len ) {
return( "" );
}
- return be->be_root_dn;
+ return be->be_rootdn.bv_val;
}
int
return 0;
}
- if( be->be_root_pw.bv_len == 0 ) {
+ if( be->be_rootpw.bv_len == 0 ) {
return 0;
}
#endif
#endif
- result = lutil_passwd( &be->be_root_pw, cred, NULL );
+ result = lutil_passwd( &be->be_rootpw, cred, NULL );
#if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD )
#ifdef SLAPD_SPASSWD
#endif
} else {
- be->be_root_dn = ch_strdup( cargv[1] );
- be->be_root_ndn = ch_strdup( cargv[1] );
-
+ struct berval dn, *pdn = NULL, *ndn = NULL;
+
if ( load_ucdata( NULL ) < 0 ) {
return( 1 );
}
- if( dn_normalize( be->be_root_ndn ) == NULL ) {
- free( be->be_root_dn );
- free( be->be_root_ndn );
+
+ dn.bv_val = cargv[1];
+ dn.bv_len = strlen( cargv[1] );
+
+ rc = dnPretty( NULL, &dn, &pdn );
+ if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
- "%s: line %d: rootdn DN is invalid.\n",
- fname, lineno ));
+ "%s: line %d: rootdn DN is invalid.\n",
+ fname, lineno ));
#else
Debug( LDAP_DEBUG_ANY,
-"%s: line %d: rootdn DN is invalid\n",
+ "%s: line %d: rootdn DN is invalid\n",
fname, lineno, 0 );
#endif
+ return( 1 );
+ }
+ rc = dnNormalize( NULL, &dn, &ndn );
+ if( rc != LDAP_SUCCESS ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
+ "%s: line %d: rootdn DN is invalid.\n",
+ fname, lineno ));
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "%s: line %d: rootdn DN is invalid\n",
+ fname, lineno, 0 );
+#endif
+ ber_bvfree( ndn );
return( 1 );
}
+
+ be->be_rootdn = *pdn;
+ be->be_rootndn = *ndn;
+
+ free( pdn );
+ free( ndn );
}
/* set super-secret magic database password */
#endif
} else {
- be->be_root_pw.bv_val = ch_strdup( cargv[1] );
- be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
+ be->be_rootpw.bv_val = ch_strdup( cargv[1] );
+ be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
}
/* make this database read-only */
#endif
} else {
- be->be_update_ndn = ch_strdup( cargv[1] );
+ struct berval dn, *ndn = NULL;
+
if ( load_ucdata( NULL ) < 0 ) {
return( 1 );
}
- if( dn_normalize( be->be_update_ndn ) == NULL ) {
+
+ dn.bv_val = cargv[1];
+ dn.bv_len = strlen( cargv[1] );
+
+ rc = dnNormalize( NULL, &dn, &ndn );
+ if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
- "%s: line %d: updatedn DN is invalid.\n",
- fname, lineno ));
+ "%s: line %d: updatedn DN is invalid.\n",
+ fname, lineno ));
#else
Debug( LDAP_DEBUG_ANY,
-"%s: line %d: updatedn DN is invalid\n",
+ "%s: line %d: updatedn DN is invalid\n",
fname, lineno, 0 );
#endif
-
return 1;
}
+
+ be->be_update_ndn = *ndn;
+ free( ndn );
}
} else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
}
if ( be == NULL ) {
#ifdef NEW_LOGGING
- LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
- "updateref line must appear inside a database definition "
- "(ignored)\n", fname, lineno ));
+ LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: updateref"
+ " line must appear inside a database definition\n",
+ fname, lineno ));
#else
- Debug( LDAP_DEBUG_ANY, "%s: line %d: "
- "updateref line must appear inside a database definition "
- "(ignored)\n", fname, lineno, 0 );
+ Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
+ " line must appear inside a database definition\n",
+ fname, lineno, 0 );
#endif
return 1;
- } else if ( be->be_update_ndn == NULL ) {
+ } else if ( !be->be_update_ndn.bv_len ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
- "updateref line must come after updatedn (ignored).\n",
+ "updateref line must come after updatedn.\n",
fname, lineno ));
#else
Debug( LDAP_DEBUG_ANY, "%s: line %d: "
- "updateref line must after updatedn (ignored)\n",
+ "updateref line must after updatedn.\n",
fname, lineno, 0 );
#endif
return 1;
*/
if ( be->be_delete ) {
/* do the update here */
- int repl_user = be_isupdate( be, op->o_ndn.bv_val );
+ int repl_user = be_isupdate( be, &op->o_ndn );
#ifndef SLAPD_MULTIMASTER
- if ( be->be_update_ndn == NULL || repl_user )
+ if ( !be->be_update_ndn.bv_len || repl_user )
#endif
{
if ( (*be->be_delete)( be, conn, op, pdn->bv_val, ndn->bv_val ) == 0 ) {
#ifdef SLAPD_MULTIMASTER
- if (be->be_update_ndn == NULL || !repl_user )
+ if ( !be->be_update_ndn.bv_len || !repl_user )
#endif
{
replog( be, op, pdn->bv_val, ndn->bv_val, NULL );
*/
if ( be->be_modify ) {
/* do the update here */
- int repl_user = be_isupdate( be, op->o_ndn.bv_val );
+ int repl_user = be_isupdate( be, &op->o_ndn );
#ifndef SLAPD_MULTIMASTER
/* Multimaster slapd does not have to check for replicator dn
* because it accepts each modify request
*/
- if ( be->be_update_ndn == NULL || repl_user )
+ if ( !be->be_update_ndn.bv_len || repl_user )
#endif
{
- int update = be->be_update_ndn != NULL;
+ int update = be->be_update_ndn.bv_len;
const char *text;
char textbuf[SLAP_TEXT_BUFLEN];
size_t textlen = sizeof textbuf;
*/
if ( be->be_modrdn ) {
/* do the update here */
- int repl_user = be_isupdate( be, op->o_ndn.bv_val );
+ int repl_user = be_isupdate( be, &op->o_ndn );
#ifndef SLAPD_MULTIMASTER
- if ( be->be_update_ndn == NULL || repl_user )
+ if ( !be->be_update_ndn.bv_len || repl_user )
#endif
{
if ( (*be->be_modrdn)( be, conn, op, pdn->bv_val, ndn->bv_val,
pnewrdn->bv_val, deloldrdn, pnewSuperior ? pnewSuperior->bv_val : NULL ) == 0
#ifdef SLAPD_MULTIMASTER
- && ( be->be_update_ndn == NULL || !repl_user )
+ && ( !be->be_update_ndn.bv_len || !repl_user )
#endif
) {
- struct replog_moddn moddn;
- moddn.newrdn = pnewrdn->bv_val;
+ struct slap_replog_moddn moddn;
+ moddn.newrdn = pnewrdn;
moddn.deloldrdn = deloldrdn;
- moddn.newsup = pnewSuperior ? pnewSuperior->bv_val : NULL;
+ moddn.newsup = pnewSuperior;
replog( be, op, pdn->bv_val, ndn->bv_val, &moddn );
}
*text = "authorization database is read only";
rc = LDAP_UNWILLING_TO_PERFORM;
- } else if( conn->c_authz_backend->be_update_ndn != NULL ) {
+ } else if( conn->c_authz_backend->be_update_ndn.bv_len ) {
/* we SHOULD return a referral in this case */
*refs = referral_rewrite( conn->c_authz_backend->be_update_refs,
NULL, NULL, LDAP_SCOPE_DEFAULT );
LDAP_SLAPD_F (int) be_isroot LDAP_P(( Backend *be, const char *ndn ));
LDAP_SLAPD_F (int) be_isroot_pw LDAP_P(( Backend *be,
Connection *conn, const char *ndn, struct berval *cred ));
-LDAP_SLAPD_F (int) be_isupdate LDAP_P(( Backend *be, const char *ndn ));
+LDAP_SLAPD_F (int) be_isupdate LDAP_P(( Backend *be, struct berval *ndn ));
LDAP_SLAPD_F (char *) be_root_dn LDAP_P(( Backend *be ));
LDAP_SLAPD_F (int) be_entry_release_rw LDAP_P((
BackendDB *be, Connection *c, Operation *o, Entry *e, int rw ));
{
Modifications *ml;
Entry *e;
- struct replog_moddn *moddn;
+ struct slap_replog_moddn *moddn;
char *tmp;
FILE *fp, *lfp;
int len, i;
fprintf( fp, "newrdn: %s\n", moddn->newrdn );
fprintf( fp, "deleteoldrdn: %d\n", moddn->deloldrdn ? 1 : 0 );
if( moddn->newsup != NULL ) {
- fprintf( fp, "newsuperior: %s\n", moddn->newsup );
+ fprintf( fp, "newsuperior: %s\n", moddn->newsup->bv_val );
}
}
fprintf( fp, "\n" );
/*
* replog moddn param structure
*/
-struct replog_moddn {
- char *newrdn;
+struct slap_replog_moddn {
+ struct berval *newrdn;
int deloldrdn;
- char *newsup;
+ struct berval *newsup;
};
/*
/* these should be renamed from be_ to bd_ */
char **be_suffix; /* the DN suffixes of data in this backend */
- struct berval **be_nsuffix; /* the normalized DN suffixes in this backend */
- struct berval **be_suffixAlias; /* pairs of DN suffix aliases and deref values */
- char *be_root_dn; /* the magic "root" dn for this db */
- char *be_root_ndn; /* the magic "root" normalized dn for this db */
- struct berval be_root_pw; /* the magic "root" password for this db */
+ struct berval **be_nsuffix; /* the normalized DN suffixes in this backend */
+ struct berval **be_suffixAlias; /* pairs of DN suffix aliases and deref values */
+ struct berval be_rootdn; /* the magic "root" name (DN) for this db */
+ struct berval be_rootndn; /* the magic "root" normalized name (DN) for this db */
+ struct berval be_rootpw; /* the magic "root" password for this db */
unsigned int be_max_deref_depth; /* limit for depth of an alias deref */
#define be_sizelimit be_def_limit.lms_s_soft
#define be_timelimit be_def_limit.lms_t_soft
slap_access_t be_dfltaccess; /* access given if no acl matches */
struct slap_replica_info **be_replica; /* replicas of this backend (in master) */
char *be_replogfile; /* replication log file (in master) */
- char *be_update_ndn; /* allowed to make changes (in replicas) */
+ struct berval be_update_ndn; /* allowed to make changes (in replicas) */
struct berval **be_update_refs; /* where to refer modifying clients to */
int be_lastmod; /* keep track of lastmodified{by,time} */