diff options
author | cvsadm <cvsadm> | 2005-01-21 00:44:34 +0000 |
---|---|---|
committer | cvsadm <cvsadm> | 2005-01-21 00:44:34 +0000 |
commit | b2093e3016027d6b5cf06b3f91f30769bfc099e2 (patch) | |
tree | cf58939393a9032182c4fbc4441164a9456e82f8 /ldap/cm/newinst | |
download | ds-b2093e3016027d6b5cf06b3f91f30769bfc099e2.tar.gz ds-b2093e3016027d6b5cf06b3f91f30769bfc099e2.tar.xz ds-b2093e3016027d6b5cf06b3f91f30769bfc099e2.zip |
Moving NSCP Directory Server from DirectoryBranch to TRUNK, initial drop. (foxworth)ldapserver7x
Diffstat (limited to 'ldap/cm/newinst')
-rw-r--r-- | ldap/cm/newinst/Makefile | 159 | ||||
-rw-r--r-- | ldap/cm/newinst/fixINF.pl | 50 | ||||
-rwxr-xr-x | ldap/cm/newinst/ns-keygen | 168 | ||||
-rwxr-xr-x | ldap/cm/newinst/ns-update | 135 | ||||
-rw-r--r-- | ldap/cm/newinst/replaceToken.pl | 34 | ||||
-rwxr-xr-x | ldap/cm/newinst/setup.pl | 141 | ||||
-rwxr-xr-x | ldap/cm/newinst/setup.sh | 10 | ||||
-rw-r--r-- | ldap/cm/newinst/slapd.inf | 48 | ||||
-rwxr-xr-x | ldap/cm/newinst/uninstall | 75 | ||||
-rw-r--r-- | ldap/cm/newinst/ux-config.cc | 1151 | ||||
-rw-r--r-- | ldap/cm/newinst/ux-config.h | 172 | ||||
-rw-r--r-- | ldap/cm/newinst/ux-dialog.cc | 4332 | ||||
-rw-r--r-- | ldap/cm/newinst/ux-dialog.h | 69 | ||||
-rw-r--r-- | ldap/cm/newinst/ux-dsalib_dn.c | 13 | ||||
-rw-r--r-- | ldap/cm/newinst/ux-guesses.cc | 125 |
15 files changed, 6682 insertions, 0 deletions
diff --git a/ldap/cm/newinst/Makefile b/ldap/cm/newinst/Makefile new file mode 100644 index 00000000..9fa0867e --- /dev/null +++ b/ldap/cm/newinst/Makefile @@ -0,0 +1,159 @@ +# +# BEGIN COPYRIGHT BLOCK +# Copyright 2001 Sun Microsystems, Inc. +# Portions copyright 1999, 2001-2003 Netscape Communications Corporation. +# All rights reserved. +# END COPYRIGHT BLOCK +# +# Source for the install forms and CGI programs + +.SUFFIXES: .cc + +# We do this to force a 32-bit build of this stuff, even in a 64-bit build +# (because we want to avoid various complexities inherenet in having a 64-bit +# installer rubbing shoulders with other 32-bit stuff at install time). +COMPONENT_DEPS := 1 +override USE_64= + +MCOM_ROOT = ../../../.. +LDAP_SRC = ../.. + +MODULE=slapdInstallBin +# override BUILD_MODULE = HTTP_ADMIN + +include $(MCOM_ROOT)/ldapserver/nsconfig.mk +include $(LDAP_SRC)/nsldap.mk + +test: + echo $(SETUPSDK_VERSION) + echo $(SETUPSDK_RELEASE) + +# MODULE_CFLAGS = -DUSE_ADMSERV + +BINDEST=$(LDAP_ADMIN_BIN_RELDIR) +OBJDEST=$(LDAP_ADMOBJDIR) + +ifndef $(OFFLAG) +OFFLAG=-o +endif + +# we don't want to build with warnings-as-errors for the cm/ stuff, because +# it's crappy C++ code which is LITTERED with warnings, most of which we +# can't fix because it comes from files in dist/, etc. +ifeq ($(ARCH), Linux) +CFLAGS := $(subst -Werror,,$(CFLAGS)) +endif + +NOSTDCLEAN=true +NOSTDSTRIP=true + +OSOBJS= +OBJS1=$(OBJDEST)/ux-dialog.o $(OBJDEST)/ux-config.o $(OBJDEST)/ux-dsalib_dn.o +OBJS1GT=$(OBJDEST)/ux-guesses.o + +PROGS= ns-config +ifeq ($(ARCH),WINNT) +BINS= +OSOBJS= +OBJS1= +OBJS2= +OSLIBS= +OSDEPLIBS= +LIBS= +else +BINS=$(addprefix $(BINDEST)/, $(PROGS)) +endif +INFO= $(OBJDIR)/$(DIR) + +# Source for staged installation utilities +INCDIR=$(SETUPSDK_INCLUDE) -I$(LDAP_SRC)/admin/include -I$(LDAP_SRC)/admin/lib -I$(LDAP_SRC)/admin/src + +# ADM_VERSDIR = admserv40 +# ADM_RELDATE = 19980112 + +all: $(OBJDEST) $(BINDEST) $(SETUPSDK_DEP) $(LDAPSDK_DEP) $(SECURITY_DEP) $(NSPR_DEP) $(OSOBJS) $(OBJS1) $(OBJS2) $(BINS) $(INFO) $(BINDEST)/ns-update $(BINDEST)/uninstall +# removed ns-keygen from build - it was only used for Dir Lite +# $(BINDEST)/ns-keygen +ifeq ($(ARCH), BSDI) +CFLAGS += -DNO_DOMAINNAME +endif + +ifeq ($(ARCH), IRIX) +CFLAGS += -exceptions +EXTRA_LIBS += -lm -lc +endif + +ifeq ($(ARCH), OSF1) +EXTRA_LIBS += -lm +endif + +#LIBLDAPU= ldapu +#LIBLDAP= $(LDAP_LIBPATH)/libldap$(LDAP_SUF).a +#DEPLIBS=$(addprefix $(OBJDIR)/lib/lib, \ +# $(addsuffix .$(LIB_SUFFIX), $(LIBLDAPU))) $(OSDEPLIBS) + +ifeq ($(ARCH), HPUX) + +ifeq ($(NSOS_RELEASE),B.10.10) +CURSES=-lHcurses +endif + +ifeq ($(NSOS_RELEASE),B.11.00) + MODERNHP=1 +endif + +ifeq ($(NSOS_RELEASE),B.11.11) + MODERNHP=1 +endif + +ifeq ($(MODERNHP),1) +CURSES=-lHcurses +else +CURSES=/usr/lib/libcurses.a +endif +ifeq ($(USE_64), 1) +CURSES=-lcurses +endif +else +CURSES=-lcurses -ltermcap +endif + +ifeq ($(ARCH), AIX) +CURSES=-lcurses +endif + +$(BINDEST)/ns-update : ns-update + -@$(RM) $@ + $(CP) $< $@ + +$(BINDEST)/ns-keygen: ns-keygen + -@$(RM) $@ + $(CP) $< $@ + +$(BINDEST)/uninstall: uninstall + -@$(RM) $@ + $(CP) $< $@ + +$(BINDEST)/ns-config: $(OBJS1) $(OBJS2) + $(PURIFY) $(CXX) $(SHARED_FLAG) $(CFLAGS) $(MCC_INCLUDE) $(INCDIR) \ + -o $(BINDEST)/ns-config $(RPATHFLAG_PREFIX)$(RPATHFLAG)$(RPATHFLAG_EXTRAS) $(OBJS1) $(OBJS2) $(SETUPSDKLINK) $(LDAPLINK) $(SECURITYLINK) $(NSPRLINK) \ + $(EXTRA_LIBS) $(CURSES) + +ifeq ($(ARCH), WINNT) +$(INFO): + $(PERL) fixINF.pl $(BUILD_MODULE) $(DIR_VERSION) $(MCOM_ROOT)/ldapserver/$(BUILD_ARCH)/buildnum.dat slapd.inf $(SECURITY) $(PRODUCT) $(IS_DIR_LITE) $(INSTANCE_NAME_PREFIX) $@.inf $(BUILD_BOMB) "bin/admin/ns-admin,bin/admin/ns-admin.so" +else +$(INFO): + $(PERL) fixINF.pl $(BUILD_MODULE) $(DIR_VERSION) $(MCOM_ROOT)/ldapserver/$(BUILD_ARCH)/buildnum.dat slapd.inf $(SECURITY) $(PRODUCT) $(IS_DIR_LITE) $(INSTANCE_NAME_PREFIX) $@.inf $(BUILD_BOMB) "$(addprefix lib/,$(LDAP_SOLIBS)) bin/admin/libnsslapd.sl bin/slapd/bin/ns-slapd bin/slapd/bin/ns-slapd.so bin/slapd/bin/libnsslapd_shr.a" +endif + +$(OBJDEST)/%.o: %.c + $(CC) $(NONSHARED) $(CFLAGS) $(MCC_INCLUDE) $(INCDIR) -c $< $(OFFLAG)$@ + +$(OBJDEST)/%.o: %.cc + $(CXX) $(NONSHARED) $(CFLAGS) $(MCC_INCLUDE) $(INCDIR) -c $< $(OFFLAG)$@ + +ns-config-gt: $(OBJS1GT) + $(PURIFY) $(CXX) $(NONSHARED) $(CFLAGS) $(MCC_INCLUDE) $(INCDIR) \ + -o ns-config-gt $(OBJS1GT) $(SETUPSDKLINK) $(LIBLDAP) \ + $(EXTRA_LIBS) $(CURSES) diff --git a/ldap/cm/newinst/fixINF.pl b/ldap/cm/newinst/fixINF.pl new file mode 100644 index 00000000..0861a9b9 --- /dev/null +++ b/ldap/cm/newinst/fixINF.pl @@ -0,0 +1,50 @@ +# +# BEGIN COPYRIGHT BLOCK +# Copyright 2001 Sun Microsystems, Inc. +# Portions copyright 1999, 2001-2003 Netscape Communications Corporation. +# All rights reserved. +# END COPYRIGHT BLOCK +# +# parameters: BUILD_MODULE versionString buildnum.dat input security name isdirLite output [expDefine] + +$module = shift; +$version = shift; +$buildFile = shift; +$input = shift; +$security = shift; +$name = shift; +$isdirLite = shift; +$instanceNamePrefix = shift; +$output = shift; +$expDefine = shift; +if ($expDefine) { + ( $junk, $expires ) = split( /=/, $expDefine ); + if ( ! $expires ) { + $expires = 0; + } +} else { + $expires = 0; +} + +# get the build number +open( FILE, $buildFile ); +while ( <FILE> ) { + last if ( $buildNum ) = /\\"(.*)\\"/; +} +close( FILE ); + +# copy the input file to the output file changing stuff along the way +open( FILE, $input ); +open( OUT, ">$output" ); +while ( <FILE> ) { + s/%%%INSTANCE_NAME_PREFIX%%%/$instanceNamePrefix/; + s/%%%SERVER_NAME%%%/$name/; + s/%%%SERVER_VERSION%%%/$version/; + s/%%%SERVER_BUILD_NUM%%%/$buildNum/; + s/%%%PUMPKIN_HOUR%%%/$expires/; + s/%%%SECURITY%%%/$security/; + s/%%%IS_DIR_LITE%%%/$isdirLite/; + print OUT; +} +close( OUT ); +close( FILE ); diff --git a/ldap/cm/newinst/ns-keygen b/ldap/cm/newinst/ns-keygen new file mode 100755 index 00000000..599c8e2f --- /dev/null +++ b/ldap/cm/newinst/ns-keygen @@ -0,0 +1,168 @@ +#!/bin/sh +# +# BEGIN COPYRIGHT BLOCK +# Copyright 2001 Sun Microsystems, Inc. +# Portions copyright 1999, 2001-2003 Netscape Communications Corporation. +# All rights reserved. +# END COPYRIGHT BLOCK +# +# +# Usage ns-keygen password_file fully_qualified_hostname +# Example: +# ./ns-keygen ../password.txt myhost.netscape.com +# +# Assumes that NSHOME is Set +# if NSHOME is not set, it will be derived from the path of this script, which is +# usually NSHOME/bin/slapd/admin/bin + +if [ $# -ge 2 ] +then + passwd_file="$1" + certDN="$2" +else + echo "ERROR:Incorrect Usage: $0 password_file certDN" + exit +fi + +if [ ! "$NSHOME" ]; then + fullpath=`pwd` + if echo $0 | grep \^/ > /dev/null 2>&1 ; then # is absolute + fullpath=`dirname $0` + else # is a relative path - could be ./ or ../ or something else + base=`basename $0` + if [ "$base" != $0 ]; then # e.g. ns-keygen bare from that directory + savedir=$fullpath + cd `dirname $0` + fullpath=`pwd` + cd $savedir + fi + fi + # is $0 relative or absolute path? + NSHOME=`echo $fullpath | sed -e s@/bin/slapd/admin/bin@@g` +fi + +# set the LD_LIBRARY_PATH - required for the cert tools +TOOL_PATH=$NSHOME/bin/slapd/admin/bin ; export TOOL_PATH +# for HPUX +SHLIB_PATH=$TOOL_PATH:$TOOL_PATH/../lib:$TOOL_PATH/../../lib:$TOOL_PATH/../../../lib:$TOOL_PATH/../../../../lib:$SHLIB_PATH ; export SHLIB_PATH +# for other unix +LD_LIBRARY_PATH=$TOOL_PATH:$TOOL_PATH/../lib:$TOOL_PATH/../../lib:$TOOL_PATH/../../../lib:$TOOL_PATH/../../../../lib:$LD_LIBRARY_PATH ; export LD_LIBRARY_PATH + +#echo password file name is: $passwd_file +#echo certDN is: $certDN + +rm -f key3.db key4.db cert7.db cert8.db secmodule.db secmod.db random.dat keyid.dat + +# Check for password file + +# +# Set umask for best security +# +umask 077 + +# +# Create some "random" data. +# +ps -ale >>random.dat +date >>random.dat +netstat -a >>random.dat + +if [ ! -s "$passwd_file" ] +then + echo "Error:Password file is missing." + exit 1 +fi + +# +# Set the key database password +# +$TOOL_PATH/certutil -W -d . -f "$passwd_file" +RC=$? +if [ $RC != 0 ] +then + echo "Error:Unable to set the key database password." + exit 1 +fi + +# +# Create and sign a self-signed certificate for this +# server using the server name +# +$TOOL_PATH/certutil -S -s "$certDN" -x -t u,, \ + -v 60 -d . -n Server-Cert -f "$passwd_file" -z random.dat +RC=$? +if [ $RC != 0 ] +then + echo "Error:Unable to create the cert." + exit 1 +fi + +hostname=`uname -n` + +# +# Copy the key/cert db & password file to the correct place. +# +keydb=key3.db +if [ -f key4.db ] ; then + keydb=key4.db +fi + +if [ -f $NSHOME/alias/slapd-$hostname-$keydb ]; then + echo "Found existing key database - copying to $NSHOME/alias/slapd-$hostname-$keydb.bak" + cp $NSHOME/alias/slapd-$hostname-$keydb $NSHOME/alias/slapd-$hostname-$keydb.bak + if [ ! -f $NSHOME/alias/slapd-$hostname-$keydb.orig ] ; then + cp $NSHOME/alias/slapd-$hostname-$keydb $NSHOME/alias/slapd-$hostname-$keydb.orig + fi +fi +cp $keydb $NSHOME/alias/slapd-$hostname-$keydb +RC=$? +if [ $RC != 0 ] +then + echo "Error:Key Database $keydb could not be copied" + exit 1 +fi + +certdb=cert7.db +if [ -f cert8.db ] ; then + certdb=cert8.db +fi +if [ -f $NSHOME/alias/slapd-$hostname-$certdb ]; then + echo "Found existing cert database - copying to $NSHOME/alias/slapd-$hostname-$certdb.bak" + cp $NSHOME/alias/slapd-$hostname-$certdb $NSHOME/alias/slapd-$hostname-$certdb.bak + if [ ! -f $NSHOME/alias/slapd-$hostname-$certdb.orig ] ; then + cp $NSHOME/alias/slapd-$hostname-$certdb $NSHOME/alias/slapd-$hostname-$certdb.orig + fi +fi +cp $certdb $NSHOME/alias/slapd-$hostname-$certdb +RC=$? +if [ $RC != 0 ] +then + echo "Error:Cert Database $certdb could not be copied" + exit 1 +fi + +# create and copy pin file +passwd=`cat $passwd_file` +if [ -f $NSHOME/alias/slapd-$hostname-pin.txt ]; then + echo "Found existing pin file - copying to $NSHOME/alias/slapd-$hostname-pin.txt.bak" + cp $NSHOME/alias/slapd-$hostname-pin.txt $NSHOME/alias/slapd-$hostname-pin.txt.bak + if [ ! -f $NSHOME/alias/slapd-$hostname-pin.txt.orig ]; then + cp $NSHOME/alias/slapd-$hostname-pin.txt $NSHOME/alias/slapd-$hostname-pin.txt.orig + fi +fi +echo "Internal (Software) Token:$passwd" > $NSHOME/alias/slapd-$hostname-pin.txt +RC=$? +if [ $RC != 0 ] +then + echo "Error:password file could not be copied" + exit 1 +fi +# Test the new location for the files. + +# +# Cleanup +rm -f random.dat + +# +# End +# diff --git a/ldap/cm/newinst/ns-update b/ldap/cm/newinst/ns-update new file mode 100755 index 00000000..a4c86788 --- /dev/null +++ b/ldap/cm/newinst/ns-update @@ -0,0 +1,135 @@ +#!/bin/sh +# +# BEGIN COPYRIGHT BLOCK +# Copyright 2001 Sun Microsystems, Inc. +# Portions copyright 1999, 2001-2003 Netscape Communications Corporation. +# All rights reserved. +# END COPYRIGHT BLOCK +# +# This file essentially serves as a wrapper around the instance +# creation and configuration program (index) since it must be run from +# the directory it lives in due to run time shared library +# dependencies + +sroot=`echo $0 | sed s#/bin/slapd/admin/bin/.\*##g` +PERL=$sroot/bin/slapd/admin/bin/perl + +start_server() +{ + NETSITE_ROOT=$1 + REQUEST_METHOD=GET + export NETSITE_ROOT REQUEST_METHOD + QUERY_STRING="InstanceName=$2" + SERVER_NAMES=$2 + export QUERY_STRING SERVER_NAMES + cwd=`pwd` + cd `dirname $0` + ./start 2>&1 | grep -v '^Content' | grep -v '^ds_' + cd $cwd +} + +install_nsperl() +{ + # the current version of nsPerl to use is defined in the slapd.inf + nsperlinst=`grep '^NSPerlPostInstall' setup/slapd/slapd.inf | cut -f2 -d=` + # run the nsperl installer + $nsperlinst > setup/nsperl/install.log + # use nsperl as our local copy of perl + cp `dirname $nsperlinst`/nsperl $PERL +} + +wrap_security_tools() +{ + cwd=`pwd` + SECURITY_BINNAMES="certutil derdump modutil pk12util pp ssltap" + arch=`uname` + if [ $arch = HP-UX ]; then + env_ld_library_path=SHLIB_PATH + elif [ $arch = AIX ]; then + env_ld_library_path=LIBPATH + else + env_ld_library_path=LD_LIBRARY_PATH + fi + cd $sroot/shared/bin + for file in $SECURITY_BINNAMES + do + if [ -f $file -a ! -f $file-bin ]; then + mv $file $file-bin + echo "#!/bin/sh" > $file + echo $env_ld_library_path=$sroot/shared/lib >> $file + echo "export $env_ld_library_path" >> $file + echo "$sroot/shared/bin/$file-bin " '${1+"$@"}' >> $file + chmod 755 $file + fi + done + cd $cwd +} + +# if the -r flag is present, this means we're doing a +# reinstall or an upgrade, so restart the servers +for arg in $* ; do + if [ "$arg" = "-r" ]; then + reconfig=1 + fi + if [ "$arg" = "-S" ]; then + iDSISolaris=1 + fi + +done + +extraflags= +# For Solaris 9+ specific installation, the following +# method of determining reconfiguration by checking +# the existence of <sroot>/slapd-nickname/config +# directory cannot be used. This is because the +# server_root is the same for all instances. Also, it +# uses standard Solaris supplied perl. +if [ "$iDSISolaris" = "" ]; then + # for some reason, we are not being passed the -r flag during + # reinstall; so, determine if there are existing server + # instances in this server root, and assume -r if there + # are + if [ "$reconfig" = "" ]; then + cd $sroot + for dir in slapd-* ; do + if [ -d $dir/config ]; then + reconfig=1 + extraflags="-r" + break + fi + done + fi + + install_nsperl +fi + +if [ $reconfig ] ; then + cd $sroot + for dir in slapd-* ; do + # first, fix any old password files + if [ -d alias ]; then + cd alias + echo Converting $dir to new format password file . . . + $PERL $sroot/bin/slapd/admin/bin/migratePwdFile $sroot $dir + cd .. + fi + # Copy new schema ldiffiles + echo Copying new schema ldiffiles . . . + $PERL $sroot/bin/slapd/admin/bin/upgradeServer $sroot $dir + + # next, start the server + echo Starting $dir . . . + start_server $sroot $dir + echo "" + done +fi + +wrap_security_tools $sroot + +cd `dirname $0` + +if [ "$iDSISolaris" = "" ]; then + exec ./ds_create $* $extraflags +else + exec $PERL -w Install.pl $* $extraflags +fi diff --git a/ldap/cm/newinst/replaceToken.pl b/ldap/cm/newinst/replaceToken.pl new file mode 100644 index 00000000..13265efe --- /dev/null +++ b/ldap/cm/newinst/replaceToken.pl @@ -0,0 +1,34 @@ +# +# BEGIN COPYRIGHT BLOCK +# Copyright 2001 Sun Microsystems, Inc. +# Portions copyright 1999, 2001-2003 Netscape Communications Corporation. +# All rights reserved. +# END COPYRIGHT BLOCK +# + +# The first argument is the file to edit +# The remaining arguments are pairs of values: the first value of the pair is +# the token to look for, and the second is the value to replace it with e.g. +# if the input file foo contains +# $NETSITE_ROOT/%%%PERL_RUNTIME%%% -w perlscript ... +# then running $(PERL) thisscript foo %%%PERL_RUNTIME%%% foo/bar/perl5 > output/foo +# will result in output/foo containing +# NETSITE_ROOT/foo/bar/perl5 -w perlscript ... + +($input, %tokens) = @ARGV; + +if (! $input) { + print STDERR "Usage: $ $0 <inputfilename> [token1 replace1] ... [tokenN replaceN]\n"; + exit 1; +} + +open(INPUT, $input) or die "Error: could not open file $input: $!"; + +while (<INPUT>) { + while (($key, $value) = each %tokens) { + s/$key/$value/g; + } + print; +} + +close INPUT; diff --git a/ldap/cm/newinst/setup.pl b/ldap/cm/newinst/setup.pl new file mode 100755 index 00000000..f5c95b65 --- /dev/null +++ b/ldap/cm/newinst/setup.pl @@ -0,0 +1,141 @@ +#!./tools/perl +# Author: Nathan Kinder +# +# This program will package a downloaded JRE into a nsjre.zip +# file suitable for a DS install. + +use lib './lib'; +use FileHandle; + +autoflush STDERR 1; +autoflush STDOUT 1; + +delete $ENV{LD_LIBRARY_PATH}; + +# Set required JRE version +if ($^O eq "hpux") { + $jdkVersion = "HP's 32-bit HP-UX"; + $reqVersion = "1.4.2.04"; + delete $ENV{SHLIB_PATH}; +} elsif ($^O eq "MSWin32") { + $jdkVersion = "Sun's 32-bit MS Windows"; + $reqVersion = "1.4.2_05"; +} elsif ($^O eq "linux") { + $jdkVersion = "Sun's 32-bit Linux"; + $reqVersion = "1.4.2_05"; +} elsif ($^O eq "solaris") { + $jdkVersion = "Sun's 32-bit Solaris"; + $reqVersion = "1.4.2_05"; +} else { + print("Unsupported operating system: $^O!\n"); + exit; +} + +# Check if base/nsjre.zip or base/jre.z already exists +unless (-e "./base/nsjre.zip" || -e "./base/jre.z") { + # Check if NSJRE environment variable is set + if ($ENV{NSJRE}) { + chomp ($jrepath = $ENV{NSJRE}); + print ("Using NSJRE environment variable: $jrepath\n"); + } else { + print ("In order to run setup, you need to have version"); + print (" $reqVersion of\n"); + print ("$jdkVersion Java runtime environment on your system.\n\n"); + print ("Enter the path to the unpackaged JRE: "); + chomp ($jrepath = <STDIN>); + } + + VerifyJRE(); + CreatePackage(); + CleanUp(); +} + +# Kick off setup +exec("./dssetup @ARGV"); + +sub VerifyJRE { + print ("\nVerifying JRE..."); + unless (-e "$jrepath" && -r "$jrepath") { die ("\nError: Can't access JRE: $!\n"); } + unless (-e "$jrepath/bin" && -r "$jrepath/bin") { die ("\nError: Can't access $jrepath/bin: $!\n"); } + unless (-e "$jrepath/bin" && -r "$jrepath/lib") { die ("\nError: Can't access $jrepath/lib: $!\n"); } + unless (-e "$jrepath/bin/java" || -e "$jrepath/bin/java.exe") { die ("\nError: Invalid JRE found: $!\n"); } + + my $jreVersion = `\"$jrepath/bin/java\" -version 2>&1`; + $jreVersion =~ /".*"/; + $foundVersion = $&; + print (" Found JRE $foundVersion\n"); + unless ($foundVersion =~ $reqVersion) { + print ("\nWarning: This product was certified with JRE version \"$reqVersion\". You have version $foundVersion.\n"); + print ("The product may not behave correctly if you use this JRE.\n"); + print ("Would you like to continue anyway [yes/no]? "); + chomp ($answer = <STDIN>); + unless ($answer eq "yes") { exit; } + } +} + +sub CreatePackage { + print ("Creating JRE package..."); + + # Create packaging area + mkdir ("bin", 0755) || die ("Error: Can't create ./bin: $!\n"); + mkdir ("bin/base", 0755) || die ("Error: Can't create ./bin/base: $!\n"); + mkdir ("bin/base/jre", 0755) || die ("Error: Can't create ./bin/base/jre: $!\n"); + + # Copy bin and lib from JRE into packaging area, then create zip archive + if ($^O eq "MSWin32") { + system ("xcopy /E /I /Q \"$jrepath/bin\" \"bin/base/jre/bin\"") == 0 || + die ("\nError: Can't copy JRE: $!\n"); + system ("xcopy /E /I /Q \"$jrepath/lib\" \"bin/base/jre/lib\"") == 0 || + die ("\nError: Can't copy JRE: $!\n"); + system ("./tools/zip -q -r ./base/jre.z ./bin") == 0 || + die ("\nError: Can't create JRE archive: $!\n"); + } else { + system ("cp -R $jrepath/bin ./bin/base/jre") == 0 || + die ("\nError: Can't copy JRE: $!\n"); + system ("cp -R $jrepath/lib ./bin/base/jre") == 0 || + die ("\nError: Can't copy JRE: $!\n"); + + # On HP-UX, we need to move some libraries in the JRE package + if ($^O eq "hpux") { + system ("cp -f ./bin/base/jre/lib/PA_RISC/native_threads/libhpi.sl ./bin/base/jre/lib/PA_RISC/libhpi.sl") == 0 || + die ("\nError: Can't create JRE archive: $!\n"); + system ("cp -f ./bin/base/jre/lib/PA_RISC2.0/native_threads/libhpi.sl ./bin/base/jre/lib/PA_RISC2.0/libhpi.sl") == 0 || + die ("\nError: Can't create JRE archive: $!\n"); + system ("cp -f ./bin/base/jre/lib/PA_RISC2.0W/native_threads/libhpi.sl ./bin/base/jre/lib/PA_RISC2.0W/libhpi.sl") == 0 || + die ("\nError: Can't create JRE archive: $!\n"); + } + + system ("./tools/zip -q -r ./base/nsjre.zip ./bin") == 0 || + die ("\nError: Can't create JRE archive: $!\n"); + } + + print (" Done\n"); +} + +sub CleanUp { + print ("Cleaning up..."); + + # Remove packaging area + RemoveFiles ("./bin"); + rmdir ("./bin") || die ("Error: can't remove ./bin: $!\n"); + + print (" Done\n"); +} + +sub RemoveFiles { + my $dir = shift; + opendir (DIR, $dir) || die ("Error: Can't open $dir: $!"); + my @entries = map { "$dir/$_" } grep { !/^\.$|^\.\.$/ } readdir DIR; + closedir DIR; + for (@entries) { + if (-l $_) { + unlink || die ("Error: Can't remove $_: $!\n"); + } elsif (-d $_) { + RemoveFiles($_); + rmdir($_) || die ("Error: Can't remove $_: $!\n"); + } else { + unlink || die ("Error: Can't remove $_: $!\n"); + } + } +} + diff --git a/ldap/cm/newinst/setup.sh b/ldap/cm/newinst/setup.sh new file mode 100755 index 00000000..a4059e94 --- /dev/null +++ b/ldap/cm/newinst/setup.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# Configure nsPerl +if [ ! -f "./tools/perl" ]; then + ./tools/nsPerl5.6.1/install > /dev/null + ln -s ./nsPerl5.6.1/nsperl ./tools/perl +fi + +# Kick off setup script +./setup.pl $* diff --git a/ldap/cm/newinst/slapd.inf b/ldap/cm/newinst/slapd.inf new file mode 100644 index 00000000..50ccb706 --- /dev/null +++ b/ldap/cm/newinst/slapd.inf @@ -0,0 +1,48 @@ +# +# BEGIN COPYRIGHT BLOCK +# Copyright 2001 Sun Microsystems, Inc. +# Portions copyright 1999, 2001-2003 Netscape Communications Corporation. +# All rights reserved. +# END COPYRIGHT BLOCK +# +[General] +Name=Netscape Directory Suite +Components=slapd, slapd-client + +[slapd] +Name= %%%SERVER_NAME%%% +InstanceNamePrefix= %%%INSTANCE_NAME_PREFIX%%% +NickName= slapd +Version= %%%SERVER_VERSION%%% +Compatible= 4.0 +BuildNumber= %%%SERVER_BUILD_NUM%%% +Expires= %%%PUMPKIN_HOUR%%% +Security= %%%SECURITY%%% +Vendor= Netscape Communications Corp. +Description= %%%SERVER_NAME%%% +Dependencies= base/4.5, svrcore/4.5, nsperl561/1.13, perldap14/1.01 +ProductName=Directory Server +IsDirLite=%%%IS_DIR_LITE%%% +SourcePath=slapd +Archive= nsslapd.zip +PrePreInstall= dsktune +PreInstall= ns-config +PostInstall= bin/slapd/admin/bin/ns-update +PreUninstall= bin/slapd/admin/bin/uninstall +PostUninstall= +Checked=True +Mandatory=False +IsLdap=True +NSPerlPostInstall=lib/nsPerl5.6.1/install + +[slapd-client] +Name= Netscape Directory Server Console +NickName= slapd-client +Version= %%%SERVER_VERSION%%% +Compatible= 4.0 +Checked=True +Mandatory=False +IsLdap=False +SourcePath=slapd +IsMCC=True +Archive=slapd-client.zip diff --git a/ldap/cm/newinst/uninstall b/ldap/cm/newinst/uninstall new file mode 100755 index 00000000..cdcc2491 --- /dev/null +++ b/ldap/cm/newinst/uninstall @@ -0,0 +1,75 @@ +#!/bin/sh +# +# BEGIN COPYRIGHT BLOCK +# Copyright 2001 Sun Microsystems, Inc. +# Portions copyright 1999, 2001-2003 Netscape Communications Corporation. +# All rights reserved. +# END COPYRIGHT BLOCK +# + +# determine server root directory from $0; this script is being run +# from server root/bin/slapd/admin/bin + +sroot=`echo $0 | sed 's#/bin/slapd/admin/bin/.*##g'` + +# check if Solaris 9+ specific un-installation +for arg in $* ; do + if [ "$arg" = "-S" ]; then + iDSISolaris=1 + fi +done + +if [ "$iDSISolaris" = "1" ]; then + vardir=`echo $sroot | sed 's#/usr/iplanet/#/var/#'` + etcdir=`echo $sroot | sed 's#/usr/#/etc/#'` +fi + +# search for all slapd-* directories + +cd $sroot || { + echo "Could not change dir to server root directory $sroot" + exit 1 +} + +NETSITE_ROOT=$sroot +REQUEST_METHOD=GET +export NETSITE_ROOT REQUEST_METHOD +# for each server instance +for dir in slapd-* ; do + QUERY_STRING="InstanceName=$dir" + SERVER_NAMES=$dir + export QUERY_STRING SERVER_NAMES + # try to remove the nice way . . . + cd bin/slapd/admin/bin + status=0 + ./ds_remove $* > /dev/null 2>&1 || status=$? + cd $sroot + # wait for that to finish + sleep 2 + if [ $status -ne 0 -o -d $dir ]; then + # something went wrong; kill with extreme prejudice . . . + # Solaris 9+ specific un-installation + if [ -f $dir/logs/pid ]; then + pid=`cat $dir/logs/pid` + # kill the server + kill -9 $pid > /dev/null 2>&1 + # wait for it to stop + sleep 2 + fi + # remove the instance directory + rm -rf $dir + fi + # Solaris 9+ specific un-installation + if [ "$iDSISolaris" = "1" ]; then + rm -rf $etcdir/$dir + rm -rf $vardir/$dir + fi + +done + +# remove some other stuff which is dynamically created +if [ "$iDSISolaris" = "" ]; then + rm -rf bin/slapd +fi + +exit 0 diff --git a/ldap/cm/newinst/ux-config.cc b/ldap/cm/newinst/ux-config.cc new file mode 100644 index 00000000..64f936f2 --- /dev/null +++ b/ldap/cm/newinst/ux-config.cc @@ -0,0 +1,1151 @@ +/** BEGIN COPYRIGHT BLOCK + * Copyright 2001 Sun Microsystems, Inc. + * Portions copyright 1999, 2001-2003 Netscape Communications Corporation. + * All rights reserved. + * END COPYRIGHT BLOCK **/ +/********************************************************************* +** +** NAME: +** ux-config.cc +** +** DESCRIPTION: +** Netscape Directory Server Pre-installation Program +** +** NOTES: +** This program is intended for UNIX only and is NOT thread-safe. +** Based on the original ux-config.c. +** +*********************************************************************/ + +extern "C" { +#include <stdio.h> +#include <string.h> +#ifdef AIX +#include <strings.h> +#endif +} +/* Newer g++ wants the new std header forms */ +#if defined( Linux ) +#include <strstream> +using std::ostrstream; +/* But some platforms won't accept those (specifically HP-UX aCC */ +#else +#include <strstream.h> +#endif +#include "dialog.h" +#include "ux-config.h" +#include "ux-dialog.h" +#include "install_keywords.h" +#include "utf8.h" +extern "C" { +#include <dsalib.h> + +#if defined(__sun) || defined(__hppa) || defined(__osf__) || defined(__linux__) || defined(linux) +#include <netdb.h> +#endif +} + +extern const char *DEFAULT_SYSUSER = "root"; +extern const char *DEFAULT_OLDROOT = "/usr/ns-home"; +static const char *DEFAULT_SLAPDCONF = "slapd.conf"; + +const int RECONFIG_EXIT_CODE = 7; + +/* + * iDSISolaris is set to 1 for Solaris 9+ specific installation. + * This can be done by passing -S as the command line argument. + */ +int iDSISolaris = 0; + +static int +isLiteMode() +{ + int ret = 0; + InstallInfo infFile("slapd/slapd.inf"); + InstallInfo *slapdInf = infFile.getSection("slapd"); + if (!slapdInf || !slapdInf->get("IsDirLite")) + { + infFile.read("slapd.inf"); + slapdInf = infFile.getSection("slapd"); + } + + const char *tmp; + ret = (slapdInf && (tmp = slapdInf->get("IsDirLite")) && + !strcasecmp(tmp, "true")); + + return ret; +} + +static char * +my_strdup(const char *s) +{ + char *ret = 0; + if (s) + { + ret = new char[strlen(s) + 1]; + strcpy(ret, s); + } + + return ret; +} + +/********************************************************************* +** +** METHOD: +** main +** DESCRIPTION: +** This is the ns-config program. This program functions as +** - The Pre-installation program used during the Installation +** of the Directory Server. In this case, the program +** is supposed to be executed by the common installer (ns-setup) +** and can be executed from anywhere. +** +** - The stand-alone configuration program used to re-configure +** the directory server. In this case, the program has +** to be executed from the serverroot. +** +** SIDE EFFECTS: +** None +** RESTRICTIONS: +** +** ALGORITHM: +** +**********************************************************************/ +int +main(int argc, char **argv) +{ + int err = 0; + + SlapdPreInstall program(argc, argv); + + err = program.init(); + if (!err) + { + err = program.start(); + } + + return err; +} + +SlapdPreInstall::SlapdPreInstall(int argc, char **argv) : _reconfig(False) +{ + setInstallMode(Interactive); + setInstallType(Typical); + _configured = False; + + getOptions(argc, argv); + +} + +SlapdPreInstall::~SlapdPreInstall() +{ +} + +void +SlapdPreInstall::getOptions(int argc, char **argv) +{ + int opt; + + while ((opt = getopt(argc,argv, "l:f:m:rsS")) != EOF) + { + switch (opt) + { + case 'l': + _logFile = strdup(optarg); + break; + case 'f': + _infoFile = strdup(optarg); + break; + case 's': + setInstallMode(Silent); + break; + case 'm': + setInstallType((InstallType)atoi(optarg)); + break; + case 'r': + _reconfig = True; + break; + case 'S': + /* + * Solaris 9+ specific installation + */ + iDSISolaris = 1; + break; + default: + fprintf(stderr, "SlapdPreInstall::getOptions(): " + "invalid option [%s]\n", argv[optind-1]); + break; + } + } +} + + +int +SlapdPreInstall::init() +{ + char errMsg[40]; + struct stat fi; + Bool shell = True; + + _installInfo = NULL; + _slapdInfo = new InstallInfo; + + if (installMode() != Silent) + { +/* richm 20011005 - we can't do this until we get setupsdk46 - if ever + if (iDSISolaris) + Dialog::initDisplay("Directory", (const char *) NULL, "Configuration"); + else +*/ + Dialog::initDisplay("Directory"); + } + + if ((installMode() == Silent && _infoFile == (char *) NULL) || + (_infoFile != (char *) NULL && InstUtil::fileExists(_infoFile) == False)) + { + sprintf(errMsg, "ERROR: answer cache not found\n"); + if (installMode() == Silent) + { + printf(errMsg); + } + else + { + DialogAlert alert(errMsg); + alert.execute(); + } + return -1; + } + + _serverRoot = InstUtil::getCurrentDir(); + if (installMode() != Silent) + { + if (_infoFile == (char *) NULL) + { + // Not executing from the Shell, check if this is the server + if (stat ("admin-serv", &fi) != 0) + { + sprintf(errMsg, "ERROR: %s is not a server root\n",_serverRoot.data()); + DialogAlert alert(errMsg); + alert.execute(); + return -1; + } + shell = False; + // if we are here, we are being run to reconfigure + _reconfig = True; + } + } + + if (installMode() == Silent) + { + if (_logFile == (char *) NULL) + { + // Should have a logfile + _logFile = _serverRoot + "/setup/install.log"; + } + _installLog = new InstallLog (_logFile); + } + + if (shell) + { + _installInfo = new InstallInfo(_infoFile); + _serverRoot = _installInfo->get(SLAPD_KEY_SERVER_ROOT); + if (!(_adminInfo = _installInfo->getSection("admin"))) + { + _adminInfo = new InstallInfo; + } + } + else + { + // Retrieve configuration data into installInfo + _infoFile = _serverRoot + "/" + "setup/install.inf"; + _installInfo = new InstallInfo(); + if (initDefaultConfig() == -1) { + const char *guess_host = InstUtil::guessHostname(); + if (guess_host) { + sprintf(errMsg, "ERROR: %s is not an addressable hostname\n", + guess_host); + } else { + sprintf(errMsg, "ERROR: cannot determine an addressable hostname\n"); + } + DialogAlert alert(errMsg); + alert.execute(); + return -1; + } + if (getDNSDomain() == NULL) { + const char *guess_domain = InstUtil::guessDomain(); + + if (guess_domain == NULL) { + sprintf(errMsg, "ERROR: cannot determine domainname\n"); + } else { + sprintf(errMsg, "ERROR: domainname is not valid for DNS\n"); + } + DialogAlert alert(errMsg); + alert.execute(); + return -1; + } + } + + setDefaultScript(_slapdInfo); + + char *url = 0; + char *adminid = 0; + char *admin_domain = 0; + getDefaultLdapInfo(_serverRoot, &url, &adminid, &admin_domain); + if (url && admin_domain) // in some cases adminid is NULL + { + if (!adminid) + { + // look up the admin ID in the config ds + } + // use these values as our default values + _installInfo->set(SLAPD_KEY_K_LDAP_URL, url); + if (adminid) + { + _installInfo->set(SLAPD_KEY_SERVER_ADMIN_ID, adminid); + } + _installInfo->set(SLAPD_KEY_ADMIN_DOMAIN, admin_domain); + // since this server root is already configured to use + // an existing configuration directory server, we will + // not allow the user to install another one here, so + // the directory server created here will be a user + // directory; we will still need to ask for the admin + // user password + _slapdInfo->set(SLAPD_KEY_USE_EXISTING_MC, "Yes"); + _slapdInfo->set(SLAPD_KEY_USE_EXISTING_UG, "No"); + _slapdInfo->set(SLAPD_KEY_SLAPD_CONFIG_FOR_MC, "No"); + } + else + { + _slapdInfo->set(SLAPD_KEY_SLAPD_CONFIG_FOR_MC, "Yes"); + } + + return 0; +} +/* + * PVO + */ + +int +SlapdPreInstall::initDefaultConfig() +{ + // PVO - should read from DS instead + if (_adminInfo->isEmpty()) + { + const char *guess_host = InstUtil::guessHostname(); + + if (guess_host) { +#if defined(__sun) || defined(__hppa) || defined(__osf__) || defined(__linux__) || defined(linux) + static char test_host[BIG_BUF] = {0}; + struct hostent *hp; + + strcpy(test_host,guess_host); + hp = gethostbyname(test_host); + if (hp == NULL) { + return -1; + } +#endif + } + _installInfo->set(SLAPD_KEY_SERVER_ROOT, _serverRoot); + _installInfo->set(SLAPD_KEY_FULL_MACHINE_NAME, guess_host); + _installInfo->set(SLAPD_KEY_K_LDAP_URL, NSString("ldap://") + + guess_host + + "/" + + DEFAULT_LDAP_SUFFIX); + _installInfo->set(SLAPD_KEY_SUITESPOT_USERID, DEFAULT_SSUSER); + _installInfo->set(SS_GROUP, DEFAULT_SSGROUP); + } + else + { + _configured = True; + } + return 0; +} + +inline void +changeIndex(int &ii, int incr, int min, int max) +{ + ii += incr; + if (ii < min) + ii = min; + if (ii > max) + ii = max; +} + +int +SlapdPreInstall::start() +{ + // if we're in silent install mode, don't execute any of the dialogs, just + // assume the user knows what he/she is doing . . . + if (installMode() == Silent) + { + if (_reconfig) + shutdownServers(); + return 0; + } + + // only enable win mode if we are not doing a silent install because + // it messes up terminal settings + enableWinMode(); + + DialogAction action = DIALOG_NEXT; + int err = 0; + Dialog *advancedDialogList[] = { + &askUseExistingMC, + &askMCHost, + &askMCPort, + &askMCDN, + &askMCAdminDomain, + &askUseExistingUG, + &askUGHost, + &askUGPort, + &askUGSuffix, + &askUGDN, + &askSlapdPort, + &askSlapdServerID, + &askMCAdminID, + &askSlapdSuffix, + &askSlapdRootDN, + &askAdminDomain, + /* + &askReplication, + &askSIR, + &askChangeLogSuffix, + &askChangeLogDir, + &askConsumerDN, + &askSIRHost, + &askSIRPort, + &askSIRDN, + &askSIRSuffix, + &askSIRDays, + &askSIRTimes, + &askCIR, + &askCIRHost, + &askCIRPort, + &askCIRDN, + &askCIRSuffix, + &askCIRInterval, + &askCIRDays, + &askCIRTimes, + &askReplicationDN, + */ + &askSample, + &askPopulate, + &askDisableSchemaChecking + }; + Dialog *advancedDialogLiteList[] = { + &askUseExistingMC, + &askMCHost, + &askMCPort, + &askMCDN, + &askMCAdminDomain, + &askUseExistingUG, + &askUGHost, + &askUGPort, + &askUGSuffix, + &askUGDN, + &askSlapdPort, + &askSlapdServerID, + &askMCAdminID, + &askSlapdSuffix, + &askSlapdRootDN, + &askAdminDomain, + &askSample, + &askPopulate, + &askDisableSchemaChecking + }; + Dialog *advancediDSISolarisForceUGDialogList[] = { + &askSlapdPort, + &askSlapdServerID, + &askMCHost, + &askMCPort, + &askMCDN, + &askSlapdSuffix, + &askSlapdRootDN, + &askSample, + &askPopulate, + &askDisableSchemaChecking + }; + Dialog *normalDialogList[] = { + &askUseExistingMC, + &askMCHost, + &askMCPort, + &askMCDN, + &askUseExistingUG, + &askUGHost, + &askUGPort, + &askUGSuffix, + &askUGDN, + &askSlapdPort, + &askSlapdServerID, + &askMCAdminID, + &askSlapdSuffix, + &askSlapdRootDN, + &askAdminDomain + }; + Dialog *normalForceUGDialogList[] = { + &askSlapdPort, + &askSlapdServerID, + &askMCDN, + &askSlapdSuffix, + &askSlapdRootDN + }; + Dialog *normaliDSISolarisForceUGDialogList[] = { + &askSlapdPort, + &askSlapdServerID, + &askMCHost, + &askMCPort, + &askMCDN, + &askSlapdSuffix, + &askSlapdRootDN + }; + Dialog *expressDialogList[] = { + &askMCAdminID, + &askSlapdRootDN + }; + Dialog *expressForceUGDialogList[] = { + &askMCDN, + &askSlapdRootDN + }; + Dialog *expressiDSISolarisForceUGDialogList[] = { + &askMCHost, + &askMCPort, + &askMCDN, + &askSlapdRootDN + }; + Dialog *reconfigDialogList[] = { + &askReconfigMCAdminPwd + }; + const int nNormalDialogs = sizeof(normalDialogList) / sizeof(normalDialogList[0]); + const int nExpressDialogs = sizeof(expressDialogList) / sizeof(expressDialogList[0]); + const int nExpressForceUGDialogs = sizeof(expressForceUGDialogList) / sizeof(expressForceUGDialogList[0]); + const int nExpressiDSISolarisForceUGDialogs = sizeof(expressiDSISolarisForceUGDialogList) / sizeof(expressiDSISolarisForceUGDialogList[0]); + const int nAdvancedDialogs = sizeof(advancedDialogList) / sizeof(advancedDialogList[0]); + const int nAdvancedLiteDialogs = sizeof(advancedDialogLiteList) / sizeof(advancedDialogLiteList[0]); + const int nAdvancediDSISolarisForceUGDialogs = sizeof(advancediDSISolarisForceUGDialogList) / sizeof(advancediDSISolarisForceUGDialogList[0]); + const int nReconfigDialogs = sizeof(reconfigDialogList) / sizeof(reconfigDialogList[0]); + const int nNormalForceUGDialogs = sizeof(normalForceUGDialogList) / sizeof(normalForceUGDialogList[0]); + const int nNormaliDSISolarisForceUGDialogs = sizeof(normaliDSISolarisForceUGDialogList) / sizeof(normaliDSISolarisForceUGDialogList[0]); + + int liteMode = 0; + int nDialogs = nNormalDialogs; + Dialog** dialogList = normalDialogList; + if (_reconfig) + { + nDialogs = nReconfigDialogs; + dialogList = reconfigDialogList; + } + else if (installType() == Express) + { + nDialogs = nExpressDialogs; + dialogList = expressDialogList; + } + else if (installType() == Custom) + { + if (liteMode = isLiteMode()) + { + nDialogs = nAdvancedLiteDialogs; + dialogList = advancedDialogLiteList; + } + else + { + nDialogs = nAdvancedDialogs; + dialogList = advancedDialogList; + } + } + else if (!iDSISolaris && featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC)) + { + if (installType() == Typical) + { + nDialogs = nNormalForceUGDialogs; + dialogList = normalForceUGDialogList; + } + else if (installType() == Express) + { + nDialogs = nExpressForceUGDialogs; + dialogList = expressForceUGDialogList; + } + } + + if (iDSISolaris && featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC)) + { + if (installType() == Typical) + { + nDialogs = nNormaliDSISolarisForceUGDialogs; + dialogList = normaliDSISolarisForceUGDialogList; + } + else if (installType() == Express) + { + nDialogs = nExpressiDSISolarisForceUGDialogs; + dialogList = expressiDSISolarisForceUGDialogList; + } + else if (installType() == Custom) + { + nDialogs = nAdvancediDSISolarisForceUGDialogs; + dialogList = advancediDSISolarisForceUGDialogList; + } + + } + + getDefaultScript()->set(SLAPD_KEY_SECURITY_ON, "No"); + + int ii = 0; + + // initialize all dialogs + + if (!_reconfig) + { + for (ii = 0; ii < nAdvancedDialogs; ++ii) + { + advancedDialogList[ii]->registerDialogNext(this); + advancedDialogList[ii]->enable8BitInput(); + // this next bit of hackery allows us to use the dialog->setup() + // method of each dialog to setup the default values for the + // .inf file; if the SETUP_ONLY flag is set, each setup() method + // will just return DIALOG_NEXT after setting up the default + // values; pretty sneaky, huh? + advancedDialogList[ii]->setUserData(SETUP_DEFAULTS, SETUP_ONLY); + advancedDialogList[ii]->setUserData(ACTION, DIALOG_NEXT); + advancedDialogList[ii]->execute(); + advancedDialogList[ii]->setUserData(SETUP_DEFAULTS, (long)0); + } + advancedDialogList[nAdvancedDialogs-1]->registerDialogLast(this); + } + else + { + for (ii = 0; ii < nReconfigDialogs; ++ii) + { + reconfigDialogList[ii]->registerDialogNext(this); + reconfigDialogList[ii]->enable8BitInput(); + } + reconfigDialogList[nReconfigDialogs-1]->registerDialogLast(this); + } + + ii = 0; + int min = 0; + // keep looping until we hit the end + while (ii < nDialogs) + { + int incr = 1; // go to next by default + Dialog *d = dialogList[ii]; + + // tell the dialog what the action was that brought it here so that + // the dialog knows if it was called as the result of a next or + // a prev or whatever + d->setUserData(ACTION, (long)action); +// cerr << "set action in dialog " << ii << " to " << action << endl; +// cerr << "DIALOG_PREV, SAME, NEXT = " << DIALOG_PREV << "," << DIALOG_SAME << "," << DIALOG_NEXT << endl; + + // execute the dialog +// cerr << "executing dialog number " << ii << endl; + action = d->execute(); + if (action == DIALOG_PREV) + { + incr = -1; // go to prev +// cerr << "prev" << endl; + } + else if (action == DIALOG_SAME) + { + incr = 0; // repeat this state +// cerr << "same" << endl; + } + else if (action != DIALOG_NEXT) + { + incr = nDialogs; + err = -1; // could just break here, I suppose . . . + } + else + { +// cerr << "next" << endl; + } + + changeIndex(ii, incr, min, nDialogs); + } + + if (err == 0) + { + if (!_reconfig) + { + _installInfo->addSection("slapd", _slapdInfo); + if (!_installInfo->getSection("admin") && _adminInfo && + !_adminInfo->isEmpty()) + { + _installInfo->addSection("admin", _adminInfo); + delete _adminInfo; + _adminInfo = 0; + } + + if (!_installInfo->get(SLAPD_KEY_K_LDAP_HOST)) + { + _installInfo->set(SLAPD_KEY_K_LDAP_HOST, + _installInfo->get(SLAPD_KEY_FULL_MACHINE_NAME)); + } + if (!_installInfo->get(SLAPD_KEY_K_LDAP_PORT)) + { + _installInfo->set(SLAPD_KEY_K_LDAP_PORT, + _slapdInfo->get(SLAPD_KEY_SERVER_PORT)); + } + const char *test = 0; + if (!(test = _installInfo->get(SLAPD_KEY_BASE_SUFFIX)) || !*test) + { + // if there's no config directory suffix we must use + // o=NetscapeRoot + _installInfo->set(SLAPD_KEY_BASE_SUFFIX, DEFAULT_ROOT_DN); + } + + // only UG directories have a user base suffix . . . + if (featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG)) + _slapdInfo->remove(SLAPD_KEY_SUFFIX); + + // if there is no LdapURL and other ldap info in the installInfo, write + // it + if (!_installInfo->get(SLAPD_KEY_K_LDAP_URL)) + { + // construct a new LdapURL based on host, port, and suffix + const char *suffix = _installInfo->get(SLAPD_KEY_BASE_SUFFIX); + if (!suffix || !*suffix) + suffix = DEFAULT_ROOT_DN; + NSString ldapURL = NSString("ldap://") + + _installInfo->get(SLAPD_KEY_K_LDAP_HOST) + ":" + + _installInfo->get(SLAPD_KEY_K_LDAP_PORT) + "/" + + suffix; + _installInfo->set(SLAPD_KEY_K_LDAP_URL, ldapURL); + } + + if (!featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC)) + { + // if this is to be both the MC and the UG host . . . + if (!featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG)) + { + // use the MC admin ID for the UG admin ID + if (!_installInfo->get(SLAPD_KEY_USER_GROUP_ADMIN_ID)) + _installInfo->set(SLAPD_KEY_USER_GROUP_ADMIN_ID, + _installInfo->get(SLAPD_KEY_SERVER_ADMIN_ID)); + + if (!_installInfo->get(SLAPD_KEY_USER_GROUP_ADMIN_PWD)) + _installInfo->set(SLAPD_KEY_USER_GROUP_ADMIN_PWD, + _installInfo->get(SLAPD_KEY_SERVER_ADMIN_PWD)); + } + } + + // set the ug ldap url if we need one + if (!_installInfo->get(SLAPD_KEY_USER_GROUP_LDAP_URL)) + { + if (featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG)) + { + NSString url = NSString("ldap://") + + _installInfo->get(SLAPD_KEY_UG_HOST) + ":" + + _installInfo->get(SLAPD_KEY_UG_PORT) + "/" + + _installInfo->get(SLAPD_KEY_UG_SUFFIX); + _installInfo->set(SLAPD_KEY_USER_GROUP_LDAP_URL, url); + } + else // the directory we're creating is the UG + { + NSString url = NSString("ldap://") + + _installInfo->get(SLAPD_KEY_FULL_MACHINE_NAME) + ":" + + _slapdInfo->get(SLAPD_KEY_SERVER_PORT) + "/" + + _slapdInfo->get(SLAPD_KEY_SUFFIX); + _installInfo->set(SLAPD_KEY_USER_GROUP_LDAP_URL, url); + } + } + + if (!_installInfo->get(SLAPD_KEY_USER_GROUP_ADMIN_ID)) + _installInfo->set(SLAPD_KEY_USER_GROUP_ADMIN_ID, + _slapdInfo->get(SLAPD_KEY_ROOTDN)); + + if (!_installInfo->get(SLAPD_KEY_USER_GROUP_ADMIN_PWD)) + _installInfo->set(SLAPD_KEY_USER_GROUP_ADMIN_PWD, + _slapdInfo->get(SLAPD_KEY_ROOTDNPWD)); + } else { + // for reconfigure, just shutdown the servers + shutdownServers(); + } + + // remove the fields we don't need + _installInfo->remove(SLAPD_KEY_K_LDAP_HOST); + _installInfo->remove(SLAPD_KEY_K_LDAP_PORT); + _installInfo->remove(SLAPD_KEY_BASE_SUFFIX); + _installInfo->remove(SLAPD_KEY_UG_HOST); + _installInfo->remove(SLAPD_KEY_UG_PORT); + _installInfo->remove(SLAPD_KEY_UG_SUFFIX); + + // normalize and convert the DN valued attributes to LDAPv3 style + normalizeDNs(); + + // format for .inf file + _installInfo->setFormat(1); + + // convert internally stored UTF8 to local + _installInfo->toLocal(); + _installInfo->write(_infoFile); + } + + disableWinMode(); + + return err; +} + +int +SlapdPreInstall::cont() +{ + return 0; +} + +void +SlapdPreInstall::clear() +{ +} + +void +SlapdPreInstall::add(Dialog *p) +{ + p = p; +} +void +SlapdPreInstall::resetLast() +{ +} + +void +SlapdPreInstall::addLast(Dialog *p) +{ + p = p; +} +void +SlapdPreInstall::setParent(void *parent) +{ + parent = parent; + return; +} +void * +SlapdPreInstall::parent() const +{ + return (void *) this; +} + +void +SlapdPreInstall::setAdminScript(InstallInfo *script) +{ + _adminInfo = script; +} + +InstallInfo * +SlapdPreInstall::getAdminScript() const +{ + return _adminInfo; +} + +InstallInfo * +SlapdPreInstall::getBaseScript() const +{ + return _installInfo; +} + +void +SlapdPreInstall::showAlert(const char *msg) +{ + char *localMsg = UTF8ToLocal(msg); + DialogAlert alert(localMsg); + alert.execute(); + nsSetupFree(localMsg); + + return; +} + +int +SlapdPreInstall::verifyRemoteLdap( + const char *host, + const char *port, + const char *suffix, + const char *binddn, + const char *binddnpwd +) const +{ + const char *myhost = getDefaultScript()->get(host); + if (!myhost) + myhost = getBaseScript()->get(host); + const char *myport = getDefaultScript()->get(port); + if (!myport) + myport = getBaseScript()->get(port); + const char *mysuffix = getDefaultScript()->get(suffix); + if (!mysuffix) + mysuffix = getBaseScript()->get(suffix); + if (!mysuffix) + mysuffix = DEFAULT_ROOT_DN; + const char *mydn = getDefaultScript()->get(binddn); + if (!mydn) + mydn = getBaseScript()->get(binddn); + const char *mypwd = getDefaultScript()->get(binddnpwd); + if (!mypwd) + mypwd = getBaseScript()->get(binddnpwd); + + char *s = (char *)malloc(10 + strlen(myhost) + strlen(myport) + + ((suffix && mysuffix) ? strlen(mysuffix):0)); + strcpy(s, "ldap://"); + strcat(s, myhost); + strcat(s, ":"); + strcat(s, myport); + strcat(s, "/"); + if (suffix && mysuffix) + strcat(s, mysuffix); + int status = authLdapUser(s, mydn, mypwd, NULL, NULL); + free(s); + return status; +} + +int +SlapdPreInstall::verifyAdminDomain( + const char *host, + const char *port, + const char *suffix, + const char *admin_domain, + const char *binddn, + const char *binddnpwd +) const +{ + const char *myhost = getDefaultScript()->get(host); + if (!myhost) + myhost = getBaseScript()->get(host); + const char *myport = getDefaultScript()->get(port); + if (!myport) + myport = getBaseScript()->get(port); + const char *mysuffix = getDefaultScript()->get(suffix); + if (!mysuffix) + mysuffix = getBaseScript()->get(suffix); + if (!mysuffix) + mysuffix = DEFAULT_ROOT_DN; + const char *mydn = getDefaultScript()->get(binddn); + if (!mydn) + mydn = getBaseScript()->get(binddn); + const char *mypwd = getDefaultScript()->get(binddnpwd); + if (!mypwd) + mypwd = getBaseScript()->get(binddnpwd); + const char *myadmin_domain = getDefaultScript()->get(admin_domain); + if (!myadmin_domain) + myadmin_domain = getBaseScript()->get(admin_domain); + + char *s = (char *)malloc(10 + strlen(myhost) + strlen(myport) + + ((suffix && mysuffix) ? strlen(mysuffix):0)); + strcpy(s, "ldap://"); + strcat(s, myhost); + strcat(s, ":"); + strcat(s, myport); + strcat(s, "/"); + if (suffix && mysuffix) + strcat(s, mysuffix); + LdapError ldapErr; + Ldap ldap(ldapErr, s, mydn, mypwd); + int status = ldapErr; + if (!status && admin_domain && myadmin_domain && mysuffix) + { + LdapEntry ad(&ldap); + NSString dn = NSString("ou=") + myadmin_domain + ", " + mysuffix; + status = ad.retrieve(dn); + } + + free(s); + return status; +} + +const char * +SlapdPreInstall::getDNSDomain() const +{ + static char domain[BIG_BUF] = {0}; + + if (domain[0]) + return domain; + + const char *FQDN = + getBaseScript()->get(SLAPD_KEY_FULL_MACHINE_NAME); + if (!FQDN) { + FQDN = InstUtil::guessHostname(); + } + + const char *ptr = NULL; + if (FQDN != NULL) { + // copy the domain name part (not the hostname) into the suffix + // find the last '.' in the FQDN + ptr = strchr(FQDN, '.'); + } + + if (FQDN == NULL || ptr == NULL) { + const char *guess_domain = InstUtil::guessDomain(); + + if (guess_domain) { + /* ensure domain is of at least 2 components */ + const char *dptr = strchr(guess_domain, '.'); + if (dptr == NULL) { + return NULL; + } + + strcpy(domain, guess_domain); + return domain; + } else { + return NULL; + } + } + + ++ptr; + strcpy(domain, ptr); + + return domain; +} + +const char * +SlapdPreInstall::getDefaultSuffix() const +{ + const char *SUF = "dc="; + const int SUF_LEN = 3; + static char suffix[BIG_BUF] = {0}; + + if (suffix[0]) + return suffix; + + char *sptr = suffix; + strcat(sptr, SUF); + sptr += SUF_LEN; + for (const char *ptr = getDNSDomain(); ptr && *ptr; *ptr++) { + if (*ptr == '.') { + strcat(sptr, ", "); + sptr += 2; + strcat(sptr, SUF); + sptr += SUF_LEN; + } else { + *sptr++ = *ptr; + } + } + *sptr = 0; + if (!*suffix) + sprintf(suffix, "%s%s", SUF, "unknown-domain"); + + return suffix; +} + +const char * +SlapdPreInstall::getConsumerDN() const +{ + static char dn[BIG_BUF]; + + dn[0] = 0; + const char *suffix = + getDefaultScript()->get(SLAPD_KEY_SUFFIX); + if (suffix) + sprintf(dn, "cn=Replication Consumer, %s", suffix); + else + sprintf(dn, "cn=Replication Consumer"); + + return dn; +} + +int +SlapdPreInstall::featureIsEnabled(const char *which) const +{ + const char *val = getDefaultScript()->get(which); + if (!val) + val = getBaseScript()->get(which); + if (!val || !*val || !strncasecmp(val, "no", strlen(val))) + return 0; // feature is disabled + + return 1; // feature is enabled +} + +void +SlapdPreInstall::shutdownServers() +{ + const char *nick = "slapd"; + const char *script = "stop-slapd"; + int len = strlen(nick); + const char *sroot = getBaseScript()->get(SLAPD_KEY_SERVER_ROOT); + if (!sroot) + return; + + DIR* srootdir = opendir(sroot); + if (!srootdir) + return; + + struct dirent* entry = 0; + while (entry = readdir(srootdir)) + { + // look for instance directories + if (!strncasecmp(entry->d_name, nick, len)) + { + NSString instanceDir = NSString(sroot) + "/" + entry->d_name; + if (InstUtil::dirExists(instanceDir)) + { + NSString prog = instanceDir + "/" + script; + // call the stop-slapd script + if (InstUtil::fileExists(prog)) + { + cout << "Shutting down server " << entry->d_name + << " . . . " << flush; + int status = InstUtil::execProgram(prog); + if (status) + // attempt to determine cause of failure + cout << "Could not shutdown server: status=" << status + << " error=" << errno << endl; + else + cout << "Done." << endl; + } + } + } + } + closedir(srootdir); + + return; +} + +void +SlapdPreInstall::normalizeDNs() +{ + static const char *DN_VALUED_ATTRS[] = { + SLAPD_KEY_SUFFIX, + SLAPD_KEY_ROOTDN, + SLAPD_KEY_CIR_SUFFIX, + SLAPD_KEY_CIR_BINDDN, + SLAPD_KEY_REPLICATIONDN, + SLAPD_KEY_CONSUMERDN, + SLAPD_KEY_SIR_SUFFIX, + SLAPD_KEY_SIR_BINDDN + }; + static const int N = sizeof(DN_VALUED_ATTRS)/sizeof(DN_VALUED_ATTRS[0]); + static const char *URL_ATTRS[] = { + SLAPD_KEY_K_LDAP_URL, + SLAPD_KEY_USER_GROUP_LDAP_URL + }; + static const int NURLS = sizeof(URL_ATTRS)/sizeof(URL_ATTRS[0]); + + int ii; + for (ii = 0; _slapdInfo && (ii < N); ++ii) + { + const char *attr = DN_VALUED_ATTRS[ii]; + char *dn = my_strdup(_slapdInfo->get(attr)); + if (dn) + { + _slapdInfo->remove(attr); + _slapdInfo->set(attr, dn_normalize_convert(dn)); + fflush(stdout); + delete [] dn; + } + } + + for (ii = 0; _installInfo && (ii < NURLS); ++ii) + { + const char *attr = URL_ATTRS[ii]; + const char *url = _installInfo->get(attr); + LDAPURLDesc *desc = 0; + if (url && !ldap_url_parse((char *)url, &desc) && desc) + { + char *dn = dn_normalize_convert(my_strdup(desc->lud_dn)); + if (dn) + { + char port[6]; + sprintf(port, "%d", desc->lud_port); + NSString newurl = NSString("ldap://") + desc->lud_host + + ":" + port + "/" + dn; + _installInfo->set(attr, newurl); + delete [] dn; + } + } + if (desc) + ldap_free_urldesc(desc); + } +} diff --git a/ldap/cm/newinst/ux-config.h b/ldap/cm/newinst/ux-config.h new file mode 100644 index 00000000..dbce264a --- /dev/null +++ b/ldap/cm/newinst/ux-config.h @@ -0,0 +1,172 @@ +/** BEGIN COPYRIGHT BLOCK + * Copyright 2001 Sun Microsystems, Inc. + * Portions copyright 1999, 2001-2003 Netscape Communications Corporation. + * All rights reserved. + * END COPYRIGHT BLOCK **/ +/********************************************************************* +** +** +** NAME: +** ux-config.h +** +** DESCRIPTION: +** Netscape Directory Server Pre-installation Program +** +** NOTES: +** +** HISTORY: +** $Log: ux-config.h,v $ +** Revision 1.1 2005/01/21 00:40:49 cvsadm +** Initial revision +** +** Revision 1.1.2.6.8.9 2005/01/14 01:22:10 nhosoi +** For the open-source project. +** 1) eliminated 'netsite' level +** 2) moved ns/config one level lower +** 3) moved fasttime to lib/base +** +** Revision 1.1.2.6.8.8 2003/09/22 19:38:51 ulfw +** Update copyright years from 2001 to 2001-2003 +** +** Revision 1.1.2.6.8.7 2001/11/02 23:32:56 richm +** XXX use new copyright XXX +** +** Revision 1.1.2.6.8.6 2001/10/06 20:01:04 richm +** ldapserver/ldap/cm/newinst/ux-config.h +** 1.1.2.6.8.5 +** 20010918 +** +** Remove copyright caracter form copyright +** +** +** ==================================================== +** +** Revision 1.1.2.6.8.5 2001/09/21 15:25:29 richm +** rebrand to Netscape and change version to 6.0 +** +** Revision 1.1.2.6.8.4 2001/02/13 09:40:08 rmarco +** copyrights +** +** Revision 1.1.2.6.8.3 2000/08/22 10:07:32 elp +** First bunch of branding fixes. +** Replaced 'Netscape Directory Server' by 'iPlanet Directory Server'. +** +** Revision 1.1.2.6.8.2 2000/08/08 19:34:10 mwahl +** ensure domainname is valid before beginning install +** +** Revision 1.1.2.6.8.1 1999/02/23 02:14:08 ggood +** Merge changes made on server4_directory_branch after 4.0 RTM to DirectoryBranch +** +** Revision 1.1.2.7 1998/11/25 02:07:59 rweltman +** Merging from DS 4.0 RTM into server4_directory_branch +** +** Revision 1.1.2.6.4.2 1998/11/06 21:33:15 richm +** added normalizeDNs +** +** Revision 1.1.2.6.4.1 1998/10/15 18:23:05 richm +** check for bogus admin domain +** +** Revision 1.1.2.6 1998/07/23 21:32:39 richm +** allow re-installation into existing server root +** +** Revision 1.1.2.5 1998/06/15 23:52:08 richm +** added support for user/group separation, better flow control, and support for AS 0611 +** +** Revision 1.1.2.4 1997/12/17 21:10:19 richm +** updated for minor 19971216 changes to admin setup sdk +** +** Revision 1.1.2.3 1997/12/06 01:43:18 richm +** upgraded to latest changes from 12.03 admin +** +** Revision 1.1.2.2 1997/11/12 23:42:57 richm +** updates for unix installer +** +** Revision 1.1.2.1 1997/11/04 01:57:53 richm +** Kingpin UNIX installation modules +** +** Revision 1.1.2.4 1997/10/22 02:46:08 pvo +** Removed restore(). +** +** Revision 1.1.2.3 1997/10/01 17:24:11 pvo +** Changed include path. +** +** Revision 1.1.2.2 1997/09/27 02:43:39 pvo +** Check in. +** +** +*********************************************************************/ +#include "dialog.h" +#include "ux-util.h" +extern const char *DEFAULT_SYSUSER; +extern const char *DEFAULT_OLDROOT; + + +class SlapdPreInstall:public DialogManager +{ +public: + + SlapdPreInstall(int, char **); + ~SlapdPreInstall(); + + int init(); + + int start(); + void add (Dialog *); + void addLast(Dialog *); + void resetLast(); + void clear(); + int cont(); + void setParent(void *); + void *parent() const; + + void setAdminScript(InstallInfo *script); + InstallInfo *getAdminScript() const; + + InstallInfo *getBaseScript() const; + + int verifyRemoteLdap(const char *host, const char *port, const char *suffix, + const char *binddn, const char *binddnpwd) const; + + int verifyAdminDomain(const char *host, const char *port, const char *suffix, + const char *admin_domain, + const char *binddn, const char *binddnpwd) const; + + const char *getDNSDomain() const; + const char *getDefaultSuffix() const; + const char *getConsumerDN() const; + int featureIsEnabled(const char *which) const; + + static void showAlert(const char *msg); + +private: + + NSString _serverRoot; + + NSString _infoFile; + InstallInfo *_installInfo; + InstallInfo *_slapdInfo; + InstallInfo *_adminInfo; + + NSString _logFile; + InstallLog *_installLog; + + Bool _configured; + Bool _reconfig; + + + void getOptions(int argc, char **argv); + int initDefaultConfig(); + + void shutdownServers(); + + void normalizeDNs(); +}; + +typedef SlapdPreInstall DialogManagerType; + +inline DialogManagerType* +getManager(Dialog *me) +{ + return (DialogManagerType*)me->manager(); +} + diff --git a/ldap/cm/newinst/ux-dialog.cc b/ldap/cm/newinst/ux-dialog.cc new file mode 100644 index 00000000..30ca68c8 --- /dev/null +++ b/ldap/cm/newinst/ux-dialog.cc @@ -0,0 +1,4332 @@ +/** BEGIN COPYRIGHT BLOCK + * Copyright 2001 Sun Microsystems, Inc. + * Portions copyright 1999, 2001-2003 Netscape Communications Corporation. + * All rights reserved. + * END COPYRIGHT BLOCK **/ +/********************************************************************* +** +** NAME: +** ux-dialog.cc +** +** DESCRIPTION: +** Netscape Directory Server Pre-installation Program +** Definitions for UI dialogs. +** +** NOTES: +** +** +*********************************************************************/ + +#include <errno.h> +#include <iostream.h> +#include <fstream.h> +/* Newer g++ wants the new std header forms */ +#if defined( Linux ) +#include <strstream> +using std::ostrstream; +/* But some platforms won't accept those (specifically HP-UX aCC */ +#else +#include <strstream.h> +#endif +#include <stdio.h> +#include <unistd.h> +#include <ctype.h> +#include <string.h> +#include <strings.h> +#include "utf8.h" +#include "ux-util.h" +#include "dialog.h" +#include "ux-dialog.h" +#include "ux-config.h" +#include "install_keywords.h" +extern "C" { +#include "dsalib.h" +} + +static const char *DEFAULT_SLAPDUSER = "cn=Directory Manager"; + +// #define DEBUG 2 + +/* +** Forward References +*/ + +static DialogAction yesNoDefaultNo (const char *answer); +static DialogAction askReconfigNext (Dialog *me); +static DialogAction askSlapdServerNameSetup (Dialog *me); +static DialogAction askSlapdServerNameNext(Dialog *me); +static DialogAction askAdminPortSetup (Dialog *me); +static DialogAction askAdminPortNext(Dialog *me); +static DialogAction askSlapdPortSetup (Dialog *me); +static DialogAction askSlapdPortNext(Dialog *me); +static DialogAction askSecurityNext (Dialog *me); +static DialogAction askSlapdSecPortSetup (Dialog *me); +static DialogAction askSlapdSecPortNext(Dialog *me); +static DialogAction askSlapdServerIDSetup (Dialog *me); +static DialogAction askSlapdServerIDNext(Dialog *me); +static DialogAction askSr2xInfoSetup(Dialog *me); +static DialogAction askSr2xInfoNext(Dialog *me); +static DialogAction askSlapdRootDNSetup(Dialog *me); +static DialogAction askSlapdRootDNNext (Dialog *me); +static DialogAction askSlapdSysUserSetup (Dialog *me); +static DialogAction askSlapdSysUserNext (Dialog *me); +static DialogAction askConfigForMCNext (Dialog *me); +static DialogAction askMCAdminIDSetup (Dialog *me); +static DialogAction askMCAdminIDNext (Dialog *me); +static DialogAction askReconfigMCAdminPwdSetup (Dialog *me); +static DialogAction askReconfigMCAdminPwdNext (Dialog *me); +static DialogAction askSlapdSuffixSetup (Dialog *me); +static DialogAction askSlapdSuffixNext (Dialog *me); +static DialogAction askSampleSetup (Dialog *me); +static DialogAction askSampleNext (Dialog *me); +static DialogAction askPopulateSetup (Dialog *me); +static DialogAction askPopulateNext (Dialog *me); +static DialogAction askOrgSizeSetup (Dialog *me); +static DialogAction askOrgSizeNext (Dialog *me); +static DialogAction askCIRSetup(Dialog *me); +static DialogAction askCIRNext(Dialog *me); +static DialogAction askCIRHostSetup(Dialog *me); +static DialogAction askCIRHostNext(Dialog *me); +static DialogAction askCIRPortSetup(Dialog *me); +static DialogAction askCIRPortNext(Dialog *me); +static DialogAction askCIRDNSetup(Dialog *me); +static DialogAction askCIRDNNext(Dialog *me); +static DialogAction askCIRSuffixSetup(Dialog *me); +static DialogAction askCIRSuffixNext(Dialog *me); +static DialogAction askCIRSSLSetup(Dialog *me); +static DialogAction askCIRSSLNext(Dialog *me); +static DialogAction askCIRIntervalSetup(Dialog *me); +static DialogAction askCIRIntervalNext(Dialog *me); +static DialogAction askCIRDaysSetup(Dialog *me); +static DialogAction askCIRDaysNext(Dialog *me); +static DialogAction askCIRTimesSetup(Dialog *me); +static DialogAction askCIRTimesNext(Dialog *me); +static DialogAction askSIRSetup(Dialog *me); +static DialogAction askSIRNext(Dialog *me); +static DialogAction askChangeLogSuffixSetup(Dialog *me); +static DialogAction askChangeLogSuffixNext(Dialog *me); +static DialogAction askChangeLogDirSetup(Dialog *me); +static DialogAction askChangeLogDirNext(Dialog *me); +static DialogAction askReplicationDNSetup(Dialog *me); +static DialogAction askReplicationDNNext(Dialog *me); +static DialogAction askReplicationSetup(Dialog *me); +static DialogAction askReplicationNext(Dialog *me); +static DialogAction askConsumerDNSetup(Dialog *me); +static DialogAction askConsumerDNNext(Dialog *me); +static DialogAction askSIRHostSetup(Dialog *me); +static DialogAction askSIRHostNext(Dialog *me); +static DialogAction askSIRPortSetup(Dialog *me); +static DialogAction askSIRPortNext(Dialog *me); +static DialogAction askSIRDNSetup(Dialog *me); +static DialogAction askSIRDNNext(Dialog *me); +static DialogAction askSIRSuffixSetup(Dialog *me); +static DialogAction askSIRSuffixNext(Dialog *me); +static DialogAction askSIRSSLSetup(Dialog *me); +static DialogAction askSIRSSLNext(Dialog *me); +static DialogAction askSIRDaysSetup(Dialog *me); +static DialogAction askSIRDaysNext(Dialog *me); +static DialogAction askSIRTimesSetup(Dialog *me); +static DialogAction askSIRTimesNext(Dialog *me); +static DialogAction askUseExistingMCSetup(Dialog *me); +static DialogAction askUseExistingMCNext(Dialog *me); +static DialogAction askMCHostSetup(Dialog *me); +static DialogAction askMCHostNext(Dialog *me); +static DialogAction askMCPortSetup(Dialog *me); +static DialogAction askMCPortNext(Dialog *me); +static DialogAction askMCDNSetup(Dialog *me); +static DialogAction askMCDNNext(Dialog *me); +static DialogAction askDisableSchemaCheckingSetup(Dialog *me); +static DialogAction askDisableSchemaCheckingNext(Dialog *me); +static DialogAction askMCAdminDomainSetup(Dialog *me); +static DialogAction askMCAdminDomainNext(Dialog *me); +static DialogAction askAdminDomainSetup(Dialog *me); +static DialogAction askAdminDomainNext(Dialog *me); +static DialogAction askUseExistingUGSetup(Dialog *me); +static DialogAction askUseExistingUGNext(Dialog *me); +static DialogAction askUGHostSetup(Dialog *me); +static DialogAction askUGHostNext(Dialog *me); +static DialogAction askUGPortSetup(Dialog *me); +static DialogAction askUGPortNext(Dialog *me); +static DialogAction askUGDNSetup(Dialog *me); +static DialogAction askUGDNNext(Dialog *me); +static DialogAction askUGSuffixSetup(Dialog *me); +static DialogAction askUGSuffixNext(Dialog *me); + +static int +isAValidDN(const char *dn_to_test) +{ + int ret = 1; + + if (!dn_to_test || !*dn_to_test) + { + ret = 0; + } + else + { + char **rdnList = ldap_explode_dn(dn_to_test, 0); + char **rdnNoTypes = ldap_explode_dn(dn_to_test, 1); + if (!rdnList || !rdnList[0] || !rdnNoTypes || !rdnNoTypes[0] || + !*rdnNoTypes[0] || !strcasecmp(rdnList[0], rdnNoTypes[0])) + { + ret = 0; + } + if (rdnList) + ldap_value_free(rdnList); + if (rdnNoTypes) + ldap_value_free(rdnNoTypes); + } + + if ((ret == 1) && ds_dn_uses_LDAPv2_quoting(dn_to_test)) + { + char *newdn = strdup(dn_to_test); + dn_normalize_convert(newdn); + char *oldlocaldn = UTF8ToLocal(dn_to_test); + char *newlocaldn = UTF8ToLocal(newdn); + free(newdn); + NSString msg = NSString( + "The given value [") + oldlocaldn + "] is quoted in the deprecated LDAPv2 style\n" + + "quoting format. It will be automatically converted to use the\n" + + "LDAPv3 style escaped format [" + newlocaldn + "]."; + DialogManagerType::showAlert(msg); + nsSetupFree(oldlocaldn); + nsSetupFree(newlocaldn); + } + + return ret; +} + +static int +contains8BitChars(const char *s) +{ + int ret = 0; + + if (s && *s) + { + for (; !ret && *s; ++s) + { + ret = (*s & 0x80); + } + } + + return ret; +} + +static int +rootDNPwdIsValid(const char *pwd) +{ + if (!pwd || !*pwd || (strlen(pwd) < 8)) + return 0; + + return !contains8BitChars(pwd); +} + +static int +isValid(const char *s) +{ + if (!s) + return 1; // null is a valid response (means to accept default) + + int ret = 1; + + char *ncs = (char *)s; // cast away const-ness for ldaputf8 stuff + // trim spaces from the beginning of the string + while (*ncs && ldap_utf8isspace(ncs)) + LDAP_UTF8INC(ncs); + + if (!*ncs) // empty string or all spaces + ret = 0; + + return ret; +} + +static int +isValidServerID(const char *s) +{ + if (!s || !*s) + return 0; + + if (!isValid(s)) + return 0; + + if (contains8BitChars(s)) + return 0; + + // server ID should contain alphanum, _, -, . since it will + // be used for both a filename and a DN component + const char *badChars = "`~!@#$%^&*()[]|\\\"\':;,+=/<>?"; + const char *p = s; + for (; *p && !strchr(badChars, *p); ++p) + ; + + if (!*p) // the string contains all valid chars + return 1; + + return 0; +} + +static int +isValidYesNo(const char *s) +{ + if (!s) + return 1; // null means accept default + + const char *msg = 0; + if (isValid(s)) + { + int len = strlen(s); + if (strncasecmp(s, "yes", len) && strncasecmp(s, "no", len)) + { + msg = "Please type yes or no."; + } + } + else + { + msg = "Please specify a valid string."; + } + + if (msg) + { + DialogManagerType::showAlert(msg); + return 0; + } + + return 1; +} + +static DialogAction +yesNoDefaultNo(const char *answer) +{ + if (answer[0] == '\0' || answer[0] == '\n') + return DIALOG_EXIT; + else if (answer[0] != 'y' && answer[0] != 'Y') + return DIALOG_EXIT; + else + return DIALOG_NEXT; +} + +static int +dialogSetup (Dialog *me, const char *which, const char *defaultAns) +{ + const char *ans = getManager(me)->getDefaultScript()->get(which); + if (!ans) + ans = getManager(me)->getAdminScript()->get(which); + if (!ans) + ans = getManager(me)->getBaseScript()->get(which); + + int status; + if (ans == NULL) + status = 0; + else + status = 1; +/* + int status = (int)ans; // 0 - there was already a value in the script + // not zero - no value already in script +*/ + if (ans) + me->setDefaultAns(ans); + else if (defaultAns) + me->setDefaultAns(defaultAns); + + return status; +} + +DialogInput askSlapdPort( +"The standard directory server network port number is 389. However, if\n" +"you are not logged as the superuser, or port 389 is in use, the\n" +"default value will be a random unused port number greater than 1024.\n" +"If you want to use port 389, make sure that you are logged in as the\n" +"superuser, that port 389 is not in use, and that you run the admin\n" +"server as the superuser.\n", + +"Directory server network port", + +NULL, + +askSlapdPortSetup, +askSlapdPortNext +); + +static DialogAction +askSlapdPortSetup(Dialog *me) +{ +#if DEBUG > 1 + cerr << "Entering askSlapdPortSetup" << endl; +#endif + char tmp[10]; + int port = 389; + const char *defPort = + getManager(me)->getDefaultScript()->get(SLAPD_KEY_SERVER_PORT); + + if (defPort && *defPort && atoi(defPort) > 0) + { + strcpy(tmp, defPort); + port = atoi(defPort); + } + else + sprintf(tmp, "%d", port); + + // see if default port is available + if (InstUtil::portAvailable(port) == False) + { + // start with a random port number, and keep going until we find + // an available port + int origport = port = InstUtil::guessPort(); + while (InstUtil::portAvailable(port) == False) + { + ++port; + if (port > MAXPORT) + port = MINPORT; + if (port == origport) + { + port = -1; // NO AVAILABLE PORTS!!!!!!! + break; + } + } + } + + if (port == -1) // NO AVAILABLE PORTS!!!!!!! + { +#if DEBUG > 1 + cerr << "Leaving askSlapdPortSetup DIALOG_ERROR" << endl; +#endif + return DIALOG_ERROR; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SERVER_PORT, (long)port); + + dialogSetup(me, SLAPD_KEY_SERVER_PORT, tmp); + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + { +#if DEBUG > 1 + cerr << "Leaving askSlapdPortSetup DIALOG_NEXT" << endl; +#endif + return DIALOG_NEXT; + } + +#if DEBUG > 1 + cerr << "Leaving askSlapdPortSetup DIALOG_SAME" << endl; +#endif + return DIALOG_SAME; +} + +static DialogAction +askSlapdPortNext(Dialog *me) +{ +#if DEBUG > 1 + cerr << "Entering askSlapdPortNext" << endl; +#endif + const char *buf = me->input(); + const char *tmp; + char testbuf[1024]; + int port, err = 0; + + if (buf[0] == 0) + { + tmp = me->defaultAns(); + } + else + { + tmp = buf; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SERVER_PORT, tmp); + + port = atoi(tmp); + sprintf(testbuf, "%d", port); + if (strncmp(testbuf, tmp, 6) || port > MAXPORT || port < 1) + { + sprintf(testbuf, "OVERFLOW ERROR: Unable to bind to port %d\n" + "Please choose another port between 1 and %d.\n\n", + port, MAXPORT); + err = -1; + } + else if (InstUtil::portAvailable(port) == False) + { + sprintf(testbuf, "ERROR: Unable to bind to port %d\n" + "Please choose another port.\n\n", port); + err = -1; + } + + if (err) + { + DialogManagerType::showAlert(testbuf); + return DIALOG_SAME; + } + +#if DEBUG > 1 + cerr << "Leaving askSlapdPortNext" << endl; +#endif + return DIALOG_NEXT; +} + +DialogInput askSlapdServerID( +"Each instance of a directory server requires a unique identifier.\n" +"Press Enter to accept the default, or type in another name and press\n" +"Enter.\n", + +"Directory server identifier", + +NULL, + +askSlapdServerIDSetup, +askSlapdServerIDNext +); + +static DialogAction +askSlapdServerIDSetup(Dialog *me) +{ +#if DEBUG > 1 + cerr << "Entering askSlapdServerIDSetup" << endl; +#endif + // extract the hostname part of the FQDN + const char *tmp = 0; + char *basehost = 0; + if (tmp = getManager(me)->getBaseScript()->get(SLAPD_KEY_FULL_MACHINE_NAME)) { + basehost = strdup(tmp); + } else { + basehost = strdup(InstUtil::guessHostname()); + } + if (!basehost) + return DIALOG_ERROR; + char *ptr = strchr(basehost, '.'); + if (ptr) + { + *ptr = 0; + } + else + { + free(basehost); + basehost = 0; + } + + const char *ans = + getManager(me)->getDefaultScript()->get(SLAPD_KEY_SERVER_IDENTIFIER); + + if (!ans && basehost) + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SERVER_IDENTIFIER, + basehost); + else if (!ans && !basehost) + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SERVER_IDENTIFIER, + InstUtil::guessHostname()); + + if (ans) + { + me->setDefaultAns(ans); + } + else if (basehost) + { + me->setDefaultAns(basehost); + } + else + { + me->setDefaultAns(InstUtil::guessHostname()); + } + + if (basehost) + free(basehost); + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + { +#if DEBUG > 1 + cerr << "Leaving askSlapdServerIDSetup DIALOG_SAME" << endl; +#endif + return DIALOG_NEXT; + } + +#if DEBUG > 1 + cerr << "Leaving askSlapdServerIDSetup DIALOG_SAME" << endl; +#endif + return DIALOG_SAME; +} + +static DialogAction +askSlapdServerIDNext(Dialog *me) +{ + const char *ans = + getManager(me)->getDefaultScript()->get(SLAPD_KEY_SERVER_IDENTIFIER); + + const char *buf = me->input(); + const char *tmp; + char testbuf[1024]; + int err = 0; + + if (buf[0] == 0) + { + tmp = me->defaultAns(); + } + else + { + tmp = buf; + } + + if (!tmp) + { + err = -1; + sprintf(testbuf, "The name must not be empty"); + } + else if (!isValid(tmp)) + { + err = -1; + sprintf(testbuf, "Please specify a valid value for the name."); + } + else if (contains8BitChars(tmp)) + { + err = -1; + sprintf(testbuf, "The server ID must contain 7 bit ascii only."); + } + else if (!isValidServerID(tmp)) + { + err = -1; + sprintf(testbuf, "The server ID must be a valid filename and DN component."); + } + + if (!err) + { + // see if an instance by the same name already exists + + NSString instanceDir = NSString( + getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ROOT) + ) + "/slapd-" + tmp; + if (InstUtil::fileExists(instanceDir)) + { + sprintf(testbuf, "ERROR: a server instance named [%s] already exists." + " Please choose a unique name.\n", tmp); + err = -1; + } + } + + if (tmp) + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SERVER_IDENTIFIER, tmp); + + if (err) + { + DialogManagerType::showAlert(testbuf); + return DIALOG_SAME; + } + + return DIALOG_NEXT; +} + +DialogInput askMCAdminID( +"Please enter the administrator ID for the Netscape configuration\n" +"directory server. This is the ID typically used to log in to the\n" +"console. You will also be prompted for the password.\n", + +"Netscape configuration directory server\nadministrator ID", + +"admin", + +askMCAdminIDSetup, +askMCAdminIDNext +); + +static DialogAction +askMCAdminIDSetup(Dialog *me) +{ +#if DEBUG > 1 + cerr << "Entering askMCAdminIDSetup" << endl; +#endif + if (getManager(me)->getAdminScript() && + getManager(me)->getAdminScript()->get(SLAPD_KEY_ADMIN_SERVER_ID) && + getManager(me)->getAdminScript()->get(SLAPD_KEY_ADMIN_SERVER_PWD)) + { + // see if the MC Admin ID has been provided + if (getManager(me)->getBaseScript() && + !(getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ADMIN_ID) && + getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ADMIN_PWD))) + { + getManager(me)->getBaseScript()->set( + SLAPD_KEY_SERVER_ADMIN_ID, + getManager(me)->getAdminScript()->get(SLAPD_KEY_ADMIN_SERVER_ID) + ); + getManager(me)->getBaseScript()->set( + SLAPD_KEY_SERVER_ADMIN_PWD, + getManager(me)->getAdminScript()->get(SLAPD_KEY_ADMIN_SERVER_PWD) + ); + } + } + + dialogSetup(me, SLAPD_KEY_SERVER_ADMIN_ID, "admin"); + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + { +#if DEBUG > 1 + cerr << "Leaving askMCAdminIDSetup setup DIALOG_NEXT" << endl; +#endif + return DIALOG_NEXT; + } + + // this dialog is only used for creating the MC Admin; don't use it if + // we will be using an existing MC i.e. we are not creating the MC host + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC)) + { +#if DEBUG > 1 + cerr << "Leaving askMCAdminIDSetup DIALOG_NEXT" << endl; +#endif + return action; + } + +#if DEBUG > 1 + cerr << "Leaving askMCAdminIDSetup DIALOG_SAME" << endl; +#endif + return DIALOG_SAME; +} + +static DialogAction +askMCAdminIDNext(Dialog *me) +{ + if (getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC)) + return DIALOG_NEXT; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + { +#if DEBUG > 1 + cerr << "Leaving askMCAdminIDNext setup DIALOG_NEXT" << endl; +#endif + return DIALOG_NEXT; + } + + const char *adminUser; + const char *adminPwd; + const char *buf; + + buf = me->input(); + if (buf[0] == 0) + { + adminUser = me->defaultAns(); + } + else + { + adminUser = buf; + } + + if (!isValid(adminUser)) + { + DialogManagerType::showAlert("Please enter a valid ID."); + return DIALOG_SAME; + } + else if (!isAValidDN(adminUser) && contains8BitChars(adminUser)) + { + DialogManagerType::showAlert("The user ID value must be 7 bit ASCII only."); + return DIALOG_SAME; + } + + getManager(me)->getBaseScript()->set(SLAPD_KEY_SERVER_ADMIN_ID, adminUser); + + while (1) + { +// cerr << "before password in askMCAdminIDNext" << endl; + me->showString("Password: "); +// cerr << "after password in askMCAdminIDNext" << endl; + if (me->getPassword () == 0) + { + return DIALOG_PREV; + } + else + { + char *inp = strdup(me->input()); + + if (inp[0] == 0) + { + continue; + } + else if (contains8BitChars(inp)) + { + DialogManagerType::showAlert("Password must contain 7 bit characters only."); + return DIALOG_SAME; + } + else if (!isValid(inp)) + { + DialogManagerType::showAlert("Please enter a valid password."); + return DIALOG_SAME; + } + else + { + me->showString("Password (again): "); + if (me->getPassword() == 0) + { + return DIALOG_PREV; + } + else + { + adminPwd = me->input(); + if (strcmp(inp,adminPwd)) + { + DialogManagerType::showAlert("Passwords don't match."); + return DIALOG_SAME; + } + break; + } + } + free(inp); + } + } + getManager(me)->getBaseScript()->set(SLAPD_KEY_SERVER_ADMIN_PWD, adminPwd); + return DIALOG_NEXT; +} + +DialogInput askSlapdSuffix( +"The suffix is the root of your directory tree. You may have more than\n" +"one suffix.\n", + +"Suffix", + +NULL, + +askSlapdSuffixSetup, +askSlapdSuffixNext +); + +static DialogAction +askSlapdSuffixSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG)) + return action; + + if (!getManager(me)->getDefaultScript()->get(SLAPD_KEY_SUFFIX)) { + getManager(me)->getDefaultScript()->set( + SLAPD_KEY_SUFFIX, getManager(me)->getDefaultSuffix()); + } + + dialogSetup(me, SLAPD_KEY_SUFFIX, getManager(me)->getDefaultSuffix()); + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askSlapdSuffixNext(Dialog *me) +{ + const char *buf; + NSString val; + + buf = me->input(); + if (buf[0] == 0) + val = me->defaultAns(); + else + val = buf; + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SUFFIX, val); + + // check the value to see if it is a valid DN + if (!isAValidDN(val)) + { + DialogManagerType::showAlert("A suffix must be a valid DN."); + return DIALOG_SAME; + } + else if (!isValid(val)) + { + DialogManagerType::showAlert("Please enter a valid string."); + return DIALOG_SAME; + } + + return DIALOG_NEXT; +} + +DialogInput askSlapdRootDN( +"Certain directory server operations require an administrative user.\n" +"This user is referred to as the Directory Manager and typically has a\n" +"bind Distinguished Name (DN) of cn=Directory Manager. Press Enter to\n" +"accept the default value, or enter another DN. In either case, you\n" +"will be prompted for the password for this user. The password must\n" +"be at least 8 characters long.\n", + +"Directory Manager DN", + +DEFAULT_SLAPDUSER, + +askSlapdRootDNSetup, +askSlapdRootDNNext +); + +static DialogAction +askSlapdRootDNSetup(Dialog *me) +{ + if (!getManager(me)->getDefaultScript()->get(SLAPD_KEY_ROOTDN)) + getManager(me)->getDefaultScript()->set(SLAPD_KEY_ROOTDN, + DEFAULT_SLAPDUSER); + + dialogSetup(me, SLAPD_KEY_ROOTDN, DEFAULT_SLAPDUSER); + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askSlapdRootDNNext(Dialog *me) +{ + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + { +#if DEBUG > 1 + cerr << "Leaving askSlapdRootDNNext setup DIALOG_NEXT" << endl; +#endif + return DIALOG_NEXT; + } + + const char *slapdUser; + const char *slapdPwd; + const char *buf; + + buf = me->input(); + if (buf[0] == 0) + { + slapdUser = me->defaultAns(); + } + else + { + slapdUser = buf; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_ROOTDN, slapdUser); + + // check the value to see if it is a valid DN + if (!isAValidDN(slapdUser)) + { + DialogManagerType::showAlert("The Directory Manager must be a valid DN."); + return DIALOG_SAME; + } + else if (!isValid(slapdUser)) + { + DialogManagerType::showAlert("Please enter a valid string."); + return DIALOG_SAME; + } + + while (1) + { +// cerr << "before password in askSlapdRootDNNext" << endl; + me->showString("Password: "); +// cerr << "after password in askSlapdRootDNNext" << endl; + if (me->getPassword () == 0) + { + return DIALOG_PREV; + } + else + { + char *inp = strdup(me->input()); + + if (inp[0] == 0) + { + continue; + } + else if (contains8BitChars(inp)) + { + DialogManagerType::showAlert("Password must contain 7 bit characters only."); + return DIALOG_SAME; + } + else if (!isValid(inp)) + { + DialogManagerType::showAlert("Please enter a valid password."); + return DIALOG_SAME; + } + else + { + me->showString("Password (again): "); + if (me->getPassword() == 0) + { + return DIALOG_PREV; + } + else + { + slapdPwd = me->input(); + if (strcmp(inp,slapdPwd)) + { + DialogManagerType::showAlert("Passwords don't match."); + return DIALOG_SAME; + } + else if (!rootDNPwdIsValid(inp)) + { + DialogManagerType::showAlert("Password must be at least 8 characters long"); + return DIALOG_SAME; + } + break; + } + } + free(inp); + } + } + getManager(me)->getDefaultScript()->set(SLAPD_KEY_ROOTDNPWD, slapdPwd); + return DIALOG_NEXT; +} + +DialogYesNo askSample( +"You may install some sample entries in this directory instance. These\n" +"entries will be installed in a separate suffix and will not interfere\n" +"with the normal operation of the directory server.\n", + +"Do you want to install the sample entries?", + +"No", + +askSampleSetup, +askSampleNext +); + +static DialogAction +askSampleSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER)) + return action; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askSampleNext(Dialog *me) +{ + const char *buf = me->input(); + if (!buf || !*buf) + { + buf = me->defaultAns(); + if (!buf || !*buf) + buf = "No"; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_ADD_SAMPLE_ENTRIES, buf); + + if (!isValidYesNo(buf)) + return DIALOG_SAME; + + return DIALOG_NEXT; +} + +DialogYesNo askPopulate( +"You may wish to populate your new directory instance with some data.\n" +"You may already have a file in LDIF format to use or some suggested\n" +"entries can be added. If you want to import entries from an LDIF\n" +"file, you may type in the full path and filename at the prompt. If\n" +"you want the install program to add the suggested entries, type the\n" +"word suggest at the prompt. The suggested entries are common\n" +"container entries under your specified suffix, such as ou=People and\n" +"ou=Groups, which are commonly used to hold the entries for the persons\n" +"and groups in your organization. If you do not want to add any of\n" +"these entries, type the word none at the prompt.\n", + +"Type the full path and filename, the word suggest, or the word none\n", + +"none", + +askPopulateSetup, +askPopulateNext +); + +static DialogAction +askPopulateSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER)) + return action; + + // if setting up a UG host, by default setup the suggested entries + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG)) + { + getManager(me)->getDefaultScript()->set(SLAPD_KEY_INSTALL_LDIF_FILE, + "suggest"); + getManager(me)->getDefaultScript()->set(SLAPD_KEY_ADD_ORG_ENTRIES, + "Yes"); + } + + dialogSetup(me, SLAPD_KEY_INSTALL_LDIF_FILE, "none"); + me->setInputLen(1024); // it seems to get reset somewhere . . . + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askPopulateNext(Dialog *me) +{ + if (getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER)) + return DIALOG_NEXT; + + const char *buf = me->input(); + if (!buf || !*buf) + { + buf = me->defaultAns(); + if (!buf || !*buf) + buf = "No"; + } + + if (buf && !strncasecmp(buf, "none", strlen(buf))) + { + getManager(me)->getDefaultScript()->set(SLAPD_KEY_ADD_ORG_ENTRIES, "No"); + getManager(me)->getDefaultScript()-> + set(SLAPD_KEY_INSTALL_LDIF_FILE, "none"); + } + else if (buf && !strncasecmp(buf, "suggest", strlen(buf))) + { + getManager(me)->getDefaultScript()-> + set(SLAPD_KEY_INSTALL_LDIF_FILE, "suggest"); + getManager(me)->getDefaultScript()->set(SLAPD_KEY_ADD_ORG_ENTRIES, "Yes"); + } else { + getManager(me)->getDefaultScript()->set(SLAPD_KEY_INSTALL_LDIF_FILE, buf); + if (!InstUtil::fileExists(buf)) + { + NSString msg = NSString("The specified filename ") + buf + "\n" + + "does not exist. Please try again.\n"; + DialogManagerType::showAlert(msg); + return DIALOG_SAME; + } + else + { + getManager(me)->getDefaultScript()-> + set(SLAPD_KEY_ADD_ORG_ENTRIES, "Yes"); + getManager(me)->getDefaultScript()-> + set(SLAPD_KEY_INSTALL_LDIF_FILE, buf); + } + } + + return DIALOG_NEXT; +} + +DialogInput askOrgSize( +"Your directory will be populated with entries based on the size of\n" +"your organization. The choices are small or large. Please specify 1\n" +"for small and 2 for large.\n", + +"Organization size (1 or 2)", + +"1", + +askOrgSizeSetup, +askOrgSizeNext +); + +static DialogAction +askOrgSizeSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER)) + return action; + + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_ADD_ORG_ENTRIES)) + return action; + else if (dialogSetup(me, SLAPD_KEY_ORG_SIZE, "1") && + getManager(me)->installMode() == Silent) + return DIALOG_ERROR; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askOrgSizeNext(Dialog *me) +{ + if (getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER)) + return DIALOG_NEXT; + + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_ADD_ORG_ENTRIES)) + return DIALOG_NEXT; + + const char *buf = me->input(); + const char *tmp; + char testbuf[1024]; + int num, err = 0; + + if (buf[0] == 0) + { + tmp = me->defaultAns(); + } + else + { + tmp = buf; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_ORG_SIZE, tmp); + + num = atoi(tmp); + if (num != 1 && num != 2) + { + sprintf(testbuf, "Please enter a 1 or a 2\n\n"); + err = -1; + } + + if (err) + { + DialogManagerType::showAlert(testbuf); + return DIALOG_SAME; + } + + return DIALOG_NEXT; +} + +DialogYesNo askReplication( +"Replication is used to duplicate all or part of a directory server to\n" +"another directory server. This can be used for failsafe purposes, to\n" +"ensure that the directory data is always online and up-to-date in case\n" +"one server goes down. It is also useful for distributing directory\n" +"data from a central main repository to remote directory servers.\n", + +"Do you want to configure this directory server\nto use replication?", + +"No", + +askReplicationSetup, +askReplicationNext +); + +static DialogAction +askReplicationSetup(Dialog *me) +{ + me = me; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askReplicationNext(Dialog *me) +{ + const char *buf = me->input(); + if (!buf || !*buf) + { + buf = me->defaultAns(); + if (!buf || !*buf) + buf = "No"; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_USE_REPLICATION, buf); + + if (!isValidYesNo(buf)) + return DIALOG_SAME; + + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_REPLICATION)) + { + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SETUP_SUPPLIER, "No"); + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SETUP_CONSUMER, "No"); + } + + return DIALOG_NEXT; +} + +DialogYesNo askCIR( +"You may want to set up your directory server as a consumer server to\n" +"receive replicated entries from another directory server. The first\n" +"two of the following methods configure this server as a consumer:\n\n" +"1) The supplier server will push its entries to this server (SIR)\n" +"2) This server will pull the entries from the supplier (CIR)\n" +"3) This server will not be a consumer for replication (NONE)\n", + +"Do you want to set up this server as a consumer\n" +"for replication? (1, 2, or 3)", + +"3", + +askCIRSetup, +askCIRNext +); + +static DialogAction +askCIRSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_REPLICATION)) + return action; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askCIRNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_REPLICATION)) + return DIALOG_NEXT; + + const char *buf = me->input(); + if (!buf || !*buf) + { + buf = me->defaultAns(); + if (!buf || !*buf) + buf = "3"; + } + + int val = atoi(buf); + if (!val || val < 1 || val > 3) + { + DialogManagerType::showAlert("Please enter a 1, 2, or 3."); + return DIALOG_SAME; + } + else if (val == 3) + { + buf = "No"; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SETUP_CONSUMER, buf); + + return DIALOG_NEXT; +} + +DialogYesNo askSIR( +"You may want to set up your directory server as a supplier server to\n" +"replicate its entries to another directory server. The first two of\n" +"the following methods configure this server as a supplier:\n\n" +"1) This server will push its entries to another one (SIR)\n" +"2) Another server will pull entries from this one (CIR)\n" +"3) This server will not be a supplier for replication (NONE)\n", + +"Do you want to set up this server as a supplier\n" +"for replication? (1, 2, or 3)", + +"3", + +askSIRSetup, +askSIRNext +); + +static DialogAction +askSIRSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_REPLICATION)) + return action; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askSIRNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_REPLICATION)) + return DIALOG_NEXT; + + const char *buf = me->input(); + if (!buf || !*buf) + { + buf = me->defaultAns(); + if (!buf || !*buf) + buf = "3"; + } + + int val = atoi(buf); + if (!val || val < 1 || val > 3) + { + DialogManagerType::showAlert("Please enter a 1, 2, or 3."); + return DIALOG_SAME; + } + else if (val == 3) + { + buf = "No"; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SETUP_SUPPLIER, buf); + + return DIALOG_NEXT; +} + +DialogInput askCIRHost( +"Please specify the host name of the server from which the replicated\n" +"entries will be copied.\n", + +"Supplier host name", + +0, + +askCIRHostSetup, +askCIRHostNext +); + +static DialogAction +askCIRHostSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2")) + return action; + else if (dialogSetup(me, SLAPD_KEY_CIR_HOST, 0) && + getManager(me)->installMode() == Silent) + return DIALOG_ERROR; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askCIRHostNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2")) + return DIALOG_NEXT; + + const char *buf = me->input(); + const char *tmp; + int err = 0; + + if (buf[0] == 0) + { + tmp = me->defaultAns(); + } + else + { + tmp = buf; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_HOST, tmp); + + if (!tmp || !isValid(tmp)) + { + DialogManagerType::showAlert("Please enter a valid hostname"); + return DIALOG_SAME; + } + + return DIALOG_NEXT; +} + +DialogInput askCIRPort( +"Please specify the port of the server from which the replicated\n" +"entries will be copied.\n", + +"Supplier port", + +"389", + +askCIRPortSetup, +askCIRPortNext +); + +static DialogAction +askCIRPortSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2")) + return action; + + const char *defaultPort = "389"; + if (getManager(me)->featureIsEnabled(SLAPD_KEY_CIR_SECURITY_ON)) + defaultPort = "636"; + + if (dialogSetup(me, SLAPD_KEY_CIR_PORT, defaultPort) && + getManager(me)->installMode() == Silent) + return DIALOG_ERROR; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askCIRPortNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2")) + return DIALOG_NEXT; + + const char *buf = me->input(); + const char *tmp; + char testbuf[1024]; + int port, err = 0; + + if (buf[0] == 0) + { + tmp = me->defaultAns(); + } + else + { + tmp = buf; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_PORT, tmp); + + port = atoi(tmp); + sprintf(testbuf, "%d", port); + if (strncmp(testbuf, tmp, 6) || port > MAXPORT || port < 1) + { + sprintf(testbuf, "OVERFLOW ERROR: Unable to bind to port %d\n" + "Please choose another port between 1 and %d.\n\n", + port, MAXPORT); + err = -1; + } + + if (err) + { + DialogManagerType::showAlert(testbuf); + return DIALOG_SAME; + } + + return DIALOG_NEXT; +} + +DialogInput askCIRDN( +"Replication requires that this consumer has access to the portion of\n" +"the remote directory to be replicated. This requires a bind DN and\n" +"password for access to the supplier. You will first be asked for the\n" +"bind DN, then the password.\n", + +"Replication DN", + +NULL, + +askCIRDNSetup, +askCIRDNNext +); + +static DialogAction +askCIRDNSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2")) + return action; + + if (dialogSetup(me, SLAPD_KEY_CIR_BINDDN, getManager(me)->getConsumerDN()) && + getManager(me)->installMode() == Silent) + return DIALOG_ERROR; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askCIRDNNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2")) + return DIALOG_NEXT; + + const char *slapdUser; + char *slapdPwd = 0; + const char *buf; + + buf = me->input(); + if (buf[0] == 0) + { + slapdUser = me->defaultAns(); + } + else + { + slapdUser = buf; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_BINDDN, slapdUser); + + // check to see if it is a valid DN + if (!isAValidDN(slapdUser)) + { + DialogManagerType::showAlert("The consumer must be a valid DN."); + return DIALOG_SAME; + } + else if (!isValid(slapdUser)) + { + DialogManagerType::showAlert("Please enter a valid string."); + return DIALOG_SAME; + } + + while (1) + { + me->showString("Password: "); + if (me->getPassword () == 0) + { + return DIALOG_PREV; + } + else + { + char *inp = strdup(me->input()); + + if (inp[0] == 0) + { + free(inp); + continue; + } + else + { + slapdPwd = inp; + break; + } + } + } + + if (slapdPwd) + { + getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_BINDDNPWD, slapdPwd); + free(slapdPwd); + } + + return DIALOG_NEXT; +} + +DialogInput askCIRSuffix( +"Please enter the full DN of the part of the tree to replicate,\n" +"including the suffix (e.g. ou=People, o=company.com).\n", + +"Enter the directory path", + +NULL, + +askCIRSuffixSetup, +askCIRSuffixNext +); + +static DialogAction +askCIRSuffixSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2")) + return action; + + if (dialogSetup(me, SLAPD_KEY_CIR_SUFFIX, getManager(me)->getDefaultSuffix()) && + getManager(me)->installMode() == Silent) + return DIALOG_ERROR; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askCIRSuffixNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2")) + return DIALOG_NEXT; + + const char *buf; + NSString val; + + buf = me->input(); + if (buf[0] == 0) + val = me->defaultAns(); + else + val = buf; + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_SUFFIX, val); + + // check val to see if it is a valid DN + if (!isAValidDN(val)) + { + DialogManagerType::showAlert("The suffix must be a valid DN."); + return DIALOG_SAME; + } + if (!isValid(val)) + { + DialogManagerType::showAlert("Please enter a valid string."); + return DIALOG_SAME; + } + + int status; + if (status = getManager(me)->verifyRemoteLdap( + SLAPD_KEY_CIR_HOST, + SLAPD_KEY_CIR_PORT, + SLAPD_KEY_CIR_SUFFIX, + SLAPD_KEY_CIR_BINDDN, + SLAPD_KEY_CIR_BINDDNPWD + ) + ) + { + ostrstream msg; + msg << "Could not connect to ldap://" + << getManager(me)->getDefaultScript()->get(SLAPD_KEY_CIR_HOST) + << ":" + << getManager(me)->getDefaultScript()->get(SLAPD_KEY_CIR_PORT) + << "/" + << getManager(me)->getDefaultScript()->get(SLAPD_KEY_CIR_SUFFIX) + << endl << "for bind DN " + << getManager(me)->getDefaultScript()->get(SLAPD_KEY_CIR_BINDDN) + << " status = " << status << endl + << "Please check your typing. If you have mis-typed, you can backup" + << endl + << "and retype. Otherwise, the remote server may be down at this time." + << endl + << "The replication agreement will be created anyway. Proceeding..." + << endl << ends; + DialogManagerType::showAlert(msg.str()); + delete [] msg.str(); + return DIALOG_NEXT; + } + + return DIALOG_NEXT; +} + +DialogYesNo askCIRSSL( +"You may use SSL authentication for replication if you have enabled it\n" +"on the remote server.\n", + +"Do you want to use SSL?", + +"No", + +askCIRSSLSetup, +askCIRSSLNext +); + +static DialogAction +askCIRSSLSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2")) + return action; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askCIRSSLNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2")) + return DIALOG_NEXT; + + const char *buf = me->input(); + if (!buf || !*buf) + { + buf = me->defaultAns(); + if (!buf || !*buf) + buf = "No"; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_SECURITY_ON, buf); + + if (!isValidYesNo(buf)) + return DIALOG_SAME; + + return DIALOG_NEXT; +} + +DialogInput askCIRInterval( +"Please specify the time interval to check the remote server for new\n" +"entries to be replicated. Use the directory server console to set up\n" +"more fine-grained control. Specify the time in minutes. Use a 0\n" +"(zero) to indicate that changes should be propagated immediately all\n" +"the time.\n", + +"Replication Sync Interval (in minutes)", + +"10", + +askCIRIntervalSetup, +askCIRIntervalNext +); + +static DialogAction +askCIRIntervalSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2")) + return action; + + if (dialogSetup(me, SLAPD_KEY_CIR_INTERVAL, "10") && + getManager(me)->installMode() == Silent) + return DIALOG_ERROR; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askCIRIntervalNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2")) + return DIALOG_NEXT; + + const char *buf = me->input(); + const char *tmp; + char testbuf[1024]; + int interval, err = 0; + + if (buf[0] == 0) + { + tmp = me->defaultAns(); + } + else + { + tmp = buf; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_INTERVAL, tmp); + + interval = atoi(tmp); + if (!isdigit((*tmp)) || interval < 0) + { + sprintf(testbuf, "Please specify an integer greater than or equal to 0"); + err = -1; + } + + if (err) + { + DialogManagerType::showAlert(testbuf); + return DIALOG_SAME; + } + + return DIALOG_NEXT; +} + +DialogInput askChangeLogSuffix( +"Changes to the database will be kept under a separate suffix in the\n" +"directory tree. These changes are used to replicate changes to other\n" +"directory servers.\n", + +"Changelog suffix", + +"cn=changelog", + +askChangeLogSuffixSetup, +askChangeLogSuffixNext +); + +static DialogAction +askChangeLogSuffixSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER)) + return action; + + if (dialogSetup(me, SLAPD_KEY_CHANGELOGSUFFIX, "cn=changelog") && + getManager(me)->installMode() == Silent) + return DIALOG_ERROR; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askChangeLogSuffixNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER)) + return DIALOG_NEXT; + + const char *buf; + NSString val; + + buf = me->input(); + if (buf[0] == 0) + val = me->defaultAns(); + else + val = buf; + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_CHANGELOGSUFFIX, val); + + // check to see if val is a valid DN + if (!isAValidDN(val)) + { + DialogManagerType::showAlert("The ChangeLog suffix must be a valid DN"); + return DIALOG_SAME; + } + else if (!isValid(val)) + { + DialogManagerType::showAlert("Please enter a valid string."); + return DIALOG_SAME; + } + + return DIALOG_NEXT; +} + +DialogInput askChangeLogDir( +"Changes to the main database will be kept in a separate database\n" +"stored in a separate directory path, usually under your server\n" +"instance directory.\n", + +"Changelog database\n" +"directory", + +NULL, + +askChangeLogDirSetup, +askChangeLogDirNext +); + +static DialogAction +askChangeLogDirSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER)) + return action; + + NSString dir = NSString( + getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ROOT) + ) + "/slapd-" + + getManager(me)->getDefaultScript()->get(SLAPD_KEY_SERVER_IDENTIFIER) + + "/logs/changelogdb"; + if (dialogSetup(me, SLAPD_KEY_CHANGELOGDIR, dir) && + getManager(me)->installMode() == Silent) + return DIALOG_ERROR; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askChangeLogDirNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER)) + return DIALOG_NEXT; + + const char *buf; + NSString val; + + buf = me->input(); + if (buf[0] == 0) + val = me->defaultAns(); + else + val = buf; + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_CHANGELOGDIR, val); + + if (InstUtil::dirExists(val) && !InstUtil::dirWritable(val)) + { + DialogManagerType::showAlert("You do not have access to that directory. Please try again."); + return DIALOG_SAME; + } + + return DIALOG_NEXT; +} + +DialogInput askReplicationDN( +"In order to allow remote servers to replicate new entries to this\n" +"server, the remote server must have the ability to bind to this server\n" +"as some entity with permission to do so. The Supplier DN is the DN of\n" +"the entity the remote server will use to connect to this server to\n" +"supply updates. The Supplier DN also requires a password which you\n" +"will be prompted for after the DN.\n", + +"Supplier Bind DN", + +"cn=supplier", + +askReplicationDNSetup, +askReplicationDNNext +); + +static DialogAction +askReplicationDNSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "1")) + return action; + + if (dialogSetup(me, SLAPD_KEY_REPLICATIONDN, "cn=supplier") && + getManager(me)->installMode() == Silent) + return DIALOG_ERROR; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askReplicationDNNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "1")) + return DIALOG_NEXT; + + const char *replicationdn; + const char *replicationpw; + const char *buf; + + buf = me->input(); + if (buf[0] == 0) + { + replicationdn = me->defaultAns(); + } + else + { + replicationdn = buf; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_REPLICATIONDN, replicationdn); + + // check to see if it is a valid DN + if (!isAValidDN(replicationdn)) + { + DialogManagerType::showAlert("The Supplier Bind DN must be a valid DN"); + return DIALOG_SAME; + } + if (!isValid(replicationdn)) + { + DialogManagerType::showAlert("Please enter a valid string."); + return DIALOG_SAME; + } + + while (1) + { + me->showString("Password: "); + if (me->getPassword () == 0) + { + return DIALOG_PREV; + } + else + { + char *inp = strdup(me->input()); + + if (inp[0] == 0) + { + continue; + } + else if (contains8BitChars(inp)) + { + DialogManagerType::showAlert("Password must contain 7 bit characters only."); + return DIALOG_SAME; + } + else if (!isValid(inp)) + { + DialogManagerType::showAlert("Please enter a valid password."); + return DIALOG_SAME; + } + else + { + me->showString("Password (again): "); + if (me->getPassword() == 0) + { + return DIALOG_PREV; + } + else + { + replicationpw = me->input(); + if (strcmp(inp,replicationpw)) + { + DialogManagerType::showAlert("Passwords don't match."); + return DIALOG_SAME; + } + break; + } + } + free(inp); + } + } + getManager(me)->getDefaultScript()->set(SLAPD_KEY_REPLICATIONPWD, replicationpw); + return DIALOG_NEXT; +} + +DialogInput askConsumerDN( +"In order to allow remote servers to replicate new entries from this\n" +"server, the remote server must have the ability to bind to this server\n" +"as some entity with permission to do so. The Consumer DN is the DN of\n" +"the entity the remote server will use to connect to this server to\n" +"pull the new entries. This entity will have access to the entire\n" +"database as well as the changelog entries. The Consumer DN also\n" +"requires a password which you will be prompted for after the DN. If\n" +"you leave this entry blank, no consumer bind DN will be created. The\n" +"default is no consumer bind DN.\n", + +"Consumer Bind DN", + +NULL, + +askConsumerDNSetup, +askConsumerDNNext +); + +static DialogAction +askConsumerDNSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "2")) + return action; + + if (dialogSetup(me, SLAPD_KEY_CONSUMERDN, 0) && + getManager(me)->installMode() == Silent) + return DIALOG_ERROR; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askConsumerDNNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "2")) + return DIALOG_NEXT; + + const char *consumerdn; + const char *consumerpw; + const char *buf; + + buf = me->input(); + if (buf[0] == 0) + { + consumerdn = me->defaultAns(); + } + else + { + consumerdn = buf; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_CONSUMERDN, consumerdn); + + if (!consumerdn || !*consumerdn || + !strncasecmp(consumerdn, "none", strlen(consumerdn))) + { + getManager(me)->getDefaultScript()->remove(SLAPD_KEY_CONSUMERDN); + return DIALOG_NEXT; + } + + // check to see if it is a valid dn + if (!isAValidDN(consumerdn)) + { + DialogManagerType::showAlert("The Consumer Bind DN must be a valid DN"); + return DIALOG_SAME; + } + else if (!isValid(consumerdn)) + { + DialogManagerType::showAlert("Please enter a valid string."); + return DIALOG_SAME; + } + + while (1) + { + me->showString("Password: "); + if (me->getPassword () == 0) + { + return DIALOG_PREV; + } + else + { + char *inp = strdup(me->input()); + + if (inp[0] == 0) + { + continue; + } + else if (contains8BitChars(inp)) + { + DialogManagerType::showAlert("Password must contain 7 bit characters only."); + return DIALOG_SAME; + } + else if (!isValid(inp)) + { + DialogManagerType::showAlert("Please enter a valid password."); + return DIALOG_SAME; + } + else + { + me->showString("Password (again): "); + if (me->getPassword() == 0) + { + return DIALOG_PREV; + } + else + { + consumerpw = me->input(); + if (strcmp(inp,consumerpw)) + { + DialogManagerType::showAlert("Passwords don't match."); + return DIALOG_SAME; + } + break; + } + } + free(inp); + } + } + getManager(me)->getDefaultScript()->set(SLAPD_KEY_CONSUMERPWD, consumerpw); + return DIALOG_NEXT; +} + +DialogInput askSIRHost( +"Please specify the host name of the server to which the replicated\n" +"entries will be pushed.\n", + +"Consumer host name", + +0, + +askSIRHostSetup, +askSIRHostNext +); + +static DialogAction +askSIRHostSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1")) + return action; + else if (dialogSetup(me, SLAPD_KEY_SIR_HOST, 0) && + getManager(me)->installMode() == Silent) + return DIALOG_ERROR; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askSIRHostNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1")) + return DIALOG_NEXT; + + const char *buf = me->input(); + const char *tmp; + int err = 0; + + if (buf[0] == 0) + { + tmp = me->defaultAns(); + } + else + { + tmp = buf; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SIR_HOST, tmp); + + if (!tmp || !isValid(tmp)) + { + DialogManagerType::showAlert("Please enter a valid hostname"); + return DIALOG_SAME; + } + + return DIALOG_NEXT; +} + +DialogInput askSIRPort( +"Please specify the port of the server to which the replicated entries\n" +"will be pushed.\n", + +"Consumer port", + +"389", + +askSIRPortSetup, +askSIRPortNext +); + +static DialogAction +askSIRPortSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1")) + return action; + + const char *defaultPort = "389"; + if (getManager(me)->featureIsEnabled(SLAPD_KEY_SIR_SECURITY_ON)) + defaultPort = "636"; + + if (dialogSetup(me, SLAPD_KEY_SIR_PORT, defaultPort) && + getManager(me)->installMode() == Silent) + return DIALOG_ERROR; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askSIRPortNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1")) + return DIALOG_NEXT; + + const char *buf = me->input(); + const char *tmp; + char testbuf[1024]; + int port, err = 0; + + if (buf[0] == 0) + { + tmp = me->defaultAns(); + } + else + { + tmp = buf; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SIR_PORT, tmp); + + port = atoi(tmp); + sprintf(testbuf, "%d", port); + if (strncmp(testbuf, tmp, 6) || port > MAXPORT || port < 1) + { + sprintf(testbuf, "OVERFLOW ERROR: Unable to bind to port %d\n" + "Please choose another port between 1 and %d.\n\n", + port, MAXPORT); + err = -1; + } + + if (err) + { + DialogManagerType::showAlert(testbuf); + return DIALOG_SAME; + } + + return DIALOG_NEXT; +} + +DialogInput askSIRDN( +"Replication requires that this supplier has access to the portion of\n" +"the remote directory to be replicated. This requires a bind DN and\n" +"password for access to the consumer. You will first be asked for the\n" +"bind DN, then the password. This is the same as the Supplier DN on\n" +"the consumer.\n", + +"Replication DN on the Consumer", + +"cn=supplier", + +askSIRDNSetup, +askSIRDNNext +); + +static DialogAction +askSIRDNSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1")) + return action; + + if (dialogSetup(me, SLAPD_KEY_SIR_BINDDN, "cn=supplier") && + getManager(me)->installMode() == Silent) + return DIALOG_ERROR; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askSIRDNNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1")) + return DIALOG_NEXT; + + const char *slapdUser; + char *slapdPwd = 0; + const char *buf; + + buf = me->input(); + if (buf[0] == 0) + { + slapdUser = me->defaultAns(); + } + else + { + slapdUser = buf; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SIR_BINDDN, slapdUser); + + // check to see if it is a valid dn + if (!isAValidDN(slapdUser)) + { + DialogManagerType::showAlert("The Consumer Replication DN must be a valid DN"); + return DIALOG_SAME; + } + else if (!isValid(slapdUser)) + { + DialogManagerType::showAlert("Please enter a valid string."); + return DIALOG_SAME; + } + + while (1) + { + me->showString("Password: "); + if (me->getPassword () == 0) + { + return DIALOG_PREV; + } + else + { + char *inp = strdup(me->input()); + + if (inp[0] == 0) + { + free(inp); + continue; + } + else + { + slapdPwd = inp; + break; + } + } + } + + if (slapdPwd) + { + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SIR_BINDDNPWD, slapdPwd); + free(slapdPwd); + } + + return DIALOG_NEXT; +} + +DialogInput askSIRSuffix( +"Please enter the full DN of the part of the tree to replicate,\n" +"including the suffix (e.g. ou=People, o=company.com).\n", + +"Directory path (DN)", + +NULL, + +askSIRSuffixSetup, +askSIRSuffixNext +); + +static DialogAction +askSIRSuffixSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1")) + return action; + + if (dialogSetup(me, SLAPD_KEY_SIR_SUFFIX, getManager(me)->getDefaultSuffix()) && + getManager(me)->installMode() == Silent) + return DIALOG_ERROR; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askSIRSuffixNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1")) + return DIALOG_NEXT; + + const char *buf; + NSString val; + + buf = me->input(); + if (buf[0] == 0) + val = me->defaultAns(); + else + val = buf; + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SIR_SUFFIX, val); + + // check to see if it is a valid dn + if (!isAValidDN(val)) + { + DialogManagerType::showAlert("The suffix must be a valid DN"); + return DIALOG_SAME; + } + else if (!isValid(val)) + { + DialogManagerType::showAlert("Please enter a valid string."); + return DIALOG_SAME; + } + + int status; + if (status = getManager(me)->verifyRemoteLdap( + SLAPD_KEY_SIR_HOST, + SLAPD_KEY_SIR_PORT, + SLAPD_KEY_SIR_SUFFIX, + SLAPD_KEY_SIR_BINDDN, + SLAPD_KEY_SIR_BINDDNPWD + ) + ) + { + ostrstream msg; + msg << "Could not connect to ldap://" + << getManager(me)->getDefaultScript()->get(SLAPD_KEY_SIR_HOST) + << ":" + << getManager(me)->getDefaultScript()->get(SLAPD_KEY_SIR_PORT) + << "/" + << getManager(me)->getDefaultScript()->get(SLAPD_KEY_SIR_SUFFIX) + << endl << "for bind DN " + << getManager(me)->getDefaultScript()->get(SLAPD_KEY_SIR_BINDDN) + << " status = " << status << endl + << "Please check your typing. If you have mis-typed, you can backup" + << endl + << "and retype. Otherwise, the remote server may be down at this time." + << endl + << "The replication agreement will be created anyway. Proceeding..." + << endl << ends; + DialogManagerType::showAlert(msg.str()); + delete [] msg.str(); + return DIALOG_NEXT; + } + + return DIALOG_NEXT; +} + +DialogYesNo askSIRSSL( +"You may use SSL authentication for replication if you have enabled it\n" +"on the remote server.\n", + +"Do you want to use SSL?", + +"No", + +askSIRSSLSetup, +askSIRSSLNext +); + +static DialogAction +askSIRSSLSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1")) + return action; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askSIRSSLNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1")) + return DIALOG_NEXT; + + const char *buf = me->input(); + if (!buf || !*buf) + { + buf = me->defaultAns(); + if (!buf || !*buf) + buf = "No"; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SIR_SECURITY_ON, buf); + + if (!isValidYesNo(buf)) + return DIALOG_SAME; + + return DIALOG_NEXT; +} + +DialogInput askCIRDays( +"Please enter the days of the week on which you would like replication\n" +"to occur. The days are specified by a number. For example, use 0 for\n" +"Sunday, 1 for Monday, etc. Use 6 for Saturday. You may not specify a\n" +"number greater than 6 or less than 0. The numbers should be entered\n" +"one after another in a list. For example, 0123 would be Sunday,\n" +"Monday, Tuesday, and Wednesday. 06 would be Sunday and Saturday. The\n" +"default is everyday.\n", + +"Enter the replication days", + +"all", + +askCIRDaysSetup, +askCIRDaysNext +); + +static DialogAction +askCIRDaysSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2")) + return action; + + if (dialogSetup(me, SLAPD_KEY_CIR_DAYS, "all") && + getManager(me)->installMode() == Silent) + return DIALOG_ERROR; + + const char *tmp; + if ((tmp = getManager(me)->getDefaultScript()->get(SLAPD_KEY_SIR_DAYS)) && + !*tmp) + me->setDefaultAns("all"); + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askCIRDaysNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2")) + return DIALOG_NEXT; + + const char *buf; + NSString val; + + buf = me->input(); + if (buf[0] == 0) + val = me->defaultAns(); + else + val = buf; + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_DAYS, val); + + int status = 0; + ostrstream msg; + + char realval[8] = "-------"; + if (!strncasecmp(val, "all", strlen(val))) + strcpy(realval, ""); // default is everyday + else + { + for (const char *ptr = val; *ptr; ++ptr) + { + if (!isdigit(*ptr)) + { + msg << "The string [" << val << "] contains non-digit characters." + << " Please re enter the string." << ends; + status = 1; + break; + } + + int ival = (int)(*ptr) - (int)'0'; + if (ival > 6) + { + msg << "The string contains an invalid value [" << ival << "]." + << " Please re enter the string." << ends; + status = 2; + break; + } + + // this step makes sure we get the numbers in order with no duplicates + realval[ival] = *ptr; + } + + if (status) + { + DialogManagerType::showAlert(msg.str()); + delete [] msg.str(); + return DIALOG_SAME; + } + + // realval now contains a string like + // 0---4-6, but we really want 046 + int index = 0; + for (char *p2 = realval; *p2; ++p2) + { + if (*p2 != '-') + realval[index++] = *p2; + } + realval[index] = 0; + + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_DAYS, realval); + + return DIALOG_NEXT; +} + +DialogInput askSIRDays( +"Please enter the days of the week on which you would like replication\n" +"to occur. The days are specified by a number. For example, use 0 for\n" +"Sunday, 1 for Monday, etc. Use 6 for Saturday. You may not specify a\n" +"number greater than 6 or less than 0. The numbers should be entered\n" +"one after another in a list. For example, 0123 would be Sunday,\n" +"Monday, Tuesday, and Wednesday. 06 would be Sunday and Saturday. The\n" +"default is everyday.\n", + +"Enter the replication days", + +"all", + +askSIRDaysSetup, +askSIRDaysNext +); + +static DialogAction +askSIRDaysSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1")) + return action; + + if (dialogSetup(me, SLAPD_KEY_SIR_DAYS, "all") && + getManager(me)->installMode() == Silent) + return DIALOG_ERROR; + + const char *tmp; + if ((tmp = getManager(me)->getDefaultScript()->get(SLAPD_KEY_SIR_DAYS)) && + !*tmp) + me->setDefaultAns("all"); + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askSIRDaysNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1")) + return DIALOG_NEXT; + + const char *buf; + NSString val; + + buf = me->input(); + if (buf[0] == 0) + val = me->defaultAns(); + else + val = buf; + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SIR_DAYS, val); + + int status = 0; + ostrstream msg; + + char realval[8] = "-------"; + if (!strncasecmp(val, "all", strlen(val))) + strcpy(realval, ""); // default is everyday + else + { + for (const char *ptr = val; *ptr; ++ptr) + { + if (!isdigit(*ptr)) + { + msg << "The string [" << val << "] contains non-digit characters." + << " Please re enter the string." << ends; + status = 1; + break; + } + + int ival = (int)(*ptr) - (int)'0'; + if (ival > 6) + { + msg << "The string contains an invalid value [" << ival << "]." + << " Please re enter the string." << ends; + status = 2; + break; + } + + // this step makes sure we get the numbers in order with no duplicates + realval[ival] = *ptr; + } + + if (status) + { + DialogManagerType::showAlert(msg.str()); + delete [] msg.str(); + return DIALOG_SAME; + } + + // realval now contains a string like + // 0---4-6, but we really want 046 + int index = 0; + for (char *p2 = realval; *p2; ++p2) + { + if (*p2 != '-') + realval[index++] = *p2; + } + realval[index] = 0; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SIR_DAYS, realval); + + return DIALOG_NEXT; +} + +DialogInput askCIRTimes( +"Please enter the time of day you would like replication to occur. The\n" +"time is specified as a range in the form HHMM-HHMM in 24 hour time.\n" +"HH represents the hour portion of the time, and MM the minutes.\n" +"Numbers less than 10 should be preceeded by a 0. For example, to\n" +"enable replication between 1 am and 4:30 am, specify 0100-0430. To\n" +"specify 11 am to 9 pm, use 1100-2100. 12 am to 12:59 am is specified\n" +"as 0000-0059. The default is all day.\n", + +"Enter the replication times", + +"all day", + +askCIRTimesSetup, +askCIRTimesNext +); + +static DialogAction +askCIRTimesSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2")) + return action; + + if (dialogSetup(me, SLAPD_KEY_CIR_TIMES, "all day") && + getManager(me)->installMode() == Silent) + return DIALOG_ERROR; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askCIRTimesNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2")) + return DIALOG_NEXT; + + const char *buf; + NSString val; + + buf = me->input(); + if (buf[0] == 0) + val = me->defaultAns(); + else + val = buf; + + if (!strncasecmp(val, "all day", strlen(val))) + { + val = ""; + getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_TIMES, val); + return DIALOG_NEXT; + } + + int status = 0; + ostrstream msg; + + int pos = 0; + // format should be HHMM-HHMM + int maxvals[9] = {0, 23, 0, 59, 0, 0, 23, 0, 59}; + char teststr[3]; // 2 digits plus \0 + int testindex = 0; + for (const char *ptr = val; *ptr; ++ptr, ++pos) + { + // position 4 should contain the '-' + if (pos == 4 && *ptr != '-') + { + msg << "The time specification [" << val << "] is invalid.\n" + << "Please re enter the string." << ends; + status = 1; + break; + } + else if (pos == 4) + continue; + + if (!isdigit(*ptr) && pos != 4) + { + msg << "The time specification [" << val << "] contains non-digit characters.\n" + << "Please re enter the string." << ends; + status = 2; + break; + } + + teststr[testindex++] = *ptr; + if (pos == 1 || pos == 3 || pos == 6 || pos == 8) + { + teststr[testindex] = 0; + testindex = 0; + if (teststr[0] == '0') + teststr[0] = ' '; + int ival = atoi(teststr); + if (ival > maxvals[pos]) + { + msg << "The string contains an invalid value [" << ival << "].\n" + << "Please re enter the string." << ends; + status = 3; + break; + } + } + } + + if (pos != 9) + { + msg << "The string [" << val << "] is invalid.\n" + << "Please re enter the string." << ends; + status = 4; + } + + if (status) + { + DialogManagerType::showAlert(msg.str()); + delete [] msg.str(); + return DIALOG_SAME; + } + + return DIALOG_NEXT; +} + +DialogInput askSIRTimes( +"Please enter the time of day you would like replication to occur. The\n" +"time is specified as a range in the form HHMM-HHMM in 24 hour time.\n" +"HH represents the hour portion of the time, and MM the minutes.\n" +"Numbers less than 10 should be preceeded by a 0. For example, to\n" +"enable replication between 1 am and 4:30 am, specify 0100-0430. To\n" +"specify 11 am to 9 pm, use 1100-2100. 12 am to 12:59 am is specified\n" +"as 0000-0059. The default is all day.\n", + +"Enter the replication times", + +"all day", + +askSIRTimesSetup, +askSIRTimesNext +); + +static DialogAction +askSIRTimesSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1")) + return action; + + if (dialogSetup(me, SLAPD_KEY_SIR_TIMES, "all day") && + getManager(me)->installMode() == Silent) + return DIALOG_ERROR; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askSIRTimesNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) || + strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1")) + return DIALOG_NEXT; + + const char *buf; + NSString val; + + buf = me->input(); + if (buf[0] == 0) + val = me->defaultAns(); + else + val = buf; + + if (!strncasecmp(val, "all day", strlen(val))) + { + val = ""; + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SIR_TIMES, val); + return DIALOG_NEXT; + } + + int status = 0; + ostrstream msg; + + int pos = 0; + // format should be HHMM-HHMM + int maxvals[9] = {0, 23, 0, 59, 0, 0, 23, 0, 59}; + char teststr[3]; // 2 digits plus \0 + int testindex = 0; + for (const char *ptr = val; *ptr; ++ptr, ++pos) + { + // position 4 should contain the '-' + if (pos == 4 && *ptr != '-') + { + msg << "The time specification [" << val << "] is invalid.\n" + << "Please re enter the string." << ends; + status = 1; + break; + } + else if (pos == 4) + continue; + + if (!isdigit(*ptr) && pos != 4) + { + msg << "The time specification [" << val << "] contains non-digit characters.\n" + << "Please re enter the string." << ends; + status = 2; + break; + } + + teststr[testindex++] = *ptr; + if (pos == 1 || pos == 3 || pos == 6 || pos == 8) + { + teststr[testindex] = 0; + testindex = 0; + if (teststr[0] == '0') + teststr[0] = ' '; + int ival = atoi(teststr); + if (ival > maxvals[pos]) + { + msg << "The string contains an invalid value [" << ival << "].\n" + << "Please re enter the string." << ends; + status = 3; + break; + } + } + } + + if (pos != 9) + { + msg << "The string [" << val << "] is invalid.\n" + << "Please re enter the string." << ends; + status = 4; + } + + if (status) + { + DialogManagerType::showAlert(msg.str()); + delete [] msg.str(); + return DIALOG_SAME; + } + + return DIALOG_NEXT; +} + +DialogYesNo askUseExistingMC( +"Netscape server information is stored in the Netscape configuration\n" +"directory server, which you may have already set up. If so, you\n" +"should configure this server to be managed by the configuration\n" +"server. To do so, the following information about the configuration\n" +"server is required: the fully qualified host name of the form\n" +"<hostname>.<domainname>(e.g. hostname.domain.com), the port number,\n" +"the suffix, and the DN and password of a user having permission to\n" +"write the configuration information, usually the Netscape\n" +"configuration directory administrator.\n\n" +"If you want to install this software as a standalone server, or if you\n" +"want this instance to serve as your Netscape configuration directory\n" +"server, press Enter.\n", + +"Do you want to register this software with an existing\n" +"Netscape configuration directory server?", + +"No", + +askUseExistingMCSetup, +askUseExistingMCNext +); + +static DialogAction +askUseExistingMCSetup(Dialog *me) +{ +#if DEBUG > 1 + cerr << "Entering askUseExistingMCSetup" << endl; +#endif + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + + if (action != DIALOG_PREV) + { + if (getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_URL)) + { + // tell the instance creator not to create the Config entries + // new instance + getManager(me)->getDefaultScript()->set( + SLAPD_KEY_USE_EXISTING_MC, "Yes"); + getManager(me)->getDefaultScript()->set( + SLAPD_KEY_SLAPD_CONFIG_FOR_MC, "No"); + } + else + { + getManager(me)->getDefaultScript()->set( + SLAPD_KEY_USE_EXISTING_MC, "No"); + getManager(me)->getDefaultScript()->set( + SLAPD_KEY_SLAPD_CONFIG_FOR_MC, "Yes"); + } + } + + dialogSetup(me, SLAPD_KEY_USE_EXISTING_MC, "No"); + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + { +#if DEBUG > 1 + cerr << "Leaving askUseExistingMCSetup DIALOG_NEXT" << endl; +#endif + return DIALOG_NEXT; + } + +#if DEBUG > 1 + cerr << "Leaving askUseExistingMCSetup DIALOG_SAME" << endl; +#endif + return DIALOG_SAME; +} + +static DialogAction +askUseExistingMCNext(Dialog *me) +{ +#if DEBUG > 1 + cerr << "Entering askUseExistingMCNext" << endl; +#endif + const char *buf = me->input(); + if (!buf || !*buf) + { + buf = me->defaultAns(); + if (!buf || !*buf) + buf = "No"; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_USE_EXISTING_MC, buf); + + if (!isValidYesNo(buf)) + return DIALOG_SAME; + +#if DEBUG > 1 + cerr << "Leaving askUseExistingMCNext" << endl; +#endif + return DIALOG_NEXT; +} + +DialogInput askMCHost( +"Enter the fully qualified domain name of the Netscape configuration\n" +"directory server host in the form <hostname>.<domainname>\n" +"(e.g. hostname.domain.com).\n", + +"Netscape configuration directory server\nhost name", + +0, + +askMCHostSetup, +askMCHostNext +); + +static DialogAction +askMCHostSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC)) + return action; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askMCHostNext(Dialog *me) +{ + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC)) + return DIALOG_NEXT; + + const char *buf = me->input(); + const char *tmp; + + if (buf[0] == 0) + { + tmp = me->defaultAns(); + } + else + { + tmp = buf; + } + + getManager(me)->getBaseScript()->set(SLAPD_KEY_K_LDAP_HOST, tmp); + + if (!tmp || !isValid(tmp)) + { + DialogManagerType::showAlert("Please enter a valid hostname"); + return DIALOG_SAME; + } + + return DIALOG_NEXT; +} + +DialogInput askMCPort( +"Please specify the port number on which the Netscape configuration\n" +"directory server listens.\n", + +"Netscape configuration directory server\nport number", + +"389", + +askMCPortSetup, +askMCPortNext +); + +static DialogAction +askMCPortSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC)) + return action; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askMCPortNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC)) + return DIALOG_NEXT; + + const char *buf = me->input(); + const char *tmp; + char testbuf[1024]; + int port, err = 0; + + if (buf[0] == 0) + { + tmp = me->defaultAns(); + } + else + { + tmp = buf; + } + + getManager(me)->getBaseScript()->set(SLAPD_KEY_K_LDAP_PORT, tmp); + + port = atoi(tmp); + sprintf(testbuf, "%d", port); + if (strncmp(testbuf, tmp, 6) || port > MAXPORT || port < 1) + { + sprintf(testbuf, "OVERFLOW ERROR: Unable to bind to port %d\n" + "Please choose another port between 1 and %d.\n\n", + port, MAXPORT); + err = -1; + } + + if (err) + { + DialogManagerType::showAlert(testbuf); + return DIALOG_SAME; + } + + return DIALOG_NEXT; +} + +DialogInput askMCDN( +"To write configuration information into the Netscape configuration\n" +"directory, you must bind to the server as an entity with the\n" +"appropriate permissions. Usually, the Netscape configuration\n" +"directory administrator is used for this purpose, although you can\n" +"give other directory accounts the proper access.\n", + +"Netscape configuration directory server\nadministrator ID", + +0, + +askMCDNSetup, +askMCDNNext +); + +static DialogAction +askMCDNSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC)) + return action; + + dialogSetup(me, SLAPD_KEY_SERVER_ADMIN_ID, "admin"); + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askMCDNNext(Dialog *me) +{ + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC)) + return DIALOG_NEXT; + + const char *slapdUser; + char *slapdPwd = 0; + const char *buf; + + buf = me->input(); + if (buf[0] == 0) + { + slapdUser = me->defaultAns(); + } + else + { + slapdUser = buf; + } + + getManager(me)->getBaseScript()->set(SLAPD_KEY_SERVER_ADMIN_ID, slapdUser); + + if (!isValid(slapdUser)) + { + DialogManagerType::showAlert("Please enter a valid string."); + return DIALOG_SAME; + } + + while (1) + { + me->showString("Password: "); + if (me->getPassword () == 0) + { + return DIALOG_PREV; + } + else + { + char *inp = strdup(me->input()); + + if (inp[0] == 0) + { + free(inp); + continue; + } + else + { + slapdPwd = inp; + break; + } + } + } + + if (slapdPwd) + { + getManager(me)->getBaseScript()->set(SLAPD_KEY_SERVER_ADMIN_PWD, slapdPwd); + free(slapdPwd); + + int status; + if (status = getManager(me)->verifyRemoteLdap( + SLAPD_KEY_K_LDAP_HOST, + SLAPD_KEY_K_LDAP_PORT, + SLAPD_KEY_BASE_SUFFIX, + SLAPD_KEY_SERVER_ADMIN_ID, + SLAPD_KEY_SERVER_ADMIN_PWD + ) + ) + { + ostrstream msg; + msg << "Could not connect to ldap://" + << getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_HOST) + << ":" + << getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_PORT) + << "/" + << getManager(me)->getBaseScript()->get(SLAPD_KEY_BASE_SUFFIX) + << endl << "for bind DN " + << getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ADMIN_ID) + << " status = " << status << endl + << "Please check your typing. If you have mis-typed, you can backup" + << endl + << "and retype. Otherwise, the remote server may be down at this time." + << endl + << "The installation cannot proceed." + << endl << ends; + DialogManagerType::showAlert(msg.str()); + delete [] msg.str(); + return DIALOG_SAME; + } + else if ((getManager(me)->installType() < Custom) && + (status = getManager(me)->verifyAdminDomain( + SLAPD_KEY_K_LDAP_HOST, + SLAPD_KEY_K_LDAP_PORT, + SLAPD_KEY_BASE_SUFFIX, + SLAPD_KEY_ADMIN_DOMAIN, + SLAPD_KEY_SERVER_ADMIN_ID, + SLAPD_KEY_SERVER_ADMIN_PWD + )) + ) + { + ostrstream msg; + msg << "Could not find the Admin Domain " + << getManager(me)->getBaseScript()->get(SLAPD_KEY_ADMIN_DOMAIN) + << " in the server" << endl << "ldap://" + << getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_HOST) + << ":" + << getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_PORT) + << "/" + << getManager(me)->getBaseScript()->get(SLAPD_KEY_BASE_SUFFIX) + << endl << "for bind DN " + << getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ADMIN_ID) + << " status = " << status << endl + << "You may need to re-run setup in Custom mode in order to specify" + << endl + << "the correct Admin Domain." + << endl + << "The installation cannot proceed." + << endl << ends; + DialogManagerType::showAlert(msg.str()); + delete [] msg.str(); + return DIALOG_SAME; + } + } + + // tell the instance creator not to create the config entries in the + // new instance + getManager(me)->getDefaultScript()->set(SLAPD_KEY_SLAPD_CONFIG_FOR_MC, "No"); + + return DIALOG_NEXT; +} + +DialogYesNo askDisableSchemaChecking( +"If you are going to import an old database immediately after or during\n" +"installation, and you think you may have problems with your old\n" +"schema, you may want to turn off schema checking until after the\n" +"import. If you choose to do this, schema checking will remain off\n" +"until you manually turn it back on. Netscape recommends that you turn\n" +"it back on as soon as possible.\n", + +"Do you want to disable schema checking?", + +"No", + +askDisableSchemaCheckingSetup, +askDisableSchemaCheckingNext +); + +static DialogAction +askDisableSchemaCheckingSetup(Dialog *me) +{ + me = me; + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askDisableSchemaCheckingNext(Dialog *me) +{ + const char *buf = me->input(); + if (!buf || !*buf) + { + buf = me->defaultAns(); + if (!buf || !*buf) + buf = "No"; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_DISABLE_SCHEMA_CHECKING, buf); + + if (!isValidYesNo(buf)) + return DIALOG_SAME; + + return DIALOG_NEXT; +} + +DialogInput askMCAdminDomain( +"The Administration Domain is a part of the configuration directory\n" +"server used to store information about Netscape software. If you are\n" +"managing multiple software releases at the same time, or managing\n" +"information about multiple domains, you may use the Administration\n" +"Domain to keep them separate.\n\n" +"If you are not using administrative domains, press Enter to select the\n" +"default. Otherwise, enter some descriptive, unique name for the\n" +"administration domain, such as the name of the organization responsible\n" +"for managing the domain.\n", + +"Administration Domain", + +NULL, + +askMCAdminDomainSetup, +askMCAdminDomainNext +); + +static DialogAction +askMCAdminDomainSetup(Dialog *me) +{ + if (!getManager(me)->getBaseScript()->get(SLAPD_KEY_ADMIN_DOMAIN)) { + getManager(me)->getBaseScript()->set( + SLAPD_KEY_ADMIN_DOMAIN, getManager(me)->getDNSDomain()); + } + + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC)) + { +#if DEBUG > 1 + cerr << "leaving askMCAdminDomainSetup " << action << endl; +#endif + return action; + } + + // if we are creating the Configuration server, the admin domain will not + // yet exist, and we need to ask the user to create one. Otherwise, we are + // installing into an existing one + + dialogSetup(me, SLAPD_KEY_ADMIN_DOMAIN, getManager(me)->getDNSDomain()); + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askMCAdminDomainNext(Dialog *me) +{ + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC)) + return DIALOG_NEXT; + + const char *buf; + int status = 0; + NSString val; + + buf = me->input(); + if (buf[0] == 0) + val = me->defaultAns(); + else + val = buf; + + getManager(me)->getBaseScript()->set(SLAPD_KEY_ADMIN_DOMAIN, val); + + if (!isValid(val)) + { + DialogManagerType::showAlert("Please enter a valid string."); + return DIALOG_SAME; + } + else if (isAValidDN(val)) + { + DialogManagerType::showAlert("A DN is not allowed here. Please enter a valid string."); + return DIALOG_SAME; + } + else if (status = getManager(me)->verifyAdminDomain( + SLAPD_KEY_K_LDAP_HOST, + SLAPD_KEY_K_LDAP_PORT, + SLAPD_KEY_BASE_SUFFIX, + SLAPD_KEY_ADMIN_DOMAIN, + SLAPD_KEY_SERVER_ADMIN_ID, + SLAPD_KEY_SERVER_ADMIN_PWD + ) + ) + { + ostrstream msg; + msg << "Could not find the Admin Domain " + << getManager(me)->getBaseScript()->get(SLAPD_KEY_ADMIN_DOMAIN) + << " in the server" << endl << "ldap://" + << getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_HOST) + << ":" + << getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_PORT) + << "/" + << getManager(me)->getBaseScript()->get(SLAPD_KEY_BASE_SUFFIX) + << endl << "for bind DN " + << getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ADMIN_ID) + << " status = " << status << endl + << "Please check your typing. If you have mis-typed, you can backup" + << endl + << "and retype. Otherwise, the remote server may be down at this time." + << endl + << "The installation cannot proceed." + << endl << ends; + DialogManagerType::showAlert(msg.str()); + delete [] msg.str(); + return DIALOG_SAME; + } + + return DIALOG_NEXT; +} + +DialogInput askAdminDomain( +"The Administration Domain is a part of the configuration directory\n" +"server used to store information about Netscape software. If you are\n" +"managing multiple software releases at the same time, or managing\n" +"information about multiple domains, you may use the Administration\n" +"Domain to keep them separate.\n\n" +"If you are not using administrative domains, press Enter to select the\n" +"default. Otherwise, enter some descriptive, unique name for the\n" +"administration domain, such as the name of the organization responsible\n" +"for managing the domain.\n", + +"Administration Domain", + +NULL, + +askAdminDomainSetup, +askAdminDomainNext +); + +static DialogAction +askAdminDomainSetup(Dialog *me) +{ + if (!getManager(me)->getBaseScript()->get(SLAPD_KEY_ADMIN_DOMAIN)) { + getManager(me)->getBaseScript()->set( + SLAPD_KEY_ADMIN_DOMAIN, getManager(me)->getDNSDomain()); + } + + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC)) + return action; + + // if we are creating the Configuration server, the admin domain will not + // yet exist, and we need to ask the user to create one. Otherwise, we are + // installing into an existing one + + dialogSetup(me, SLAPD_KEY_ADMIN_DOMAIN, getManager(me)->getDNSDomain()); + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askAdminDomainNext(Dialog *me) +{ + if (getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC)) + return DIALOG_NEXT; + + const char *buf; + NSString val; + + buf = me->input(); + if (buf[0] == 0) + val = me->defaultAns(); + else + val = buf; + + getManager(me)->getBaseScript()->set(SLAPD_KEY_ADMIN_DOMAIN, val); + + if (!isValid(val)) + { + DialogManagerType::showAlert("Please enter a valid string."); + return DIALOG_SAME; + } + + if (isAValidDN(val)) + { + DialogManagerType::showAlert("A DN is not allowed here. Please enter a valid string."); + return DIALOG_SAME; + } + + return DIALOG_NEXT; +} + +DialogYesNo askUseExistingUG( +"If you already have a directory server you want to use to store your\n" +"data, such as user and group information, answer Yes to the following\n" +"question. You will be prompted for the host, port, suffix, and bind\n" +"DN to use for that directory server.\n\n" +"If you want this directory server to store your data, answer No.\n", + +"Do you want to use another directory to store your data?", + +"No", + +askUseExistingUGSetup, +askUseExistingUGNext +); + +static DialogAction +askUseExistingUGSetup(Dialog *me) +{ +#if DEBUG > 1 + cerr << "Entering askUseExistingUGSetup" << endl; +#endif + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + // if this server is not an MC host, it must be a UG host + if (getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC)) + { + getManager(me)->getDefaultScript()->set( + SLAPD_KEY_USE_EXISTING_UG, "No"); +#if DEBUG > 1 + cerr << "Leaving askUseExistingUGSetup DIALOG_NEXT" << endl; +#endif + return action; + } + else if (getManager(me)->getBaseScript()->get(SLAPD_KEY_USER_GROUP_LDAP_URL)) + { + getManager(me)->getDefaultScript()->set( + SLAPD_KEY_USE_EXISTING_UG, "Yes"); + } + else + { + getManager(me)->getDefaultScript()->set( + SLAPD_KEY_USE_EXISTING_UG, "No"); + } + + dialogSetup(me, SLAPD_KEY_USE_EXISTING_UG, "No"); + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + { +#if DEBUG > 1 + cerr << "Leaving askUseExistingUGSetup DIALOG_NEXT" << endl; +#endif + return DIALOG_NEXT; + } + +#if DEBUG > 1 + cerr << "Leaving askUseExistingUGSetup DIALOG_SAME" << endl; +#endif + return DIALOG_SAME; +} + +static DialogAction +askUseExistingUGNext(Dialog *me) +{ +#if DEBUG > 1 + cerr << "Entering askUseExistingUGNext" << endl; +#endif + const char *buf = me->input(); + if (!buf || !*buf) + { + buf = me->defaultAns(); + if (!buf || !*buf) + buf = "No"; + } + + getManager(me)->getDefaultScript()->set(SLAPD_KEY_USE_EXISTING_UG, buf); + + if (!isValidYesNo(buf)) + return DIALOG_SAME; + +#if DEBUG > 1 + cerr << "Leaving askUseExistingUGNext DIALOG_NEXT" << endl; +#endif + return DIALOG_NEXT; +} + +DialogInput askUGHost( +"Enter the fully qualified domain name of the user directory host of\n" +"the form <hostname>.<domainname> (e.g. hostname.domain.com).\n", + +"User directory host name", + +0, + +askUGHostSetup, +askUGHostNext +); + +static DialogAction +askUGHostSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG)) + return action; + + dialogSetup(me, SLAPD_KEY_UG_HOST, 0); + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askUGHostNext(Dialog *me) +{ + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG)) + return DIALOG_NEXT; + + const char *buf = me->input(); + const char *tmp; + + if (buf[0] == 0) + { + tmp = me->defaultAns(); + } + else + { + tmp = buf; + } + + getManager(me)->getBaseScript()->set(SLAPD_KEY_UG_HOST, tmp); + + if (!tmp || !isValid(tmp)) + { + DialogManagerType::showAlert("Please enter a valid hostname"); + return DIALOG_SAME; + } + + return DIALOG_NEXT; +} + +DialogInput askUGPort( +"Please specify the port number on which the user directory listens.\n", + +"User directory port number", + +"389", + +askUGPortSetup, +askUGPortNext +); + +static DialogAction +askUGPortSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG)) + return action; + + dialogSetup(me, SLAPD_KEY_UG_PORT, me->defaultAns()); + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askUGPortNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG)) + return DIALOG_NEXT; + + const char *buf = me->input(); + const char *tmp; + char testbuf[1024]; + int port, err = 0; + + if (buf[0] == 0) + { + tmp = me->defaultAns(); + } + else + { + tmp = buf; + } + + getManager(me)->getBaseScript()->set(SLAPD_KEY_UG_PORT, tmp); + + port = atoi(tmp); + sprintf(testbuf, "%d", port); + if (strncmp(testbuf, tmp, 6) || port > MAXPORT || port < 1) + { + sprintf(testbuf, "OVERFLOW ERROR: Unable to bind to port %d\n" + "Please choose another port between 1 and %d.\n\n", + port, MAXPORT); + err = -1; + } + + if (err) + { + DialogManagerType::showAlert(testbuf); + return DIALOG_SAME; + } + + return DIALOG_NEXT; +} + +DialogInput askUGDN( +"In order to add and modify information in the user directory, you must\n" +"be able to bind to the server as an entity with the correct\n" +"permissions. This user is usually the Directory Manager, although\n" +"other users may be given the proper access. You will also be asked to\n" +"provide the password.\n", + +"User directory administrator ID", + +0, + +askUGDNSetup, +askUGDNNext +); + +static DialogAction +askUGDNSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG)) + return action; + + dialogSetup(me, SLAPD_KEY_USER_GROUP_ADMIN_ID, DEFAULT_SLAPDUSER); + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askUGDNNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG)) + return DIALOG_NEXT; + + const char *slapdUser; + char *slapdPwd = 0; + const char *buf; + + buf = me->input(); + if (buf[0] == 0) + { + slapdUser = me->defaultAns(); + } + else + { + slapdUser = buf; + } + + getManager(me)->getBaseScript()->set(SLAPD_KEY_USER_GROUP_ADMIN_ID, slapdUser); + + if (!isValid(slapdUser)) + { + DialogManagerType::showAlert("Please enter a valid string."); + return DIALOG_SAME; + } + + while (1) + { + me->showString("Password: "); + if (me->getPassword () == 0) + { + return DIALOG_PREV; + } + else + { + char *inp = strdup(me->input()); + + if (inp[0] == 0) + { + free(inp); + continue; + } + else + { + slapdPwd = inp; + break; + } + } + } + + if (slapdPwd) + { + getManager(me)->getBaseScript()->set(SLAPD_KEY_USER_GROUP_ADMIN_PWD, slapdPwd); + free(slapdPwd); + + int status; + if (status = getManager(me)->verifyRemoteLdap( + SLAPD_KEY_UG_HOST, + SLAPD_KEY_UG_PORT, + SLAPD_KEY_UG_SUFFIX, + SLAPD_KEY_USER_GROUP_ADMIN_ID, + SLAPD_KEY_USER_GROUP_ADMIN_PWD + ) + ) + { + ostrstream msg; + msg << "Could not connect to ldap://" + << getManager(me)->getBaseScript()->get(SLAPD_KEY_UG_HOST) + << ":" + << getManager(me)->getBaseScript()->get(SLAPD_KEY_UG_PORT) + << "/" + << getManager(me)->getBaseScript()->get(SLAPD_KEY_UG_SUFFIX) + << endl << "for bind DN " + << getManager(me)->getBaseScript()->get(SLAPD_KEY_USER_GROUP_ADMIN_ID) + << " status = " << status << endl + << "Please check your typing. If you have mis-typed, you can backup" + << endl + << "and retype. Otherwise, the remote server may be down at this time." + << endl + << "The installation cannot proceed." + << endl << ends; + DialogManagerType::showAlert(msg.str()); + delete [] msg.str(); + return DIALOG_SAME; + } + } + + return DIALOG_NEXT; +} + +DialogInput askUGSuffix( +"Please specify the suffix for the user directory server.\n", + +"User directory server suffix", + +NULL, + +askUGSuffixSetup, +askUGSuffixNext +); + +static DialogAction +askUGSuffixSetup(Dialog *me) +{ + DialogAction action = DIALOG_NEXT; + long actionval = 0; + me->getUserData(ACTION, actionval); + action = (DialogAction)actionval; + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG)) + return action; + + dialogSetup(me, SLAPD_KEY_UG_SUFFIX, getManager(me)->getDefaultSuffix()); + + long setupval = 0; + if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY || + setupval == SETUP_ONLY) + return DIALOG_NEXT; + + return DIALOG_SAME; +} + +static DialogAction +askUGSuffixNext(Dialog *me) +{ + if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG)) + return DIALOG_NEXT; + + const char *buf; + NSString val; + + buf = me->input(); + if (buf[0] == 0) + val = me->defaultAns(); + else + val = buf; + + getManager(me)->getBaseScript()->set(SLAPD_KEY_UG_SUFFIX, val); + + // check to see if it is a valid dn + if (!isAValidDN(val)) + { + DialogManagerType::showAlert("The suffix must be a valid DN"); + return DIALOG_SAME; + } + if (!isValid(val)) + { + DialogManagerType::showAlert("Please enter a valid string."); + return DIALOG_SAME; + } + + return DIALOG_NEXT; +} + +DialogInput askReconfigMCAdminPwd( +(const char*)0, +"Netscape configuration directory server\nadministrator ID", + +(const char*)0, + +askReconfigMCAdminPwdSetup, +askReconfigMCAdminPwdNext +); + +static DialogAction +askReconfigMCAdminPwdSetup(Dialog *me) +{ +#if DEBUG > 1 + cerr << "Entering askReconfigMCAdminPwdSetup" << endl; +#endif + NSString msg = NSString( +"In order to reconfigure your installation, the Configuration Directory\n" +"Administrator password is required. Here is your current information:\n\n" +"Configuration Directory: ") + + getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_URL) + "\n" + +"Configuration Administrator ID: " + + getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ADMIN_ID) + "\n" + +"\nAt the prompt, please enter the password for the Configuration Administrator.\n"; + + me->setText(msg); + + me->setDefaultAns(getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ADMIN_ID)); +#if DEBUG > 1 + cerr << "Leaving askReconfigMCAdminPwdSetup" << endl; +#endif + return DIALOG_SAME; +} + +static DialogAction +askReconfigMCAdminPwdNext(Dialog *me) +{ + const char *buf; + + buf = me->input(); + if (!buf || buf[0] == 0) + { + buf = me->defaultAns(); + } + + getManager(me)->getBaseScript()->set(SLAPD_KEY_SERVER_ADMIN_ID, buf); + + if (!isValid(buf)) + { + DialogManagerType::showAlert("Please enter a valid string."); + return DIALOG_SAME; + } + + me->showString("Password: "); + while (1) + { + if (me->getPassword () == 0) + { + return DIALOG_PREV; + } + else + { + char *inp = strdup(me->input()); + + if (inp[0] == 0) + { + me->showString("Password: "); + continue; + } + else if (contains8BitChars(inp)) + { + DialogManagerType::showAlert("Password must contain 7 bit characters only."); + return DIALOG_SAME; + } + else if (!isValid(inp)) + { + DialogManagerType::showAlert("Please enter a valid password."); + return DIALOG_SAME; + } + else + { + int status; + if (status = authLdapUser( + getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_URL), + getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ADMIN_ID), + inp, 0, 0)) + { + ostrstream msg; + msg << "Could not connect to " + << getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_URL) + << endl << "for ID " + << getManager(me)->getBaseScript()->get(SLAPD_KEY_USER_GROUP_ADMIN_ID) + << " status = " << status << endl + << "Please check your typing. If you have mis-typed, you can backup" + << endl + << "and retype. Otherwise, the remote server may be down at this time." + << endl + << "The reconfiguration cannot proceed." + << endl << ends; + DialogManagerType::showAlert(msg.str()); + delete [] msg.str(); + return DIALOG_SAME; + } + } + getManager(me)->getBaseScript()->set(SLAPD_KEY_SERVER_ADMIN_PWD, inp); + free(inp); + break; + } + } + + return DIALOG_NEXT; +} diff --git a/ldap/cm/newinst/ux-dialog.h b/ldap/cm/newinst/ux-dialog.h new file mode 100644 index 00000000..bc8b47b8 --- /dev/null +++ b/ldap/cm/newinst/ux-dialog.h @@ -0,0 +1,69 @@ +/** BEGIN COPYRIGHT BLOCK + * Copyright 2001 Sun Microsystems, Inc. + * Portions copyright 1999, 2001-2003 Netscape Communications Corporation. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _UX_DIALOG_H_ +#define _UX_DIALOG_H_ + +#include "dialog.h" +extern DialogYesNo askReconfig; +extern DialogInput askSlapdServerName; +extern DialogInput askAdminPort; +extern DialogInput askSlapdPort; +extern DialogYesNo askSecurity; +extern DialogInput askSlapdSecPort; +extern DialogInput askSlapdServerID; +extern DialogInput askSlapdSysUser; +extern DialogYesNo askConfigForMC; +extern DialogInput askMCAdminID; +extern DialogInput askSlapdSuffix; +extern DialogInput askSlapdRootDN; +extern DialogYesNo askReplication; +extern DialogYesNo askSample; +extern DialogYesNo askPopulate; +extern DialogInput askOrgSize; +extern DialogYesNo askCIR; +extern DialogInput askCIRHost; +extern DialogInput askCIRPort; +extern DialogInput askCIRDN; +extern DialogInput askCIRSuffix; +extern DialogYesNo askCIRSSL; +extern DialogInput askCIRInterval; +extern DialogInput askCIRDays; +extern DialogInput askCIRTimes; +extern DialogYesNo askSIR; +extern DialogInput askChangeLogSuffix; +extern DialogInput askChangeLogDir; +extern DialogInput askReplicationDN; +extern DialogInput askConsumerDN; +extern DialogYesNo askSIR; +extern DialogInput askSIRHost; +extern DialogInput askSIRPort; +extern DialogInput askSIRDN; +extern DialogInput askSIRSuffix; +extern DialogYesNo askSIRSSL; +extern DialogInput askSIRDays; +extern DialogInput askSIRTimes; +extern DialogYesNo askUseExistingMC; +extern DialogInput askMCHost; +extern DialogInput askMCPort; +extern DialogInput askMCDN; +extern DialogYesNo askDisableSchemaChecking; +extern DialogInput askMCAdminDomain; +extern DialogInput askAdminDomain; +extern DialogYesNo askUseExistingUG; +extern DialogInput askUGHost; +extern DialogInput askUGPort; +extern DialogInput askUGDN; +extern DialogInput askUGSuffix; +extern DialogInput askReconfigMCAdminPwd; + +// these keywords and values are used in the Dialog::setUserData to +// control the behavior of the dialogs +#define SETUP_DEFAULTS "SETUP_DEFAULTS" +const int SETUP_ONLY = 1; +#define ACTION "ACTION" + +#endif // _UX_DIALOG_H_ diff --git a/ldap/cm/newinst/ux-dsalib_dn.c b/ldap/cm/newinst/ux-dsalib_dn.c new file mode 100644 index 00000000..535bf53f --- /dev/null +++ b/ldap/cm/newinst/ux-dsalib_dn.c @@ -0,0 +1,13 @@ +/** BEGIN COPYRIGHT BLOCK + * Copyright 2001 Sun Microsystems, Inc. + * Portions copyright 1999, 2001-2003 Netscape Communications Corporation. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifdef __cplusplus +extern "C" { +#endif +#include <dsalib_dn.c> +#ifdef __cplusplus +} +#endif diff --git a/ldap/cm/newinst/ux-guesses.cc b/ldap/cm/newinst/ux-guesses.cc new file mode 100644 index 00000000..6b54127c --- /dev/null +++ b/ldap/cm/newinst/ux-guesses.cc @@ -0,0 +1,125 @@ +/** BEGIN COPYRIGHT BLOCK + * Copyright 2001 Sun Microsystems, Inc. + * Portions copyright 1999, 2001-2003 Netscape Communications Corporation. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +/* Print guesses of host and domain name as made by the setup SDK. */ + + + +/* $RCSfile: ux-guesses.cc,v $ $Revision: 1.1 $ $Date: 2005/01/21 00:40:49 $ $State: Exp $ */ +/* + * $Log: ux-guesses.cc,v $ + * Revision 1.1 2005/01/21 00:40:49 cvsadm + * Initial revision + * + * Revision 1.1.2.4 2004/07/14 01:39:20 dboreham + * changes to make newer C++ compilers happy + * + * Revision 1.1.1.1 2004/06/03 22:32:45 telackey + * Initial import Thu Jun 3 15:32:43 PDT 2004 + * + * Revision 1.1.2.3 2003/09/22 19:38:52 ulfw + * Update copyright years from 2001 to 2001-2003 + * + * Revision 1.1.2.2 2001/11/02 23:33:04 richm + * XXX use new copyright XXX + * + * Revision 1.1.2.1 2000/08/07 15:14:28 mwahl + * rename functions + * + * + */ + +#include "dialog.h" + +extern "C" { +#if defined(__sun) || defined(__hppa) || defined(__osf__) || defined(__linux__) || defined(linux) +#include <netdb.h> +#endif +} + + +class PrintGuessPreInstall:public DialogManager +{ +public: + + PrintGuessPreInstall(int, char **); + ~PrintGuessPreInstall(); + + int init(); + + int start(); + + + void setParent(void *) { } + void *parent() const { return 0;} + void resetLast() { } + void add (Dialog *) { } + void addLast(Dialog *) { } + void clear() { } + int cont() { return -1;} + + +private: + Bool _reconfig; + Bool _configured; +}; + +PrintGuessPreInstall::PrintGuessPreInstall(int argc, char **argv) : _reconfig(False) +{ + setInstallMode(Interactive); + setInstallType(Typical); + _configured = False; + + /* getOptions(argc, argv); */ + +} + +PrintGuessPreInstall::~PrintGuessPreInstall() +{ + +} + +int PrintGuessPreInstall::init() +{ + return 0; +} + +int PrintGuessPreInstall::start() +{ + const char *hno = InstUtil::guessHostname(); + printf("hostname: %s\n",hno ? hno : "<unknown>"); + if (hno) { +#if defined(__sun) || defined(__hppa) || defined(__osf__) || defined(__linux__) || defined(linux) + static char test_host[BIG_BUF] = {0}; + struct hostent *hp; + + strcpy(test_host,hno); + hp = gethostbyname(test_host); + if (hp == NULL) { + printf("addressable: no\n"); + } else { + printf("addressable: yes\n"); + } +#endif + } + const char *dno = InstUtil::guessDomain(); + printf("domain: %s\n",dno ? dno : "<unknown>"); + return 0; +} + + + +int main(int argc,char **argv) +{ + PrintGuessPreInstall program(argc,argv); + + int err = program.init(); + if (!err) { + err = program.start(); + } + return err; + +} |