]> git.sur5r.net Git - openldap/blobdiff - tests/progs/slapd-modrdn.c
ITS#6003, #5916 fix ldap_back_entry_get_rw, no deref here
[openldap] / tests / progs / slapd-modrdn.c
index 2080ac4aab5f2e70d5297e20ade2a8f6d8da77c2..bc3da1c6f38eb22e9ecd199412e8dc06ad35d718 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-2009 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"
 
@@ -52,6 +52,7 @@ usage( char *name )
                "-D <manager> "
                "-w <passwd> "
                "-e <entry> "
+               "[-i <ignore>] "
                "[-l <loops>] "
                "[-L <outerloops>] "
                "[-r <maxretries>] "
@@ -79,10 +80,11 @@ main( int argc, char **argv )
        int             friendly = 0;
        int             chaserefs = 0;
 
-       tester_init( "slapd-modrdn" );
+       tester_init( "slapd-modrdn", TESTER_MODRDN );
 
-       while ( (i = getopt( argc, argv, "CFH:h:p:D:w:e:l:L:r:t:" )) != EOF ) {
-               switch( i ) {
+       while ( ( i = getopt( argc, argv, "CD:e:FH:h:i:L:l:p:r:t:w:" ) ) != EOF )
+       {
+               switch ( i ) {
                case 'C':
                        chaserefs++;
                        break;
@@ -99,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] );
@@ -112,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 */
@@ -176,15 +183,13 @@ do_modrdn( char *uri, char *manager,
        int delay, int friendly, int chaserefs )
 {
        LDAP    *ld = NULL;
-       int     i = 0, do_retry = maxretries;
-       pid_t   pid;
+       int     i, do_retry = maxretries;
        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 );
 
@@ -203,10 +208,12 @@ do_modrdn( char *uri, char *manager,
        rdns[0] = strdup( DNs[1] );
        DNs[1][i] = ',';
 
+       i = 0;
+
 retry:;
        ldap_initialize( &ld, uri );
        if ( ld == NULL ) {
-               tester_perror( "ldap_initialize" );
+               tester_perror( "ldap_initialize", NULL );
                exit( EXIT_FAILURE );
        }
 
@@ -221,7 +228,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:
@@ -242,7 +249,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
@@ -267,7 +274,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
@@ -293,7 +300,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 );
 }