version 1.21, 2005/08/31 21:25:50
|
version 1.37, 2010/04/13 20:18:09
|
Line 1
|
Line 1
|
|
/* $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 <http://www.openldap.org/>. |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
* |
* |
* Copyright 2004-2005 The OpenLDAP Foundation. |
* Copyright 2004-2010 The OpenLDAP Foundation. |
* Portions Copyright 2004 Pierangelo Masarati. |
* Portions Copyright 2004 Pierangelo Masarati. |
* All rights reserved. |
* All rights reserved. |
* |
* |
Line 52 print_access(
|
Line 53 print_access(
|
desc->ad_cname.bv_val, |
desc->ad_cname.bv_val, |
( val && !BER_BVISNULL( val ) ) ? "=" : "", |
( val && !BER_BVISNULL( 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 ) ); |
accessmask2str( mask, accessmaskbuf, 1 ) ); |
|
|
return rc; |
return rc; |
Line 65 slapacl( int argc, char **argv )
|
Line 67 slapacl( int argc, char **argv )
|
const char *progname = "slapacl"; |
const char *progname = "slapacl"; |
Connection conn = { 0 }; |
Connection conn = { 0 }; |
Listener listener; |
Listener listener; |
char opbuf[OPERATION_BUFFER_SIZE]; |
OperationBuffer opbuf; |
Operation *op; |
Operation *op = NULL; |
Entry e = { 0 }, *ep = &e; |
Entry e = { 0 }, *ep = &e; |
char *attr = NULL; |
char *attr = NULL; |
int doclose = 0; |
int doclose = 0; |
BackendDB *bd; |
BackendDB *bd; |
|
void *thrctx; |
|
|
slap_tool_init( progname, SLAPACL, argc, argv ); |
slap_tool_init( progname, SLAPACL, argc, argv ); |
|
|
Line 94 slapacl( int argc, char **argv )
|
Line 97 slapacl( int argc, char **argv )
|
argv = &argv[ optind ]; |
argv = &argv[ optind ]; |
argc -= optind; |
argc -= optind; |
|
|
op = (Operation *)opbuf; |
thrctx = ldap_pvt_thread_pool_context(); |
connection_fake_init( &conn, op, &conn ); |
connection_fake_init( &conn, &opbuf, thrctx ); |
|
op = &opbuf.ob_op; |
|
op->o_tmpmemctx = NULL; |
|
|
conn.c_listener = &listener; |
conn.c_listener = &listener; |
conn.c_listener_url = listener_url; |
conn.c_listener_url = listener_url; |
Line 237 slapacl( int argc, char **argv )
|
Line 242 slapacl( int argc, char **argv )
|
if ( !be->be_entry_open || |
if ( !be->be_entry_open || |
!be->be_entry_close || |
!be->be_entry_close || |
!be->be_dn2id_get || |
!be->be_dn2id_get || |
!be->be_id2entry_get ) |
!be->be_entry_get ) |
{ |
{ |
fprintf( stderr, "%s: target database " |
fprintf( stderr, "%s: target database " |
"doesn't support necessary operations; " |
"doesn't support necessary operations; " |
Line 263 slapacl( int argc, char **argv )
|
Line 268 slapacl( int argc, char **argv )
|
rc = 1; |
rc = 1; |
goto destroy; |
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", |
fprintf( stderr, "%s: unable to fetch entry \"%s\" (%lu)\n", |
progname, e.e_nname.bv_val, id ); |
progname, e.e_nname.bv_val, id ); |
rc = 1; |
rc = 1; |
Line 313 slapacl( int argc, char **argv )
|
Line 319 slapacl( int argc, char **argv )
|
|
|
accessstr = strchr( attr, '/' ); |
accessstr = strchr( attr, '/' ); |
if ( accessstr != NULL ) { |
if ( accessstr != NULL ) { |
|
int invalid = 0; |
|
|
accessstr[0] = '\0'; |
accessstr[0] = '\0'; |
accessstr++; |
accessstr++; |
access = str2access( accessstr ); |
access = str2access( accessstr ); |
if ( access == ACL_INVALID_ACCESS ) { |
switch ( access ) { |
|
case ACL_INVALID_ACCESS: |
fprintf( stderr, "unknown access \"%s\" for attribute \"%s\"\n", |
fprintf( stderr, "unknown access \"%s\" for attribute \"%s\"\n", |
accessstr, attr ); |
accessstr, attr ); |
|
invalid = 1; |
|
break; |
|
|
|
case ACL_NONE: |
|
fprintf( stderr, "\"none\" not allowed for attribute \"%s\"\n", |
|
attr ); |
|
invalid = 1; |
|
break; |
|
|
|
default: |
|
break; |
|
} |
|
|
|
if ( invalid ) { |
if ( continuemode ) { |
if ( continuemode ) { |
continue; |
continue; |
} |
} |
Line 366 destroy:;
|
Line 389 destroy:;
|
ber_memfree( e.e_nname.bv_val ); |
ber_memfree( e.e_nname.bv_val ); |
} |
} |
if ( !dryrun && be ) { |
if ( !dryrun && be ) { |
if ( ep != &e ) { |
if ( ep && ep != &e ) { |
be_entry_release_r( op, ep ); |
be_entry_release_r( op, ep ); |
} |
} |
if ( doclose ) { |
if ( doclose ) { |
Line 380 destroy:;
|
Line 403 destroy:;
|
} |
} |
} |
} |
|
|
slap_tool_destroy(); |
if ( slap_tool_destroy()) |
|
rc = EXIT_FAILURE; |
|
|
return rc; |
return rc; |
} |
} |