enable abandon/cancel in ldapsearch (ITS#3670)

This commit is contained in:
Pierangelo Masarati 2005-04-19 18:07:27 +00:00
parent f2831a77c9
commit 448fa12bc1
3 changed files with 32 additions and 27 deletions

View File

@ -48,9 +48,7 @@
#include <ac/errno.h>
#include <sys/stat.h>
#if defined(TEST_ABANDON) || defined(TEST_CANCEL)
#include <ac/signal.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
@ -234,7 +232,7 @@ urlize(char *url)
}
const char options[] = "a:Ab:E:F:l:Ls:S:tT:uz:"
const char options[] = "a:Ab:cE:F:l:Ls:S:tT:uz:"
"Cd:D:e:f:h:H:IkKMnO:p:P:QR:U:vVw:WxX:y:Y:Z";
int
@ -555,15 +553,13 @@ private_conn_setup( LDAP *ld )
}
}
#if defined(TEST_ABANDON) || defined(TEST_CANCEL)
static int gotintr;
RETSIGTYPE
do_sig( int sig )
{
gotintr = 1;
gotintr = contoper;
}
#endif
int
main( int argc, char **argv )
@ -623,9 +619,9 @@ main( int argc, char **argv )
attrs = &argv[optind];
}
#if defined(TEST_ABANDON) || defined(TEST_CANCEL)
SIGNAL( SIGINT, do_sig );
#endif
if ( contoper > 0 ) {
SIGNAL( SIGINT, do_sig );
}
if ( infile != NULL ) {
if ( infile[0] == '-' && infile[1] == '\0' ) {
@ -1022,6 +1018,20 @@ static int dosearch(
sortattr ? LDAP_MSG_ALL : LDAP_MSG_ONE,
NULL, &res )) > 0 )
{
switch ( gotintr ) {
case 2:
rc = ldap_cancel_s( ld, msgid, NULL, NULL );
fprintf( stderr, "got interrupt, cancel got %d: %s\n",
rc, ldap_err2string( rc ) );
return -1;
case 1:
rc = ldap_abandon( ld, msgid );
fprintf( stderr, "got interrupt, abandon got %d: %s\n",
rc, ldap_err2string( rc ) );
return -1;
}
if( sortattr ) {
(void) ldap_sort_entries( ld, &res,
( *sortattr == '\0' ) ? NULL : sortattr, strcasecmp );
@ -1118,27 +1128,13 @@ static int dosearch(
ldap_msgfree( res );
}
#if defined(TEST_ABANDON) || defined(TEST_CANCEL)
if ( gotintr ) {
#ifdef TEST_CANCEL
rc = ldap_cancel_s( ld, msgid, NULL, NULL );
fprintf( stderr, "got interrupt, cancel got %d\n", rc );
return -1;
#endif
#ifdef TEST_ABANDON
rc = ldap_abandon( ld, msgid );
fprintf( stderr, "got interrupt, abandon got %d\n", rc );
return -1;
#endif
}
#endif
done:
if ( rc == -1 ) {
ldap_perror( ld, "ldap_result" );
return( rc );
}
done:
ldap_msgfree( res );
#ifdef LDAP_CONTROL_PAGEDRESULTS
if ( pagedResults ) {

View File

@ -1,11 +1,11 @@
Tools ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
ldapcompare * DE**HI*K M*OPQR UVWXYZ de *h**k *n*p* vwxyz
ldapcompare * DE**HI*K M*OPQR UVWXYZ de *h**k *n*p* vwxyz
ldapdelete *CDE**HI*K M*OPQR UVWXYZ cdef*h**k *n*p* vwxy
ldapmodify *CDE**HI*K M*OPQRS UVWXYZabcde *h**k *n*p*r t vwxy
ldapmodrdn *CDE**HI*K M*OPQR UVWXYZ cdef*h**k *n*p*rs vwxy
ldappasswd A*CDE**HI* *O QRS UVWXYZa def*h** * * * s vwxy
ldapsearch A*CDE**HI*KLM*OPQRSTUVWXYZab*def*h**kl*n*p* stuvwxyz
ldapwhoami * DE**HI* *O QR UVWXYZ def*h** *n*p* vwxy
ldapsearch A*CDE**HI*KLM*OPQRSTUVWXYZabcdef*h**kl*n*p* stuvwxyz
ldapwhoami * DE**HI* *O QR UVWXYZ def*h** *n*p* vwxy
* reserved

View File

@ -9,6 +9,8 @@ ldapsearch \- LDAP search tool
[\c
.BR \-n ]
[\c
.BR \-c ]
[\c
.BR \-u ]
[\c
.BR \-v ]
@ -99,6 +101,13 @@ If no \fIattrs\fP are listed, all user attributes are returned. If only
Show what would be done, but don't actually perform the search. Useful for
debugging in conjunction with -v.
.TP
.B \-c
Trap SIGINT and issue an
.B abandon
operation (if the switch appears once), or a
.B cancel
extended operation (if the switch appears twice).
.TP
.B \-u
Include the User Friendly Name form of the Distinguished Name (DN)
in the output.