Author: rmeggins
Update of /cvs/dirsec/adminserver/admserv/newinst/src
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv6416/adminserver/admserv/newinst/src
Modified Files:
AdminMigration.pm.in adminserver.map.in asmigrate.map.in
configdsroot.map.in dirserver.map.in migrate-ds-admin.res.in
register_param.map.in
Log Message:
Resolves: bug 252190
Bug Description: 7.1 to 8.0 Migration Bug
Reviewed by: nhosoi (Thanks!)
Fix Description: Lots of issues
1) Instead of using Net::Domain::hostname() for the hostname to use for server
identifiers, we must use the leftmost component of the FullMachineName specified by the
user. One of the reasons is that hostname() and hostfqdn() can give different results
such that hostname() is not the leftmost component of hostfqdn(). And we should just use
whatever the user specifies. This required several changes to the mapfiles, and a change
to the maptable processing, to process the perl code to eval last, so that we can use
token substitutions from the inf file and from hard coded strings.
2) We need to add the global preferences stuff, during migration, in order for the console
to function. We cannot rely on the migrated o=NetscapeRoot data because we have to make
sure we specify the new jar files to use. In addition, we need to migrate over any
customizations that the user has made to these preferences. This is handled by the new
updateConsoleInfo function called during admin server migration.
3) There were several resources for messages missing. These have been added.
4) With the new perl only ds instance creation code, there will actually be data in the
database even though the server is not started. This is what I believe was causing the
error_removing_temp_db_files error. So now, the code will only attempt to remove plain
files, not directories that could be globbed.
5) Use /opt/brand-ds for the old server root instead of /opt/pkgname.
6) The migration log should use [Migration} not [Setup]
7) migration should not report a fatal error upon success
Platforms tested: RHEL4
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
Index: AdminMigration.pm.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/AdminMigration.pm.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AdminMigration.pm.in 24 Jul 2007 20:10:16 -0000 1.3
+++ AdminMigration.pm.in 15 Aug 2007 22:08:14 -0000 1.4
@@ -232,6 +232,105 @@
return 1;
}
+sub updateconinfocb {
+ my ($context, $entry, $errs) = @_;
+
+ my @arycontext = ($context);
+ # add or update all of the entries except for the UserDirectory
+ my $dn = $entry->getDN();
+ if (($entry->getDN() =~ /^cn=UserDirectory/i)) {
+ return 1; # return true, continue
+ }
+
+ my $rc = check_and_add_entry(\@arycontext, $entry, $errs);
+
+ return $rc;
+}
+
+# this updates any information in the configDS that pertains
+# to the console being upgraded
+sub updateConsoleInfo {
+ my $mig = shift;
+ my $configdir = shift;
+ my $inf = $mig->{inf};
+ my @errs;
+
+ my $conn = getConfigDSConn($inf->{General}->{ConfigDirectoryLdapURL},
+ $inf->{General}->{ConfigDirectoryAdminID},
+ $inf->{General}->{ConfigDirectoryAdminPwd},
+ $configdir, \@errs);
+
+ if (@errs) {
+ $mig->msg($FATAL, @errs);
+ return 0;
+ }
+
+ # update the console info
+ my @ldiffiles = ("@ldifdir(a)/02globalpreferences.ldif.tmpl"
+ );
+ my $setupinf = new Inf("@infdir(a)/setup.inf");
+ my $admininf = new Inf("@infdir(a)/admin.inf");
+ my $dsinf = new Inf("@infdir(a)/slapd.inf");
+
+ my $mapper = new Inf("@infdir(a)/updateconsoleinfo.map");
+
+ $mapper = process_maptbl($mapper, \@errs, $inf, $admininf, $dsinf, $setupinf);
+ if (!$mapper) {
+ $conn->close();
+ $mig->msg(@errs);
+ $mig->msg($FATAL, 'error_creating_updateconsole_maptbl');
+ return 0;
+ }
+
+ # update isie and sie
+ getMappedEntries($mapper, \@ldiffiles, \@errs, \&updateconinfocb, $conn);
+ if (@errs) {
+ $conn->close();
+ $mig->msg(@errs);
+ return 0;
+ }
+
+ # now, copy over any customization entries
+ my $basedn = "ou=Admin, ou=Global Preferences, ou=" .
+ $inf->{General}->{AdminDomain} . ", o=NetscapeRoot";
+ my $versents = $conn->search($basedn, "sub",
"(objectclass=*)", 0, qw(* aci));
+ if (!$versents) {
+ $mig->msg($FATAL, 'error_migrating_console_entries', $basedn,
$conn->getErrorString());
+ $conn->close();
+ return 0;
+ }
+
+ my @oldents = ();
+ for ($versents; $versents; $versents = $conn->nextEntry()) {
+ push @oldents, $versents;
+ }
+
+ for (@oldents) {
+ my $olddn = $_->getDN();
+ if (($olddn =~ /ou=(\d.\d)/) && ($1 ne
$admininf->{admin}->{ConsoleVersion})) {
+ my $newdn = $olddn;
+ $newdn =~ s/ou=$1/ou=$admininf->{admin}->{ConsoleVersion}/;
+ my $newent = $_;
+ $newent->setDN($newdn);
+ $conn->add($newent);
+ if ($conn->getErrorCode() == LDAP_SUCCESS) {
+ debug(3, "Added new console customization entry $newdn\n");
+ } elsif ($conn->getErrorCode() == LDAP_ALREADY_EXISTS) {
+ debug(3, "Console customization entry $newdn already exists,
skipping\n");
+ } else {
+ $mig->msg($FATAL, 'error_adding_console_entries', $newdn,
$conn->getErrorString());
+ $conn->close();
+ return 0;
+ }
+ } else {
+ debug(3, "Skipping entry $olddn - do not need to migrate it\n");
+ }
+ }
+
+ $conn->close();
+ return 1;
+}
+
sub migrateSecurityFiles {
my $mig = shift;
my $configdir = shift;
@@ -390,6 +489,10 @@
return 0;
}
+ if (!updateConsoleInfo($mig, $configdir)) {
+ return 0;
+ }
+
if (!migrateAdmpw($mig, $configdir)) {
return 0;
}
Index: adminserver.map.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/adminserver.map.in,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- adminserver.map.in 10 Aug 2007 02:23:29 -0000 1.8
+++ adminserver.map.in 15 Aug 2007 22:08:14 -0000 1.9
@@ -40,11 +40,11 @@
domain = AdminDomain
brand = Brand
normbrand = NormBrand
-hostname = `use Net::Domain qw(hostname); $returnvalue = hostname();`
+hostname = `$returnvalue = $mapper->{fqdn}; $returnvalue =~ s/\..*$//;`
vendor = Vendor
timestamp = `use Time::gmtime; my $gm = gmtime; $returnvalue = sprintf
("%04d%02d%02d%02d%02d%02dZ", 1900+$gm->year, 1+$gm->mon, $gm->mday,
$gm->hour, $gm->min, $gm->sec);`
-asid = `use Net::Domain qw(hostname); $returnvalue = hostname();`
+asid = `$returnvalue = $mapper->{fqdn}; $returnvalue =~ s/\..*$//;`
as_port = Port
admpw = "@configdir@/admpw"
as_error = "@logdir@/error"
Index: asmigrate.map.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/asmigrate.map.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- asmigrate.map.in 10 Aug 2007 02:23:29 -0000 1.3
+++ asmigrate.map.in 15 Aug 2007 22:08:14 -0000 1.4
@@ -37,11 +37,11 @@
domain = AdminDomain
brand = Brand
normbrand = NormBrand
-hostname = `use Net::Domain qw(hostname); $returnvalue = hostname();`
+hostname = `$returnvalue = $mapper->{fqdn}; $returnvalue =~ s/\..*$//;`
vendor = Vendor
timestamp = `use Time::gmtime; my $gm = gmtime; $returnvalue = sprintf
("%04d%02d%02d%02d%02d%02dZ", 1900+$gm->year, 1+$gm->mon, $gm->mday,
$gm->hour, $gm->min, $gm->sec);`
-asid = `use Net::Domain qw(hostname); $returnvalue = hostname();`
+asid = `$returnvalue = $mapper->{fqdn}; $returnvalue =~ s/\..*$//;`
as_port = Port
admpw = "@configdir@/admpw"
as_error = "@logdir@/errors"
Index: configdsroot.map.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/configdsroot.map.in,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- configdsroot.map.in 10 Aug 2007 02:23:29 -0000 1.7
+++ configdsroot.map.in 15 Aug 2007 22:08:14 -0000 1.8
@@ -42,7 +42,7 @@
as_uid = ServerAdminID
as_passwd = ServerAdminPwd
-asid = `use Net::Domain qw(hostname); $returnvalue = hostname();`
+asid = `$returnvalue = $mapper->{fqdn}; $returnvalue =~ s/\..*$//;`
as_version = Version
as_baseversion = BaseVersion
ds_version = Version
Index: dirserver.map.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/dirserver.map.in,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- dirserver.map.in 24 Jul 2007 20:10:16 -0000 1.7
+++ dirserver.map.in 15 Aug 2007 22:08:14 -0000 1.8
@@ -43,7 +43,7 @@
vendor = Vendor
timestamp = `use Time::gmtime; my $gm = gmtime; $returnvalue = sprintf
("%04d%02d%02d%02d%02d%02dZ", 1900+$gm->year, 1+$gm->mon, $gm->mday,
$gm->hour, $gm->min, $gm->sec);`
-asid = `use Net::Domain qw(hostname); $returnvalue = hostname();`
+asid = `$returnvalue = $mapper->{fqdn}; $returnvalue =~ s/\..*$//;`
as_sie = "cn=admin-serv-%asid%, cn=%brand% Administration Server, cn=Server Group,
cn=%fqdn%, ou=%domain%, o=NetscapeRoot"
ds_version = Version
ds_baseversion = BaseVersion
Index: migrate-ds-admin.res.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/migrate-ds-admin.res.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- migrate-ds-admin.res.in 29 Jun 2007 21:29:05 -0000 1.1
+++ migrate-ds-admin.res.in 15 Aug 2007 22:08:14 -0000 1.2
@@ -19,3 +19,7 @@
error_opening_nssconf = Error: could not open NSS config file %s. Error: %s\n
error_writing_nssconf = Error: could not write NSS config file %s. Error: %s\n
registering_dirserver_instances = Registering the migrated directory server instances
with the configuration directory server . . .\n
+error_creating_asmigration_maptbl = Error: could not create maptable for use in admin
server migration.\n
+error_creating_updateconsole_maptbl = Error: could not create maptable for use in admin
server console migration.\n
+error_migrating_console_entries = Error: Could not find the console customization entries
under '%s'. Error: %s\n
+error_adding_console_entries = Error: Could not add console customization entry
'%s'. Error: %s\n
Index: register_param.map.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/register_param.map.in,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- register_param.map.in 10 Aug 2007 02:23:29 -0000 1.9
+++ register_param.map.in 15 Aug 2007 22:08:14 -0000 1.10
@@ -40,7 +40,7 @@
domain = `use Net::Domain qw(hostdomain); $returnvalue = hostdomain();`
brand = Brand
normbrand = NormBrand
-hostname = `use Net::Domain qw(hostname); $returnvalue = hostname();`
+hostname = `$returnvalue = $mapper->{fqdn}; $returnvalue =~ s/\..*$//;`
vendor = Vendor
uname_a = `open(UNAMEA, "uname -a |"); $returnvalue = <UNAMEA>; chomp
$returnvalue; close(UNAMEA);`
uname_m = `open(UNAMEM, "uname -m |"); $returnvalue = <UNAMEM>; chomp
$returnvalue; close(UNAMEM);`
@@ -48,7 +48,7 @@
as_uid = ServerAdminID
as_passwd = ServerAdminPwd
-asid = `use Net::Domain qw(hostname); $returnvalue = hostname();`
+asid = `$returnvalue = $mapper->{fqdn}; $returnvalue =~ s/\..*$//;`
as_port = Port
admpw = "@configdir@/admpw"
as_error = "@logdir@/error"