summaryrefslogtreecommitdiffstats
path: root/ldap/admin/src/scripts/DSCreate.pm.in
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2009-02-24 14:24:47 +0000
committerRich Megginson <rmeggins@redhat.com>2009-02-24 14:24:47 +0000
commitc1b510f60a509e54eff163003c292ebb1d94fc1a (patch)
tree84f6858bc8391cc32f2edfee080c9ee897d86125 /ldap/admin/src/scripts/DSCreate.pm.in
parentc278163aebf1a440cd99b30129bde5c135553118 (diff)
downloadds-c1b510f60a509e54eff163003c292ebb1d94fc1a.tar.gz
ds-c1b510f60a509e54eff163003c292ebb1d94fc1a.tar.xz
ds-c1b510f60a509e54eff163003c292ebb1d94fc1a.zip
Resolves: bug 468474
Bug Description: migration results in incomplete admin server sie Reviewed by: nkinder (Thanks!) Fix Description: This is a redesign of one of the core pieces of the setup/migration code - the code that adds the LDAP entries in various places. For starters, I removed the code that would implicitly delete existing trees. This is the root cause of this bug, and other similar problems with setup/instance creation that have been reported. We should never implicitly delete entries. Instead, we should explicitly delete entries by using the changetype: delete in an LDIF template file. Another source of problems was that to update an entry, we would delete it and add it back. This caused some configuration settings to be wiped out (e.g. encryption settings). We cannot do this any more. The LDIF template entries have been modified to have two sets of information for each entry that requires update - the entry to add if no entry exists (the full entry) or the changes to make to the entry if it does exist. The code in Util.pm has been changed to ignore duplicate entries and to ignore changes made to entries that do not exist. Another source of problems with migration is that the error checking was not adequate, especially with FileConn and dse.ldif reading. The fix is to add better error checking and reporting in these areas of code, including error messages. Yet another problem is the run_dir handling. On many platforms the run_dir is shared among all DS instances and the admin server. Older versions of the software allowed you to run the servers as root. We have to make sure run_dir is usable by the least privileged user of all of the servers. Platforms tested: RHEL4 Flag Day: no Doc impact: no
Diffstat (limited to 'ldap/admin/src/scripts/DSCreate.pm.in')
-rw-r--r--ldap/admin/src/scripts/DSCreate.pm.in39
1 files changed, 37 insertions, 2 deletions
diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in
index efb1fa65..89f0ba00 100644
--- a/ldap/admin/src/scripts/DSCreate.pm.in
+++ b/ldap/admin/src/scripts/DSCreate.pm.in
@@ -215,6 +215,28 @@ sub makeDSDirs {
return @errs;
}
}
+ # run_dir is a special case because it is usually shared among
+ # all instances and the admin server
+ # all instances must be able to write to it
+ # if the SuiteSpotUserID is root or 0, we can just skip
+ # this because root will have access to it - we really
+ # shouldn't be using root anyway, primarily just for
+ # legacy migration support
+ # if there are two different user IDs that need access
+ # to this directory, then SuiteSpotGroup must be defined,
+ # and both users must be members of the SuiteSpotGroup
+ if (($inf->{General}->{SuiteSpotUserID} eq 'root') ||
+ (defined($inf->{General}->{SuiteSpotUserID}) &&
+ ($inf->{General}->{SuiteSpotUserID} =~ /^0$/))) {
+ # skip
+ debug(3, "Root user " . $inf->{General}->{SuiteSpotUserID} . " already has access to $inf->{slapd}->{run_dir} - skipping\n");
+ } else {
+ my $dir = $inf->{slapd}->{run_dir};
+ # rwx by user only, or by user & group if a group is defined
+ @errs = changeOwnerMode($inf, 7, $dir, 7);
+ debug(3, "Changed owner of $dir to " . $inf->{General}->{SuiteSpotUserID} . ": error @errs\n");
+ debug(3, "\t" . `/bin/ls -ld $dir`);
+ }
# set the group of the parent dir of config_dir and inst_dir
if (defined($inf->{General}->{SuiteSpotGroup})) {
for (qw(inst_dir config_dir)) {
@@ -372,7 +394,10 @@ sub createConfigFile {
}
}
- $conn->write($conffile);
+ if (!$conn->write($conffile)) {
+ $conn->close();
+ return ("error_writing_ldif", $conffile, $!);
+ }
$conn->close();
if (@errs = changeOwnerMode($inf, 6, $conffile)) {
@@ -506,11 +531,21 @@ sub initDatabase {
my ($fh, $templdif) = tempfile("ldifXXXXXX", SUFFIX => ".ldif", OPEN => 0,
DIR => File::Spec->tmpdir);
+ if (!$templdif) {
+ return ('error_creating_templdif', $!);
+ }
my $conn = new FileConn;
$conn->setNamingContext($inf->{slapd}->{Suffix});
getMappedEntries($mapper, \@ldiffiles, \@errs, \&check_and_add_entry,
[$conn]);
- $conn->write($templdif);
+ if (@errs) {
+ $conn->close();
+ return @errs;
+ }
+ if (!$conn->write($templdif)) {
+ $conn->close();
+ return ('error_writing_ldif', $templdif, $!);
+ }
$conn->close();
if (@errs) {
return @errs;