Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • openldap/openldap
  • hyc/openldap
  • ryan/openldap
  • iboukris/openldap
  • ondra/openldap
  • sshanks-kx/openldap
  • blaggacao/openldap
  • pbrezina/openldap
  • quanah/openldap
  • dragos_h/openldap
  • lorenz/openldap
  • tsaarni/openldap
  • fei.ding/openldap
  • orent/openldap
  • arrowplum/openldap
  • barchiesi/openldap
  • jotik/openldap
  • hamano/openldap
  • ingovoss/openldap
  • henson/openldap
  • jlrine2/openldap
  • howeverAT/openldap
  • nivanova/openldap
  • orbea/openldap
  • rdubner/openldap
  • smckinney/openldap
  • jklowden/openldap
  • dpa-openldap/openldap
  • rouzier/openldap
  • orgads/openldap
  • ffontaine/openldap
  • jiaqingz/openldap
  • dcoutadeur/openldap
  • begeragus/openldap
  • pubellit/openldap
  • glandium/openldap
  • facboy/openldap
  • thesamesam/openldap
  • Johan/openldap
  • fkooman/openldap
  • gburd/openldap
  • h-homma/openldap
  • sgallagher/openldap
  • ahmed_zaki/openldap
  • gnoe/openldap
  • mid/openldap
  • clan/openldap
