summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure6
-rw-r--r--configure.ac6
-rw-r--r--ldap/admin/src/create_instance.c4
-rw-r--r--ldap/admin/src/create_instance.h11
-rw-r--r--ldap/admin/src/ds_newinst.pl.in275
5 files changed, 293 insertions, 9 deletions
diff --git a/configure b/configure
index 0a093ca4..b7e15f24 100755
--- a/configure
+++ b/configure
@@ -25030,9 +25030,9 @@ fi
# installation paths
if test "$with_fhs" = "yes"; then
- bindir=$prefix/usr/bin
- libdir=$prefix/usr/lib
- datadir=$prefix/usr/share
+ bindir=@prefix@/usr/bin
+ libdir=@prefix@/usr/lib
+ datadir=@prefix@/usr/share
fi
# relative to sysconfdir
configdir=/fedora-ds/config
diff --git a/configure.ac b/configure.ac
index 2cbe9ef7..b56a0675 100644
--- a/configure.ac
+++ b/configure.ac
@@ -129,9 +129,9 @@ AC_SUBST(netsnmp_link)
# installation paths
if test "$with_fhs" = "yes"; then
- bindir=$prefix/usr/bin
- libdir=$prefix/usr/lib
- datadir=$prefix/usr/share
+ bindir=@prefix@/usr/bin
+ libdir=@prefix@/usr/lib
+ datadir=@prefix@/usr/share
fi
# relative to sysconfdir
configdir=/fedora-ds/config
diff --git a/ldap/admin/src/create_instance.c b/ldap/admin/src/create_instance.c
index 0bae15cc..10567cf7 100644
--- a/ldap/admin/src/create_instance.c
+++ b/ldap/admin/src/create_instance.c
@@ -4346,8 +4346,8 @@ int parse_form(server_config_s *cf)
prefix = cf->prefix = PL_strdup("/");
}
- cf->sroot = PR_smprintf("%s%cusr%clib%c%s",
- prefix, FILE_PATHSEP, FILE_PATHSEP, FILE_PATHSEP, cf->brand_ds);
+ cf->sroot = PR_smprintf("%s%s%c%s",
+ prefix, LIBDIR, FILE_PATHSEP, cf->brand_ds);
temp = ds_a_get_cgi_var("sasl_path", NULL, NULL);
if (NULL != temp) {
/* if sasl_path is given, we set it in the conf file regardless of
diff --git a/ldap/admin/src/create_instance.h b/ldap/admin/src/create_instance.h
index 971da882..3616dc48 100644
--- a/ldap/admin/src/create_instance.h
+++ b/ldap/admin/src/create_instance.h
@@ -61,14 +61,23 @@ extern "C" { /* Assume C declarations for C++ */
#define PRODUCT_BIN "ns-slapd"
#define LOCALSTATEDIR "/var"
#define SYSCONFDIR "/etc"
+#if defined (IS_FHS)
+#define LIBDIR "/usr/lib"
#define BINDIR "/usr/bin"
#define DATADIR "/usr/share"
#define DOCDIR "/usr/doc"
-#else # Windows
+#else /* RPM */
+#define LIBDIR "/lib"
+#define BINDIR "/bin"
+#define DATADIR "/share"
+#define DOCDIR "/doc"
+#endif /* IS_FHS */
+#else /* Windows */
#define PRODUCT_NAME "slapd"
#define PRODUCT_BIN "slapd"
#define LOCALSTATEDIR "\\var"
#define SYSCONFDIR "\\etc"
+#define LIBDIR "\\usr\\lib"
#define BINDIR "\\usr\\bin"
#define DATADIR "\\usr\\share"
#define DOCDIR "\\usr\\doc"
diff --git a/ldap/admin/src/ds_newinst.pl.in b/ldap/admin/src/ds_newinst.pl.in
new file mode 100644
index 00000000..30840d83
--- /dev/null
+++ b/ldap/admin/src/ds_newinst.pl.in
@@ -0,0 +1,275 @@
+#!/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) 2005 Red Hat, Inc.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+use IPC::Open2;
+use Symbol;
+use CGI::Util qw(escape);
+use Cwd;
+use File::Basename;
+
+sub usage {
+ my $msg = shift;
+ print "Error: $msg\n";
+ print "Usage: $0 filename.inf\n";
+ exit 1
+}
+
+sub getCgiContentAndLength {
+ my $args = shift;
+ my $content = "";
+ my $firsttime = 1;
+ while (my ($kk, $vv) = each %{$args}) {
+ next if (!$kk || !$vv);
+ if ($firsttime) {
+ $firsttime = 0;
+ } else {
+ $content = $content . "&";
+ }
+ $content = $content . $kk . "=" . escape($vv);
+ }
+ my $length = length($content);
+
+ return ($content, $length);
+}
+
+# fakes out the ds_newinst program into thinking it is getting cgi input
+sub cgiFake {
+ my ($sroot, $verbose, $prog, $args) = @_;
+ # construct content string
+ my ($content, $length) = &getCgiContentAndLength($args);
+
+ # setup CGI environment
+ $ENV{REQUEST_METHOD} = "POST";
+ $ENV{CONTENT_LENGTH} = $length;
+ $ENV{SERVER_NAMES} = 'slapd-' . $args->{servid};
+
+# print "content = $content\n";
+
+ # open the program
+ my $curdir = getcwd();
+ my $dir = dirname($prog);
+ my $exe = basename($prog);
+ chdir $dir;
+ my $input = gensym();
+ my $output = gensym();
+ my $pid = open2($input, $output, "./$exe");
+ sleep(1); # allow prog to init stdin read buffers
+ print $output $content, "\n";
+ close $output;
+
+ if ($?) {
+ print "Warning: $prog returned code $? and $!\n";
+ }
+
+ my $exitCode = 1;
+ my @lines;
+ while (<$input>) {
+ print $_ if ($verbose);
+ push @lines, $_;
+ if (/^NMC_Status:\s*(\d+)/) {
+ $exitCode = $1;
+ last;
+ }
+ }
+ close $input;
+ chdir $curdir;
+
+ if ($exitCode) {
+ print "CGI $prog failed with $exitCode: here is the output:\n";
+ map { print $_ } @lines;
+ }
+
+ if ($exitCode != 0) {
+ print "Error: could not run $prog: $exitCode\n";
+ return $exitCode;
+ }
+
+ return 0;
+}
+
+sub addAndCheck {
+ my $dest = shift;
+ my $dkey = shift;
+ my $source = shift;
+ my $ssec = shift;
+ my $skey = shift;
+
+ if (! $source->{$ssec}->{$skey}) {
+ usage("Missing required parameter $ssec - $skey\n");
+ }
+
+ $dest->{$dkey} = $source->{$ssec}->{$skey};
+}
+
+my $filename = $ARGV[0];
+usage("$filename not found") if (! -f $filename);
+
+my $curSection;
+# each key in the table is a section name
+# the value is a hash ref of the items in that section
+# in that hash ref, each key is the config param name,
+# and the value is the config param value
+my %table = ();
+
+open(IN, $filename);
+while (<IN>) {
+ # e.g. [General]
+ if (/^\[(.*?)\]/) {
+ $curSection = $1;
+ } elsif (/^\s*$/) {
+ next; # skip blank lines
+ } elsif (/^\s*\#/) {
+ next; # skip comment lines
+ } elsif (/^\s*(.*?)\s*=\s*(.*?)\s*$/) {
+ $table{$curSection}->{$1} = $2;
+ }
+}
+close IN;
+
+#printhash (\%table);
+
+# next, construct a hash table with our arguments
+
+my %cgiargs = ();
+my $brand_ds = "fedora-ds";
+
+# the following items are always required
+addAndCheck(\%cgiargs, "sroot", \%table, "General", "ServerRoot");
+addAndCheck(\%cgiargs, "servname", \%table, "General", "FullMachineName");
+addAndCheck(\%cgiargs, "servuser", \%table, "General", "SuiteSpotUserID");
+addAndCheck(\%cgiargs, "servport", \%table, "slapd", "ServerPort");
+addAndCheck(\%cgiargs, "rootdn", \%table, "slapd", "RootDN");
+addAndCheck(\%cgiargs, "rootpw", \%table, "slapd", "RootDNPwd");
+addAndCheck(\%cgiargs, "servid", \%table, "slapd", "ServerIdentifier");
+addAndCheck(\%cgiargs, "suffix", \%table, "slapd", "Suffix");
+
+# the following items are optional
+
+$cgiargs{"lock_dir"} = $table{"slapd"}->{"lock_dir"};
+$cgiargs{"log_dir"} = $table{"slapd"}->{"log_dir"};
+$cgiargs{"run_dir"} = $table{"slapd"}->{"run_dir"};
+$cgiargs{"db_dir"} = $table{"slapd"}->{"db_dir"};
+$cgiargs{"bak_dir"} = $table{"slapd"}->{"bak_dir"};
+$cgiargs{"ldif_dir"} = $table{"slapd"}->{"ldif_dir"};
+$cgiargs{"tmp_dir"} = $table{"slapd"}->{"tmp_dir"};
+$cgiargs{"cert_dir"} = $table{"slapd"}->{"cert_dir"};
+$cgiargs{"localstatedir"} = $table{"slapd"}->{"localstatedir"};
+$cgiargs{"sysconfdir"} = $table{"slapd"}->{"sysconfdir"};
+$cgiargs{"bindir"} = $table{"slapd"}->{"bindir"};
+$cgiargs{"datadir"} = $table{"slapd"}->{"datadir"};
+$cgiargs{"docdir"} = $table{"slapd"}->{"docdir"};
+$cgiargs{"inst_dir"} = $table{"slapd"}->{"inst_dir"};
+$cgiargs{"config_dir"} = $table{"slapd"}->{"config_dir"};
+$cgiargs{"schema_dir"} = $table{"slapd"}->{"schema_dir"};
+$cgiargs{"sasl_path"} = $table{"slapd"}->{"sasl_path"};
+
+# port number for Admin Server - used to configure some web apps
+$cgiargs{adminport} = $table{admin}->{Port};
+
+# If this is set, the new DS instance will be set up for use as
+# a Configuration DS (e.g. o=NetscapeRoot)
+if ($table{slapd}->{SlapdConfigForMC} =~ /yes/i) {
+ $cgiargs{cfg_sspt} = "1";
+}
+# set this to 1 to register this DS with an existing Configuration DS
+# or 0 to create this DS as a new Configuration DS
+$cgiargs{use_existing_config_ds} = $table{slapd}->{UseExistingMC};
+# set this to 1 when creating a new Configuration DS if you do not
+# want to configure the new DS to also serve user data
+$cgiargs{use_existing_user_ds} = $table{slapd}->{UseExistingUG};
+
+# the following items are required to register this new instance with a config DS
+# or to make the new instance a Configuration DS
+if ($cgiargs{cfg_sspt} ||
+ $table{General}->{ConfigDirectoryAdminID} ||
+ $table{General}->{ConfigDirectoryAdminPwd} ||
+ $table{General}->{ConfigDirectoryLdapURL} ||
+ $table{General}->{AdminDomain}) {
+ addAndCheck(\%cgiargs, "cfg_sspt_uid", \%table, "General", "ConfigDirectoryAdminID");
+ addAndCheck(\%cgiargs, "cfg_sspt_uid_pw", \%table, "General", "ConfigDirectoryAdminPwd");
+ addAndCheck(\%cgiargs, "ldap_url", \%table, "General", "ConfigDirectoryLdapURL");
+ addAndCheck(\%cgiargs, "admin_domain", \%table, "General", "AdminDomain");
+}
+
+#
+if ($table{General}->{UserDirectoryLdapURL}) {
+ $cgiargs{user_ldap_url} = $table{General}->{UserDirectoryLdapURL};
+} else {
+ $cgiargs{user_ldap_url} = $cgiargs{ldap_url};
+}
+
+if ($table{General}->{prefix}) {
+ $prefix = $table{General}->{prefix};
+}
+$cgiargs{prefix} = $prefix;
+
+if ($table{General}->{BrandDs}) {
+ $brand_ds = $table{General}->{BrandDs};
+}
+
+# populate the DS with this file - the suffix in this file must
+# be the suffix specified in the suffix argument above
+# the filename should use the full absolute path
+$cgiargs{install_ldif_file} = $table{slapd}->{InstallLdifFile};
+
+# if for some reason you do not want the server started after instance creation
+# the following line can be commented out - NOTE that if you are creating the
+# Configuration DS, it will be started anyway
+$cgiargs{start_server} = 1;
+
+my $sroot = $cgiargs{sroot};
+
+my $rc = &cgiFake($sroot, $verbose,
+ "@libdir@/$brand_ds/ds_newinst",
+ \%cgiargs);
+
+if (!$rc) {
+ print "Success! Your new directory server instance was created\n";
+} else {
+ print "Error: Could not create new directory server instance\n";
+}
+
+sub printhash {
+ my $table = shift;
+
+ while (my ($key,$val) = each %{$table}) {
+ print "[$key]\n";
+ while (my ($k2,$v2) = each %{$val}) {
+ print "$k2 = $v2\n";
+ }
+ }
+}