Author: rmeggins
Update of /cvs/dirsec/dsgw
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv15541/dsgw
Modified Files:
Makefile.am csearch.c dsgwgetlang.c dsgwutil.c aclocal.m4
configure missing install-sh Makefile.in depcomp config.sub
config.guess compile
Added Files:
setup-ds-dsgw.in
Removed Files:
setup.in
Log Message:
Renamed setup to setup-ds-dsgw to be consistent with other setup scripts
setup-ds-dsgw will attempt to use settings from pre-configured admin server
and directory server
Config files will use an ldap url and http url - this is so that we can use
http or https and ldap or ldaps - previously, dsgw was configured during
regular DS setup, which did not allow TLS/SSL setup - we must be able to
configure the dsgw for TLS/SSL during setup now
Changed XP_GetClientStr back to just always return a malloc'd string - there
are cases where we cannot use a static
There were some places where we were using a form with POST + a query string
Use SERVER_NAME instead of HTTP_HOST because the latter has the port number
already in it
--- NEW FILE setup-ds-dsgw.in ---
#!/bin/sh
#
# BEGIN COPYRIGHT BLOCK
# This Program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 2 of the License.
#
# This Program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA.
#
# Copyright (C) 2006 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
#
###########################
#
# This shell script provides a way to set up a new installation after
# the binaries have already been extracted. This is typically after
# using native packaging support to install the package e.g. RPM,
# pkgadd, depot, etc. This script will show the license, readme,
# dsktune, then run the usual setup pre and post installers. This
# script should be run from the server root directory since it uses
# pwd to get the server root directory.
#
##########################
getValFromInf() {
cattr=$1
cfile=$2
rval=`grep -i ^$cattr $cfile | head -1 | sed -e "s/^$cattr[ ]*=[ ]*//"`
echo $rval
}
getValFromConf() {
cattr=$1
cfile=$2
rval=`grep -i ^$cattr $cfile | head -1 | sed -e "s/^$cattr[ ]*//"`
echo $rval
}
getValFromLdif() {
cattr=$1
cfile=$2
num=${3:-1}
rval=`grep -i ^$cattr: $cfile | head -$num | sed -e "s/^$cattr:[ ]*//"`
echo $rval
}
# e.g. /etc/dirsrv/dsgw
dsgwconfigdir="@contextdir@"
basecfgdir=`dirname $dsgwconfigdir`
# default security dir
securitydir="@securitydir@"
defaultsecdir=1
httpdconf="@httpdconf@"
# see if there is a $dsgwconfigdir/../admin-serv
admservdir=$basecfgdir/admin-serv
if [ -f "$admservdir/local.conf" ] ; then
host=`getValFromLdif serverHostName "$admservdir/local.conf"`
port=`getValFromLdif configuration.nsServerPort "$admservdir/local.conf"`
sec=`getValFromLdif configuration.nsServerSecurity
"$admservdir/local.conf"`
if [ "$sec" = "on" ] ; then
httpurl="https://$host:$port"
if [ -n "$defaultsecdir" ] ; then
securitydir="$admservdir"
defaultsecdir=
fi
else
httpurl="http://$host:$port"
fi
httpdconf=$admservdir/httpd.conf
fi
# see if there are any directory servers here
for dir in $basecfgdir/slapd-* ; do
case "$dir" in
*.deleted) continue ;;
esac
if [ -d "$dir" -a -f "$dir/dse.ldif" ] ; then
dirmgr=`getValFromLdif nsslapd-rootdn "$dir/dse.ldif"`
host=`getValFromLdif nsslapd-localhost "$dir/dse.ldif"`
sec=`getValFromLdif nsslapd-security "$dir/dse.ldif"`
if [ "$sec" = "on" ] ; then
port=`getValFromLdif nsslapd-secureport "$dir/dse.ldif"`
ldapurl="ldaps://$host:$port"
if [ -n "$defaultsecdir" ] ; then
securitydir="$dir"
defaultsecdir=
fi
else
port=`getValFromLdif nsslapd-port "$dir/dse.ldif"`
ldapurl="ldap://$host:$port"
fi
# get suffix
suffixlist="`getValFromLdif nsslapd-suffix $dir/dse.ldif 2`"
for suffix in $suffixlist ; do
case $suffix in
*netscaperoot) ;;
*NetscapeRoot) ;;
*) break ;; # find the first non-netscaperoot suffix
esac
done
fi
done
# get command line arguments
myargs=
silent=
inffile=
tmpinffile=
nextisinffile=
keepinffile=
for arg in "$@" ; do
if [ "$arg" = "-s" ]; then
silent=1
elif [ "$arg" = "-k" ]; then
keepinffile=1
elif [ "$arg" = "-f" ]; then
nextisinffile=1
elif [ $nextisinffile ]; then
inffile="$arg"
nextisinffile=
else
myargs="$myargs $arg"
fi
done
if [ -f "$inffile" ] ; then
hostname=`getValFromInf FullMachineName $inffile`
port=`getValFromInf ServerPort $inffile`
suffix=`getValFromInf Suffix $inffile`
dirmgr=`getValFromInf RootDN $inffile`
httpport=`getValFromInf Port $inffile`
httpurl="http://$host:$httpport"
ldapurl="ldap://$host:$port"
fi
# generate dsgw.conf and pb.conf and default.conf in the $dsgwconfigdir directory
sed -e "s#@host@#$hostname#g" \
-e "s#@port@#$port#g" \
-e "s#@httpport@#$httpport#g" \
-e "s#@suffix@#$suffix#g" \
-e "s#@dirmgr@#$dirmgr#g" \
-e "s#^securitypath.*\$#securitypath $securitydir#g" \
-e "s#@ldapurl@#$ldapurl#g" \
-e "s#@httpurl@#$httpurl#g" \
@configdir(a)/dsgw.tmpl > $dsgwconfigdir/dsgw.conf
sed -e "s#@host@#$hostname#g" \
-e "s#@port@#$port#g" \
-e "s#@httpport@#$httpport#g" \
-e "s#@suffix@#$suffix#g" \
-e "s#@dirmgr@#$dirmgr#g" \
-e "s#^securitypath.*\$#securitypath $securitydir#g" \
-e "s#@ldapurl@#$ldapurl#g" \
-e "s#@httpurl@#$httpurl#g" \
@pbconfigdir(a)/pb.tmpl > $dsgwconfigdir/pb.conf
sed -e "s#@host@#$hostname#g" \
-e "s#@port@#$port#g" \
-e "s#@httpport@#$httpport#g" \
-e "s#@suffix@#$suffix#g" \
-e "s#@dirmgr@#$dirmgr#g" \
-e "s#^securitydir.*\$#securitydir $securitydir#g" \
-e "s#@ldapurl@#$ldapurl#g" \
-e "s#@httpurl@#$httpurl#g" \
@orghtmldir(a)/orgchart.tmpl > $dsgwconfigdir/orgchart.conf
# the default.conf is just a copy of dsgw.conf
cp $dsgwconfigdir/dsgw.conf $dsgwconfigdir/default.conf
# tell Apache about the dsgw - must restart Apache
grep dsgw-httpd.conf "$httpdconf" > /dev/null 2>&1 || (echo
"" ; echo "# DSGW configuration" ; echo "Include
$dsgwconfigdir/dsgw-httpd.conf") >> $httpdconf
echo "The DSGW has been successfully configured."
if [ $isAdmServ ] ; then
echo "Please restart the Admin Server - /path/to/start-admin "
else
echo "Please restart Apache e.g."
echo " service httpd restart"
echo " OR"
echo " apachectl restart"
echo "or however you restart apache on this system."
fi
exit 0
Index: Makefile.am
===================================================================
RCS file: /cvs/dirsec/dsgw/Makefile.am,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Makefile.am 28 Jan 2008 21:22:47 -0000 1.8
+++ Makefile.am 30 Jan 2008 02:22:46 -0000 1.9
@@ -194,7 +194,7 @@
dist_gwinfo_DATA = html/info/infonav.html
nodist_context_DATA = dsgw-httpd.conf
-#nodist_context_SCRIPTS = setup-dirsrv-gw
+nodist_bin_SCRIPTS = setup-ds-dsgw
# add more here for localized bundles
nodist_property_DATA = root.res en.res en_US.res
Index: csearch.c
===================================================================
RCS file: /cvs/dirsec/dsgw/csearch.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- csearch.c 28 Jan 2008 21:22:47 -0000 1.3
+++ csearch.c 30 Jan 2008 02:22:46 -0000 1.4
@@ -253,14 +253,17 @@
} else if ( dsgw_directive_is( line, "DS_CSEARCH_TYPE_FORM" )) {
dsgw_form_begin ("searchTypeForm",
- "action=\"%s?file=attr\" target=searchAttrFrame",
+ "action=\"%s\" target=searchAttrFrame",
dsgw_getvp( DSGW_CGINUM_CSEARCH));
- dsgw_emits("\n");
+ dsgw_emits ("\n"
+ "<INPUT TYPE=hidden NAME=file VALUE=\"attr\">\n");
} else if ( dsgw_directive_is( line, "DS_CSEARCH_ATTR_FORM" )) {
dsgw_form_begin ("searchAttrForm",
- "action=\"%s?file=match\" target=searchMatchFrame",
+ "action=\"%s\" target=searchMatchFrame",
dsgw_getvp( DSGW_CGINUM_CSEARCH));
+ dsgw_emits ("\n"
+ "<INPUT TYPE=hidden NAME=file VALUE=\"match\">\n");
dsgw_emits("\n");
{
auto char* searchType = dsgw_get_cgi_var ("searchType",
DSGW_CGIVAR_OPTIONAL);
Index: dsgwgetlang.c
===================================================================
RCS file: /cvs/dirsec/dsgw/dsgwgetlang.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- dsgwgetlang.c 28 Jan 2008 21:22:47 -0000 1.4
+++ dsgwgetlang.c 30 Jan 2008 02:22:46 -0000 1.5
@@ -319,30 +319,24 @@
}
/*
- Note: This reuses a single static buffer to avoid memory leakage.
- If the caller needs an actual unique copy, then we have two options
- 1) revert the code to just leak the string - probably ok as this is
- CGI code not long running server code
- 2) have the caller free the pointer after use
+ Note: This function returns allocated memory. Most of the callers in the
+ dsgw do not free this memory - they prefer to use exit() for free() - which
+ is usually fine for short lived CGI programs - so if you use valgrind you
+ will see a lot of memory leakage around this function
*/
PR_IMPLEMENT( char * )
XP_GetClientStr(int key)
{
- static char staticbuf[256] = {0};
- static char *resstring = staticbuf;
- static size_t bufsize = sizeof(staticbuf);
int rc = 0;
char keybuf[256];
char *lang = GetClientLanguage();
+ char *resstring = NULL;
PR_snprintf(keybuf, sizeof(keybuf), "%s%d", database_name, key);
resstring = res_getstring(i18nResource, keybuf, lang,
- resstring, bufsize, &rc);
- if (rc == 1) { /* need more room */
- /* NULL means res_getstring will calculate and return needed memory */
- resstring = res_getstring(i18nResource, keybuf, lang,
- NULL, bufsize, &rc);
- bufsize = strlen(resstring);
+ NULL, 0, &rc);
+ if (rc) {
+ dsgw_emitf("The message keyword id [%d] was not found\n", key);
}
return resstring;
}
Index: dsgwutil.c
===================================================================
RCS file: /cvs/dirsec/dsgw/dsgwutil.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- dsgwutil.c 28 Jan 2008 21:22:47 -0000 1.6
+++ dsgwutil.c 30 Jan 2008 02:22:46 -0000 1.7
@@ -1319,7 +1319,7 @@
httpsstr = "s";
}
server_url = PR_smprintf("http%s://%s:%s", httpsstr,
- getenv("HTTP_HOST"),
getenv("SERVER_PORT"));
+ getenv("SERVER_NAME"),
getenv("SERVER_PORT"));
}
}
Index: Makefile.in
===================================================================
RCS file: /cvs/dirsec/dsgw/Makefile.in,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Makefile.in 28 Jan 2008 21:22:47 -0000 1.8
+++ Makefile.in 30 Jan 2008 02:22:46 -0000 1.9
@@ -88,11 +88,11 @@
am__EXEEXT_1 = unauth$(EXEEXT) search$(EXEEXT) csearch$(EXEEXT) \
newentry$(EXEEXT) tutor$(EXEEXT) lang$(EXEEXT)
am__installdirs = "$(DESTDIR)$(cgibindir)" "$(DESTDIR)$(cgibindir)"
\
- "$(DESTDIR)$(configdir)" "$(DESTDIR)$(gwinfodir)" \
- "$(DESTDIR)$(htmldir)" "$(DESTDIR)$(maninstdir)" \
- "$(DESTDIR)$(orghtmldir)" "$(DESTDIR)$(pbconfigdir)" \
- "$(DESTDIR)$(pbhtmldir)" "$(DESTDIR)$(contextdir)" \
- "$(DESTDIR)$(propertydir)"
+ "$(DESTDIR)$(bindir)" "$(DESTDIR)$(configdir)" \
+ "$(DESTDIR)$(gwinfodir)" "$(DESTDIR)$(htmldir)" \
+ "$(DESTDIR)$(maninstdir)" "$(DESTDIR)$(orghtmldir)" \
+ "$(DESTDIR)$(pbconfigdir)" "$(DESTDIR)$(pbhtmldir)" \
+ "$(DESTDIR)$(contextdir)" "$(DESTDIR)$(propertydir)"
cgibinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(cgibin_PROGRAMS) $(noinst_PROGRAMS)
am__objects_1 = htmlout.$(OBJEXT) htmlparse.$(OBJEXT) error.$(OBJEXT) \
@@ -145,7 +145,8 @@
unauth_OBJECTS = $(am_unauth_OBJECTS)
unauth_LDADD = $(LDADD)
cgibinSCRIPT_INSTALL = $(INSTALL_SCRIPT)
-SCRIPTS = $(cgibin_SCRIPTS)
+nodist_binSCRIPT_INSTALL = $(INSTALL_SCRIPT)
+SCRIPTS = $(cgibin_SCRIPTS) $(nodist_bin_SCRIPTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@@ -498,7 +499,7 @@
dist_gwinfo_DATA = html/info/infonav.html
nodist_context_DATA = dsgw-httpd.conf
-#nodist_context_SCRIPTS = setup-dirsrv-gw
+nodist_bin_SCRIPTS = setup-ds-dsgw
# add more here for localized bundles
nodist_property_DATA = root.res en.res en_US.res
@@ -705,6 +706,25 @@
echo " rm -f '$(DESTDIR)$(cgibindir)/$$f'"; \
rm -f "$(DESTDIR)$(cgibindir)/$$f"; \
done
+install-nodist_binSCRIPTS: $(nodist_bin_SCRIPTS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
+ @list='$(nodist_bin_SCRIPTS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ if test -f $$d$$p; then \
+ f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+ echo " $(nodist_binSCRIPT_INSTALL) '$$d$$p'
'$(DESTDIR)$(bindir)/$$f'"; \
+ $(nodist_binSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(bindir)/$$f";
\
+ else :; fi; \
+ done
+
+uninstall-nodist_binSCRIPTS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(nodist_bin_SCRIPTS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -1109,7 +1129,7 @@
check: check-am
all-am: Makefile $(PROGRAMS) $(SCRIPTS) $(DATA) config.h
installdirs:
- for dir in "$(DESTDIR)$(cgibindir)" "$(DESTDIR)$(cgibindir)"
"$(DESTDIR)$(configdir)" "$(DESTDIR)$(gwinfodir)"
"$(DESTDIR)$(htmldir)" "$(DESTDIR)$(maninstdir)"
"$(DESTDIR)$(orghtmldir)" "$(DESTDIR)$(pbconfigdir)"
"$(DESTDIR)$(pbhtmldir)" "$(DESTDIR)$(contextdir)"
"$(DESTDIR)$(propertydir)"; do \
+ for dir in "$(DESTDIR)$(cgibindir)" "$(DESTDIR)$(cgibindir)"
"$(DESTDIR)$(bindir)" "$(DESTDIR)$(configdir)"
"$(DESTDIR)$(gwinfodir)" "$(DESTDIR)$(htmldir)"
"$(DESTDIR)$(maninstdir)" "$(DESTDIR)$(orghtmldir)"
"$(DESTDIR)$(pbconfigdir)" "$(DESTDIR)$(pbhtmldir)"
"$(DESTDIR)$(contextdir)" "$(DESTDIR)$(propertydir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
@@ -1166,7 +1186,7 @@
install-dist_pbhtmlDATA install-nodist_contextDATA \
install-nodist_propertyDATA
-install-exec-am:
+install-exec-am: install-nodist_binSCRIPTS
install-info: install-info-am
@@ -1199,7 +1219,8 @@
uninstall-dist_htmlDATA uninstall-dist_maninstDATA \
uninstall-dist_orghtmlDATA uninstall-dist_pbconfigDATA \
uninstall-dist_pbhtmlDATA uninstall-info-am \
- uninstall-nodist_contextDATA uninstall-nodist_propertyDATA
+ uninstall-nodist_binSCRIPTS uninstall-nodist_contextDATA \
+ uninstall-nodist_propertyDATA
.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
clean-cgibinPROGRAMS clean-generic clean-libtool \
@@ -1215,16 +1236,17 @@
install-dist_orghtmlDATA install-dist_pbconfigDATA \
install-dist_pbhtmlDATA install-exec install-exec-am \
install-info install-info-am install-man \
- install-nodist_contextDATA install-nodist_propertyDATA \
- install-strip installcheck installcheck-am installdirs \
- maintainer-clean maintainer-clean-generic mostlyclean \
- mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
- pdf pdf-am ps ps-am tags uninstall uninstall-am \
- uninstall-cgibinPROGRAMS uninstall-cgibinSCRIPTS \
- uninstall-dist_configDATA uninstall-dist_gwinfoDATA \
- uninstall-dist_htmlDATA uninstall-dist_maninstDATA \
- uninstall-dist_orghtmlDATA uninstall-dist_pbconfigDATA \
- uninstall-dist_pbhtmlDATA uninstall-info-am \
+ install-nodist_binSCRIPTS install-nodist_contextDATA \
+ install-nodist_propertyDATA install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-cgibinPROGRAMS \
+ uninstall-cgibinSCRIPTS uninstall-dist_configDATA \
+ uninstall-dist_gwinfoDATA uninstall-dist_htmlDATA \
+ uninstall-dist_maninstDATA uninstall-dist_orghtmlDATA \
+ uninstall-dist_pbconfigDATA uninstall-dist_pbhtmlDATA \
+ uninstall-info-am uninstall-nodist_binSCRIPTS \
uninstall-nodist_contextDATA uninstall-nodist_propertyDATA
--- setup.in DELETED ---