]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/slapacl.c
Merge remote-tracking branch 'origin/mdb.master' into OPENLDAP_REL_ENG_2_4
[openldap] / servers / slapd / slapacl.c
index c7b6c274cf5b170ebea4027cb5fa47e71b8063a1..c488518f9896edc7a9153c2b16d336c1699e7a55 100644 (file)
@@ -1,6 +1,7 @@
+/* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004-2006 The OpenLDAP Foundation.
+ * Copyright 2004-2013 The OpenLDAP Foundation.
  * Portions Copyright 2004 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -52,7 +53,8 @@ print_access(
                        desc->ad_cname.bv_val,
                        ( val && !BER_BVISNULL( val ) ) ? "=" : "",
                        ( val && !BER_BVISNULL( val ) ) ?
-                               ( desc == slap_schema.si_ad_userPassword ? "****" : val->bv_val ) : "",
+                               ( desc == slap_schema.si_ad_userPassword ?
+                                       "****" : val->bv_val ) : "",
                        accessmask2str( mask, accessmaskbuf, 1 ) );
 
        return rc;
@@ -71,6 +73,7 @@ slapacl( int argc, char **argv )
        char                    *attr = NULL;
        int                     doclose = 0;
        BackendDB               *bd;
+       void                    *thrctx;
 
        slap_tool_init( progname, SLAPACL, argc, argv );
 
@@ -94,8 +97,10 @@ slapacl( int argc, char **argv )
        argv = &argv[ optind ];
        argc -= optind;
 
-       op = (Operation *) &opbuf;
-       connection_fake_init( &conn, op, &conn );
+       thrctx = ldap_pvt_thread_pool_context();
+       connection_fake_init( &conn, &opbuf, thrctx );
+       op = &opbuf.ob_op;
+       op->o_tmpmemctx = NULL;
 
        conn.c_listener = &listener;
        conn.c_listener_url = listener_url;
@@ -237,7 +242,7 @@ slapacl( int argc, char **argv )
                if ( !be->be_entry_open ||
                        !be->be_entry_close ||
                        !be->be_dn2id_get ||
-                       !be->be_id2entry_get )
+                       !be->be_entry_get )
                {
                        fprintf( stderr, "%s: target database "
                                "doesn't support necessary operations; "
@@ -263,7 +268,8 @@ slapacl( int argc, char **argv )
                        rc = 1;
                        goto destroy;
                }
-               if ( be->be_id2entry_get( be, id, &ep ) != 0 ) {
+               ep = be->be_entry_get( be, id );
+               if ( ep == NULL ) {
                        fprintf( stderr, "%s: unable to fetch entry \"%s\" (%lu)\n",
                                progname, e.e_nname.bv_val, id );
                        rc = 1;
@@ -330,6 +336,9 @@ slapacl( int argc, char **argv )
                                                attr );
                                invalid = 1;
                                break;
+
+                       default:
+                               break;
                        }
 
                        if ( invalid ) {
@@ -380,7 +389,7 @@ destroy:;
                ber_memfree( e.e_nname.bv_val );
        }
        if ( !dryrun && be ) {
-               if ( ep != &e ) {
+               if ( ep && ep != &e ) {
                        be_entry_release_r( op, ep );
                }
                if ( doclose ) {
@@ -394,7 +403,8 @@ destroy:;
                }
        }
 
-       slap_tool_destroy();
+       if ( slap_tool_destroy())
+               rc = EXIT_FAILURE;
 
        return rc;
 }