X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=clients%2Ftools%2Fldapmodify.c;h=0a6ccb14b990179697d33f606215d44c970957a9;hb=cc475f4bbee3db2be4b7be16750944759ed81624;hp=79e187b2d47aeb12da43bbd807a433447c79d31e;hpb=337e297fafd7719e58f0272d79d65ea7ff350db5;p=openldap diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c index 79e187b2d4..0a6ccb14b9 100644 --- a/clients/tools/ldapmodify.c +++ b/clients/tools/ldapmodify.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2005 The OpenLDAP Foundation. + * Copyright 1998-2006 The OpenLDAP Foundation. * Portions Copyright 1998-2003 Kurt D. Zeilenga. * Portions Copyright 1998-2001 Net Boolean Incorporated. * Portions Copyright 2001-2003 IBM Corporation. @@ -242,21 +242,25 @@ int main( int argc, char **argv ) { #ifdef LDAP_GROUP_TRANSACTION - BerElement *txnber; - struct berval txnCookie = { 0, NULL }; + BerElement *txnber; + struct berval txnCookie = { 0, NULL }; #endif char *rbuf, *start, *rejbuf = NULL; FILE *fp, *rejfp; char *matched_msg, *error_msg; int rc, retval; - int count, len; + int count, len; + int i = 0; + LDAPControl c[1]; + - tool_init(); prog = lutil_progname( "ldapmodify", argc, argv ); /* strncmp instead of strcmp since NT binaries carry .exe extension */ ldapadd = ( strncasecmp( prog, "ldapadd", sizeof("ldapadd")-1 ) == 0 ); + tool_init( ldapadd ? TOOL_ADD : TOOL_MODIFY ); + tool_args( argc, argv ); if ( argc != optind ) usage(); @@ -281,9 +285,9 @@ main( int argc, char **argv ) if ( debug ) ldif_debug = debug; - ld = tool_conn_setup( not, 0 ); + ld = tool_conn_setup( dont, 0 ); - if ( !not ) { + if ( !dont ) { if ( pw_file || want_bindpw ) { if ( pw_file ) { rc = lutil_get_filed_password( pw_file, &passwd ); @@ -310,15 +314,12 @@ main( int argc, char **argv ) } #endif - if ( assertion || authzid || manageDIT || manageDSAit || noop + if ( 0 #ifdef LDAP_GROUP_TRANSACTION || txn #endif - || preread || postread ) + ) { - int i = 0; - LDAPControl c[1]; - #ifdef LDAP_GROUP_TRANSACTION if( txn ) { int err; @@ -340,10 +341,10 @@ main( int argc, char **argv ) i++; } #endif - - tool_server_controls( ld, c, i ); } + tool_server_controls( ld, c, i ); + rc = 0; count = 0; retval = 0; @@ -405,7 +406,7 @@ main( int argc, char **argv ) } #endif - if ( !not ) { + if ( !dont ) { tool_unbind( ld ); } @@ -467,7 +468,12 @@ process_ldif_rec( char *rbuf, int count ) replicaport = 0; } else { *p++ = '\0'; - replicaport = atoi( p ); + if ( lutil_atoi( &replicaport, p ) != 0 ) { + fprintf( stderr, _("%s: unable to parse replica port \"%s\" (line %d) entry: \"%s\"\n"), + prog, p, linenum, dn == NULL ? "" : dn ); + rc = LDAP_PARAM_ERROR; + break; + } } if ( ldaphost != NULL && strcasecmp( val.bv_val, ldaphost ) == 0 && @@ -478,7 +484,8 @@ process_ldif_rec( char *rbuf, int count ) } else if ( count == 1 && linenum == 1 && strcasecmp( type, T_VERSION_STR ) == 0 ) { - if( val.bv_len == 0 || atoi(val.bv_val) != 1 ) { + int v; + if( val.bv_len == 0 || lutil_atoi( &v, val.bv_val) != 0 || v != 1 ) { fprintf( stderr, _("%s: invalid version %s, line %d (ignored)\n"), prog, val.bv_val, linenum ); @@ -1018,12 +1025,12 @@ domodify( } if ( newentry ) { - printf( "%sadding new entry \"%s\"\n", not ? "!" : "", dn ); + printf( "%sadding new entry \"%s\"\n", dont ? "!" : "", dn ); } else { - printf( "%smodifying entry \"%s\"\n", not ? "!" : "", dn ); + printf( "%smodifying entry \"%s\"\n", dont ? "!" : "", dn ); } - if ( !not ) { + if ( !dont ) { int msgid; if ( newentry ) { rc = ldap_add_ext( ld, dn, pmods, pctrls, NULL, &msgid ); @@ -1061,8 +1068,8 @@ dodelete( int rc; int msgid; - printf( _("%sdeleting entry \"%s\"\n"), not ? "!" : "", dn ); - if ( !not ) { + printf( _("%sdeleting entry \"%s\"\n"), dont ? "!" : "", dn ); + if ( !dont ) { rc = ldap_delete_ext( ld, dn, pctrls, NULL, &msgid ); if ( rc != LDAP_SUCCESS ) { fprintf( stderr, _("%s: delete failed: %s\n"), prog, dn ); @@ -1095,12 +1102,12 @@ dorename( int rc; int msgid; - printf( _("%smodifying rdn of entry \"%s\"\n"), not ? "!" : "", dn ); + printf( _("%smodifying rdn of entry \"%s\"\n"), dont ? "!" : "", dn ); if ( verbose ) { printf( _("\tnew RDN: \"%s\" (%skeep existing values)\n"), newrdn, deleteoldrdn ? _("do not ") : "" ); } - if ( !not ) { + if ( !dont ) { rc = ldap_rename( ld, dn, newrdn, newsup, deleteoldrdn, pctrls, NULL, &msgid ); if ( rc != LDAP_SUCCESS ) { @@ -1157,9 +1164,9 @@ static int process_response( rc = ldap_result( ld, msgid, #ifdef LDAP_GROUP_TRANSACTION - txn ? 0 : 1, + txn ? LDAP_MSG_ONE : LDAP_MSG_ALL, #else - 1, + LDAP_MSG_ALL, #endif &tv, &res ); if ( tool_check_abandon( ld, msgid ) ) {