[Fedora-directory-commits] ldapserver/ldap/admin/src/scripts DSMigration.pm.in, 1.20, 1.21

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Tue Oct 23 02:13:55 UTC 2007


Author: rmeggins

Update of /cvs/dirsec/ldapserver/ldap/admin/src/scripts
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22221/ldapserver/ldap/admin/src/scripts

Modified Files:
	DSMigration.pm.in 
Log Message:
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



Index: DSMigration.pm.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/DSMigration.pm.in,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- DSMigration.pm.in	19 Oct 2007 01:50:15 -0000	1.20
+++ DSMigration.pm.in	23 Oct 2007 02:13:53 -0000	1.21
@@ -134,6 +134,37 @@
  '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 @@
     # 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 @@
  '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) {




More information about the Fedora-directory-commits mailing list