--- servers/slapd/slapacl.c 2006/05/10 20:23:24 1.25 +++ servers/slapd/slapacl.c 2010/04/13 20:18:09 1.37 @@ -1,6 +1,7 @@ +/* $OpenLDAP: pkg/ldap/servers/slapd/slapacl.c,v 1.36 2009/07/22 02:39:57 hyc Exp $ */ /* This work is part of OpenLDAP Software . * - * Copyright 2004-2006 The OpenLDAP Foundation. + * Copyright 2004-2010 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; }