admserv/cfgstuff/start-ds-admin.in | 18 ++++
admserv/newinst/src/25changefedorato389.pl | 119 ++++++++++++++---------------
admserv/newinst/src/AdminMigration.pm.in | 4
admserv/newinst/src/AdminServer.pm.in | 8 -
4 files changed, 85 insertions(+), 64 deletions(-)
New commits:
commit cbd46e47c8f21ac516460d26f38a42d0c086d2cb
Author: Endi S. Dewata <edewata(a)redhat.com>
Date: Wed Oct 20 09:02:10 2010 -0400
Bug 470576 - Migration could do addition checks before commiting actions
https://bugzilla.redhat.com/show_bug.cgi?id=470576
The migrate-ds-admin.pl can fail for various reasons leaving the server
in an inconsistent state. Sometimes a manual cleanup is required before
the migration script can be run again. There is no easy way to revert the
changes done by this script, so the script has been modified such that it
can handle inconsistent state better.
The 25changefedorato389.pl has been modified such that it will only
delete old entries if the entries are actually renamed. If the old entry
is already using the new name it will not be deleted.
The 25changefedorato389.pl has also been modified such that it doesn't
return immediately when it doesn't find anything to change, but it will
continue executing the rest of the script, i.e. deleting bogus entries,
adding new entries, updating adm.conf and local.conf, and deleting old
entries.
The migrateAdminServer() has been modified to stop the admin server before
migrating it.
The start-ds-admin has been modified to wait until the pid file is created
before returning a success.
diff --git a/admserv/cfgstuff/start-ds-admin.in b/admserv/cfgstuff/start-ds-admin.in
index 8258b08..9bd3887 100644
--- a/admserv/cfgstuff/start-ds-admin.in
+++ b/admserv/cfgstuff/start-ds-admin.in
@@ -68,3 +68,21 @@ if [ -z "@with_selinux@" ] ; then
fi
$SELINUX_CMD $HTTPD $OMIT_DEFLATE -k start -f @configdir(a)/httpd.conf "$@"
+
+PIDFILE=@localstatedir@/run/@PACKAGE_BASE_NAME(a)/admin-serv.pid
+
+loop_counter=1
+# wait for 10 seconds for the pid file to appear
+max_count=10
+while test $loop_counter -le $max_count; do
+ loop_counter=`expr $loop_counter + 1`
+ if test ! -f $PIDFILE ; then
+ sleep 1;
+ else
+ PID=`cat $PIDFILE`
+ fi
+done
+if test ! -f $PIDFILE ; then
+ echo Server failed to start !!! Please check errors log for problems
+ return 1
+fi
diff --git a/admserv/newinst/src/25changefedorato389.pl
b/admserv/newinst/src/25changefedorato389.pl
index 3cccce6..755365b 100644
--- a/admserv/newinst/src/25changefedorato389.pl
+++ b/admserv/newinst/src/25changefedorato389.pl
@@ -57,7 +57,8 @@ sub pre {
while ($ent) {
my $olddn = $ent->getDN();
my $newdn = $olddn;
- $count += ($newdn =~ s/cn=Fedora/cn=389/g);
+ my $renamed = ($newdn =~ s/cn=Fedora/cn=389/g);
+ $count += $renamed;
$ent->setDN($newdn);
for my $attr (keys %{$ent}) {
my @newvals = $ent->getValues($attr);
@@ -75,18 +76,15 @@ sub pre {
if ($ent->hasValue('objectclass', 'netscapeServer', 1)) {
push @sielist, $olddn;
}
- # save the old DN
- $ent->{_olddn_} = $olddn;
+ # save the old DN if renamed
+ if ($renamed) {
+ $ent->{_olddn_} = $olddn;
+ }
# add to the list of entries
push @ents, $ent;
$ent = $conn->nextEntry();
}
- if (!$count) {
- # nothing to do - just return
- debug(1, "No Fedora branding found - skipping\n");
- return ();
- }
# if a prior installation was messed up, there will be both
# a Fedora branded entry and a 389 branded entry - in this
@@ -117,62 +115,63 @@ sub pre {
# found and fixed all of them, deleted old bogus entries, now try to add
# if we get Already Exists, just skip
my @dnstodel = ();
- if ($count) { # have at least one change to make
- for my $ent (@ents) {
- $conn->add($ent);
- my $rc = $conn->getErrorCode();
- if ($rc == LDAP_TYPE_OR_VALUE_EXISTS) {
- # as a result of our corrections above, we have some
- # duplicate values - let's remove them
- # this is a list of attributes that may have DN syntax
- # and are multi valued - we have to normalize them first
- my %mydnattrs = (owner => 'owner', roleoccupant =>
'roleoccupant',
- member => 'member', seealso =>
'seealso',
- uniquemember => 'uniquemember',
- parentorganization => 'parentorganization',
- secretary => 'secretary', manager =>
'manager',
- aliasedobjectname => 'aliasedobjectname',
- associatedname => 'associatedname',
- distinguishedname => 'distinguishedname',
- documentauthor => 'documentauthor',
- nsroledn => 'nsroledn',
- nsadminsiedn => 'nsadminsiedn',
- nsdirectoryinforef => 'nsdirectoryinforef',
- mailenhanceduniquemember =>
'mailenhanceduniquemember');
- my %skipattrs = (objectclass => 'objectclass');
- for my $attr (keys %{$ent}) {
- next if ($skipattrs{lc $attr});
- my @newvals = $ent->getValues($attr);
- my %uniq = ();
- # the keys of the uniq hash will be the normalized values
- # the hash table will just throw away dups, so the
- # resultant table will have as the keys the unique
- # normalized values, and will have as the values the
- # original unique un-normalized values
- if ($mydnattrs{lc $attr}) {
- %uniq = map { normalizeDN($_) => $_ } @newvals;
- } else {
- %uniq = map { lc $_ => $_ } @newvals;
- }
- $ent->setValues($attr, values %uniq);
- }
- if ($conn->update($ent)) {
- $rc = LDAP_SUCCESS;
+ for my $ent (@ents) {
+ $conn->add($ent);
+ my $rc = $conn->getErrorCode();
+ if ($rc == LDAP_TYPE_OR_VALUE_EXISTS) {
+ # as a result of our corrections above, we have some
+ # duplicate values - let's remove them
+ # this is a list of attributes that may have DN syntax
+ # and are multi valued - we have to normalize them first
+ my %mydnattrs = (owner => 'owner', roleoccupant =>
'roleoccupant',
+ member => 'member', seealso =>
'seealso',
+ uniquemember => 'uniquemember',
+ parentorganization => 'parentorganization',
+ secretary => 'secretary', manager =>
'manager',
+ aliasedobjectname => 'aliasedobjectname',
+ associatedname => 'associatedname',
+ distinguishedname => 'distinguishedname',
+ documentauthor => 'documentauthor',
+ nsroledn => 'nsroledn',
+ nsadminsiedn => 'nsadminsiedn',
+ nsdirectoryinforef => 'nsdirectoryinforef',
+ mailenhanceduniquemember =>
'mailenhanceduniquemember');
+ my %skipattrs = (objectclass => 'objectclass');
+ for my $attr (keys %{$ent}) {
+ next if ($skipattrs{lc $attr});
+ my @newvals = $ent->getValues($attr);
+ my %uniq = ();
+ # the keys of the uniq hash will be the normalized values
+ # the hash table will just throw away dups, so the
+ # resultant table will have as the keys the unique
+ # normalized values, and will have as the values the
+ # original unique un-normalized values
+ if ($mydnattrs{lc $attr}) {
+ %uniq = map { normalizeDN($_) => $_ } @newvals;
} else {
- $rc = $conn->getErrorCode();
+ %uniq = map { lc $_ => $_ } @newvals;
}
- } elsif ($rc == LDAP_SUCCESS) {
+ $ent->setValues($attr, values %uniq);
+ }
+ if ($conn->update($ent)) {
+ $rc = LDAP_SUCCESS;
+ } else {
+ $rc = $conn->getErrorCode();
+ }
+ } elsif ($rc == LDAP_SUCCESS) {
+ # delete old entry if renamed
+ if ($ent->{_olddn_}) {
push @dnstodel, $ent->{_olddn_};
}
- if ($rc != LDAP_SUCCESS) {
- if ($rc != LDAP_ALREADY_EXISTS) {
- # just bail - it's unlikely that we would get this error from
- # far down in the tree, if we didn't already get this at
- # the top level
- return ('error_adding_entry', $ent->getDN(),
$conn->getErrorString());
- } else {
- debug(1, "Entry ", $ent->getDN(), " already exists
- skipping\n");
- }
+ }
+ if ($rc != LDAP_SUCCESS) {
+ if ($rc != LDAP_ALREADY_EXISTS) {
+ # just bail - it's unlikely that we would get this error from
+ # far down in the tree, if we didn't already get this at
+ # the top level
+ return ('error_adding_entry', $ent->getDN(),
$conn->getErrorString());
+ } else {
+ debug(1, "Entry ", $ent->getDN(), " already exists -
skipping\n");
}
}
}
diff --git a/admserv/newinst/src/AdminMigration.pm.in
b/admserv/newinst/src/AdminMigration.pm.in
index 5fad60b..5cfed1c 100644
--- a/admserv/newinst/src/AdminMigration.pm.in
+++ b/admserv/newinst/src/AdminMigration.pm.in
@@ -435,6 +435,10 @@ sub migrateAdminServer {
my $mig = shift;
my @errs;
+ if (!stopAdminServer()) {
+ return 0;
+ }
+
my $configdir = $mig->{inf}->{admin}->{config_dir} ||
$ENV{ADMSERV_CONF_DIR} ||
$mig->{configdir} . "/admin-serv";
diff --git a/admserv/newinst/src/AdminServer.pm.in
b/admserv/newinst/src/AdminServer.pm.in
index a082975..1293a96 100644
--- a/admserv/newinst/src/AdminServer.pm.in
+++ b/admserv/newinst/src/AdminServer.pm.in
@@ -21,10 +21,10 @@ require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(createAdminServer reconfigAdminServer
createASFilesAndDirs setFileOwnerPerms updateHttpConfFiles
- startAdminServer removeAdminServer setDefaults);
+ startAdminServer stopAdminServer removeAdminServer setDefaults);
@EXPORT_OK = qw(createAdminServer reconfigAdminServer
createASFilesAndDirs setFileOwnerPerms updateHttpConfFiles
- startAdminServer removeAdminServer setDefaults);
+ startAdminServer stopAdminServer removeAdminServer setDefaults);
use File::Path;
# tempfiles
@@ -566,11 +566,11 @@ sub stopAdminServer {
if ($status) {
# Ignore the stop failure
debug(1,"Warning: Could not stop admin server: status $status: output
$output\n");
- return 1;
+ return 0;
}
} else {
debug(1, "stopping admin server: no such program $prog: cannot stop
server\n");
- return;
+ return 0;
}
debug(1, "Successfully stopped admin server\n");