Author: rmeggins
Update of /cvs/dirsec/adminserver/admserv/newinst/src
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv32691/adminserver/admserv/newinst/src
Modified Files:
AdminServer.pm.in AdminUtil.pm.in migrate-ds-admin.pl.in
setup-ds-admin.pl.in setup-ds-admin.res.in
Log Message:
Resolves: bug 248145
Bug Description: Replace ds_newinst binary with perl script
Reviewed by: nhosoi (Thanks!)
Fix Description: The time has come. We can finally get rid of the instance creation C
code
once and for all. I've created a DSCreate module that has all of the functionality of
the old
create_instance.c code, along with a few items from ldap/admin/lib. The way it works is
this: it first creates the dse.ldif file using template-dse.ldif and the suffix-db
template to
create the initial db and suffix. It then adds additional optional configuration
depending
on what optional features have been enabled. It creates other config files and copies in
the schema. It then initializes the database. It uses a template file based on the type
of
entry implied by the suffix, then adds the default ACIs. If the user chose to do so, it
will also create the ou=people, ou=groups, etc. entries. The user can also supply an
LDIF
file which will be used to populate the initial database, in which case none of the
default
entries or ACIs will be used. It then starts the server (if desired).
I had to create a function makePaths that works like mkdir -p except that it will chown,
chgrp, and chmod all paths created.
I had to change the other places where instance creation was called to use the new
calling semantics. ds_create changed quite a bit, since it can just use an Inf to pass in
the
information instead of calling ds_newinst as a CGI program.
I had to change FileConn to add support for namingContexts (i.e. entries with no parent),
and to have it write each change each time, and to return copies of entries when
searching,
to avoid modifying the tree in place. This makes it act much more like LDAP.
I found and fixed a few bugs in Migration along the way that were revealed while
integrating
the new DSCreate code.
Platforms tested: RHEL4, FC6
Flag Day: Yes. New instance creation code and autotool changes.
Doc impact: no
Index: AdminServer.pm.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/AdminServer.pm.in,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AdminServer.pm.in 4 Jul 2007 01:31:33 -0000 1.5
+++ AdminServer.pm.in 13 Jul 2007 18:39:15 -0000 1.6
@@ -126,18 +126,20 @@
$setup->msg('create_adminserver_filesdirs');
# these paths are owned exclusively by admin sever
+ my @errs;
for ($configdir, $securitydir, $logdir) {
- $! = 0; # clear errno
- if (! -d $_) {
- mkpath($_, 1, 0700);
- } else {
- chmod 0700, $_;
- }
- if (! -d $_) {
- $setup->msg($FATAL, 'error_creating_directory', $_, $!);
+ @errs = makePaths($_, 0700, $setup->{inf}->{admin}->{SysUser},
+ $setup->{inf}->{General}->{SuiteSpotGroup});
+ if (@errs) {
+ $setup->msg($FATAL, @errs);
return 0;
}
$! = 0; # clear errno
+ chmod 0700, $_;
+ if ($!) {
+ $setup->msg($FATAL, 'error_chmoding_directory', $_, $!);
+ return 0;
+ }
chown $uid, -1, $_;
if ($!) {
$setup->msg($FATAL, 'error_chowning_directory', $_,
@@ -147,17 +149,18 @@
}
# these paths are shared by SuiteSpotGroup members
- $! = 0; # clear errno
- if (! -d $rundir) {
- mkpath($rundir, 0, 0770);
- } else {
- chmod 0770, $rundir;
- }
- if (! -d $rundir) {
- $setup->msg($FATAL, 'error_creating_directory', $rundir, $!);
+ @errs = makePaths($rundir, 0770, $setup->{inf}->{admin}->{SysUser},
+ $setup->{inf}->{General}->{SuiteSpotGroup});
+ if (@errs) {
+ $setup->msg($FATAL, @errs);
return 0;
}
$! = 0; # clear errno
+ chmod 0770, $rundir;
+ if ($!) {
+ $setup->msg($FATAL, 'error_chmoding_directory', $rundir, $!);
+ return 0;
+ }
chown -1, $gid, $rundir;
if ($!) {
$setup->msg($FATAL, 'error_chgrping_directory', $rundir,
@@ -327,12 +330,16 @@
$cmd .= " configuration.nsServerAddress=\"$serverAddress\"";
}
- if (system($cmd)) {
+ $? = 0; # clear error
+ my $output = `$cmd 2>&1`;
+ if ($?) {
+ debug(0, $output);
$ENV{LD_LIBRARY_PATH} = $savepath;
$ENV{SHLIB_PATH} = $savepath;
return 0;
}
+ debug(1, $output);
$ENV{LD_LIBRARY_PATH} = $savepath;
$ENV{SHLIB_PATH} = $savepath;
return 1;
@@ -453,3 +460,12 @@
my $setup = shift;
return createAdminServer($setup, 1);
}
+
+1;
+
+# emacs settings
+# Local Variables:
+# mode:perl
+# indent-tabs-mode: nil
+# tab-width: 4
+# End:
Index: AdminUtil.pm.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/AdminUtil.pm.in,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AdminUtil.pm.in 11 Jul 2007 01:20:21 -0000 1.9
+++ AdminUtil.pm.in 13 Jul 2007 18:39:15 -0000 1.10
@@ -745,3 +745,12 @@
return @{$errs} ? 0 : 1;
}
+
+1;
+
+# emacs settings
+# Local Variables:
+# mode:perl
+# indent-tabs-mode: nil
+# tab-width: 4
+# End:
Index: migrate-ds-admin.pl.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/migrate-ds-admin.pl.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- migrate-ds-admin.pl.in 12 Jul 2007 14:00:10 -0000 1.3
+++ migrate-ds-admin.pl.in 13 Jul 2007 18:39:15 -0000 1.4
@@ -82,7 +82,9 @@
# next, migrate the admin server - this also registers the directory servers
$mig->msg('begin_as_migration', $mig->{oldsroot});
-migrateAdminServer($mig);
+if (!migrateAdminServer($mig)) {
+ exit 1;
+}
# next, register/update the new directory servers
# in the config ds
Index: setup-ds-admin.pl.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/setup-ds-admin.pl.in,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- setup-ds-admin.pl.in 4 Jul 2007 01:31:33 -0000 1.7
+++ setup-ds-admin.pl.in 13 Jul 2007 18:39:15 -0000 1.8
@@ -46,6 +46,7 @@
use Inf;
use Resource;
use DialogManager;
+use DSCreate;
use AdminUtil;
use AdminServer;
use Util;
@@ -145,16 +146,13 @@
$setup->msg('create_dirserver');
# create a directory server instance
-my @errs = ();
-my ($rc, $output) = createDSInstance($setup->{inf}, \@errs);
-if ($rc) {
- if (@errs) {
- $setup->msg(@errs);
- }
- $setup->msg($FATAL, 'error_creating_dsinstance', $rc, $output);
+my @errs = createDSInstance($setup->{inf});
+if (@errs) {
+ $setup->msg(@errs);
+ $setup->msg($FATAL, 'error_creating_dsinstance',
$setup->{inf}->{slapd}->{ServerIdentifier});
exit 1;
} else {
- $setup->msg('created_dsinstance', $output);
+ $setup->msg('created_dsinstance',
$setup->{inf}->{slapd}->{ServerIdentifier});
}
# setup directory server instance to be the configuration DS
Index: setup-ds-admin.res.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/setup-ds-admin.res.in,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- setup-ds-admin.res.in 20 Jun 2007 16:35:02 -0000 1.4
+++ setup-ds-admin.res.in 13 Jul 2007 18:39:15 -0000 1.5
@@ -92,11 +92,6 @@
error_create_dirserver = Failed to create directory server instance\n
error_create_configds = Failed to create the configuration directory server\n
error_create_adminserver = Failed to create and configure the admin server\n
-error_creating_directory = Could not create admin server directory '%s'. Error:
%s\n
-error_chowning_directory = Could not change ownership of directory '%s' to userid
'%s': Error: %s\n
-error_chowning_file = Could not change ownership of file '%s' to userid
'%s': Error: %s\n
-error_chmoding_file = Could not change permissions of file '%s': Error: %s\n
-error_chgrping_directory = Could not change group of directory '%s' to group
'%s': Error: %s\n
updating_admconf = Updating adm.conf . . .\n
error_updating_admconf = Could not update adm.conf. Error: %s\n
updating_admpw = Updating admpw . . .\n