]> git.sur5r.net Git - openldap/blobdiff - tests/progs/slapd-modrdn.c
Add missing revision string
[openldap] / tests / progs / slapd-modrdn.c
index b28ae2848439f48b6def20a6936ca5f53c37cf92..983b79fbd1139e5a0825262fc469ae8339ff9049 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2006 The OpenLDAP Foundation.
+ * Copyright 1999-2008 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 
 #include <stdio.h>
 
-#include <ac/stdlib.h>
+#include "ac/stdlib.h"
 
-#include <ac/ctype.h>
-#include <ac/param.h>
-#include <ac/socket.h>
-#include <ac/string.h>
-#include <ac/unistd.h>
-#include <ac/wait.h>
+#include "ac/ctype.h"
+#include "ac/param.h"
+#include "ac/socket.h"
+#include "ac/string.h"
+#include "ac/unistd.h"
+#include "ac/wait.h"
 
-#include <ldap.h>
-#include <lutil.h>
+#include "ldap.h"
+#include "lutil.h"
 
 #include "slapd-common.h"
 
@@ -41,7 +41,7 @@
 static void
 do_modrdn( char *uri, char *manager, struct berval *passwd,
                char *entry, int maxloop, int maxretries, int delay,
-               int friendly );
+               int friendly, int chaserefs );
 
 static void
 usage( char *name )
@@ -52,11 +52,13 @@ usage( char *name )
                "-D <manager> "
                "-w <passwd> "
                "-e <entry> "
+               "[-i <ignore>] "
                "[-l <loops>] "
                "[-L <outerloops>] "
                "[-r <maxretries>] "
                "[-t <delay>] "
-               "[-F]\n",
+               "[-F] "
+               "[-C]\n",
                        name );
        exit( EXIT_FAILURE );
 }
@@ -76,11 +78,17 @@ main( int argc, char **argv )
        int             retries = RETRIES;
        int             delay = 0;
        int             friendly = 0;
+       int             chaserefs = 0;
 
-       tester_init( "slapd-modrdn" );
+       tester_init( "slapd-modrdn", TESTER_MODRDN );
+
+       while ( ( i = getopt( argc, argv, "CD:e:FH:h:i:L:l:p:r:t:w:" ) ) != EOF )
+       {
+               switch ( i ) {
+               case 'C':
+                       chaserefs++;
+                       break;
 
-       while ( (i = getopt( argc, argv, "FH:h:p:D:w:e:l:L:r:t:" )) != EOF ) {
-               switch( i ) {
                case 'F':
                        friendly++;
                        break;
@@ -93,6 +101,10 @@ main( int argc, char **argv )
                        host = strdup( optarg );
                        break;
 
+               case 'i':
+                       /* ignored (!) by now */
+                       break;
+
                case 'p':               /* the servers port */
                        if ( lutil_atoi( &port, optarg ) != 0 ) {
                                usage( argv[0] );
@@ -106,6 +118,7 @@ main( int argc, char **argv )
                case 'w':               /* the server managers password */
                        passwd.bv_val = strdup( optarg );
                        passwd.bv_len = strlen( optarg );
+                       memset( optarg, '*', passwd.bv_len );
                        break;
 
                case 'e':               /* entry to rename */
@@ -157,7 +170,7 @@ main( int argc, char **argv )
 
        for ( i = 0; i < outerloops; i++ ) {
                do_modrdn( uri, manager, &passwd, entry,
-                               loops, retries, delay, friendly );
+                       loops, retries, delay, friendly, chaserefs );
        }
 
        exit( EXIT_SUCCESS );
@@ -166,19 +179,17 @@ main( int argc, char **argv )
 
 static void
 do_modrdn( char *uri, char *manager,
-       struct berval *passwd, char *entry, int maxloop, int maxretries, int delay,
-       int friendly )
+       struct berval *passwd, char *entry, int maxloop, int maxretries,
+       int delay, int friendly, int chaserefs )
 {
        LDAP    *ld = NULL;
        int     i = 0, do_retry = maxretries;
-       pid_t   pid;
        char    *DNs[2];
        char    *rdns[2];
        int     rc = LDAP_SUCCESS;
        char    *p1, *p2;
        int     version = LDAP_VERSION3;
 
-       pid = getpid();
        DNs[0] = entry;
        DNs[1] = strdup( entry );
 
@@ -200,11 +211,13 @@ do_modrdn( char *uri, char *manager,
 retry:;
        ldap_initialize( &ld, uri );
        if ( ld == NULL ) {
-               tester_perror( "ldap_initialize" );
+               tester_perror( "ldap_initialize", NULL );
                exit( EXIT_FAILURE );
        }
 
        (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); 
+       (void) ldap_set_option( ld, LDAP_OPT_REFERRALS,
+               chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF );
 
        if ( do_retry == maxretries ) {
                fprintf( stderr, "PID=%ld - Modrdn(%d): entry=\"%s\".\n",
@@ -213,7 +226,7 @@ retry:;
 
        rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
        if ( rc != LDAP_SUCCESS ) {
-               tester_ldap_error( ld, "ldap_sasl_bind_s" );
+               tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
                switch ( rc ) {
                case LDAP_BUSY:
                case LDAP_UNAVAILABLE:
@@ -234,7 +247,7 @@ retry:;
        for ( ; i < maxloop; i++ ) {
                rc = ldap_rename_s( ld, DNs[0], rdns[0], NULL, 0, NULL, NULL );
                if ( rc != LDAP_SUCCESS ) {
-                       tester_ldap_error( ld, "ldap_rename_s" );
+                       tester_ldap_error( ld, "ldap_rename_s", NULL );
                        switch ( rc ) {
                        case LDAP_NO_SUCH_OBJECT:
                                /* NOTE: this likely means
@@ -259,7 +272,7 @@ retry:;
                }
                rc = ldap_rename_s( ld, DNs[1], rdns[1], NULL, 1, NULL, NULL );
                if ( rc != LDAP_SUCCESS ) {
-                       tester_ldap_error( ld, "ldap_rename_s" );
+                       tester_ldap_error( ld, "ldap_rename_s", NULL );
                        switch ( rc ) {
                        case LDAP_NO_SUCH_OBJECT:
                                /* NOTE: this likely means
@@ -285,7 +298,7 @@ retry:;
        }
 
 done:;
-       fprintf( stderr, " PID=%ld - Modrdn done (%d).\n", (long) pid, rc );
+       fprintf( stderr, "  PID=%ld - Modrdn done (%d).\n", (long) pid, rc );
 
        ldap_unbind_ext( ld, NULL, NULL );
 }