[Fedora-directory-commits] adminserver/admserv/cgi-src40 ds_create.in, 1.2, 1.3

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Fri Jul 13 18:39:17 UTC 2007


Author: rmeggins

Update of /cvs/dirsec/adminserver/admserv/cgi-src40
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv32691/adminserver/admserv/cgi-src40

Modified Files:
	ds_create.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: ds_create.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/cgi-src40/ds_create.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ds_create.in	11 Jul 2007 21:36:47 -0000	1.2
+++ ds_create.in	13 Jul 2007 18:39:15 -0000	1.3
@@ -46,6 +46,7 @@
 use AdminUtil;
 use Util;
 use Resource;
+use DSCreate;
 
 my $res = new Resource("@propertydir@/ds_create.res",
                        "@propertydir@/setup-ds-admin.res",
@@ -57,41 +58,11 @@
 # 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 "Content-type: text/plain\n\n";
-    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);
+# create inf from CGI parameters
+my $inf = createInfFromCGIParams($query);
+# create the instance
+my @errs = createDSInstance($inf);
 if (@errs) {
     print "Content-type: text/plain\n\n";
     print "NMC_ErrInfo: ", $res->getText(@errs), "\n";
@@ -99,6 +70,7 @@
     exit 1;
 }
 
+# set up new DS to be managed by config DS - acis, pta config
 # 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
@@ -119,11 +91,11 @@
 }
 
 my $servid = $query->param('servid');
-if ($start_server) {
-    # ok to use here because not only will ds_newinst have validated that
+if (!defined($start_server) or $start_server) {
+    # ok to use here because not only will createDSInstance have validated that
     # servid contains only good characters, but we test for the existence
     # of this file first
-    $prog = "@dslibdir@/slapd-$servid/start-slapd";
+    my $prog = "@dslibdir@/slapd-$servid/start-slapd";
     if (-x $prog) {
         $? = 0;
         # run the CGI
@@ -144,12 +116,6 @@
 }
 
 # 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 "Content-type: text/plain\n\n";
     print "NMC_ErrInfo: ", $res->getText(@errs), "\n";
@@ -161,3 +127,20 @@
 print "Content-type: text/plain\n\n";
 print "NMC_Status: 0\n";
 exit 0;
+
+
+sub createInfFromCGIParams {
+    my $query = shift;
+    my $inf = new Inf;
+    $inf->{General}->{FullMachineName} = $query->param('servname');
+    $inf->{General}->{SuiteSpotUserID} = $query->param('servuser');
+
+    $inf->{slapd}->{ServerPort} = $query->param('servport');
+    $inf->{slapd}->{RootDN} = $query->param('rootdn');
+    $inf->{slapd}->{RootDNPwd} = $query->param('rootpw');
+    $inf->{slapd}->{ServerIdentifier} = $query->param('servid');
+    $inf->{slapd}->{Suffix} = $query->param('suffix');
+    $inf->{slapd}->{start_server} = 0; # we will start it explicitly later
+
+    return $inf;
+}




More information about the Fedora-directory-commits mailing list