From da69eca7143234c82a0803f1bbc30edebd8003db Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Tue, 12 Apr 2005 20:33:45 +0000 Subject: [PATCH] more issues related to slapacl --- servers/slapd/slapacl.c | 44 +++++++++++++++++++++++++++----------- servers/slapd/slapcommon.c | 3 +-- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/servers/slapd/slapacl.c b/servers/slapd/slapacl.c index 2b325f661a..7d967db27a 100644 --- a/servers/slapd/slapacl.c +++ b/servers/slapd/slapacl.c @@ -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(); diff --git a/servers/slapd/slapcommon.c b/servers/slapd/slapcommon.c index ed2903d8e5..2eac187988 100644 --- a/servers/slapd/slapcommon.c +++ b/servers/slapd/slapcommon.c @@ -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 " -- 2.39.5