[Fedora-directory-commits] ldapserver/ldap/admin/src/scripts DSMigration.pm.in, 1.11, 1.12 FileConn.pm, 1.3, 1.4 Migration.pm.in, 1.5, 1.6 Util.pm.in, 1.11, 1.12

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Fri Sep 14 02:41:16 UTC 2007


Author: rmeggins

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

Modified Files:
	DSMigration.pm.in FileConn.pm Migration.pm.in Util.pm.in 
Log Message:
Resolves: bug 288451
Bug Description: Show-Stopper - Migration from HP-PARISC DS 6.21 to DS80 on HP-Itaninum
Reviewed by: nhosoi (Thanks!)
Fix Description: 1) The temp file created to fix nsroot was not owned by the server user, and ldif2db could not open it.
2) The perldap LDIF parser/writer did not correctly handle the version: 1 line in the LDIF file.  It outputs dn\nversion: 1 which causes ldif2db to crash.
3) The migrate script could not start the server because it wasn't looking in the fhs-opt location.  The real solution is to just have migration start the servers after it migrates them.  This assumes the old servers are all shutdown first, which they must be, in order to have a consistent database for migration.
These last two were found and fixed by nhosoi
4) If we transform an attribute to an empty value, this means we want to remove it from the migrated entry.  We use the remove method to remove the attribute.
5) The remove method in FileConn was not working.  We have to make a clone of the entry that we have removed the attribute from.  The process of iterating over the attributes skips deleted ones because of the way the Tie::Hash functions in the Entry class work.
Platforms tested: HP-UX 11.23 IPF64
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.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- DSMigration.pm.in	8 Sep 2007 02:16:27 -0000	1.11
+++ DSMigration.pm.in	14 Sep 2007 02:41:13 -0000	1.12
@@ -269,6 +269,7 @@
     my $in = new Mozilla::LDAP::LDIF(*MYLDIF);
     while (my $ent = readOneEntry $in) {
         my $dn = $ent->getDN();
+        next if (!$dn); # netscaperoot should not have the empty dn
         $dn =~ s/\bNetscape\b/@capbrand@/g;
         $ent->setDN($dn);
         foreach my $attr (keys %{$ent}) {
@@ -305,6 +306,11 @@
         my $deleteflag = 0;
         if ($fname =~ /NetscapeRoot.ldif$/) {
             $fname = migrateNetscapeRoot($fname);
+            # make sure $fname is owned by the server user
+            my $cfgent = $dest->search("cn=config", "base", "(objectclass=*)");
+            my $user = $cfgent->getValues('nsslapd-localuser');
+            my $uid = getpwnam $user;
+            chown $uid, -1, $fname;
             $deleteflag = 1;
         }
         my $cmd = "$inst_dir/ldif2db -n \"$dbname\" -i \"$fname\"";
@@ -443,7 +449,14 @@
     for my $attr (keys %{$ent}) {
         my $lcattr = lc $attr;
         if ($transformAttr{$lcattr}) {
-            $ent->setValues($attr, &{$transformAttr{$lcattr}}($ent, $attr, $mig, $inst));
+            my $newval = &{$transformAttr{$lcattr}}($ent, $attr, $mig, $inst);
+            if (!$newval) {
+                debug(2, "Removing attribute $attr from entry ", $ent->getDN(), "\n");
+                $ent->remove($attr);
+            } else {
+                debug(2, "Setting new value $newval for attribute $attr in entry ", $ent->getDN(), "\n");
+                $ent->setValues($attr, $newval);
+            }
         }
     }
 }
@@ -484,8 +497,13 @@
             if (!$innewonly{$attr}) {
                 my $oldval = $old->getValues($attr);
                 my $newval = &{$transformAttr{$lcattr}}($old, $attr, $mig, $inst);
-                $new->setValues($attr, $newval);
-                debug(3, "mergeEntries: transformed old value $oldval to $newval\n");
+                if (!$newval) {
+                    debug(3, "Removing attribute $attr from entry ", $new->getDN(), "\n");
+                    $new->remove($attr);
+                } else {
+                    debug(3, "Setting new value $newval for attribute $attr in entry ", $new->getDN(), "\n");
+                    $new->setValues($attr, $newval);
+                }
             }
         } elsif ($cn eq "internationalization plugin" and $lcattr eq "nsslapd-pluginarg0") {
             debug(3, "mergeEntries: using new value of internationalization plugin nsslapd-pluginarg0\n");
@@ -725,6 +743,10 @@
             return 0;
         }
 
+        if (!$mig->{start_servers}) {
+            $inf->{slapd}->{start_server} = 0;
+        }
+
         # create the new instance
         @errs = createDSInstance($inf);
         unlink($inf->{filename});


Index: FileConn.pm
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/FileConn.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FileConn.pm	13 Jul 2007 18:35:32 -0000	1.3
+++ FileConn.pm	14 Sep 2007 02:41:13 -0000	1.4
@@ -411,7 +411,10 @@
         return 0;
     }
 
-    $self->{$ndn}->{data} = $entry;
+    # The cloned entry will not contain the deleted attrs - the cloning
+    # process omits the deleted attrs via the Entry FETCH, FIRSTKEY, and NEXTKEY
+    # methods
+    $self->{$ndn}->{data} = cloneEntry($entry);
     $self->write();
 
     return 1;


Index: Migration.pm.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/Migration.pm.in,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Migration.pm.in	15 Aug 2007 22:04:31 -0000	1.5
+++ Migration.pm.in	14 Sep 2007 02:41:13 -0000	1.6
@@ -225,6 +225,7 @@
     $self->{logfile} = $logfile;
     $self->{crossplatform} = $crossplatform;
     $self->{log} = new SetupLog($self->{logfile}, "migrate");
+    $self->{start_servers} = 1; # start servers as soon as they are migrated
     # if user supplied inf file, use that to initialize
     if (defined($self->{inffile})) {
         $self->{inf} = new Inf($self->{inffile});


Index: Util.pm.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/Util.pm.in,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Util.pm.in	15 Aug 2007 22:04:31 -0000	1.11
+++ Util.pm.in	14 Sep 2007 02:41:13 -0000	1.12
@@ -813,7 +813,6 @@
     print $outfh "RootDNPwd = ", $ent->getValues('nsslapd-rootpw'), "\n";
     print $outfh "ServerPort = ", $ent->getValues('nsslapd-port'), "\n";
     print $outfh "ServerIdentifier = $id\n";
-    print $outfh "start_server= 0\n";
 
     my $suffix;
     $ent = $conn->search("cn=ldbm database,cn=plugins,cn=config",




More information about the Fedora-directory-commits mailing list