From: Kurt Zeilenga Date: Sat, 12 Oct 2002 04:35:42 +0000 (+0000) Subject: Patch: 'ldapmodify -c' should return error on failure (ITS#2133) X-Git-Tag: NO_SLAP_OP_BLOCKS~887 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6b7cee69c2b4281dc366b97609630369b02cb553;p=openldap Patch: 'ldapmodify -c' should return error on failure (ITS#2133) Written by Hallvard B. Furuseth and placed into the public domain. This software is not subject to any license of the University of Oslo. 'ldapmodify -c' returned the error status from the _last_ LDIF entry, so a bad entry followed by a good entry returns success. This patch makes it return the status of the last _failed_ entry, or 0 if all entries succeeded. --- diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c index 6eea5872ce..6f2efb8782 100644 --- a/clients/tools/ldapmodify.c +++ b/clients/tools/ldapmodify.c @@ -154,7 +154,8 @@ main( int argc, char **argv ) char *infile, *rejfile, *rbuf, *start, *rejbuf = NULL; FILE *fp, *rejfp; char *matched_msg = NULL, *error_msg = NULL; - int rc, i, authmethod, version, want_bindpw, debug, manageDSAit, noop, referrals; + int rc, retval, i, authmethod, version, want_bindpw; + int debug, manageDSAit, noop, referrals; int count, len; char *pw_file = NULL; char *control, *cvalue; @@ -832,6 +833,7 @@ main( int argc, char **argv ) } count = 0; + retval = 0; while (( rc == 0 || contoper ) && ( rbuf = read_one_record( fp )) != NULL ) { count++; @@ -849,6 +851,8 @@ main( int argc, char **argv ) rc = process_ldif_rec( start, count ); + if ( rc ) + retval = rc; if ( rc && rejfp ) { fprintf(rejfp, "# Error: %s (%d)", ldap_err2string(rc), rc); @@ -876,7 +880,7 @@ main( int argc, char **argv ) fclose( rejfp ); } - return( rc ); + return( retval ); }