]> git.sur5r.net Git - openldap/commitdiff
more issues related to slapacl
authorPierangelo Masarati <ando@openldap.org>
Tue, 12 Apr 2005 20:33:45 +0000 (20:33 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 12 Apr 2005 20:33:45 +0000 (20:33 +0000)
servers/slapd/slapacl.c
servers/slapd/slapcommon.c

index 2b325f661ad6208ff6d4459b560416a70773faf3..7d967db27a4566f0a3816663489a82ce9805c213 100644 (file)
@@ -70,6 +70,7 @@ slapacl( int argc, char **argv )
        Operation               *op;
        Entry                   e = { 0 }, *ep = &e;
        char                    *attr = NULL;
+       int                     doclose = 0;
 
        slap_tool_init( progname, SLAPACL, argc, argv );
 
@@ -166,6 +167,26 @@ slapacl( int argc, char **argv )
                fprintf( stderr, "authzDN: \"%s\"\n", authzDN.bv_val );
        }
 
+       if ( !BER_BVISNULL( &authzDN ) ) {
+               op->o_dn = authzDN;
+               op->o_ndn = authzDN;
+               
+               if ( !BER_BVISNULL( &authcDN ) ) {
+                       op->o_conn->c_dn = authcDN;
+                       op->o_conn->c_ndn = authcDN;
+
+               } else {
+                       op->o_conn->c_dn = authzDN;
+                       op->o_conn->c_ndn = authzDN;
+               }
+
+       } else if ( !BER_BVISNULL( &authcDN ) ) {
+               op->o_conn->c_dn = authcDN;
+               op->o_conn->c_ndn = authcDN;
+               op->o_dn = authcDN;
+               op->o_ndn = authcDN;
+       }
+
        assert( !BER_BVISNULL( &baseDN ) );
        rc = dnPrettyNormal( NULL, &baseDN, &e.e_name, &e.e_nname, NULL );
        if ( rc != LDAP_SUCCESS ) {
@@ -177,15 +198,6 @@ slapacl( int argc, char **argv )
        }
 
        op->o_bd = be;
-       if ( !BER_BVISNULL( &authzDN ) ) {
-               op->o_dn = authzDN;
-               op->o_ndn = authzDN;
-       }
-       if ( !BER_BVISNULL( &authcDN ) ) {
-               op->o_conn->c_dn = authcDN;
-               op->o_conn->c_ndn = authcDN;
-       }
-
        if ( !dryrun && be ) {
                ID      id;
 
@@ -209,6 +221,8 @@ slapacl( int argc, char **argv )
                        goto destroy;
                }
 
+               doclose = 1;
+
                id = be->be_dn2id_get( be, &e.e_nname );
                if ( id == NOID ) {
                        fprintf( stderr, "%s: unable to fetch ID of DN \"%s\"\n",
@@ -312,13 +326,19 @@ slapacl( int argc, char **argv )
        }
 
 destroy:;
-       ber_memfree( e.e_name.bv_val );
-       ber_memfree( e.e_nname.bv_val );
+       if ( !BER_BVISNULL( &e.e_name ) ) {
+               ber_memfree( e.e_name.bv_val );
+       }
+       if ( !BER_BVISNULL( &e.e_nname ) ) {
+               ber_memfree( e.e_nname.bv_val );
+       }
        if ( !dryrun && be ) {
                if ( ep != &e ) {
                        be_entry_release_r( op, ep );
                }
-               be->be_entry_close( be );
+               if ( doclose ) {
+                       be->be_entry_close( be );
+               }
        }
 
        slap_tool_destroy();
index ed2903d8e57b9c152600d7e97aa80829af391b3a..2eac18798855ca4b26ee1d008ddf6166b64740d4 100644 (file)
@@ -516,7 +516,7 @@ slap_tool_init(
                /* If the named base is a glue master, operate on the
                 * entire context
                 */
-               if (SLAP_GLUE_INSTANCE(be)) {
+               if ( SLAP_GLUE_INSTANCE( be ) ) {
                        nosubordinates = 1;
                }
 
@@ -577,7 +577,6 @@ startup:;
 #endif
 
        if ( !dryrun && slap_startup( be ) ) {
-
                switch ( tool ) {
                case SLAPTEST:
                        fprintf( stderr, "slap_startup failed "