47 results
Show changes
Showing with 158 additions and 173 deletions
:: $OpenLDAP$ :: $OpenLDAP$
:: This work is part of OpenLDAP Software <http://www.openldap.org/>. :: This work is part of OpenLDAP Software <http://www.openldap.org/>.
:: ::
:: Copyright 1998-2007 The OpenLDAP Foundation. :: Copyright 1998-2008 The OpenLDAP Foundation.
:: All rights reserved. :: All rights reserved.
:: ::
:: Redistribution and use in source and binary forms, with or without :: Redistribution and use in source and binary forms, with or without
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# $OpenLDAP$ # $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>. ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
## ##
## Copyright 1998-2007 The OpenLDAP Foundation. ## Copyright 1998-2008 The OpenLDAP Foundation.
## All rights reserved. ## All rights reserved.
## ##
## Redistribution and use in source and binary forms, with or without ## Redistribution and use in source and binary forms, with or without
...@@ -55,7 +55,7 @@ WHOWHERE="$USER@`uname -n`:`pwd`" ...@@ -55,7 +55,7 @@ WHOWHERE="$USER@`uname -n`:`pwd`"
cat << __EOF__ cat << __EOF__
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 1998-2007 The OpenLDAP Foundation. * Copyright 1998-2008 The OpenLDAP Foundation.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -68,7 +68,7 @@ cat << __EOF__ ...@@ -68,7 +68,7 @@ cat << __EOF__
*/ */
static const char copyright[] = static const char copyright[] =
"Copyright 1998-2007 The OpenLDAP Foundation. All rights reserved.\n" "Copyright 1998-2008 The OpenLDAP Foundation. All rights reserved.\n"
"COPYING RESTRICTIONS APPLY\n"; "COPYING RESTRICTIONS APPLY\n";
$static $const char $SYMBOL[] = $static $const char $SYMBOL[] =
......
# $OpenLDAP$ # $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>. ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
## ##
## Copyright 1998-2007 The OpenLDAP Foundation. ## Copyright 1998-2008 The OpenLDAP Foundation.
## All rights reserved. ## All rights reserved.
## ##
## Redistribution and use in source and binary forms, with or without ## Redistribution and use in source and binary forms, with or without
......
...@@ -2,7 +2,7 @@ dnl OpenLDAP Autoconf Macros ...@@ -2,7 +2,7 @@ dnl OpenLDAP Autoconf Macros
dnl $OpenLDAP$ dnl $OpenLDAP$
dnl This work is part of OpenLDAP Software <http://www.openldap.org/>. dnl This work is part of OpenLDAP Software <http://www.openldap.org/>.
dnl dnl
dnl Copyright 1998-2007 The OpenLDAP Foundation. dnl Copyright 1998-2008 The OpenLDAP Foundation.
dnl All rights reserved. dnl All rights reserved.
dnl dnl
dnl Redistribution and use in source and binary forms, with or without dnl Redistribution and use in source and binary forms, with or without
......
# $OpenLDAP$ # $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>. ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
## ##
## Copyright 1998-2007 The OpenLDAP Foundation. ## Copyright 1998-2008 The OpenLDAP Foundation.
## All rights reserved. ## All rights reserved.
## ##
## Redistribution and use in source and binary forms, with or without ## Redistribution and use in source and binary forms, with or without
......
# $OpenLDAP$ # $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>. ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
## ##
## Copyright 1998-2007 The OpenLDAP Foundation. ## Copyright 1998-2008 The OpenLDAP Foundation.
## All rights reserved. ## All rights reserved.
## ##
## Redistribution and use in source and binary forms, with or without ## Redistribution and use in source and binary forms, with or without
......
# $OpenLDAP$ # $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>. ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
## ##
## Copyright 1998-2007 The OpenLDAP Foundation. ## Copyright 1998-2008 The OpenLDAP Foundation.
## All rights reserved. ## All rights reserved.
## ##
## Redistribution and use in source and binary forms, with or without ## Redistribution and use in source and binary forms, with or without
......
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 1998-2007 The OpenLDAP Foundation. * Copyright 1998-2008 The OpenLDAP Foundation.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -13,6 +13,6 @@ ...@@ -13,6 +13,6 @@
*/ */
static const char copyright[] = static const char copyright[] =
"Copyright 1998-2007 The OpenLDAP Foundation. All rights reserved.\n" "Copyright 1998-2008 The OpenLDAP Foundation. All rights reserved.\n"
"COPYING RESTRICTIONS APPLY.\n"; "COPYING RESTRICTIONS APPLY.\n";
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# $OpenLDAP$ # $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>. ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
## ##
## Copyright 1998-2007 The OpenLDAP Foundation. ## Copyright 1998-2008 The OpenLDAP Foundation.
## All rights reserved. ## All rights reserved.
## ##
## Redistribution and use in source and binary forms, with or without ## Redistribution and use in source and binary forms, with or without
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# $OpenLDAP$ # $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>. ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
## ##
## Copyright 1998-2007 The OpenLDAP Foundation. ## Copyright 1998-2008 The OpenLDAP Foundation.
## All rights reserved. ## All rights reserved.
## ##
## Redistribution and use in source and binary forms, with or without ## Redistribution and use in source and binary forms, with or without
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
## <http://www.OpenLDAP.org/license.html>. ## <http://www.OpenLDAP.org/license.html>.
ol_package=OpenLDAP ol_package=OpenLDAP
ol_major=2 ol_major=2
ol_minor=X ol_minor=4
ol_patch=X ol_patch=x
ol_api_inc=000000 ol_api_inc=20408
ol_api_current=0 ol_api_current=2
ol_api_revision=0 ol_api_revision=4
ol_api_age=0 ol_api_age=0
ol_release_date="0000/00/00" ol_release_date="2008/02/19"
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# $OpenLDAP$ # $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>. ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
## ##
## Copyright 1998-2007 The OpenLDAP Foundation. ## Copyright 1998-2008 The OpenLDAP Foundation.
## All rights reserved. ## All rights reserved.
## ##
## Redistribution and use in source and binary forms, with or without ## Redistribution and use in source and binary forms, with or without
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# $OpenLDAP$ # $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>. ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
## ##
## Copyright 1998-2007 The OpenLDAP Foundation. ## Copyright 1998-2008 The OpenLDAP Foundation.
## All rights reserved. ## All rights reserved.
## ##
## Redistribution and use in source and binary forms, with or without ## Redistribution and use in source and binary forms, with or without
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* $OpenLDAP$ */ /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 1998-2007 The OpenLDAP Foundation. * Copyright 1998-2008 The OpenLDAP Foundation.
* Portions Copyright 2003 Kurt D. Zeilenga. * Portions Copyright 2003 Kurt D. Zeilenga.
* Portions Copyright 2003 IBM Corporation. * Portions Copyright 2003 IBM Corporation.
* All rights reserved. * All rights reserved.
...@@ -149,8 +149,8 @@ static struct tool_ctrls_t { ...@@ -149,8 +149,8 @@ static struct tool_ctrls_t {
}; };
/* "features" */ /* "features" */
static int gotintr; enum { Intr_None = 0, Intr_Abandon, Intr_Cancel, Intr_Ignore };
static int abcan; static volatile sig_atomic_t gotintr, abcan;
#ifdef LDAP_CONTROL_X_SESSION_TRACKING #ifdef LDAP_CONTROL_X_SESSION_TRACKING
...@@ -223,6 +223,17 @@ tool_destroy( void ) ...@@ -223,6 +223,17 @@ tool_destroy( void )
#ifdef HAVE_TLS #ifdef HAVE_TLS
ldap_pvt_tls_destroy(); ldap_pvt_tls_destroy();
#endif #endif
if ( ldapuri != NULL ) {
ber_memfree( ldapuri );
ldapuri = NULL;
}
if ( pr_cookie.bv_val != NULL ) {
ber_memfree( pr_cookie.bv_val );
pr_cookie.bv_val = NULL;
pr_cookie.bv_len = 0;
}
} }
void void
...@@ -558,19 +569,19 @@ tool_args( int argc, char **argv ) ...@@ -558,19 +569,19 @@ tool_args( int argc, char **argv )
/* this shouldn't go here, really; but it's a feature... */ /* this shouldn't go here, really; but it's a feature... */
} else if ( strcasecmp( control, "abandon" ) == 0 ) { } else if ( strcasecmp( control, "abandon" ) == 0 ) {
abcan = LDAP_REQ_ABANDON; abcan = Intr_Abandon;
if ( crit ) { if ( crit ) {
gotintr = abcan; gotintr = abcan;
} }
} else if ( strcasecmp( control, "cancel" ) == 0 ) { } else if ( strcasecmp( control, "cancel" ) == 0 ) {
abcan = LDAP_REQ_EXTENDED; abcan = Intr_Cancel;
if ( crit ) { if ( crit ) {
gotintr = abcan; gotintr = abcan;
} }
} else if ( strcasecmp( control, "ignore" ) == 0 ) { } else if ( strcasecmp( control, "ignore" ) == 0 ) {
abcan = -1; abcan = Intr_Ignore;
if ( crit ) { if ( crit ) {
gotintr = abcan; gotintr = abcan;
} }
...@@ -746,7 +757,7 @@ tool_args( int argc, char **argv ) ...@@ -746,7 +757,7 @@ tool_args( int argc, char **argv )
case 'P': case 'P':
ival = strtol( optarg, &next, 10 ); ival = strtol( optarg, &next, 10 );
if ( next == NULL || next[0] != '\0' ) { if ( next == NULL || next[0] != '\0' ) {
fprintf( stderr, "%s: unabel to parse protocol version \"%s\"\n", prog, optarg ); fprintf( stderr, "%s: unable to parse protocol version \"%s\"\n", prog, optarg );
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
} }
switch( ival ) { switch( ival ) {
...@@ -1720,19 +1731,19 @@ tool_check_abandon( LDAP *ld, int msgid ) ...@@ -1720,19 +1731,19 @@ tool_check_abandon( LDAP *ld, int msgid )
int rc; int rc;
switch ( gotintr ) { switch ( gotintr ) {
case LDAP_REQ_EXTENDED: case Intr_Cancel:
rc = ldap_cancel_s( ld, msgid, NULL, NULL ); rc = ldap_cancel_s( ld, msgid, NULL, NULL );
fprintf( stderr, "got interrupt, cancel got %d: %s\n", fprintf( stderr, "got interrupt, cancel got %d: %s\n",
rc, ldap_err2string( rc ) ); rc, ldap_err2string( rc ) );
return -1; return -1;
case LDAP_REQ_ABANDON: case Intr_Abandon:
rc = ldap_abandon_ext( ld, msgid, NULL, NULL ); rc = ldap_abandon_ext( ld, msgid, NULL, NULL );
fprintf( stderr, "got interrupt, abandon got %d: %s\n", fprintf( stderr, "got interrupt, abandon got %d: %s\n",
rc, ldap_err2string( rc ) ); rc, ldap_err2string( rc ) );
return -1; return -1;
case -1: case Intr_Ignore:
/* just unbind, ignoring the request */ /* just unbind, ignoring the request */
return -1; return -1;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* $OpenLDAP$ */ /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 1998-2007 The OpenLDAP Foundation. * Copyright 1998-2008 The OpenLDAP Foundation.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* $OpenLDAP$ */ /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 1998-2007 The OpenLDAP Foundation. * Copyright 1998-2008 The OpenLDAP Foundation.
* Portions Copyright 1998-2003 Kurt D. Zeilenga. * Portions Copyright 1998-2003 Kurt D. Zeilenga.
* Portions Copyright 1998-2001 Net Boolean Incorporated. * Portions Copyright 1998-2001 Net Boolean Incorporated.
* All rights reserved. * All rights reserved.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* $OpenLDAP$ */ /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 1998-2007 The OpenLDAP Foundation. * Copyright 1998-2008 The OpenLDAP Foundation.
* Portions Copyright 1998-2003 Kurt D. Zeilenga. * Portions Copyright 1998-2003 Kurt D. Zeilenga.
* All rights reserved. * All rights reserved.
* *
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
static int prune = 0; static int prune = 0;
static int sizelimit = -1;
static int dodelete LDAP_P(( static int dodelete LDAP_P((
...@@ -59,7 +60,8 @@ static int dodelete LDAP_P(( ...@@ -59,7 +60,8 @@ static int dodelete LDAP_P((
static int deletechildren LDAP_P(( static int deletechildren LDAP_P((
LDAP *ld, LDAP *ld,
const char *dn )); const char *dn,
int subentries ));
void void
usage( void ) usage( void )
...@@ -76,11 +78,13 @@ usage( void ) ...@@ -76,11 +78,13 @@ usage( void )
const char options[] = "r" const char options[] = "r"
"cd:D:e:f:h:H:IMnO:o:p:P:QR:U:vVw:WxX:y:Y:Z"; "cd:D:e:f:h:H:IMnO:o:p:P:QR:U:vVw:WxX:y:Y:z:Z";
int int
handle_private_option( int i ) handle_private_option( int i )
{ {
int ival;
char *next;
switch ( i ) { switch ( i ) {
#if 0 #if 0
int crit; int crit;
...@@ -115,6 +119,29 @@ handle_private_option( int i ) ...@@ -115,6 +119,29 @@ handle_private_option( int i )
prune = 1; prune = 1;
break; break;
case 'z': /* size limit */
if ( strcasecmp( optarg, "none" ) == 0 ) {
sizelimit = 0;
} else if ( strcasecmp( optarg, "max" ) == 0 ) {
sizelimit = LDAP_MAXINT;
} else {
ival = strtol( optarg, &next, 10 );
if ( next == NULL || next[0] != '\0' ) {
fprintf( stderr,
_("Unable to parse size limit \"%s\"\n"), optarg );
exit( EXIT_FAILURE );
}
sizelimit = ival;
}
if( sizelimit < 0 || sizelimit > LDAP_MAXINT ) {
fprintf( stderr, _("%s: invalid sizelimit (%d) specified\n"),
prog, sizelimit );
exit( EXIT_FAILURE );
}
break;
default: default:
return 0; return 0;
} }
...@@ -212,6 +239,7 @@ static int dodelete( ...@@ -212,6 +239,7 @@ static int dodelete(
char *matcheddn = NULL, *text = NULL, **refs = NULL; char *matcheddn = NULL, *text = NULL, **refs = NULL;
LDAPControl **ctrls = NULL; LDAPControl **ctrls = NULL;
LDAPMessage *res; LDAPMessage *res;
int subentries = 0;
if ( verbose ) { if ( verbose ) {
printf( _("%sdeleting entry \"%s\"\n"), printf( _("%sdeleting entry \"%s\"\n"),
...@@ -225,7 +253,10 @@ static int dodelete( ...@@ -225,7 +253,10 @@ static int dodelete(
/* If prune is on, remove a whole subtree. Delete the children of the /* If prune is on, remove a whole subtree. Delete the children of the
* DN recursively, then the DN requested. * DN recursively, then the DN requested.
*/ */
if ( prune ) deletechildren( ld, dn ); if ( prune ) {
retry:;
deletechildren( ld, dn, subentries );
}
rc = ldap_delete_ext( ld, dn, NULL, NULL, &id ); rc = ldap_delete_ext( ld, dn, NULL, NULL, &id );
if ( rc != LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
...@@ -257,7 +288,18 @@ static int dodelete( ...@@ -257,7 +288,18 @@ static int dodelete(
rc = ldap_parse_result( ld, res, &code, &matcheddn, &text, &refs, &ctrls, 1 ); rc = ldap_parse_result( ld, res, &code, &matcheddn, &text, &refs, &ctrls, 1 );
if( rc != LDAP_SUCCESS ) { switch ( rc ) {
case LDAP_SUCCESS:
break;
case LDAP_NOT_ALLOWED_ON_NONLEAF:
if ( prune && !subentries ) {
subentries = 1;
goto retry;
}
/* fallthru */
default:
fprintf( stderr, "%s: ldap_parse_result: %s (%d)\n", fprintf( stderr, "%s: ldap_parse_result: %s (%d)\n",
prog, ldap_err2string( rc ), rc ); prog, ldap_err2string( rc ), rc );
return rc; return rc;
...@@ -290,7 +332,7 @@ static int dodelete( ...@@ -290,7 +332,7 @@ static int dodelete(
if (ctrls) { if (ctrls) {
tool_print_ctrls( ld, ctrls ); tool_print_ctrls( ld, ctrls );
ldap_controls_free( ctrls ); ldap_controls_free( ctrls );
} }
ber_memfree( text ); ber_memfree( text );
ber_memfree( matcheddn ); ber_memfree( matcheddn );
...@@ -304,27 +346,55 @@ static int dodelete( ...@@ -304,27 +346,55 @@ static int dodelete(
*/ */
static int deletechildren( static int deletechildren(
LDAP *ld, LDAP *ld,
const char *dn ) const char *base,
int subentries )
{ {
LDAPMessage *res, *e; LDAPMessage *res, *e;
int entries; int entries;
int rc; int rc = LDAP_SUCCESS, srch_rc;
static char *attrs[] = { LDAP_NO_ATTRS, NULL }; static char *attrs[] = { LDAP_NO_ATTRS, NULL };
LDAPControl c, *ctrls[2]; LDAPControl c, *ctrls[2], **ctrlsp = NULL;
BerElement *ber = NULL; BerElement *ber = NULL;
LDAPMessage *res_se;
if ( verbose ) printf ( _("deleting children of: %s\n"), dn ); if ( verbose ) printf ( _("deleting children of: %s\n"), base );
if ( subentries ) {
/*
* Do a one level search at base for subentry children.
*/
if ((ber = ber_alloc_t(LBER_USE_DER)) == NULL) {
return EXIT_FAILURE;
}
rc = ber_printf( ber, "b", 1 );
if ( rc == -1 ) {
ber_free( ber, 1 );
fprintf( stderr, _("Subentries control encoding error!\n"));
return EXIT_FAILURE;
}
if ( ber_flatten2( ber, &c.ldctl_value, 0 ) == -1 ) {
return EXIT_FAILURE;
}
c.ldctl_oid = LDAP_CONTROL_SUBENTRIES;
c.ldctl_iscritical = 1;
ctrls[0] = &c;
ctrls[1] = NULL;
ctrlsp = ctrls;
}
/* /*
* Do a one level search at dn for children. For each, delete its children. * Do a one level search at base for children. For each, delete its children.
*/ */
more:;
rc = ldap_search_ext_s( ld, dn, LDAP_SCOPE_ONELEVEL, NULL, attrs, 1, srch_rc = ldap_search_ext_s( ld, base, LDAP_SCOPE_ONELEVEL, NULL, attrs, 1,
NULL, NULL, NULL, -1, &res ); ctrlsp, NULL, NULL, sizelimit, &res );
if ( rc != LDAP_SUCCESS ) { switch ( srch_rc ) {
tool_perror( "ldap_search", rc, NULL, NULL, NULL, NULL ); case LDAP_SUCCESS:
return( rc ); case LDAP_SIZELIMIT_EXCEEDED:
break;
default:
tool_perror( "ldap_search", srch_rc, NULL, NULL, NULL, NULL );
return( srch_rc );
} }
entries = ldap_count_entries( ld, res ); entries = ldap_count_entries( ld, res );
...@@ -344,8 +414,8 @@ static int deletechildren( ...@@ -344,8 +414,8 @@ static int deletechildren(
return rc; return rc;
} }
rc = deletechildren( ld, dn ); rc = deletechildren( ld, dn, 0 );
if ( rc == -1 ) { if ( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_prune", rc, NULL, NULL, NULL, NULL ); tool_perror( "ldap_prune", rc, NULL, NULL, NULL, NULL );
ber_memfree( dn ); ber_memfree( dn );
return rc; return rc;
...@@ -356,7 +426,7 @@ static int deletechildren( ...@@ -356,7 +426,7 @@ static int deletechildren(
} }
rc = ldap_delete_ext_s( ld, dn, NULL, NULL ); rc = ldap_delete_ext_s( ld, dn, NULL, NULL );
if ( rc == -1 ) { if ( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_delete", rc, NULL, NULL, NULL, NULL ); tool_perror( "ldap_delete", rc, NULL, NULL, NULL, NULL );
ber_memfree( dn ); ber_memfree( dn );
return rc; return rc;
...@@ -373,72 +443,9 @@ static int deletechildren( ...@@ -373,72 +443,9 @@ static int deletechildren(
ldap_msgfree( res ); ldap_msgfree( res );
/* if ( srch_rc == LDAP_SIZELIMIT_EXCEEDED ) {
* Do a one level search at dn for subentry children. goto more;
*/
if ((ber = ber_alloc_t(LBER_USE_DER)) == NULL) {
return EXIT_FAILURE;
}
rc = ber_printf( ber, "b", 1 );
if ( rc == -1 ) {
ber_free( ber, 1 );
fprintf( stderr, _("Subentries control encoding error!\n"));
return EXIT_FAILURE;
}
if ( ber_flatten2( ber, &c.ldctl_value, 0 ) == -1 ) {
return EXIT_FAILURE;
}
c.ldctl_oid = LDAP_CONTROL_SUBENTRIES;
c.ldctl_iscritical = 1;
ctrls[0] = &c;
ctrls[1] = NULL;
rc = ldap_search_ext_s( ld, dn, LDAP_SCOPE_ONELEVEL, NULL, attrs, 1,
ctrls, NULL, NULL, -1, &res_se );
if ( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_search", rc, NULL, NULL, NULL, NULL );
return( rc );
}
ber_free( ber, 1 );
entries = ldap_count_entries( ld, res_se );
if ( entries > 0 ) {
int i;
for (e = ldap_first_entry( ld, res_se ), i = 0; e != NULL;
e = ldap_next_entry( ld, e ), i++ )
{
char *dn = ldap_get_dn( ld, e );
if( dn == NULL ) {
ldap_get_option( ld, LDAP_OPT_RESULT_CODE, &rc );
tool_perror( "ldap_prune", rc, NULL, NULL, NULL, NULL );
ber_memfree( dn );
return rc;
}
if ( verbose ) {
printf( _("\tremoving %s\n"), dn );
}
rc = ldap_delete_ext_s( ld, dn, NULL, NULL );
if ( rc == -1 ) {
tool_perror( "ldap_delete", rc, NULL, NULL, NULL, NULL );
ber_memfree( dn );
return rc;
}
if ( verbose ) {
printf( _("\t%s removed\n"), dn );
}
ber_memfree( dn );
}
} }
ldap_msgfree( res_se );
return rc; return rc;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* $OpenLDAP$ */ /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 2005-2007 The OpenLDAP Foundation. * Copyright 2005-2008 The OpenLDAP Foundation.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* $OpenLDAP$ */ /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 1998-2007 The OpenLDAP Foundation. * Copyright 1998-2008 The OpenLDAP Foundation.
* Portions Copyright 2006 Howard Chu. * Portions Copyright 2006 Howard Chu.
* Portions Copyright 1998-2003 Kurt D. Zeilenga. * Portions Copyright 1998-2003 Kurt D. Zeilenga.
* Portions Copyright 1998-2001 Net Boolean Incorporated. * Portions Copyright 1998-2001 Net Boolean Incorporated.
...@@ -70,15 +70,14 @@ ...@@ -70,15 +70,14 @@
#include "common.h" #include "common.h"
static int ldapadd, force = 0; static int ldapadd;
static char *rejfile = NULL; static char *rejfile = NULL;
static LDAP *ld = NULL; static LDAP *ld = NULL;
#define M_SEP 0x7f #define M_SEP 0x7f
/* strings found in replog/LDIF entries (mostly lifted from slurpd/slurp.h) */ /* strings found in LDIF entries */
static struct berval BV_VERSION = BER_BVC("version"); static struct berval BV_VERSION = BER_BVC("version");
static struct berval BV_REPLICA = BER_BVC("replica");
static struct berval BV_DN = BER_BVC("dn"); static struct berval BV_DN = BER_BVC("dn");
static struct berval BV_CONTROL = BER_BVC("control"); static struct berval BV_CONTROL = BER_BVC("control");
static struct berval BV_CHANGETYPE = BER_BVC("changetype"); static struct berval BV_CHANGETYPE = BER_BVC("changetype");
...@@ -144,7 +143,6 @@ usage( void ) ...@@ -144,7 +143,6 @@ usage( void )
fprintf( stderr, fprintf( stderr,
_(" [!]txn=<commit|abort> (transaction)\n")); _(" [!]txn=<commit|abort> (transaction)\n"));
#endif #endif
fprintf( stderr, _(" -F force all changes records to be used\n"));
fprintf( stderr, _(" -S file write skipped modifications to `file'\n")); fprintf( stderr, _(" -S file write skipped modifications to `file'\n"));
tool_common_usage(); tool_common_usage();
...@@ -152,7 +150,7 @@ usage( void ) ...@@ -152,7 +150,7 @@ usage( void )
} }
const char options[] = "aE:FrS:" const char options[] = "aE:rS:"
"cd:D:e:f:h:H:IMnO:o:p:P:QR:U:vVw:WxX:y:Y:Z"; "cd:D:e:f:h:H:IMnO:o:p:P:QR:U:vVw:WxX:y:Y:Z";
int int
...@@ -217,10 +215,6 @@ handle_private_option( int i ) ...@@ -217,10 +215,6 @@ handle_private_option( int i )
ldapadd = 1; ldapadd = 1;
break; break;
case 'F': /* force all changes records to be used */
force = 1;
break;
case 'r': /* replace (obsolete) */ case 'r': /* replace (obsolete) */
break; break;
...@@ -408,10 +402,10 @@ static int ...@@ -408,10 +402,10 @@ static int
process_ldif_rec( char *rbuf, int linenum ) process_ldif_rec( char *rbuf, int linenum )
{ {
char *line, *dn, *newrdn, *newsup; char *line, *dn, *newrdn, *newsup;
int rc, modop, replicaport; int rc, modop;
int expect_modop, expect_sep; int expect_modop, expect_sep;
int deleteoldrdn; int deleteoldrdn;
int saw_replica, use_record, new_entry, delete_entry, got_all; int new_entry, delete_entry, got_all;
LDAPMod **pmods, *lm = NULL; LDAPMod **pmods, *lm = NULL;
int version; int version;
LDAPControl **pctrls; LDAPControl **pctrls;
...@@ -422,11 +416,10 @@ process_ldif_rec( char *rbuf, int linenum ) ...@@ -422,11 +416,10 @@ process_ldif_rec( char *rbuf, int linenum )
new_entry = ldapadd; new_entry = ldapadd;
rc = got_all = saw_replica = delete_entry = modop = expect_modop = 0; rc = got_all = delete_entry = modop = expect_modop = 0;
expect_sep = 0; expect_sep = 0;
version = 0; version = 0;
deleteoldrdn = 1; deleteoldrdn = 1;
use_record = force;
pmods = NULL; pmods = NULL;
pctrls = NULL; pctrls = NULL;
dn = newrdn = newsup = NULL; dn = newrdn = newsup = NULL;
...@@ -464,27 +457,7 @@ process_ldif_rec( char *rbuf, int linenum ) ...@@ -464,27 +457,7 @@ process_ldif_rec( char *rbuf, int linenum )
freeval[i] = freev; freeval[i] = freev;
if ( dn == NULL ) { if ( dn == NULL ) {
if ( !use_record && !BVICMP( btype+i, &BV_REPLICA )) { if ( linenum+i == 1 && !BVICMP( btype+i, &BV_VERSION )) {
char *p;
++saw_replica;
if (( p = strchr( vals[i].bv_val, ':' )) == NULL ) {
replicaport = 0;
} else {
*p++ = '\0';
if ( lutil_atoi( &replicaport, p ) != 0 ) {
fprintf( stderr, _("%s: unable to parse replica port \"%s\" (line %d) entry: \"%s\"\n"),
prog, p, linenum+i, dn == NULL ? "" : dn );
rc = LDAP_PARAM_ERROR;
break;
}
}
if ( ldaphost != NULL &&
strcasecmp( vals[i].bv_val, ldaphost ) == 0 &&
replicaport == ldapport )
{
use_record = 1;
}
} else if ( linenum+i == 1 && !BVICMP( btype+i, &BV_VERSION )) {
int v; int v;
if( vals[i].bv_len == 0 || lutil_atoi( &v, vals[i].bv_val) != 0 || v != 1 ) { if( vals[i].bv_len == 0 || lutil_atoi( &v, vals[i].bv_val) != 0 || v != 1 ) {
fprintf( stderr, fprintf( stderr,
...@@ -496,13 +469,6 @@ process_ldif_rec( char *rbuf, int linenum ) ...@@ -496,13 +469,6 @@ process_ldif_rec( char *rbuf, int linenum )
} else if ( !BVICMP( btype+i, &BV_DN )) { } else if ( !BVICMP( btype+i, &BV_DN )) {
dn = vals[i].bv_val; dn = vals[i].bv_val;
idn = i; idn = i;
if ( !use_record && saw_replica ) {
printf(_("%s: skipping change record for entry: %s at line %d\n"),
prog, dn, linenum+i);
printf(_("\t(LDAP host/port does not match replica: lines)\n"));
rc = 0;
goto leave;
}
} }
/* skip all lines until we see "dn:" */ /* skip all lines until we see "dn:" */
} }
...@@ -1136,13 +1102,14 @@ domodify( ...@@ -1136,13 +1102,14 @@ domodify(
tool_perror( newentry ? "ldap_add" : "ldap_modify", tool_perror( newentry ? "ldap_add" : "ldap_modify",
rc, NULL, NULL, NULL, NULL ); rc, NULL, NULL, NULL, NULL );
goto done; goto done;
} else if ( verbose ) {
printf( _("modify complete\n") );
} }
rc = process_response( ld, msgid, rc = process_response( ld, msgid,
newentry ? LDAP_RES_ADD : LDAP_RES_MODIFY, dn ); newentry ? LDAP_RES_ADD : LDAP_RES_MODIFY, dn );
if ( verbose && rc == LDAP_SUCCESS ) {
printf( _("modify complete\n") );
}
} else { } else {
rc = LDAP_SUCCESS; rc = LDAP_SUCCESS;
} }
...@@ -1168,12 +1135,12 @@ dodelete( ...@@ -1168,12 +1135,12 @@ dodelete(
fprintf( stderr, _("%s: delete failed: %s\n"), prog, dn ); fprintf( stderr, _("%s: delete failed: %s\n"), prog, dn );
tool_perror( "ldap_delete", rc, NULL, NULL, NULL, NULL ); tool_perror( "ldap_delete", rc, NULL, NULL, NULL, NULL );
goto done; goto done;
} else if ( verbose ) {
printf( _("delete complete") );
} }
rc = process_response( ld, msgid, LDAP_RES_DELETE, dn ); rc = process_response( ld, msgid, LDAP_RES_DELETE, dn );
if ( verbose && rc == LDAP_SUCCESS ) {
printf( _("delete complete\n") );
}
} else { } else {
rc = LDAP_SUCCESS; rc = LDAP_SUCCESS;
} }
...@@ -1207,12 +1174,12 @@ dorename( ...@@ -1207,12 +1174,12 @@ dorename(
fprintf( stderr, _("%s: rename failed: %s\n"), prog, dn ); fprintf( stderr, _("%s: rename failed: %s\n"), prog, dn );
tool_perror( "ldap_rename", rc, NULL, NULL, NULL, NULL ); tool_perror( "ldap_rename", rc, NULL, NULL, NULL, NULL );
goto done; goto done;
} else {
printf( _("rename completed\n") );
} }
rc = process_response( ld, msgid, LDAP_RES_RENAME, dn ); rc = process_response( ld, msgid, LDAP_RES_RENAME, dn );
if ( verbose && rc == LDAP_SUCCESS ) {
printf( _("rename complete\n") );
}
} else { } else {
rc = LDAP_SUCCESS; rc = LDAP_SUCCESS;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* $OpenLDAP$ */ /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 1998-2007 The OpenLDAP Foundation. * Copyright 1998-2008 The OpenLDAP Foundation.
* Portions Copyright 1998-2003 Kurt D. Zeilenga. * Portions Copyright 1998-2003 Kurt D. Zeilenga.
* Portions Copyright 1998-2001 Net Boolean Incorporated. * Portions Copyright 1998-2001 Net Boolean Incorporated.
* Portions Copyright 2001-2003 IBM Corporation. * Portions Copyright 2001-2003 IBM Corporation.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* $OpenLDAP$ */ /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 1998-2007 The OpenLDAP Foundation. * Copyright 1998-2008 The OpenLDAP Foundation.
* Portions Copyright 1998-2003 Kurt D. Zeilenga. * Portions Copyright 1998-2003 Kurt D. Zeilenga.
* Portions Copyright 1998-2001 Net Boolean Incorporated. * Portions Copyright 1998-2001 Net Boolean Incorporated.
* Portions Copyright 2001-2003 IBM Corporation. * Portions Copyright 2001-2003 IBM Corporation.
......