[Fedora-directory-commits] adminserver/tests setup.sh,1.1,1.2
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/adminserver/tests
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv30934/adminserver/tests
Modified Files:
setup.sh
Log Message:
Resolves: bug 246683
Bug Description: Reimplement ds_create without setuputil code
Reviewed by: nhosoi (Thanks!)
Fix Description: ds_create was a CGI program that would create a new instance, set it up to be managed by console, and register it with the config ds. The new ds_create CGI perl script does just that. One tricky part was that, rather than enabling the pass through auth plugin and having to restart the server, the new server is created without being started, then the modification is done to the new server dse.ldif file directly, using the new FileConn.pm module, which simulates a Mozilla::LDAP::Conn on an LDIF file. This also allows us to create a new instance with a pre-hashed rootdn password, rather than having to send the cleartext password.
I had to move around some code in AdminServer and AdminUtil so that I could use it from ds_create. I also implemented support for the admin server PASSWORD_PIPE in perl so we could use it in other CGI perl scripts.
Finally, the error handling was not consistent in our code, so I made explicit the passing of error messages up and down the stack. Oh how I wish we could just do this in python and use exception handling . . .
I added a test for ds_create.
Platforms tested: RHEL4
Flag Day: Yes - autotool changes
Doc impact: No. Should work the same way as the old ds_create.
Index: setup.sh
===================================================================
RCS file: /cvs/dirsec/adminserver/tests/setup.sh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- setup.sh 9 May 2007 00:26:39 -0000 1.1
+++ setup.sh 4 Jul 2007 01:31:33 -0000 1.2
@@ -10,9 +10,9 @@
#adminpw=boguspassword
adminpw=admin
#needinstance=1
-needdata=1
-usessl=1
-PATH=/usr/lib64/mozldap:$PATH
+#needdata=1
+#usessl=1
+PATH=/usr/lib64/mozldap:/usr/lib/mozldap:$PATH
export PATH
if [ "$needinstance" ] ; then
@@ -77,10 +77,11 @@
dir=`pwd`
# CGI env. vars
-ADMSERV_CONF_DIR=$dir/testtmp
-export ADMSERV_CONF_DIR
-ADMSERV_LOG_DIR=$dir/testtmp
-export ADMSERV_LOG_DIR
+#ADMSERV_CONF_DIR=$dir/testtmp
+#ADMSERV_CONF_DIR=$sroot/etc/fedora-ds/admin-serv
+#export ADMSERV_CONF_DIR
+#ADMSERV_LOG_DIR=$dir/testtmp
+#export ADMSERV_LOG_DIR
HTTP_ACCEPT_LANGUAGE=en
export HTTP_ACCEPT_LANGUAGE
SERVER_URL=http://localhost
@@ -95,15 +96,16 @@
SIEPWD: $adminpw
EOF
-VALGRIND="valgrind --log-file=/var/tmp/vg.out --tool=memcheck --leak-check=yes --suppressions=/home/rmeggins/valgrind.supp --num-callers=40 "
+VALGRIND="valgrind --log-file=/var/tmp/vg.out --tool=memcheck --leak-check=yes --suppressions=$HOME/valgrind.supp --num-callers=40 "
GDB="gdb -x .gdbinit "
-DEBUGCMD="$VALGRIND"
+#DEBUGCMD="$VALGRIND"
#DEBUGCMD="$GDB"
PROGS="mergeConfig admpw security ugdsconfig ReadLog start_config_ds \
config statpingserv viewdata dsconfig monreplication restartsrv \
statusping viewlog htmladmin sec-activate stopsrv download help"
-PROGS=restartsrv
+
+SCRIPTS=ds_create
# each prog has a subdir containing the GET/POST args and any other test data
for prog in $PROGS ; do
@@ -151,4 +153,26 @@
rm -f $postlist
done
+for prog in $SCRIPTS ; do
+ getlist=/tmp/gettests.$$
+ find $testdir/$prog -name testget.\* -print 2> /dev/null | sort -n > $getlist
+ for test in `cat $getlist` ; do
+ if [ ! -d results/$prog ] ; then mkdir -p results/$prog ; fi
+ basetest=`basename $test`
+ echo "Running test $test"
+ REQUEST_METHOD=GET ; export REQUEST_METHOD
+ QUERY_STRING="`cat $test`" ; export QUERY_STRING
+ SCRIPT_NAME=slapd/Tasks/Operation/$prog ; export SCRIPT_NAME
+ # open pwpfile for reading as file desc 4 - CGIs have to use stdin (0) for POST
+ exec 4<$pwpfile
+ PASSWORD_PIPE=4 ; export PASSWORD_PIPE
+ if [ -n "$DEBUGCMD" -a "$DEBUGCMD" = "$GDB" ] ; then
+ perl -d admserv/cgi-src40/$prog
+ else
+ perl -w admserv/cgi-src40/$prog
+ fi
+ done
+ rm -f $getlist
+done
+
rm -rf $pwpfile .gdbinit
16 years, 9 months
[Fedora-directory-commits] adminserver/tests/ds_create testget.1, NONE, 1.1
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/adminserver/tests/ds_create
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv30934/adminserver/tests/ds_create
Added Files:
testget.1
Log Message:
Resolves: bug 246683
Bug Description: Reimplement ds_create without setuputil code
Reviewed by: nhosoi (Thanks!)
Fix Description: ds_create was a CGI program that would create a new instance, set it up to be managed by console, and register it with the config ds. The new ds_create CGI perl script does just that. One tricky part was that, rather than enabling the pass through auth plugin and having to restart the server, the new server is created without being started, then the modification is done to the new server dse.ldif file directly, using the new FileConn.pm module, which simulates a Mozilla::LDAP::Conn on an LDIF file. This also allows us to create a new instance with a pre-hashed rootdn password, rather than having to send the cleartext password.
I had to move around some code in AdminServer and AdminUtil so that I could use it from ds_create. I also implemented support for the admin server PASSWORD_PIPE in perl so we could use it in other CGI perl scripts.
Finally, the error handling was not consistent in our code, so I made explicit the passing of error messages up and down the stack. Oh how I wish we could just do this in python and use exception handling . . .
I added a test for ds_create.
Platforms tested: RHEL4
Flag Day: Yes - autotool changes
Doc impact: No. Should work the same way as the old ds_create.
--- NEW FILE testget.1 ---
servport=38900&cfg_sspt_uid=uid%3Dadmin%2C+ou%3DAdministrators%2C+ou%3DTopologyManagement%2C+o%3DNetscapeRoot&ldap_url=ldap%3A%2F%2Flocalhost.localdomain%3A1100%2Fo%3DNetscapeRoot&servuser=SETTOYOURUSERID&cfg_sspt_uid_pw=admin&rootpw=password&servid=localhost2&start_server=1&suitespot3x_uid=admin&suffix=dc%3Dexample%2Cdc%3Dcom&servname=localhost.localdomain&rootdn=cn%3DDirectory+Manager&admin_domain=localdomain
16 years, 9 months
[Fedora-directory-commits] adminserver Makefile.am, 1.21, 1.22 aclocal.m4, 1.16, 1.17 configure, 1.19, 1.20 missing, 1.10, 1.11 install-sh, 1.10, 1.11 compile, 1.9, 1.10 Makefile.in, 1.21, 1.22 depcomp, 1.10, 1.11 config.sub, 1.10, 1.11 config.guess, 1.10, 1.11
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/adminserver
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv30934/adminserver
Modified Files:
Makefile.am aclocal.m4 configure missing install-sh compile
Makefile.in depcomp config.sub config.guess
Log Message:
Resolves: bug 246683
Bug Description: Reimplement ds_create without setuputil code
Reviewed by: nhosoi (Thanks!)
Fix Description: ds_create was a CGI program that would create a new instance, set it up to be managed by console, and register it with the config ds. The new ds_create CGI perl script does just that. One tricky part was that, rather than enabling the pass through auth plugin and having to restart the server, the new server is created without being started, then the modification is done to the new server dse.ldif file directly, using the new FileConn.pm module, which simulates a Mozilla::LDAP::Conn on an LDIF file. This also allows us to create a new instance with a pre-hashed rootdn password, rather than having to send the cleartext password.
I had to move around some code in AdminServer and AdminUtil so that I could use it from ds_create. I also implemented support for the admin server PASSWORD_PIPE in perl so we could use it in other CGI perl scripts.
Finally, the error handling was not consistent in our code, so I made explicit the passing of error messages up and down the stack. Oh how I wish we could just do this in python and use exception handling . . .
I added a test for ds_create.
Platforms tested: RHEL4
Flag Day: Yes - autotool changes
Doc impact: No. Should work the same way as the old ds_create.
Index: Makefile.am
===================================================================
RCS file: /cvs/dirsec/adminserver/Makefile.am,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- Makefile.am 29 Jun 2007 21:29:06 -0000 1.21
+++ Makefile.am 4 Jul 2007 01:31:32 -0000 1.22
@@ -161,7 +161,7 @@
ds_db2bak ds_listdb ds_rmdb ds_remove ds_snmpctrl ds_vlvindex ds_addindex
bin_SCRIPTS = admserv/newinst/src/register_server.pl
-cgibin_SCRIPTS = admserv/cgi-src40/Cgi.pm
+cgibin_SCRIPTS = admserv/cgi-src40/ds_create
nodist_cmdbin_SCRIPTS = admserv/cfgstuff/start-ds-admin admserv/cfgstuff/stop-ds-admin admserv/cfgstuff/restart-ds-admin
cmdbin_SCRIPTS = admserv/newinst/src/setup-ds-admin.pl \
@@ -373,7 +373,8 @@
nodist_property_DATA = $(RESOURCE_BUNDLES_ROOT)
# regular property files go here
property_DATA = admserv/newinst/src/setup-ds-admin.res \
- admserv/newinst/src/migrate-ds-admin.res
+ admserv/newinst/src/migrate-ds-admin.res \
+ admserv/cgi-src40/ds_create.res
# French resource bundles (for the French localization in the future)
#RESOURCE_BUNDLES_FR = foo_fr.res
Index: Makefile.in
===================================================================
RCS file: /cvs/dirsec/adminserver/Makefile.in,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- Makefile.in 29 Jun 2007 21:29:06 -0000 1.21
+++ Makefile.in 4 Jul 2007 01:31:32 -0000 1.22
@@ -595,7 +595,7 @@
admserv/newinst/src/asmigrate.map
bin_SCRIPTS = admserv/newinst/src/register_server.pl
-cgibin_SCRIPTS = admserv/cgi-src40/Cgi.pm
+cgibin_SCRIPTS = admserv/cgi-src40/ds_create
nodist_cmdbin_SCRIPTS = admserv/cfgstuff/start-ds-admin admserv/cfgstuff/stop-ds-admin admserv/cfgstuff/restart-ds-admin
cmdbin_SCRIPTS = admserv/newinst/src/setup-ds-admin.pl \
admserv/newinst/src/migrate-ds-admin.pl
@@ -784,7 +784,8 @@
nodist_property_DATA = $(RESOURCE_BUNDLES_ROOT)
# regular property files go here
property_DATA = admserv/newinst/src/setup-ds-admin.res \
- admserv/newinst/src/migrate-ds-admin.res
+ admserv/newinst/src/migrate-ds-admin.res \
+ admserv/cgi-src40/ds_create.res
# these are for the config files and scripts that we need to generate and replace
16 years, 9 months
[Fedora-directory-commits] adminserver/admserv/newinst/src AdminMigration.pm.in, 1.1, 1.2 AdminServer.pm.in, 1.4, 1.5 AdminUtil.pm.in, 1.7, 1.8 migrate-ds-admin.pl.in, 1.1, 1.2 register_server.pl.in, 1.3, 1.4 setup-ds-admin.pl.in, 1.6, 1.7
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/adminserver/admserv/newinst/src
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv30934/adminserver/admserv/newinst/src
Modified Files:
AdminMigration.pm.in AdminServer.pm.in AdminUtil.pm.in
migrate-ds-admin.pl.in register_server.pl.in
setup-ds-admin.pl.in
Log Message:
Resolves: bug 246683
Bug Description: Reimplement ds_create without setuputil code
Reviewed by: nhosoi (Thanks!)
Fix Description: ds_create was a CGI program that would create a new instance, set it up to be managed by console, and register it with the config ds. The new ds_create CGI perl script does just that. One tricky part was that, rather than enabling the pass through auth plugin and having to restart the server, the new server is created without being started, then the modification is done to the new server dse.ldif file directly, using the new FileConn.pm module, which simulates a Mozilla::LDAP::Conn on an LDIF file. This also allows us to create a new instance with a pre-hashed rootdn password, rather than having to send the cleartext password.
I had to move around some code in AdminServer and AdminUtil so that I could use it from ds_create. I also implemented support for the admin server PASSWORD_PIPE in perl so we could use it in other CGI perl scripts.
Finally, the error handling was not consistent in our code, so I made explicit the passing of error messages up and down the stack. Oh how I wish we could just do this in python and use exception handling . . .
I added a test for ds_create.
Platforms tested: RHEL4
Flag Day: Yes - autotool changes
Doc impact: No. Should work the same way as the old ds_create.
Index: AdminMigration.pm.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/AdminMigration.pm.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AdminMigration.pm.in 29 Jun 2007 21:29:05 -0000 1.1
+++ AdminMigration.pm.in 4 Jul 2007 01:31:33 -0000 1.2
@@ -160,7 +160,7 @@
# This is how we extract the sie and isie as the as entries are
# being added
sub migratecb {
- my ($context, $entry) = @_;
+ my ($context, $entry, $errs) = @_;
my @arycontext = ($context);
# always replace the tasks and commands with the new ones
@@ -170,7 +170,7 @@
push @arycontext, 1; # means to delete any existing entries first
}
- my $rc = check_and_add_entry(\@arycontext, $entry);
+ my $rc = check_and_add_entry(\@arycontext, $entry, $errs);
return $rc;
}
@@ -207,21 +207,29 @@
my $mapper = new Inf("@infdir(a)/asmigrate.map");
- $mapper = process_maptbl($mapper, ($inf, $admininf, $setupinf));
+ $mapper = process_maptbl($mapper, \@errs, $inf, $admininf, $setupinf);
if (!$mapper) {
$conn->close();
+ $mig->msg(@errs);
$mig->msg($FATAL, 'error_creating_asmigration_maptbl');
return 0;
}
# update isie and sie
- getMappedEntries($mapper, \@ldiffiles, \&migratecb, $conn);
+ getMappedEntries($mapper, \@ldiffiles, \@errs, \&migratecb, $conn);
+ if (@errs) {
+ $conn->close();
+ $mig->msg(@errs);
+ return 0;
+ }
+
my $localconf = "$configdir/local.conf";
my $isnew;
if (! -f $localconf) {
$isnew = 1;
}
if (!open(LOCALCONF, ">$localconf")) {
+ $conn->close();
$mig->msg($FATAL, 'error_updating_localconf', $localconf, $!);
return 0;
}
Index: AdminServer.pm.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/AdminServer.pm.in,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AdminServer.pm.in 29 Jun 2007 21:29:05 -0000 1.4
+++ AdminServer.pm.in 4 Jul 2007 01:31:33 -0000 1.5
@@ -39,12 +39,12 @@
package AdminServer;
require Exporter;
@ISA = qw(Exporter);
-@EXPORT = qw(createAdminServer reconfigAdminServer registerDSWithConfigDS
+@EXPORT = qw(createAdminServer reconfigAdminServer
createASFilesAndDirs setFileOwnerPerms updateHttpConfFiles
- startAdminServer registerManyDSWithConfigDS);
-@EXPORT_OK = qw(createAdminServer reconfigAdminServer registerDSWithConfigDS
+ startAdminServer);
+@EXPORT_OK = qw(createAdminServer reconfigAdminServer
createASFilesAndDirs setFileOwnerPerms updateHttpConfFiles
- startAdminServer registerManyDSWithConfigDS);
+ startAdminServer);
use File::Path;
# tempfiles
@@ -206,9 +206,9 @@
# This is how we extract the sie and isie as the as entries are
# being added
sub registercb {
- my ($context, $entry) = @_;
+ my ($context, $entry, $errs) = @_;
- my $rc = check_and_add_entry([$context->{conn}], $entry);
+ my $rc = check_and_add_entry([$context->{conn}], $entry, $errs);
my $setup = $context->{setup};
if ($rc) {
if ($entry->hasValue('objectclass', 'nsApplication', 1)) {
@@ -224,6 +224,7 @@
}
}
} else {
+ $setup->msg(@{$errs});
$setup->msg($FATAL, 'error_adding_adminserver_config_entry', $entry->getDN());
}
@@ -258,9 +259,10 @@
my $mapper = new Inf("@infdir(a)/adminserver.map");
- $mapper = process_maptbl($mapper, ($inf, $admininf, $setupinf));
- if (!$mapper) {
+ $mapper = process_maptbl($mapper, \@errs, $inf, $admininf, $setupinf);
+ if (!$mapper or @errs) {
$conn->close();
+ $setup->msg(@errs);
$setup->msg($FATAL, 'error_creating_adminserver_maptbl');
return 0;
}
@@ -276,7 +278,7 @@
return 0;
}
my $context = {conn => $conn, localfh => \*LOCALCONF, setup => $setup};
- getMappedEntries($mapper, \@ldiffiles, \®istercb, $context);
+ getMappedEntries($mapper, \@ldiffiles, \@errs, \®istercb, $context);
close(LOCALCONF);
if ($isnew) {
@@ -298,7 +300,7 @@
}
$conn->close();
- return 1;
+ return @errs ? 0 : 1;
}
# update other config files - these are the fields which users typically want to
@@ -451,98 +453,3 @@
my $setup = shift;
return createAdminServer($setup, 1);
}
-
-sub registerDSWithConfigDS {
- my $setup = shift;
- my $inf = shift || $setup->{inf};
- my $configdir = shift || "$setup->{configdir}/admin-serv";
- my @errs;
-
- $setup->msg('registering_dirserver');
- # open a connection to the configuration directory server
- my $conn;
- if (ref($configdir)) {
- $conn = $configdir;
- } else {
- $conn = getConfigDSConn($inf->{General}->{ConfigDirectoryLdapURL},
- $inf->{General}->{ConfigDirectoryAdminID},
- $inf->{General}->{ConfigDirectoryAdminPwd},
- $configdir, \@errs);
- }
-
- if (@errs) {
- $setup->msg($FATAL, @errs);
- return 0;
- }
-
- # add the Admin Server configuration entries
- my @ldiffiles = ("@ldifdir(a)/10dsdata.ldif.tmpl",
- "@ldifdir(a)/11dstasks.ldif.tmpl"
- );
- my $setupinf = new Inf("@infdir(a)/setup.inf");
- my $slapdinf = new Inf("@infdir(a)/slapd.inf");
-
- my $mapper = new Inf("@infdir(a)/dirserver.map");
-
- if (!$inf->{General}->{ConfigDirectoryLdapURL}) {
- $inf->{General}->{ConfigDirectoryLdapURL} =
- $setup->{inf}->{General}->{ConfigDirectoryLdapURL};
- }
-
- $mapper = process_maptbl($mapper, ($inf, $slapdinf, $setupinf));
- if (!$mapper) {
- $conn->close();
- $setup->msg($FATAL, 'error_creating_dirserver_maptbl');
- return 0;
- }
-
- my $context = [$conn];
- getMappedEntries($mapper, \@ldiffiles, \&check_and_add_entry, $context);
-
- if (!ref($configdir)) {
- $conn->close();
- }
-
- return 1;
-}
-
-# this takes a list of DS instances and registers all of them
-# with the config DS
-sub registerManyDSWithConfigDS {
- my $setup = shift;
- my $configdir = shift;
- my @instances = @_;
- my @errs;
- my $inf = $setup->{inf};
-
- if (!@instances) {
- return 1;
- }
-
- $setup->msg('registering_dirserver_instances');
- # open a connection to the configuration directory server
- my $conn = getConfigDSConn($inf->{General}->{ConfigDirectoryLdapURL},
- $inf->{General}->{ConfigDirectoryAdminID},
- $inf->{General}->{ConfigDirectoryAdminPwd},
- $configdir, \@errs);
-
- if (@errs) {
- $setup->msg($FATAL, @errs);
- return 0;
- }
-
- my $admConf = getAdmConf($configdir);
-
- for (@instances) {
- my $instinf = createInfFromConfig("$setup->{configdir}/$_", $_);
- $instinf->{General}->{AdminDomain} = $admConf->{AdminDomain};
- unlink($instinf->{filename});
- if (!registerDSWithConfigDS($setup, $instinf, $conn)) {
- return 0;
- }
- }
-
- $conn->close();
-
- return 0;
-}
Index: AdminUtil.pm.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/AdminUtil.pm.in,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AdminUtil.pm.in 29 Jun 2007 21:29:05 -0000 1.7
+++ AdminUtil.pm.in 4 Jul 2007 01:31:33 -0000 1.8
@@ -41,10 +41,12 @@
@ISA = qw(Exporter);
@EXPORT = qw(getAdmConf getConfigDSConn createConfigDS createSubDS
updateAdmConf updateAdmpw updateLocalConf importCACert
- getLocalConfigDS getPset);
+ getLocalConfigDS getPset registerDSWithConfigDS
+ registerManyDSWithConfigDS createSubDSNoConn);
@EXPORT_OK = qw(getAdmConf getConfigDSConn createConfigDS createSubDS
updateAdmConf updateAdmpw updateLocalConf importCACert
- getLocalConfigDS getPset);
+ getLocalConfigDS getPset registerDSWithConfigDS
+ registerManyDSWithConfigDS createSubDSNoConn);
# load perldap
use Mozilla::LDAP::Conn;
@@ -54,6 +56,7 @@
use Util;
use Inf;
+use FileConn;
use strict;
@@ -264,34 +267,27 @@
my $dsinf = new Inf("@infdir(a)/slapd.inf");
my $mapper = new Inf("@infdir(a)/configdsroot.map");
- $mapper = process_maptbl($mapper, ($inf, $dsinf, $admininf, $setupinf));
- if (!$mapper) {
+ $mapper = process_maptbl($mapper, $errs, $inf, $dsinf, $admininf, $setupinf);
+ if (!$mapper or @{$errs}) {
$conn->close();
- @{$errs} = ('error_creating_configds_maptbl');
+ if (!@{$errs}) {
+ @{$errs} = ('error_creating_configds_maptbl');
+ }
return 0;
}
- getMappedEntries($mapper, \@ldiffiles, \&check_and_add_entry,
+ getMappedEntries($mapper, \@ldiffiles, $errs, \&check_and_add_entry,
[$conn]);
$conn->close();
- return 1;
+ return @{$errs} ? 0 : 1;
}
-# Take the slapd server instance specified in the slapd section of the given inf
-# and make it into a subordinative directory server
-# (no o=netscaperoot, with PTA setup)
-sub createSubDS {
+sub internalCreateSubDS {
+ my $conn = shift;
my $inf = shift;
my $errs = shift;
- # open a connection to the directory server
- my $conn = new Mozilla::LDAP::Conn($inf->{General}->{FullMachineName},
- $inf->{slapd}->{ServerPort},
- $inf->{slapd}->{RootDN},
- $inf->{slapd}->{RootDNPwd},
- $inf->{General}->{certdir});
-
# add the o=NetscapeRoot tree using the mapper and ldif templates
my @ldiffiles = ('@ldifdir(a)/12dsconfig.mod.tmpl',
'@ldifdir(a)/13dsschema.mod.tmpl',
@@ -303,18 +299,50 @@
my $dsinf = new Inf("@infdir(a)/slapd.inf");
my $mapper = new Inf("@infdir(a)/dirserver.map");
- $mapper = process_maptbl($mapper, ($inf, $dsinf, $admininf, $setupinf));
- if (!$mapper) {
+ $mapper = process_maptbl($mapper, $errs, $inf, $dsinf, $admininf, $setupinf);
+ if (!$mapper or @{$errs}) {
$conn->close();
- @{$errs} = ('error_creating_configds_maptbl');
+ if (!@{$errs}) {
+ @{$errs} = ('error_creating_configds_maptbl');
+ }
return 0;
}
- getMappedEntries($mapper, \@ldiffiles, \&check_and_add_entry,
+ getMappedEntries($mapper, \@ldiffiles, $errs, \&check_and_add_entry,
[$conn]);
$conn->close();
- return 1;
+ return @{$errs} ? 0 : 1;
+}
+
+# Take the slapd server instance specified in the slapd section of the given inf
+# and make it into a subordinative directory server
+# (no o=netscaperoot, with PTA setup)
+sub createSubDS {
+ my $inf = shift;
+ my $errs = shift;
+
+ # open a connection to the directory server
+ my $conn = new Mozilla::LDAP::Conn($inf->{General}->{FullMachineName},
+ $inf->{slapd}->{ServerPort},
+ $inf->{slapd}->{RootDN},
+ $inf->{slapd}->{RootDNPwd},
+ $inf->{General}->{certdir});
+
+ return internalCreateSubDS($conn, $inf, $errs);
+}
+
+# same as createSubDS but works directly on the dse.ldif file itself
+# this is suitable for use when creating a new DS instance on the local
+# machine,
+sub createSubDSNoConn {
+ my $inf = shift;
+ my $errs = shift;
+
+ my $dseldif = "@instconfigdir@/slapd-" . $inf->{slapd}->{ServerIdentifier} . "/dse.ldif";
+ my $conn = new FileConn($dseldif);
+
+ return internalCreateSubDS($conn, $inf, $errs);
}
sub updateAdmConf {
@@ -511,3 +539,173 @@
return $inst;
}
+
+# most admin server CGIs only use PASSWORD and USERDN
+sub getAuthCredentials {
+ if ($AdminUtil::USER) {
+ return ($AdminUtil::USER, $AdminUtil::PASSWORD,
+ $AdminUtil::AUTHORIZATION, $AdminUtil::USERDN,
+ $AdminUtil::SIEPWD);
+ }
+
+ if (!defined($ENV{PASSWORD_PIPE})) {
+ return ();
+ }
+
+ my $fh;
+ if (fileno(STDIN) == $ENV{PASSWORD_PIPE}) {
+ $fh = \*STDIN;
+ } else {
+ open(INPUT, "<&=$ENV{PASSWORD_PIPE}") or
+ die "Error: could not open PASSWORD_PIPE $ENV{PASSWORD_PIPE}: $!";
+ $fh = \*INPUT;
+ }
+ while (<$fh>) {
+ if (/^User: (.*)$/) {
+ $AdminUtil::USER = $1;
+ }
+ if (/^Password: (.*)$/) {
+ $AdminUtil::PASSWORD = $1;
+ }
+ if (/^Authorization: (.*)$/) {
+ $AdminUtil::AUTHORIZATION = $1;
+ }
+ if (/^UserDN: (.*)$/) {
+ $AdminUtil::USERDN = $1;
+ }
+ if (/^SIEPWD: (.*)$/) {
+ $AdminUtil::SIEPWD = $1;
+ }
+ }
+ if (fileno(STDIN) != $ENV{PASSWORD_PIPE}) {
+ close $fh;
+ }
+
+ return ($AdminUtil::USER, $AdminUtil::PASSWORD,
+ $AdminUtil::AUTHORIZATION, $AdminUtil::USERDN,
+ $AdminUtil::SIEPWD);
+}
+
+# this takes a list of DS instances and registers all of them
+# with the config DS
+sub registerManyDSWithConfigDS {
+ my $inf = shift;
+ my $errs = shift;
+ my $configdir = shift;
+ my @instances = @_;
+
+ if (!@instances) {
+ return 1; # no instances to register - just return ok
+ }
+
+ # open a connection to the configuration directory server
+ my $conn = getConfigDSConn($inf->{General}->{ConfigDirectoryLdapURL},
+ $inf->{General}->{ConfigDirectoryAdminID},
+ $inf->{General}->{ConfigDirectoryAdminPwd},
+ "$configdir/admin-serv", $errs);
+
+ if (!$conn or @{$errs}) {
+ return 0;
+ }
+
+ my $admConf = getAdmConf("$configdir/admin-serv");
+
+ for my $inst (@instances) {
+ my $instinf = createInfFromConfig("$configdir/$inst", $inst);
+ unlink($instinf->{filename});
+ $instinf->{General}->{ConfigDirectoryLdapURL} =
+ $inf->{General}->{ConfigDirectoryLdapURL};
+ if (!registerDSWithConfigDS($inst, $errs, $instinf,
+ $conn, $admConf, $configdir)) {
+ return 0;
+ }
+ }
+
+ $conn->close();
+
+ return 1
+}
+
+sub registerDSWithConfigDS {
+ my $servid = shift;
+ my $errs = shift;
+ my $inf = shift;
+ my $conn = shift;
+ my $admConf = shift;
+ my $configdir = shift || "@instconfigdir@";
+ my $inst;
+ my $needclose;
+
+ if ($servid =~ /^slapd-/) {
+ $inst = $servid;
+ } else {
+ $inst = "slapd-$servid";
+ }
+
+ my ($dummy1, $pwd, $dummy2, $userdn) = getAuthCredentials();
+
+ if (!$inf->{General}->{AdminDomain}) {
+ if (!$admConf) {
+ $admConf = getAdmConf("$configdir/admin-serv");
+ }
+ $inf->{General}->{AdminDomain} = $admConf->{AdminDomain};
+ }
+
+ # open a connection to the configuration directory server
+ if (!$conn) {
+ if (!$userdn) {
+ $userdn = $inf->{General}->{ConfigDirectoryAdminID};
+ }
+ if (!$pwd) {
+ $pwd = $inf->{General}->{ConfigDirectoryAdminPwd};
+ }
+
+ $conn = getConfigDSConn($inf->{General}->{ConfigDirectoryLdapURL},
+ $userdn, $pwd,
+ "$configdir/admin-serv", $errs);
+ $needclose = 1;
+ }
+
+ if (!$conn or @{$errs}) {
+ return 0;
+ }
+
+ my $instinf;
+ # setup will usually supply everything, but ds_create will not
+ if (!$inf->{slapd}->{RootDNPwd}) {
+ $instinf = createInfFromConfig("$configdir/$inst", $inst, $errs);
+ if (!$instinf or @{$errs}) {
+ if ($needclose) {
+ $conn->close();
+ }
+ return 0;
+ }
+ }
+
+ # add the Admin Server configuration entries
+ my @ldiffiles = ("@ldifdir(a)/10dsdata.ldif.tmpl",
+ "@ldifdir(a)/11dstasks.ldif.tmpl"
+ );
+ my $setupinf = new Inf("@infdir(a)/setup.inf");
+ my $slapdinf = new Inf("@infdir(a)/slapd.inf");
+
+ my $mapper = new Inf("@infdir(a)/dirserver.map");
+
+ $mapper = process_maptbl($mapper, $errs, $inf, $instinf, $slapdinf, $setupinf);
+ if (!$mapper or @{$errs}) {
+ if ($needclose) {
+ $conn->close();
+ }
+ return 0;
+ }
+
+ my $context = [$conn];
+ getMappedEntries($mapper, \@ldiffiles, $errs, \&check_and_add_entry, $context);
+
+ if ($needclose) {
+ $conn->close();
+ }
+
+ return @{$errs} ? 0 : 1;
+}
+
Index: migrate-ds-admin.pl.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/migrate-ds-admin.pl.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- migrate-ds-admin.pl.in 29 Jun 2007 21:29:05 -0000 1.1
+++ migrate-ds-admin.pl.in 4 Jul 2007 01:31:33 -0000 1.2
@@ -47,6 +47,7 @@
use Migration;
use Resource;
use DSMigration;
+use SetupLog;
my $res = new Resource("@propertydir(a)/migrate-ds-admin.res",
"@propertydir(a)/migrate-ds.res",
@@ -83,7 +84,14 @@
# next, register/update the new directory servers
# in the config ds
-registerManyDSWithConfigDS($mig, "$mig->{configdir}/admin-serv", @{$mig->{instances}});
+$mig->msg('registering_dirserver_instances');
+my @errs;
+if (!registerManyDSWithConfigDS($mig->{inf}, \@errs,
+ $mig->{configdir},
+ @{$mig->{instances}})) {
+ $mig->msg($FATAL, @errs);
+ exit 1;
+}
$mig->msg('end_dsadmin_migration');
Index: register_server.pl.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/register_server.pl.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- register_server.pl.in 18 Jun 2007 17:14:51 -0000 1.3
+++ register_server.pl.in 4 Jul 2007 01:31:33 -0000 1.4
@@ -186,17 +186,20 @@
my $mapper = new Inf($mapfile);
my $infdatum = new Inf($thisinf);
push(@infdata, ($infdatum));
- $mapper = process_maptbl($mapper, @infdata);
+ my @errs;
+ $mapper = process_maptbl($mapper, \@errs, @infdata);
if ( NULL eq $mapper )
{
+ print "@errs\n";
print "ERROR: failed to generate mapper\n";
exit 1;
}
- my @ents = getMappedEntries($mapper, \@ldiffiles, \&check_and_add_entry,
- [$conn, $confds_fresh, $confds_verbose]);
- if ( @ents )
+ getMappedEntries($mapper, \@ldiffiles, \@errs, \&check_and_add_entry,
+ [$conn, $confds_fresh, $confds_verbose]);
+ if ( @errs )
{
+ print "@errs\n";
print "ERROR: failed to register server info\n";
return 1;
}
Index: setup-ds-admin.pl.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/setup-ds-admin.pl.in,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- setup-ds-admin.pl.in 29 Jun 2007 21:29:05 -0000 1.6
+++ setup-ds-admin.pl.in 4 Jul 2007 01:31:33 -0000 1.7
@@ -145,8 +145,12 @@
$setup->msg('create_dirserver');
# create a directory server instance
-my ($rc, $output) = createDSInstance($setup->{inf});
+my @errs = ();
+my ($rc, $output) = createDSInstance($setup->{inf}, \@errs);
if ($rc) {
+ if (@errs) {
+ $setup->msg(@errs);
+ }
$setup->msg($FATAL, 'error_creating_dsinstance', $rc, $output);
exit 1;
} else {
@@ -155,7 +159,6 @@
# setup directory server instance to be the configuration DS
if ($createconfigds) {
- my @errs = ();
$setup->msg('create_configds');
if (!createConfigDS($setup->{inf}, \@errs)) {
$setup->msg($FATAL, @errs);
@@ -165,7 +168,6 @@
}
else
{
- my @errs = ();
$setup->msg('create_configds');
if (!createSubDS($setup->{inf}, \@errs)) {
$setup->msg($FATAL, @errs);
@@ -175,7 +177,10 @@
}
# register ds instances with config DS
-if (!registerDSWithConfigDS($setup)) {
+if (!registerDSWithConfigDS($setup->{inf}->{slapd}->{ServerIdentifier},
+ \@errs,
+ $setup->{inf})) {
+ $setup->msg(@errs);
$setup->msg($FATAL, 'error_register_dirserver');
exit 1;
}
16 years, 9 months
[Fedora-directory-commits] adminserver/admserv/schema/ldif 11dstasks.ldif.tmpl, 1.3, 1.4 15dspta.ldif.tmpl.in, 1.1, 1.2
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/adminserver/admserv/schema/ldif
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv30934/adminserver/admserv/schema/ldif
Modified Files:
11dstasks.ldif.tmpl 15dspta.ldif.tmpl.in
Log Message:
Resolves: bug 246683
Bug Description: Reimplement ds_create without setuputil code
Reviewed by: nhosoi (Thanks!)
Fix Description: ds_create was a CGI program that would create a new instance, set it up to be managed by console, and register it with the config ds. The new ds_create CGI perl script does just that. One tricky part was that, rather than enabling the pass through auth plugin and having to restart the server, the new server is created without being started, then the modification is done to the new server dse.ldif file directly, using the new FileConn.pm module, which simulates a Mozilla::LDAP::Conn on an LDIF file. This also allows us to create a new instance with a pre-hashed rootdn password, rather than having to send the cleartext password.
I had to move around some code in AdminServer and AdminUtil so that I could use it from ds_create. I also implemented support for the admin server PASSWORD_PIPE in perl so we could use it in other CGI perl scripts.
Finally, the error handling was not consistent in our code, so I made explicit the passing of error messages up and down the stack. Oh how I wish we could just do this in python and use exception handling . . .
I added a test for ds_create.
Platforms tested: RHEL4
Flag Day: Yes - autotool changes
Doc impact: No. Should work the same way as the old ds_create.
Index: 11dstasks.ldif.tmpl
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/schema/ldif/11dstasks.ldif.tmpl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- 11dstasks.ldif.tmpl 27 Jun 2007 22:25:00 -0000 1.3
+++ 11dstasks.ldif.tmpl 4 Jul 2007 01:31:33 -0000 1.4
@@ -180,7 +180,7 @@
objectClass: top
objectClass: nstask
objectClass: nsAdminObject
-nsExecRef: ds_newinst
+nsExecRef: ds_create
cn: Create
dn: cn=GetConfigInfo, cn=Operation, cn=Tasks, cn=%brand% Directory Server, cn=Server Group, cn=%fqdn%, ou=%domain%, o=NetscapeRoot
Index: 15dspta.ldif.tmpl.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/schema/ldif/15dspta.ldif.tmpl.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- 15dspta.ldif.tmpl.in 28 Jun 2007 18:41:29 -0000 1.1
+++ 15dspta.ldif.tmpl.in 4 Jul 2007 01:31:33 -0000 1.2
@@ -22,11 +22,11 @@
objectClass: nsSlapdPlugin
objectClass: extensibleObject
cn: Pass Through Authentication
-nsslapd-pluginPath: @dslibdir(a)/plugins/libpassthru-plugin.so
+nsslapd-pluginPath: libpassthru-plugin
nsslapd-pluginInitfunc: passthruauth_init
nsslapd-pluginType: preoperation
nsslapd-pluginEnabled: on
-nsslapd-pluginarg0: %config_ds_url%/o%3DNetscapeRoot
+nsslapd-pluginarg0: %config_ds_url%
nsslapd-plugin-depends-on-type: database
nsslapd-pluginId: passthruauth
nsslapd-pluginVersion: %ds_version%
16 years, 9 months
[Fedora-directory-commits] adminserver/admserv/cgi-src40 ds_create.in, NONE, 1.1 ds_create.res, NONE, 1.1 Cgi.pm, 1.1.1.1, NONE Makefile, 1.13, NONE
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/adminserver/admserv/cgi-src40
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv30934/adminserver/admserv/cgi-src40
Added Files:
ds_create.in ds_create.res
Removed Files:
Cgi.pm Makefile
Log Message:
Resolves: bug 246683
Bug Description: Reimplement ds_create without setuputil code
Reviewed by: nhosoi (Thanks!)
Fix Description: ds_create was a CGI program that would create a new instance, set it up to be managed by console, and register it with the config ds. The new ds_create CGI perl script does just that. One tricky part was that, rather than enabling the pass through auth plugin and having to restart the server, the new server is created without being started, then the modification is done to the new server dse.ldif file directly, using the new FileConn.pm module, which simulates a Mozilla::LDAP::Conn on an LDIF file. This also allows us to create a new instance with a pre-hashed rootdn password, rather than having to send the cleartext password.
I had to move around some code in AdminServer and AdminUtil so that I could use it from ds_create. I also implemented support for the admin server PASSWORD_PIPE in perl so we could use it in other CGI perl scripts.
Finally, the error handling was not consistent in our code, so I made explicit the passing of error messages up and down the stack. Oh how I wish we could just do this in python and use exception handling . . .
I added a test for ds_create.
Platforms tested: RHEL4
Flag Day: Yes - autotool changes
Doc impact: No. Should work the same way as the old ds_create.
--- NEW FILE ds_create.in ---
#!/usr/bin/env perl
# BEGIN COPYRIGHT BLOCK
# This Program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 2 of the License.
#
# This Program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA.
#
# In addition, as a special exception, Red Hat, Inc. gives You the additional
# right to link the code of this Program with code not covered under the GNU
# General Public License ("Non-GPL Code") and to distribute linked combinations
# including the two, subject to the limitations in this paragraph. Non-GPL Code
# permitted under this exception must only link to the code of this Program
# through those well defined interfaces identified in the file named EXCEPTION
# found in the source code files (the "Approved Interfaces"). The files of
# Non-GPL Code may instantiate templates or use macros or inline functions from
# the Approved Interfaces without causing the resulting work to be covered by
# the GNU General Public License. Only Red Hat, Inc. may make changes or
# additions to the list of Approved Interfaces. You must obey the GNU General
# Public License in all respects for all of the Program code and other code used
# in conjunction with the Program except the Non-GPL Code covered by this
# exception. If you modify this file, you may extend this exception to your
# version of the file, but you are not obligated to do so. If you do not wish to
# provide this exception without modification, you must delete this exception
# statement from your version and license this file solely under the GPL without
# exception.
#
#
# Copyright (C) 2007 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
#
use lib '@perldir@';
use strict;
use CGI qw(:cgi :oldstyle_urls);
use Inf;
use AdminUtil;
use Util;
use Resource;
my $res = new Resource("@propertydir(a)/ds_create.res",
"@propertydir(a)/setup-ds-admin.res",
"@propertydir(a)/setup-ds.res");
# parse the input parameters
my $query = new CGI;
# look at arguments
# save old start_server param
# set start_server=0
my $start_server = $query->param('start_server');
$query->param('start_server', '0'); # create server but do not start
# call ds_newinst as a GET (GET or POST works, GET is simpler)
$ENV{REQUEST_METHOD} = "GET";
$ENV{QUERY_STRING} = $query->query_string();
# make sure the child exit code is reset before starting the fake
# cgi program
my $prog = "@bindir@/ds_newinst";
if (! -x $prog) {
$prog = "@dslibdir@/ds_newinst";
}
$? = 0;
# run the CGI
my $output = `$prog 2>&1`;
my $status = $?;
# check for and report errors
if ($status) {
print $output;
exit $status;
}
# set up new DS to be managed by config DS - acis, pta config
# new ds info, needed for registration (or get from new dse.ldif)
# temp = ds_a_get_cgi_var("servport", NULL, NULL);
# if (!(cf->servid = ds_a_get_cgi_var("servid", "Server Identifier",
# "Please give your server a short identifier.")))
# cf->rootdn = dn_normalize_convert(ds_a_get_cgi_var("rootdn", NULL, NULL));
# if (!(cf->rootpw = ds_a_get_cgi_var("rootpw", NULL, NULL)))
# cf->start_server = ds_a_get_cgi_var("start_server", NULL, NULL);
my $inst = $query->param('servid');
my @errs;
my $inf = createInfFromConfig("@instconfigdir@/slapd-$inst", $inst, \@errs);
if (@errs) {
print "NMC_ErrInfo: ", $res->getText(@errs), "\n";
print "NMC_Status: 1\n";
exit 1;
}
# add the parmeters necessary to configure this DS to be managed
# by the console and to be registered with the config DS - these
# are usually passed in via the CGI params, or use reasonable
# default values
my $admConf = getAdmConf("@instconfigdir@/admin-serv");
$inf->{General}->{ConfigDirectoryLdapURL} = $query->param('ldap_url') ||
$admConf->{ldapurl};
$inf->{General}->{ConfigDirectoryAdminID} = $query->param('cfg_sspt_uid');
$inf->{General}->{ConfigDirectoryAdminPwd} = $query->param('cfg_sspt_uid_pw');
$inf->{General}->{AdminDomain} = $query->param('admin_domain') ||
$admConf->{AdminDomain};
if (!createSubDSNoConn($inf, \@errs)) {
print "NMC_ErrInfo: ", $res->getText(@errs), "\n";
print "NMC_Status: 1\n";
exit 1;
}
my $servid = $query->param('servid');
if ($start_server) {
# ok to use here because not only will ds_newinst have validated that
# servid contains only good characters, but we test for the existence
# of this file first
$prog = "@dslibdir@/slapd-$servid/start-slapd";
if (-x $prog) {
$? = 0;
# run the CGI
my $output = `$prog 2>&1`;
my $status = $?;
if ($status) {
print "NMC_ErrInfo: Could not start directory server: $output\n";
print "NMC_Status: $status\n";
exit $status;
}
} else {
print "NMC_ErrInfo: The program $prog does not exist\n";
print "NMC_Status: 1\n";
exit 1;
}
}
# register the new server with the configuration ds
# get config ds url from input or admconf
# get admin id from input or admconf
# must get admin password from input (PASSWORD_PIPE?)
# get admin domain
# config ds info
if (!registerDSWithConfigDS($servid, \@errs, $inf)) {
print "NMC_ErrInfo: ", $res->getText(@errs), "\n";
print "NMC_Status: 1\n";
exit 1;
}
# if we got here, report success
print "NMC_Status: 0\n";
exit 0;
--- NEW FILE ds_create.res ---
# resources for ds_create
--- Cgi.pm DELETED ---
--- Makefile DELETED ---
16 years, 9 months
[Fedora-directory-commits] ldapserver/ldap/admin/src/scripts FileConn.pm, NONE, 1.1 DSMigration.pm.in, 1.1, 1.2 Resource.pm, 1.3, 1.4 Util.pm.in, 1.4, 1.5 setup-ds.pl.in, 1.3, 1.4 setup-ds.res.in, 1.5, 1.6
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/admin/src/scripts
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv29013/ldapserver/ldap/admin/src/scripts
Modified Files:
DSMigration.pm.in Resource.pm Util.pm.in setup-ds.pl.in
setup-ds.res.in
Added Files:
FileConn.pm
Log Message:
Resolves: bug 246683
Bug Description: Reimplement ds_create without setuputil code
Reviewed by: nhosoi (Thanks!)
Fix Description: ds_create was a CGI program that would create a new instance, set it up to be managed by console, and register it with the config ds. The new ds_create CGI perl script does just that. One tricky part was that, rather than enabling the pass through auth plugin and having to restart the server, the new server is created without being started, then the modification is done to the new server dse.ldif file directly, using the new FileConn.pm module, which simulates a Mozilla::LDAP::Conn on an LDIF file. This also allows us to create a new instance with a pre-hashed rootdn password, rather than having to send the cleartext password.
I had to move around some code in AdminServer and AdminUtil so that I could use it from ds_create. I also implemented support for the admin server PASSWORD_PIPE in perl so we could use it in other CGI perl scripts.
Finally, the error handling was not consistent in our code, so I made explicit the passing of error messages up and down the stack. Oh how I wish we could just do this in python and use exception handling . . .
I added a test for ds_create.
Platforms tested: RHEL4
Flag Day: Yes - autotool changes
Doc impact: No. Should work the same way as the old ds_create.
--- NEW FILE FileConn.pm ---
# BEGIN COPYRIGHT BLOCK
# This Program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 2 of the License.
#
# This Program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA.
#
# In addition, as a special exception, Red Hat, Inc. gives You the additional
# right to link the code of this Program with code not covered under the GNU
# General Public License ("Non-GPL Code") and to distribute linked combinations
# including the two, subject to the limitations in this paragraph. Non-GPL Code
# permitted under this exception must only link to the code of this Program
# through those well defined interfaces identified in the file named EXCEPTION
# found in the source code files (the "Approved Interfaces"). The files of
# Non-GPL Code may instantiate templates or use macros or inline functions from
# the Approved Interfaces without causing the resulting work to be covered by
# the GNU General Public License. Only Red Hat, Inc. may make changes or
# additions to the list of Approved Interfaces. You must obey the GNU General
# Public License in all respects for all of the Program code and other code used
# in conjunction with the Program except the Non-GPL Code covered by this
# exception. If you modify this file, you may extend this exception to your
# version of the file, but you are not obligated to do so. If you do not wish to
# provide this exception without modification, you must delete this exception
# statement from your version and license this file solely under the GPL without
# exception.
#
#
# Copyright (C) 2007 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
#
# FileConn is a subclass of Mozilla::LDAP::Conn. This class does
# not use LDAP. Instead, it operates on a given LDAP file, allowing
# you to search, add, modify, and delete entries in the file.
#
package FileConn;
use Mozilla::LDAP::Conn;
use Mozilla::LDAP::API qw(:constant ldap_explode_dn ldap_err2string); # Direct access to C API
use Mozilla::LDAP::Utils qw(normalizeDN);
use Mozilla::LDAP::LDIF;
require Exporter;
@ISA = qw(Exporter Mozilla::LDAP::Conn);
@EXPORT = qw();
@EXPORT_OK = qw();
sub new {
my $class = shift;
my $filename = shift;
my $self = {};
$self = bless $self, $class;
$self->read($filename);
return $self;
}
sub getParentDN {
my $dn = shift;
my @rdns = ldap_explode_dn($dn, 0);
shift @rdns;
return join(',', @rdns);
}
sub read {
my $self = shift;
my $filename = shift;
if ($filename) {
$self->{filename} = $filename;
} else {
$filename = $self->{filename};
}
if (!$self->{filename}) {
return;
}
open( MYLDIF, "$filename" ) || die "Can't open $filename: $!";
my $in = new Mozilla::LDAP::LDIF(*MYLDIF);
while ($ent = readOneEntry $in) {
if (!$self->add($ent)) {
die "Error: could not add entry ", $ent->getDN(), ":", $self->getErrorString();
}
}
close( MYLDIF );
}
# return all nodes below the given node
sub iterate {
my $self = shift;
my $dn = shift;
my $scope = shift;
my $callback = shift;
my $context = shift;
my $suppress = shift;
my $ndn = normalizeDN($dn);
my $children = $self->{$ndn}->{children};
if (($scope != LDAP_SCOPE_ONELEVEL) && $self->{$ndn}->{data} && !$suppress) {
&{$callback}($self->{$ndn}->{data}, $context);
}
if ($scope == LDAP_SCOPE_BASE) {
return;
}
for my $node (@{$children}) {
&{$callback}($node->{data}, $context);
}
if ($scope == LDAP_SCOPE_SUBTREE) {
for my $node (@{$children}) {
$self->iterate($node->{data}->getDN(), $scope, $callback, $context, 1);
}
}
}
sub writecb {
my $entry = shift;
my $fh = shift;
if (! $entry->getDN()) { # rootDSE requires special hack around perldap bug
my $ary = $entry->getLDIFrecords();
shift @$ary; # remove "dn"
shift @$ary; # remove the empty dn value
print $fh "dn:\n";
print $fh (Mozilla::LDAP::LDIF::pack_LDIF (78, $ary), "\n");
} else {
Mozilla::LDAP::LDIF::put_LDIF($fh, 78, $entry);
}
}
sub write {
my $self = shift;
my $filename = shift;
if ($filename) {
$self->{filename} = $filename;
} else {
$filename = $self->{filename};
}
if (!$self->{filename}) {
return;
}
open( MYLDIF, ">$filename" ) || die "Can't write $filename: $!";
$self->iterate("", LDAP_SCOPE_SUBTREE, \&writecb, \*MYLDIF);
close( MYLDIF );
}
sub setErrorCode {
my $self = shift;
$self->{lastErrorCode} = shift;
}
sub getErrorCode {
my $self = shift;
return $self->{lastErrorCode};
}
sub getErrorString {
my $self = shift;
return ($self->{lastErrorCode} ? ldap_err2string($self->{lastErrorCode}) : LDAP_SUCCESS);
}
#############################################################################
# Print the last error code...
#
sub printError
{
my ($self, $str) = @_;
$str = "LDAP error:" unless defined($str);
print "$str ", $self->getErrorString(), "\n";
}
sub close {
my $self = shift;
$self->write();
}
sub printcb {
my $entry = shift;
print $entry->getDN(), "\n";
}
sub print {
my $self = shift;
my $dn = shift;
my $scope = shift;
$self->iterate($dn, $scope, \&printcb);
}
# for each entry, call the user provided filter callback
# with the entry and the user provided filter context
# if the filtercb returns true, add the entry to the
# list of entries to return
sub searchcb {
my $entry = shift;
my $context = shift;
my $self = $context->[0];
my $filtercb = $context->[1];
my $filtercontext = $context->[2];
if (&{$filtercb}($entry, $filtercontext)) {
push @{$self->{entries}}, $entry;
}
}
sub matchall {
return 1;
}
sub matchAttrVal {
my $entry = shift;
my $context = shift;
my $attr = $context->[0];
my $val = $context->[1];
if ($val eq "*") {
return $entry->exists($attr);
}
return $entry->hasValue($attr, $val, 1);
}
my $attrpat = '[-;.:\w]*[-;\w]';
# given a string filter, figure out which subroutine to
# use to match
sub filterToMatchSub {
my $self = shift;
my ($basedn, $scope, $filter, $attrsonly, @rest) = @_;
my ($matchsub, $context);
# do some filter processing
if (!$filter or ($filter eq "(objectclass=*)") or
($filter eq "objectclass=*")) {
$matchsub = \&matchall;
} elsif ($filter =~ /^\(($attrpat)=(.+)\)$/o) {
push @{$context}, $1, $2;
$matchsub = \&matchAttrVal;
# } elsif ($filter =~ /^\(\|\(($attrpat)=(.+)\)\(($attrpat)=(.+)\)\)$/o) {
# $attr = $1;
# $val = $2;
# $attr1 = $1;
# $val1 = $2;
# $isand = 0;
# } elsif ($filter =~ /^\(\&\(($attrpat)=(.+)\)\(($attrpat)=(.+)\)\)$/o) {
# $attr = $1;
# $val = $2;
# $attr1 = $1;
# $val1 = $2;
# $isand = 1;
# } elsif ($filter =~ /^\(\|\(($attrpat)=(.+)\)\(($attrpat)=(.+)\)\)$/o) {) {
# # "(&(objectclass=nsBackendInstance)(|(nsslapd-suffix=$suffix)(nsslapd-suffix=$nsuffix)))");
}
$self->iterate($basedn, $scope, \&searchcb, [$self, $matchsub, $context]);
}
# simple searches only
sub search {
my $self = shift;
my ($basedn, $scope, $filter, $attrsonly, @rest) = @_;
my $attrs;
if (ref($rest[0]) eq "ARRAY") {
$attrs = $rest[0];
} elsif (scalar(@rest) > 0) {
$attrs = \@rest;
}
$scope = Mozilla::LDAP::Utils::str2Scope($scope);
$self->{entries} = [];
my $ndn = normalizeDN($basedn);
if (!exists($self->{$ndn})) {
$self->setErrorCode(LDAP_NO_SUCH_OBJECT);
return undef;
}
$self->setErrorCode(0);
if (ref($filter) eq 'CODE') {
$self->iterate($basedn, $scope, \&searchcb, [$self, $filter, $attrsonly]);
} else {
$self->filterToMatchSub($basedn, $scope, $filter, $attrsonly);
}
return $self->nextEntry();
}
sub nextEntry {
my $self = shift;
return shift @{$self->{entries}};
}
sub add {
my $self = shift;
my $entry = shift;
my $dn = $entry->getDN();
my $ndn = normalizeDN($dn);
my $parentdn = getParentDN($dn);
my $nparentdn = normalizeDN($parentdn);
$self->setErrorCode(0);
if (exists($self->{$ndn})) {
$self->setErrorCode(LDAP_ALREADY_EXISTS);
return 0;
}
if ($nparentdn && !exists($self->{$nparentdn})) {
$self->setErrorCode(LDAP_NO_SUCH_OBJECT);
return 0;
}
# each hash entry has two keys
# data is the actual Entry
# children is the array ref of the one level children of this dn
$self->{$ndn}->{data} = $entry;
push @{$self->{$nparentdn}->{children}}, $self->{$ndn};
return 1;
}
sub update {
my $self = shift;
my $entry = shift;
my $dn = $entry->getDN();
my $ndn = normalizeDN($dn);
$self->setErrorCode(0);
if (!exists($self->{$ndn})) {
$self->setErrorCode(LDAP_NO_SUCH_OBJECT);
return 0;
}
$self->{$ndn}->{data} = $entry;
return 1;
}
sub delete {
my $self = shift;
my $dn = shift;
if (ref($dn)) {
$dn = $dn->getDN(); # an Entry
}
my $ndn = normalizeDN($dn);
$self->setErrorCode(0);
if (!exists($self->{$ndn})) {
$self->setErrorCode(LDAP_NO_SUCH_OBJECT);
return 0;
}
if (@{$self->{$ndn}->{children}}) {
$self->setErrorCode(LDAP_NOT_ALLOWED_ON_NONLEAF);
return 0;
}
# delete the data associated with this node
delete $self->{$ndn}->{data};
delete $self->{$ndn}->{children};
my $parentdn = getParentDN($dn);
my $nparentdn = normalizeDN($parentdn);
# delete this node from its parent
for (my $ii = 0; $ii < @{$self->{$nparentdn}->{children}}; ++$ii) {
# find matching hash ref in parent's child list
if ($self->{$nparentdn}->{children}->[$ii] eq $self->{$ndn}) {
# remove that element from the array
splice @{$self->{$nparentdn}->{children}}, $ii, 1;
# done - should only ever be one matching child
last;
}
}
# delete this node
delete $self->{$ndn};
return 0;
}
1;
Index: DSMigration.pm.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/DSMigration.pm.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DSMigration.pm.in 29 Jun 2007 21:12:21 -0000 1.1
+++ DSMigration.pm.in 4 Jul 2007 01:28:17 -0000 1.2
@@ -374,6 +374,7 @@
my $mig = shift;
$pkgname = $mig->{pkgname}; # set globals
$oldsroot = $mig->{oldsroot}; # set globals
+ my @errs;
# for each instance
foreach my $inst (@{$mig->{instances}}) {
@@ -388,13 +389,18 @@
# extract the information needed for ds_newinst.pl
my $configdir = "$oldsroot/$inst/config";
- my $inf = createInfFromConfig($configdir, $inst);
+ my $inf = createInfFromConfig($configdir, $inst, \@errs);
debug(2, "Using inffile $inf->{filename} created from $configdir\n");
+ if (@errs) {
+ $mig->msg(@errs);
+ return 0;
+ }
# create the new instance
- my ($rc, $output) = createDSInstance($inf);
+ my ($rc, $output) = createDSInstance($inf, \@errs);
unlink($inf->{filename});
if ($rc) {
+ $mig->msg(@errs);
$mig->msg($FATAL, 'error_creating_dsinstance', $rc, $output);
return 0;
} else {
Index: Resource.pm
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/Resource.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Resource.pm 15 Jun 2007 22:11:15 -0000 1.3
+++ Resource.pm 4 Jul 2007 01:28:17 -0000 1.4
@@ -112,7 +112,9 @@
}
}
# replace \n with real newline
- $self->{res}->{$curkey} =~ s/\\n/\n/g;
+ if (defined($curkey)) {
+ $self->{res}->{$curkey} =~ s/\\n/\n/g;
+ }
close RES;
}
}
Index: Util.pm.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/Util.pm.in,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Util.pm.in 29 Jun 2007 21:12:21 -0000 1.4
+++ Util.pm.in 4 Jul 2007 01:28:17 -0000 1.5
@@ -119,8 +119,7 @@
$conn->delete($dn);
my $rc = $conn->getErrorCode();
if ( $rc != 0 ) {
- $conn->printError();
- print "ERROR: unable to delete entry $dn, error code: $rc\n";
+ debug(1, "ERROR: unable to delete entry $dn, error code: $rc:" . $conn->getErrorString() . "\n");
return 1;
}
$dn = pop @mystack;
@@ -220,7 +219,7 @@
# $verbose prints out more info
sub check_and_add_entry
{
- my ($context, $aentry) = @_;
+ my ($context, $aentry, $errs) = @_;
my $conn = $context->[0];
my $fresh = $context->[1];
my $verbose = $context->[2];
@@ -277,6 +276,7 @@
$rc = delete_all($conn, $sentry);
if ( 0 != $rc )
{
+ push @{$errs}, 'error_deleteall_entries', $sentry->{dn}, $conn->getErrorString();
debug(1, "Error deleting $sentry->{dn}\n");
return 0;
}
@@ -305,8 +305,8 @@
if ( $rc != 0 )
{
my $string = $conn->getErrorString();
- print "ERROR: adding an entry $aentry->{dn} failed, error: $string\n";
- print "[entry]\n";
+ push @{$errs}, 'error_adding_entry', $aentry->{dn}, $string;
+ debug(1, "ERROR: adding an entry $aentry->{dn} failed, error: $string\n");
$aentry->printLDIF();
$conn->close();
return 0;
@@ -359,8 +359,8 @@
if ( $rc != 0 )
{
my $string = $conn->getErrorString();
- print "ERROR: updating an entry $sentry->{dn} failed, error: $string\n";
- print "[entry]\n";
+ push @{$errs}, 'error_updating_entry', $sentry->{dn}, $string;
+ debug(1, "ERROR: updating an entry $sentry->{dn} failed, error: $string\n");
$aentry->printLDIF();
$conn->close();
return 0;
@@ -396,12 +396,14 @@
# and the values are the replacements
# ldiffiles - an array ref - the list of LDIF files to
# operate on
+# errs - an array ref - this is filled in with the
+# errors encountered in processing - this is
+# suitable for passing to setup->msg or
+# Resource->getText
# callback (optional) - a code ref - a ref to a subroutine
# that will be called with each entry - see below
# context (optional) - this will be passed as the first
# argument to your given callback - see below
-# errs (optional) - an array ref - This is how errors
-# are returned to the caller - see below
# Callback:
# The callback sub will be called for each entry after
# the entry has been converted. The callback will be
@@ -413,18 +415,20 @@
# abort processing of any further.
# Errors:
# This function should return an array of errors in the
-# format described below, for use with Resource::getText().
-# If the callback returns any errors
+# format described below, for use with Resource::getText()
+# or Setup::msg()
# Return:
# The return value is a list of entries.
# Example usage:
# sub handle_entries {
# my $context = shift;
# my $entry = shift;
+# my $errs = shift;
# .... do something with entry ....
# .... if $context is Mozilla::LDAP::Conn, $conn->add($entry); ...
# .... report errors ....
# if ($fatalerror) {
+# push @{$errs}, 'error_token', arg1, arg2, ...;
# return 0;
# } else {
# return 1;
@@ -433,14 +437,16 @@
# $mapper = {foo => 'bar', baz => 'biff'};
# @ldiffiles = ('foo.ldif', 'bar.ldif', ..., 'biff.ldif');
# $conn = new Mozilla::LDAP::Conn(...);
-# @entries = getMappedEntries($mapper, \@ldiffiles, \&handle_entries, $conn);
+# my @errs;
+# @entries = getMappedEntries($mapper, \@ldiffiles, \@errs, \&handle_entries, $conn);
# Note that this will return 0 entries since a callback was used.
# The simpler example is this:
-# @entries = getMappedEntries($mapper, \@ldiffiles);
+# @entries = getMappedEntries($mapper, \@ldiffiles, \@errs);
#
sub getMappedEntries {
my $mapper = shift;
my $ldiffiles = shift;
+ my $errs = shift;
my $callback = shift || \&cbaddent; # default - just add entry to @entries
my @entries = ();
my $context = shift || \@entries;
@@ -451,7 +457,10 @@
}
foreach my $ldiffile (@{$ldiffiles}) {
- open(MYLDIF, "< $ldiffile") or die "Can't open $ldiffile : $!";
+ if (!open(MYLDIF, "< $ldiffile")) {
+ push @{$errs}, "error_opening_ldiftmpl", $ldiffile, $!;
+ return 0;
+ }
my $in = new Mozilla::LDAP::LDIF(*MYLDIF);
debug(1, "Processing $ldiffile ...\n");
ENTRY: while (my $entry = Mozilla::LDAP::LDIF::readOneEntry($in)) {
@@ -462,9 +471,7 @@
if (exists($mapper->{$1})) {
$dn =~ s{%([\w_-]+)%}{$mapper->{$1}}ge;
} else {
- print "ERROR: \"$origdn\" mapped to \"$dn\".\n";
- print "The LDIF file $ldiffile contains a token $1 for which there is no mapper.\n";
- print "Please check $ldiffile and your mapper to make sure all tokens are handled correctly.\n";
+ push @{$errs}, 'error_mapping_token_ldiftmpl', $dn, $ldiffile, $1;
$error = 1;
last ENTRY;
}
@@ -480,9 +487,8 @@
if (exists($mapper->{$1})) {
$value =~ s{%([\w_-]+)%}{$mapper->{$1}}ge;
} else {
- print "ERROR: \"$origvalue\" mapped to \"$value\".\n";
- print "The LDIF file $ldiffile contains a token $1 for which there is no mapper.\n";
- print "Please check $ldiffile and your mapper to make sure all tokens are handled correctly.\n";
+ push @{$errs}, 'error_mapping_token_ldiftmpl', $dn, $ldiffile, $1;
+ debug(1, "ERROR: \"$origvalue\" mapped to \"$value\".\n");
$error = 1;
last ENTRY;
}
@@ -492,9 +498,9 @@
$entry->setValues( $attr, @newvalues );
}
- if (!&{$callback}($context, $entry)) {
- print "There was an error processing entry ", $entry->getDN(), "\n";
- print "Cannot continue processing entries.\n";
+ if (!&{$callback}($context, $entry, $errs)) {
+ debug(1, "ERROR: There was an error processing entry ". $entry->getDN(). "\n");
+ debug(1, "Cannot continue processing entries.\n");
$error = 1;
last ENTRY;
}
@@ -640,7 +646,7 @@
# The %token% tokens are replaced in getMappedEntries
sub process_maptbl
{
- my ($mapper, @infdata) = @_;
+ my ($mapper, $errs, @infdata) = @_;
if (defined($mapper->{""})) {
$mapper = $mapper->{""}; # side effect of Inf with no sections
@@ -680,7 +686,7 @@
}
if (!defined($infsection->{$value}))
{
- print "ERROR: $value not found in the .inf files\n";
+ push @{$errs}, 'no_mapvalue_for_key', $value, $key;
return {};
}
}
@@ -709,6 +715,7 @@
sub createDSInstance {
my $inf = shift;
+ my $errs = shift; # unused for now
# find ds_newinst.pl - in same directory as this script or in PATH
my $ds_newinst;
($ds_newinst = $0) =~ s|/[^/]+$|/ds_newinst.pl|;
@@ -724,13 +731,18 @@
}
# this creates an Inf suitable for passing to createDSInstance
+# except that it has a bogus suffix
sub createInfFromConfig {
my $configdir = shift;
my $inst = shift;
+ my $errs = shift;
my $fname = "$configdir/dse.ldif";
my $id;
($id = $inst) =~ s/^slapd-//;
- open( DSELDIF, "$fname" ) || die "Can't open $fname: $!";
+ if (!open( DSELDIF, "$fname" )) {
+ push @{$errs}, "error_opening_dseldif", $fname, $!;
+ return 0;
+ }
my ($outfh, $inffile) = tempfile(SUFFIX => '.inf');
my $in = new Mozilla::LDAP::LDIF(*DSELDIF) ;
while (my $ent = readOneEntry $in) {
Index: setup-ds.pl.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/setup-ds.pl.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- setup-ds.pl.in 29 Jun 2007 21:12:21 -0000 1.3
+++ setup-ds.pl.in 4 Jul 2007 01:28:17 -0000 1.4
@@ -69,8 +69,10 @@
$setup->{inf}->write();
}
-my ($rc, $output) = createDSInstance($setup->{inf});
+my @errs;
+my ($rc, $output) = createDSInstance($setup->{inf}, \@errs);
if ($rc) {
+ $setup->msg(@errs);
$setup->msg($FATAL, 'error_creating_dsinstance', $rc, $output);
} else {
$setup->msg('created_dsinstance', $output);
Index: setup-ds.res.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/setup-ds.res.in,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- setup-ds.res.in 29 Jun 2007 21:12:21 -0000 1.5
+++ setup-ds.res.in 4 Jul 2007 01:28:17 -0000 1.6
@@ -89,3 +89,9 @@
setup_exiting = Exiting . . .\nLog file is '%s'\n\n
error_creating_dsinstance = Error: Could not create directory server instance. Error code %s. Output:\n%s\n
created_dsinstance = Your new DS instance was successfully created. Output:\n%s\n
+no_mapvalue_for_key = The map value '%s' for key '%s' did not map to a value in any of the given information files.\n
+error_opening_ldiftmpl = Could not open the LDIF template file '%s'. Error: %s\n
+error_mapping_token_ldiftmpl = The entry '%s' in LDIF file '%s' contains a token '%s' for which there is no mapper.\nPlease check the file and your mapper to make sure all tokens are handled correctly.\n
+error_deleteall_entries = Error deleting entry '%s' and all children. Error: %s\n
+error_adding_entry = Error adding entry '%s'. Error: %s\n
+error_updating_entry = Error updating entry '%s'. Error: %s\n
16 years, 9 months
[Fedora-directory-commits] ldapserver Makefile.am, 1.47, 1.48 aclocal.m4, 1.39, 1.40 configure, 1.50, 1.51 missing, 1.29, 1.30 install-sh, 1.29, 1.30 depcomp, 1.29, 1.30 compile, 1.29, 1.30 config.sub, 1.28, 1.29 config.guess, 1.28, 1.29 Makefile.in, 1.56, 1.57
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv29013/ldapserver
Modified Files:
Makefile.am aclocal.m4 configure missing install-sh depcomp
compile config.sub config.guess Makefile.in
Log Message:
Resolves: bug 246683
Bug Description: Reimplement ds_create without setuputil code
Reviewed by: nhosoi (Thanks!)
Fix Description: ds_create was a CGI program that would create a new instance, set it up to be managed by console, and register it with the config ds. The new ds_create CGI perl script does just that. One tricky part was that, rather than enabling the pass through auth plugin and having to restart the server, the new server is created without being started, then the modification is done to the new server dse.ldif file directly, using the new FileConn.pm module, which simulates a Mozilla::LDAP::Conn on an LDIF file. This also allows us to create a new instance with a pre-hashed rootdn password, rather than having to send the cleartext password.
I had to move around some code in AdminServer and AdminUtil so that I could use it from ds_create. I also implemented support for the admin server PASSWORD_PIPE in perl so we could use it in other CGI perl scripts.
Finally, the error handling was not consistent in our code, so I made explicit the passing of error messages up and down the stack. Oh how I wish we could just do this in python and use exception handling . . .
I added a test for ds_create.
Platforms tested: RHEL4
Flag Day: Yes - autotool changes
Doc impact: No. Should work the same way as the old ds_create.
Index: Makefile.am
===================================================================
RCS file: /cvs/dirsec/ldapserver/Makefile.am,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- Makefile.am 29 Jun 2007 21:12:21 -0000 1.47
+++ Makefile.am 4 Jul 2007 01:28:17 -0000 1.48
@@ -200,7 +200,8 @@
ldap/admin/src/scripts/DSDialogs.pm \
ldap/admin/src/scripts/Setup.pm \
ldap/admin/src/scripts/Migration.pm \
- ldap/admin/src/scripts/DSMigration.pm
+ ldap/admin/src/scripts/DSMigration.pm \
+ ldap/admin/src/scripts/FileConn.pm
property_DATA = ldap/admin/src/scripts/setup-ds.res \
ldap/admin/src/scripts/migrate-ds.res
Index: Makefile.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/Makefile.in,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- Makefile.in 29 Jun 2007 21:12:21 -0000 1.56
+++ Makefile.in 4 Jul 2007 01:28:17 -0000 1.57
@@ -1137,7 +1137,8 @@
ldap/admin/src/scripts/DSDialogs.pm \
ldap/admin/src/scripts/Setup.pm \
ldap/admin/src/scripts/Migration.pm \
- ldap/admin/src/scripts/DSMigration.pm
+ ldap/admin/src/scripts/DSMigration.pm \
+ ldap/admin/src/scripts/FileConn.pm
property_DATA = ldap/admin/src/scripts/setup-ds.res \
ldap/admin/src/scripts/migrate-ds.res
16 years, 9 months
[Fedora-directory-commits] console/src/com/netscape/management/client/util default.properties, 1.1.1.1, 1.2
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/console/src/com/netscape/management/client/util
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv20520/src/com/netscape/management/client/util
Modified Files:
default.properties
Log Message:
Resolves: 246651
Summary: Cleaned up dialogs when a jar file is unable to be downloaded.
Index: default.properties
===================================================================
RCS file: /cvs/dirsec/console/src/com/netscape/management/client/util/default.properties,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- default.properties 18 Jul 2005 00:34:27 -0000 1.1.1.1
+++ default.properties 3 Jul 2007 17:27:03 -0000 1.2
@@ -73,7 +73,7 @@
error-CanNotConnect=Can not connect to {0}
error-SaveFile=Can not save file as {0}
error-ClassNotFound=Class {0} not found
-error-InstallError=Failed to install a local copy of {0} or one of its supporting files:
+error-InstallError=Failed to install a local copy of {0} or one of its supporting files.\nPlease ensure that the appropriate console package is installed on the Administration Server.
# Messages for LDAPOutputStream
error-CannotModify1=Cannot modify entry, does not exist:
16 years, 9 months