From 0d446f9385c7746eb0f0391c8cd7935aa7279502 Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Thu, 30 Aug 2007 00:06:51 +0000 Subject: 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 --- ldap/admin/src/scripts/DSMigration.pm.in | 17 ++++++++--------- ldap/admin/src/scripts/migrate-ds.res | 5 +++++ 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'ldap/admin/src/scripts') diff --git a/ldap/admin/src/scripts/DSMigration.pm.in b/ldap/admin/src/scripts/DSMigration.pm.in index a0488e13..ff701d44 100644 --- a/ldap/admin/src/scripts/DSMigration.pm.in +++ b/ldap/admin/src/scripts/DSMigration.pm.in @@ -152,8 +152,8 @@ sub getNewDbDir { sub migrateCredentials { my ($ent, $attr, $mig, $inst) = @_; 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"); return $newval; } @@ -235,18 +235,15 @@ sub migrateDatabases { my $olddefault = "$mig->{actualsroot}/$inst/db"; # old default db home directory 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 # database my $foundldif; for (glob("$mig->{oldsroot}/$inst/db/*.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"); $? = 0; # clear error condition my $output = `$cmd 2>&1`; @@ -259,6 +256,8 @@ sub migrateDatabases { if ($foundldif) { 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 diff --git a/ldap/admin/src/scripts/migrate-ds.res b/ldap/admin/src/scripts/migrate-ds.res index 9629e9bd..05d1677d 100644 --- a/ldap/admin/src/scripts/migrate-ds.res +++ b/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_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 +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 -- cgit