Browse Source

Resolves: bug 260341
Bug Description: Migration script references a non-existing directory
Reviewed by: nhosoi (Thanks!)
Fix Description: This fixes a couple of problems.
1) Use the inst_dir from the directory server as the instance dir where the ldif2db script is found.
2) The password for migratecred should be quoted before being passed to the shell, in case there are shell meta chars in there
3) If using cross platform migration, and no LDIF files were found to migrate, this will cause an error message to be printed and migration will be aborted.
Platforms tested: RHEL4 i386, RHEL5 x86_64
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none

Rich Megginson 18 years ago
parent
commit
0d446f9385

+ 8 - 9
ldap/admin/src/scripts/DSMigration.pm.in

@@ -152,8 +152,8 @@ sub getNewDbDir {
 sub migrateCredentials {
 sub migrateCredentials {
     my ($ent, $attr, $mig, $inst) = @_;
     my ($ent, $attr, $mig, $inst) = @_;
     my $oldval = $ent->getValues($attr);
     my $oldval = $ent->getValues($attr);
-    debug(3, "Executing @bindir@/migratecred -o $mig->{actualsroot}/$inst -n @instconfigdir@/$inst -c $oldval . . .\n");
-    my $newval = `@bindir@/migratecred -o $mig->{actualsroot}/$inst -n @instconfigdir@/$inst -c $oldval`;
+    debug(3, "Executing @bindir@/migratecred -o $mig->{actualsroot}/$inst -n @instconfigdir@/$inst -c \'$oldval\' . . .\n");
+    my $newval = `@bindir@/migratecred -o $mig->{actualsroot}/$inst -n @instconfigdir@/$inst -c \'$oldval\'`;
     debug(3, "Converted old value [$oldval] to new value [$newval] for attr $attr in entry ", $ent->getDN(), "\n");
     debug(3, "Converted old value [$oldval] to new value [$newval] for attr $attr in entry ", $ent->getDN(), "\n");
     return $newval;
     return $newval;
 }
 }
@@ -235,18 +235,15 @@ sub migrateDatabases {
     my $olddefault = "$mig->{actualsroot}/$inst/db"; # old default db home directory
     my $olddefault = "$mig->{actualsroot}/$inst/db"; # old default db home directory
     my @errs;
     my @errs;
 
 
+    # the ldif2db command will be in nsslapd-instancedir
+    my $cfgent = $dest->search("cn=config", "base", "(objectclass=*)");
+    my $inst_dir = $cfgent->getValues('nsslapd-instancedir');
     # first, look for an LDIF file in that directory with the same name as the
     # first, look for an LDIF file in that directory with the same name as the
     # database
     # database
     my $foundldif;
     my $foundldif;
     for (glob("$mig->{oldsroot}/$inst/db/*.ldif")) {
     for (glob("$mig->{oldsroot}/$inst/db/*.ldif")) {
         my $dbname = basename($_, '.ldif');
         my $dbname = basename($_, '.ldif');
-        my $cmd = "";
-        if ("@with_fhs_opt@") {
-            $cmd = "/opt/@PACKAGE_NAME@/$inst/ldif2db -n \"$dbname\" -i \"$_\"";
-        } else {
-            $cmd = "@serverdir@/$inst/ldif2db -n \"$dbname\" -i \"$_\"";
-        }
-
+        my $cmd = "$inst_dir/ldif2db -n \"$dbname\" -i \"$_\"";
         debug(1, "migrateDatabases: executing command $cmd\n");
         debug(1, "migrateDatabases: executing command $cmd\n");
         $? = 0; # clear error condition
         $? = 0; # clear error condition
         my $output = `$cmd 2>&1`;
         my $output = `$cmd 2>&1`;
@@ -259,6 +256,8 @@ sub migrateDatabases {
 
 
     if ($foundldif) {
     if ($foundldif) {
         return (); # done - can do nothing else for cross-platform
         return (); # done - can do nothing else for cross-platform
+    } elsif ($mig->{crossplatform}) { # cross platform requires LDIF files
+        return ('ldif_required_for_cross_platform', "$mig->{oldsroot}/$inst/db");
     }
     }
 
 
     # if no LDIF files, just copy over the database directories
     # if no LDIF files, just copy over the database directories

+ 5 - 0
ldap/admin/src/scripts/migrate-ds.res

@@ -17,3 +17,8 @@ error_copying_keydb = Could not copy the private key database file '%s' to '%s'.
 error_copying_secmoddb = Could not copy the security module database file '%s' to '%s'.  Error: %s\n
 error_copying_secmoddb = Could not copy the security module database file '%s' to '%s'.  Error: %s\n
 error_copying_pinfile = Could not copy the key database PIN file '%s' to '%s'.  Error: %s\n
 error_copying_pinfile = Could not copy the key database PIN file '%s' to '%s'.  Error: %s\n
 error_copying_certmap = Could not copy the client certificate mapping file '%s' to '%s'.  Error: %s\n
 error_copying_certmap = Could not copy the client certificate mapping file '%s' to '%s'.  Error: %s\n
+ldif_required_for_cross_platform = No LDIF files were found in %s.\n
+LDIF files are required in order to do cross platform migration.  The\
+database files are not binary compatible, and the new databases must\
+be initialized from an LDIF export of the old databases.  Please refer\
+to the migration instructions for help with how to do this.\n\n