summaryrefslogtreecommitdiffstats
path: root/ldap/admin
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2007-10-23 02:13:53 +0000
committerRich Megginson <rmeggins@redhat.com>2007-10-23 02:13:53 +0000
commit428064c0d28003238ee36970be26fae6cc195423 (patch)
tree94a8035ab0922edffee6eb9c2d99bd7030415666 /ldap/admin
parent9752915cac9c99a6b753102b3f9f8f63962b2b44 (diff)
downloadds-428064c0d28003238ee36970be26fae6cc195423.tar.gz
ds-428064c0d28003238ee36970be26fae6cc195423.tar.xz
ds-428064c0d28003238ee36970be26fae6cc195423.zip
Resolves: bug 345711
Bug Description: migration : ignore idl switch value in 6.21 and earlier Reviewed by: nhosoi (Thanks!) Fix Description: If we are migrating a 6.21 or older database, we must not preserve the old idl switch setting, we must use the new default. We also have to use LDIF files for database migration as we cannot reuse the old binary database files. Platforms tested: 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
Diffstat (limited to 'ldap/admin')
-rw-r--r--ldap/admin/src/scripts/DSMigration.pm.in77
1 files changed, 55 insertions, 22 deletions
diff --git a/ldap/admin/src/scripts/DSMigration.pm.in b/ldap/admin/src/scripts/DSMigration.pm.in
index 0de30740..65f46c05 100644
--- a/ldap/admin/src/scripts/DSMigration.pm.in
+++ b/ldap/admin/src/scripts/DSMigration.pm.in
@@ -134,6 +134,37 @@ my %alwaysUseOld =
'aci' => 'aci'
);
+sub getDBVERSION {
+ my $olddbdir = shift;
+ my $data = shift;
+
+ open DBVERSION, "$olddbdir/DBVERSION" or
+ return ('error_reading_dbversion', $olddbdir, $!);
+ my $line = <DBVERSION>;
+ close DBVERSION;
+ chomp($line);
+ my @foo = split("/", $line);
+ $data = \@foo;
+ return ();
+}
+
+sub isOldDatabase {
+ my $olddbdir = shift;
+ my $errs = shift; # array ref
+ # check old DBVERSION file
+ my @verinfo;
+ if (@{$errs} = getDBVERSION($olddbdir, \@verinfo)) {
+ return 0;
+ }
+
+ if ((($verinfo[0] =~ /^netscape/i) or ($verinfo[0] =~ /^iplanet/i)) and
+ (($verinfo[1] =~ /^6/) or ($verinfo[1] =~ /^5/) or ($verinfo[1] =~ /^4/))) {
+ return 1;
+ }
+
+ return 0;
+}
+
sub getNewDbDir {
my ($ent, $attr, $mig, $inst) = @_;
my $newval;
@@ -217,7 +248,27 @@ sub migIdlSwitch {
# nsslapd-idl-switch
# if not doing cross platform, meaning we just use the existing
# database binaries, we must preserve whatever the old value is
+ # unless migrating from 6.21 or earlier, in which case we must
+ # be migrating from LDIF, and must use the new idl switch
if (!$mig->{crossplatform}) {
+ # the given entry is the old entry - see if it has the nsslapd-directory
+ my $olddbdir = $ent->getValues('nsslapd-db-home-directory') ||
+ $ent->getValues('nsslapd-directory') ||
+ "$mig->{actualsroot}/$inst/db"; # old default db home directory
+ # replace the old sroot value with the actual physical location on the target/dest
+ $olddbdir =~ s/^$mig->{actualsroot}/$mig->{oldsroot}/;
+ my @errs;
+ my $isold = isOldDatabase($olddbdir, \@errs);
+ if (@errs) {
+ $mig->msg($FATAL, @errs);
+ return $newval; # use default new value
+ } elsif ($isold) {
+ debug(3, "The database in $olddbdir is too old to migrate the idl switch setting\n");
+ return $newval; # use default new value
+ }
+
+ # else the database could be in the new format already - preserve
+ # the user's old value
$newval = $ent->getValues($attr);
}
@@ -241,35 +292,17 @@ my %transformAttr =
'nsslapd-idl-switch' => \&migIdlSwitch
);
-sub getDBVERSION {
- my $olddbdir = shift;
- my $data = shift;
-
- open DBVERSION, "$olddbdir/DBVERSION" or
- return ('error_reading_dbversion', $olddbdir, $!);
- my $line = <DBVERSION>;
- close DBVERSION;
- chomp($line);
- my @foo = split("/", $line);
- $data = \@foo;
- return ();
-}
-
sub copyDatabaseDirs {
my $srcdir = shift;
my $destdir = shift;
my $filesonly = shift;
my @errs;
- # check old DBVERSION file
- my @verinfo;
- if (@errs = getDBVERSION($srcdir, \@verinfo)) {
+ my $isold = isOldDatabase($srcdir, \@errs);
+ if (@errs) {
return @errs;
- }
-
- if ((($verinfo[0] =~ /^netscape/i) or ($verinfo[0] =~ /^iplanet/i)) and
- (($verinfo[1] =~ /^6/) or ($verinfo[1] =~ /^5/) or ($verinfo[1] =~ /^4/))) {
- return ('error_database_too_old', $srcdir, @verinfo);
+ } elsif ($isold) {
+ return ('error_database_too_old', $olddbdir, @verinfo);
}
if (-d $srcdir && ! -d $destdir && !$filesonly) {