From: Howard Chu Date: Thu, 26 Aug 2021 14:40:33 +0000 (+0100) Subject: ITS#9651 ldapmodify: add -i option for interval between ops X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5241b49afb484bb41c976b434c5c45e9c608c09;p=thirdparty%2Fopenldap.git ITS#9651 ldapmodify: add -i option for interval between ops --- diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c index 23c15a94d0..402f4e57d0 100644 --- a/clients/tools/ldapmodify.c +++ b/clients/tools/ldapmodify.c @@ -94,6 +94,8 @@ static int process_response( int res, const struct berval *dn ); +static long interval; +static struct timeval interval_tv; static int txn = 0; static int txnabort = 0; struct berval *txn_id = NULL; @@ -113,6 +115,7 @@ usage( void ) fprintf( stderr, _(" -E [!]ext=extparam modify extensions" " (! indicate s criticality)\n")); fprintf( stderr, _(" -f file read operations from `file'\n")); + fprintf( stderr, _(" -i time wait `time' microseconds between operations\n")); fprintf( stderr, _(" -M enable Manage DSA IT control (-MM to make critical)\n")); fprintf( stderr, _(" -P version protocol version (default: 3)\n")); fprintf( stderr, @@ -125,7 +128,7 @@ usage( void ) const char options[] = "aE:rS:" - "cd:D:e:f:h:H:IMnNO:o:p:P:QR:U:vVw:WxX:y:Y:Z"; + "cd:D:e:f:h:H:i:IMnNO:o:p:P:QR:U:vVw:WxX:y:Y:Z"; int handle_private_option( int i ) @@ -187,6 +190,19 @@ handle_private_option( int i ) ldapadd = 1; break; + case 'i': /* interval */ + { + char *next; + interval = strtol( optarg, &next, 10 ); + if ( !next || *next ) { + fprintf( stderr, "%s: unable to parse interval \"%s\"\n", prog, optarg); + exit(EXIT_FAILURE); + } + interval_tv.tv_usec = interval % 1000000; + interval_tv.tv_sec = interval / 1000000; + } + break; + case 'r': /* replace (obsolete) */ break; @@ -296,6 +312,10 @@ main( int argc, char **argv ) memcpy( rejbuf, rbuf, len+1 ); } + if ( interval ) { + select( 0, NULL, NULL, NULL, &interval_tv ); + } + rc = process_ldif_rec( rbuf, lineno ); lineno = nextline+1; diff --git a/doc/man/man1/ldapmodify.1 b/doc/man/man1/ldapmodify.1 index 353b075b41..2bab293566 100644 --- a/doc/man/man1/ldapmodify.1 +++ b/doc/man/man1/ldapmodify.1 @@ -21,6 +21,8 @@ ldapmodify, ldapadd \- LDAP modify entry and LDAP add entry tools [\c .BI \-f \ file\fR] [\c +.BI \-i \ time\fR] +[\c .BI \-S \ file\fR] [\c .BR \-M [ M ]] @@ -77,6 +79,8 @@ ldapmodify, ldapadd \- LDAP modify entry and LDAP add entry tools [\c .BI \-f \ file\fR] [\c +.BI \-i \ time\fR] +[\c .BI \-S \ file\fR] [\c .BR \-M [ M ]] @@ -171,6 +175,9 @@ reporting an error. Read the entry modification information from \fIfile\fP instead of from standard input. .TP +.BI \-i \ time +Wait \fItime\fP microseconds before issuing an operation. +.TP .BI \-S \ file Add or change records which were skipped due to an error are written to \fIfile\fP and the error message returned by the server is added as a comment. Most useful in