瀏覽代碼

Resolves: bug 333291
Bug Description: Do not allow direct migration if the source db index has old IDL format
Reviewed by: nkinder (Thanks!)
Fix Description: Just before the attempt to copy the database directories, look at the DBVERSION file from the source. If it is determined that the source version is too old, just exit migration and output a helpful error message.
Platforms tested: RHEL4 i386
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 年之前
父節點
當前提交
878c163528
共有 2 個文件被更改,包括 33 次插入0 次删除
  1. 27 0
      ldap/admin/src/scripts/DSMigration.pm.in
  2. 6 0
      ldap/admin/src/scripts/migrate-ds.res

+ 27 - 0
ldap/admin/src/scripts/DSMigration.pm.in

@@ -241,10 +241,37 @@ my %transformAttr =
  'nsslapd-idl-switch' => \&migIdlSwitch
  '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 {
 sub copyDatabaseDirs {
     my $srcdir = shift;
     my $srcdir = shift;
     my $destdir = shift;
     my $destdir = shift;
     my $filesonly = shift;
     my $filesonly = shift;
+    my @errs;
+
+    # check old DBVERSION file
+    my @verinfo;
+    if (@errs = getDBVERSION($srcdir, \@verinfo)) {
+        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);
+    }
+
     if (-d $srcdir && ! -d $destdir && !$filesonly) {
     if (-d $srcdir && ! -d $destdir && !$filesonly) {
         debug(1, "Copying database directory $srcdir to $destdir\n");
         debug(1, "Copying database directory $srcdir to $destdir\n");
         if (system ("cp -p -r $srcdir $destdir")) {
         if (system ("cp -p -r $srcdir $destdir")) {

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

@@ -25,3 +25,9 @@ to the migration instructions for help with how to do this.\n\n
 fixing_integer_attr_index = The index for the attribute '%s' in the database directory '%s' will be removed and re-created.\n\n
 fixing_integer_attr_index = The index for the attribute '%s' in the database directory '%s' will be removed and re-created.\n\n
 error_removing_index_file = Could not remove the index file '%s'.  Error: %s\n\n
 error_removing_index_file = Could not remove the index file '%s'.  Error: %s\n\n
 error_recreating_index_file = Could not re-create the index file '%s'.  Error: %s\n\n
 error_recreating_index_file = Could not re-create the index file '%s'.  Error: %s\n\n
+error_reading_dbversion = Could not read the old database version information from '%s'.  Error: %s\n\n
+error_database_too_old = The database at '%s' is version '%s/%s'.\
+This version cannot be migrated using the database binaries.  You must\
+first convert the databases to LDIF format and use the cross platform\
+migration procedure.  This procedure is documented in the migration\
+guide and in the help for this script.\n\n