From d51dc13a0be2d28f7d1a2c70c9b38ae5e6f040c5 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Fri, 16 Nov 2001 17:05:32 +0000 Subject: [PATCH] moved the empty dn static entry into a global const object --- servers/slapd/back-bdb/add.c | 3 +-- servers/slapd/back-bdb/delete.c | 4 +--- servers/slapd/back-bdb/modrdn.c | 5 ++--- servers/slapd/back-bdb/search.c | 7 +++---- servers/slapd/back-ldbm/add.c | 3 +-- servers/slapd/back-ldbm/delete.c | 3 +-- servers/slapd/back-ldbm/modrdn.c | 6 ++---- servers/slapd/back-ldbm/search.c | 3 +-- servers/slapd/entry.c | 5 +++++ servers/slapd/proto-slap.h | 2 ++ 10 files changed, 19 insertions(+), 22 deletions(-) diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index 73d1127359..120d3f601d 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -196,9 +196,8 @@ retry: rc = txn_abort( ltid ); */ if ( !be_isroot( be, op->o_ndn )) { if ( be_issuffix( be, "" ) || be_isupdate( be, op->o_ndn ) ) { - static const Entry rootp = { NOID, "", "", NULL, NULL }; - p = (Entry *)&rootp; + p = (Entry *)&slap_entry_root; /* check parent for "children" acl */ rc = access_allowed( be, conn, op, p, diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 6aeae10482..7b29ee0f69 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -164,9 +164,7 @@ retry: /* transaction retry */ /* no parent, must be root to delete */ if( ! be_isroot( be, op->o_ndn ) ) { if ( be_issuffix( be, "" ) || be_isupdate( be, op->o_ndn ) ) { - static const Entry rootp = { NOID, "", "", NULL, NULL }; - - p = (Entry *)&rootp; + p = (Entry *)&slap_entry_root; /* check parent for "children" acl */ rc = access_allowed( be, conn, op, p, diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 8220338703..1f535f2156 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -30,7 +30,6 @@ bdb_modrdn( char *p_dn = NULL, *p_ndn = NULL; char *new_dn = NULL, *new_ndn = NULL; int isroot = -1; - const static Entry roote = { NOID, "", "", NULL, NULL }; Entry *e, *p = NULL; Entry *matched; int rc; @@ -214,7 +213,7 @@ retry: /* transaction retry */ if ( ! isroot ) { if ( be_issuffix( be, "" ) || be_isupdate( be, op->o_ndn ) ) { - p = (Entry *)&roote; + p = (Entry *)&slap_entry_root; /* check parent for "children" acl */ rc = access_allowed( be, conn, op, p, @@ -335,7 +334,7 @@ retry: /* transaction retry */ if ( ! isroot ) { if ( be_issuffix( be, "" ) || be_isupdate( be, op->o_ndn ) ) { - np = (Entry *)&roote; + np = (Entry *)&slap_entry_root; /* check parent for "children" acl */ rc = access_allowed( be, conn, op, np, diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index 7c5ab8aedf..eb74015eca 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -51,7 +51,6 @@ bdb_search( ID id, cursor; ID candidates[BDB_IDL_UM_SIZE]; Entry *e = NULL; - const static Entry roote = { NOID, "", "", NULL, NULL }; struct berval **v2refs = NULL; Entry *matched = NULL; char *realbase = NULL; @@ -68,7 +67,7 @@ bdb_search( if ( *nbase == '\0' ) { /* DIT root special case */ - e = (Entry *) &roote; + e = (Entry *) &slap_entry_root; rc = 0; } else #ifdef BDB_ALIASES @@ -128,7 +127,7 @@ bdb_search( return rc; } - if (!manageDSAit && e != &roote && is_entry_referral( e ) ) { + if (!manageDSAit && e != &slap_entry_root && is_entry_referral( e ) ) { /* entry is a referral, don't allow add */ char *matched_dn = ch_strdup( e->e_dn ); struct berval **erefs = get_entry_referrals( be, @@ -243,7 +242,7 @@ bdb_search( * FIXME: hack to make "" base work */ cursor = e->e_id == NOID ? 1 : e->e_id; - if ( e != &roote ) { + if ( e != &slap_entry_root ) { bdb_entry_return( be, e ); } e = NULL; diff --git a/servers/slapd/back-ldbm/add.c b/servers/slapd/back-ldbm/add.c index f02429ba26..ab9b53dede 100644 --- a/servers/slapd/back-ldbm/add.c +++ b/servers/slapd/back-ldbm/add.c @@ -212,8 +212,7 @@ ldbm_back_add( if ( !be_isroot( be, op->o_ndn ) ) { if ( be_issuffix( be, "" ) || be_isupdate( be, op->o_ndn ) ) { - static const Entry rootp = { NOID, "", "", NULL, NULL }; - p = (Entry *)&rootp; + p = (Entry *)&slap_entry_root; rc = access_allowed( be, conn, op, p, children, NULL, ACL_WRITE ); diff --git a/servers/slapd/back-ldbm/delete.c b/servers/slapd/back-ldbm/delete.c index c6e9a6c501..7a09fd0fbf 100644 --- a/servers/slapd/back-ldbm/delete.c +++ b/servers/slapd/back-ldbm/delete.c @@ -156,8 +156,7 @@ ldbm_back_delete( if( ! be_isroot( be, op->o_ndn ) ) { if ( be_issuffix( be, "" ) || be_isupdate( be, op->o_ndn ) ) { - static const Entry rootp = { NOID, "", "", NULL, NULL }; - p = (Entry *)&rootp; + p = (Entry *)&slap_entry_root; rc = access_allowed( be, conn, op, p, children, NULL, ACL_WRITE ); diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index 6c30a2f5d8..43ab2c557b 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -210,8 +210,7 @@ ldbm_back_modrdn( if ( ! be_isroot ) { if ( be_issuffix( be, "" ) || be_isupdate( be, op->o_ndn ) ) { - static const Entry rootp = { NOID, "", "", NULL, NULL }; - p = (Entry *)&rootp; + p = (Entry *)&slap_entry_root; rc = access_allowed( be, conn, op, p, children, NULL, ACL_WRITE ); @@ -390,8 +389,7 @@ ldbm_back_modrdn( if ( ! be_isroot ) { if ( be_issuffix( be, "" ) || be_isupdate( be, op->o_ndn ) ) { - static const Entry rootp = { NOID, "", "", NULL, NULL }; - np = (Entry *)&rootp; + np = (Entry *)&slap_entry_root; rc = access_allowed( be, conn, op, np, children, NULL, ACL_WRITE ); diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index 1b95248dd6..365f7f8ea3 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -67,8 +67,7 @@ ldbm_back_search( if ( *nbase == '\0' ) { /* DIT root special case */ - static const Entry root = { NOID, "", "", NULL, NULL }; - e = (Entry *) &root; + e = (Entry *) &slap_entry_root; /* need normalized dn below */ realbase = ch_strdup( e->e_ndn ); diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index 36da878f93..a150097dae 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -21,6 +21,11 @@ static unsigned char *ebuf; /* buf returned by entry2str */ static unsigned char *ecur; /* pointer to end of currently used ebuf */ static int emaxsize;/* max size of ebuf */ +/* + * Empty root entry + */ +const Entry slap_entry_root = { NOID, "", "", NULL, NULL }; + int entry_destroy(void) { free( ebuf ); diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index e8f3d6ffa3..c05a4ed057 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -333,6 +333,8 @@ LDAP_SLAPD_F (void) build_new_dn LDAP_P(( char ** new_dn, * entry.c */ +extern const Entry slap_entry_root; + LDAP_SLAPD_F (int) entry_destroy LDAP_P((void)); LDAP_SLAPD_F (Entry *) str2entry LDAP_P(( char *s )); -- 2.39.5