check children access to newSuperior

This commit is contained in:
Pierangelo Masarati 2001-11-16 14:04:54 +00:00
parent 0cf9b37908
commit 7793ece6ce

View File

@ -50,6 +50,7 @@ ldbm_back_modrdn(
char *new_dn = NULL, *new_ndn = NULL;
Entry *e, *p = NULL;
Entry *matched;
int isroot = -1;
int rootlock = 0;
#define CAN_ROLLBACK -1
#define MUST_DESTROY 1
@ -205,7 +206,8 @@ ldbm_back_modrdn(
} else {
/* no parent, must be root to modify rdn */
if( ! be_isroot( be, op->o_ndn ) ) {
isroot = be_isroot( be, op->o_ndn );
if ( ! be_isroot ) {
if ( be_issuffix( be, "" ) ) {
static const Entry rootp = { NOID, "", "", NULL, NULL };
p = (Entry *)&rootp;
@ -219,7 +221,7 @@ ldbm_back_modrdn(
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ERR,
"ldbm_back_modrdn: no access "
"to parent of ("")\n" ));
"to parent \"\"\n" ));
#else
Debug( LDAP_DEBUG_TRACE,
"<=- ldbm_back_modrdn: no "
@ -299,6 +301,8 @@ ldbm_back_modrdn(
/* newSuperior == entry being moved?, if so ==> ERROR */
/* Get Entry with dn=newSuperior. Does newSuperior exist? */
if ( newSuperior[ 0 ] != '\0' ) {
if( (np = dn2entry_w( be, np_ndn, NULL )) == NULL) {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ERR,
@ -343,13 +347,12 @@ ldbm_back_modrdn(
}
if ( is_entry_alias( np ) ) {
/* entry is an alias, don't allow bind */
/* parent is an alias, don't allow add */
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
"ldbm_back_modrdn: entry (%s) is an alias.\n", np->e_dn ));
#else
Debug( LDAP_DEBUG_TRACE, "entry is alias\n", 0,
0, 0 );
Debug( LDAP_DEBUG_TRACE, "entry is alias\n", 0, 0, 0 );
#endif
@ -361,7 +364,6 @@ ldbm_back_modrdn(
if ( is_entry_referral( np ) ) {
/* parent is a referral, don't allow add */
/* parent is an alias, don't allow add */
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
"ldbm_back_modrdn: entry (%s) is a referral\n",
@ -377,6 +379,60 @@ ldbm_back_modrdn(
goto return_results;
}
} else {
/* no parent, must be root to modify newSuperior */
if ( isroot == -1 ) {
isroot = be_isroot( be, op->o_ndn );
}
if ( ! be_isroot ) {
if ( be_issuffix( be, "" ) ) {
static const Entry rootp = { NOID, "", "", NULL, NULL };
np = (Entry *)&rootp;
rc = access_allowed( be, conn, op, np,
children, NULL, ACL_WRITE );
np = NULL;
/* check parent for "children" acl */
if ( ! rc ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ERR,
"ldbm_back_modrdn: no access "
"to new superior \"\"\n" ));
#else
Debug( LDAP_DEBUG_TRACE,
"<=- ldbm_back_modrdn: no "
"access to new superior\n", 0, 0, 0 );
#endif
send_ldap_result( conn, op,
LDAP_INSUFFICIENT_ACCESS,
NULL, NULL, NULL, NULL );
goto return_results;
}
} else {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ERR,
"ldbm_back_modrdn: \"\" "
"not allowed as new superior\n" ));
#else
Debug( LDAP_DEBUG_TRACE,
"<=- ldbm_back_modrdn: \"\" "
"not allowed as new superior\n",
0, 0, 0);
#endif
send_ldap_result( conn, op,
LDAP_INSUFFICIENT_ACCESS,
NULL, NULL, NULL, NULL );
goto return_results;
}
}
}
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
"ldbm_back_modrdn: wr to new parent's children OK.\n" ));