]> git.sur5r.net Git - openldap/commitdiff
moved the empty dn static entry into a global const object
authorPierangelo Masarati <ando@openldap.org>
Fri, 16 Nov 2001 17:05:32 +0000 (17:05 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 16 Nov 2001 17:05:32 +0000 (17:05 +0000)
servers/slapd/back-bdb/add.c
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/back-bdb/search.c
servers/slapd/back-ldbm/add.c
servers/slapd/back-ldbm/delete.c
servers/slapd/back-ldbm/modrdn.c
servers/slapd/back-ldbm/search.c
servers/slapd/entry.c
servers/slapd/proto-slap.h

index 73d1127359724fca53ff6d8f5e0c4333bb811847..120d3f601d195f5410dffa34f77f9e6ceccc4d98 100644 (file)
@@ -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,
index 6aeae104829d27212bb97ebc26f9b0a0b8886c58..7b29ee0f69245ef11974a5729a501c20f24ee700 100644 (file)
@@ -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,
index 82203387034cd6b29275e4203c298600d54d10a8..1f535f215676b136c21955fef651fb0d46395115 100644 (file)
@@ -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,
index 7c5ab8aedf0f235e2a7a0153928193659786f8b2..eb74015ecafed2b2bb298526286dd94d463667a6 100644 (file)
@@ -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;
index f02429ba26b6c547d50e5242810c65bf2d005d9d..ab9b53dede9bde62ad0176c5e1ffbf35d98ef866 100644 (file)
@@ -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 );
index c6e9a6c501fc4e76e68a83619b6ff964033364cf..7a09fd0fbf5dd05ddf70938638548b6d234ef455 100644 (file)
@@ -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 );
index 6c30a2f5d881b7a244158a2997acbbe2719e61f2..43ab2c557b283f8d9808bcaf00751d023bfae586 100644 (file)
@@ -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 );
index 1b95248dd6988e0cab6f1352edcbf37151977ebe..365f7f8ea33a29bf1d1e5889a6fa024fa2d5692a 100644 (file)
@@ -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 );
index 36da878f939c2689c7197b31e0bb03ead7a7799e..a150097dae6754c7d7dcdd55723427bc4b6188be 100644 (file)
@@ -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 );
index e8f3d6ffa391fd40e59106ebe5ba680cb8304c27..c05a4ed057f7d77027add28b2c8cd2f6a87e371f 100644 (file)
@@ -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 ));