From cc475f4bbee3db2be4b7be16750944759ed81624 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sat, 11 Feb 2006 00:51:08 +0000 Subject: [PATCH] Allow arbitrary exop data to be base64 encoded Argument matches LDIF, ie --- clients/tools/ldapexop.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/clients/tools/ldapexop.c b/clients/tools/ldapexop.c index a972f9745a..0ffe42dd5e 100644 --- a/clients/tools/ldapexop.c +++ b/clients/tools/ldapexop.c @@ -42,7 +42,7 @@ void usage( void ) { fprintf( stderr, _("Issue LDAP extended operations\n\n")); - fprintf( stderr, _("usage: %s [options] [oid[:data]]\n"), prog); + fprintf( stderr, _("usage: %s [options] \n"), prog); tool_common_usage(); exit( EXIT_FAILURE ); } @@ -190,17 +190,32 @@ main( int argc, char *argv[] ) } p = strchr( argv[ 0 ], ':' ); + if ( p == argv[ 0 ] ) { + usage(); + } + if ( p != NULL ) *p++ = '\0'; if ( tool_is_oid( argv[ 0 ] ) ) { - struct berval reqdata; - - if ( p ) { - reqdata.bv_val = p; - reqdata.bv_len = strlen( reqdata.bv_val ); + struct berval reqdata; + struct berval type; + struct berval value; + int freeval; + + if ( p != NULL ) { + p[ -1 ] = ':'; + ldif_parse_line2( argv[ 0 ], &type, &value, &freeval ); + p[ -1 ] = '\0'; + + if ( freeval ) { + reqdata = value; + } else { + ber_dupbv( &reqdata, &value ); + } } + tool_server_controls( ld, NULL, 0 ); rc = ldap_extended_operation( ld, argv[ 0 ], p ? &reqdata : NULL, NULL, NULL, &id ); -- 2.39.5