From 60a115efc28ce76167b1a6b9f4cd6685f7c68103 Mon Sep 17 00:00:00 2001 From: alexpeshkoff Date: Fri, 11 Sep 2009 10:49:46 +0000 Subject: [PATCH] Fixed CORE-2601: fine tuning of the installation directories does not work in configure --- .../arch-specific/aix/misc/aixLibrary.sh.in | 2 +- .../arch-specific/aix/misc/postinstall.sh.in | 15 +- .../arch-specific/aix/misc/preuninstall.sh.in | 4 +- .../aix/misc/tarmainuninstall.sh.in | 4 +- .../arch-specific/aix/misc/taruninstall.sh.in | 3 +- .../darwin/changeMultiConnectMode | 2 +- .../hpux/classic/postInstall.sh.in | 2 - .../hpux/classic/preUninstall.sh.in | 4 +- .../hpux/classic/tarUninstall.sh.in | 3 +- .../hpux/classic/tarmainUninstall.sh.in | 4 +- .../misc/changegdslibrarycompatibleLink.sh.in | 3 - .../hpux/misc/createaliasDB.sh.in | 8 +- .../arch-specific/hpux/misc/hpuxLibrary.sh.in | 2 +- .../hpux/super/postInstall.sh.in | 17 +- .../arch-specific/hpux/super/preInstall.sh.in | 2 - .../hpux/super/preUninstall.sh.in | 14 +- .../hpux/super/tarUninstall.sh.in | 16 +- .../install/arch-specific/linux/Makefile.in | 27 +- .../linux/classic/makeInstallImage.sh.in | 257 ------------------ .../linux/misc/firebird.init.d.debian.in | 5 +- .../linux/misc/firebird.init.d.generic.in | 5 +- .../linux/misc/firebird.init.d.gentoo.in | 5 +- .../linux/misc/firebird.init.d.mandrake.in | 6 +- .../linux/misc/firebird.init.d.slackware.in | 5 +- .../linux/misc/firebird.init.d.suse.in | 15 +- .../linux/misc/firebird.xinetd.in | 2 +- .../linux/misc/linuxLibrary.sh.in | 10 +- .../linux/misc/postinstall.sh.in | 15 +- .../linux/misc/preuninstall.sh.in | 10 +- .../linux/misc/tarMainUninstall.sh.in | 4 +- .../linux/super/makeInstallImage.sh.in | 239 ---------------- .../arch-specific/linux/super/rpmfiles.txt.in | 12 +- builds/install/misc/aliases.conf.in | 4 +- .../misc/changeGdsLibraryCompatibleLink.sh.in | 3 - .../install/misc/changeMultiConnectMode.sh.in | 3 - builds/install/misc/changeRunUser.sh.in | 4 +- builds/install/misc/classicLibrary.sh.in | 10 +- builds/install/misc/createAliasDB.sh.in | 11 +- builds/install/misc/fb_config.in | 7 +- builds/install/misc/posixLibrary.sh.in | 199 +++++--------- builds/install/misc/restoreRootRunUser.sh.in | 4 +- builds/posix/Makefile.in.client.gfix | 2 +- builds/posix/Makefile.in.client.util | 6 +- builds/posix/Makefile.in.embed.gfix | 6 +- builds/posix/Makefile.in.embed.util | 6 +- builds/posix/darwin.defaults | 2 +- builds/posix/make.defaults | 4 +- builds/posix/prefix.aix_powerpc | 2 +- builds/posix/prefix.aix_powerpc_xlc | 2 +- configure.in | 36 ++- src/common/classes/MsgPrint.cpp | 4 +- src/common/config/config.cpp | 32 ++- src/common/config/config.h | 10 - src/common/utils.cpp | 107 ++++++++ src/common/utils_proto.h | 9 + src/gpre/ftn.cpp | 18 +- src/intl/utils/dtest.c | 10 +- src/jrd/IntlManager.cpp | 3 +- src/jrd/db_alias.cpp | 4 +- src/jrd/fun.epp | 79 ++++-- src/jrd/gds.cpp | 40 ++- src/jrd/jrd.cpp | 6 +- src/jrd/jrd_pwd.h | 4 +- src/jrd/os/posix/config_root.cpp | 11 + src/jrd/svc.cpp | 5 +- src/jrd/trace/TraceManager.cpp | 5 +- src/qli/help.epp | 14 +- src/remote/inet_server.cpp | 5 +- src/remote/os/win32/srvr_w32.cpp | 5 +- src/utilities/guard/guard.cpp | 4 +- src/utilities/guard/util.cpp | 25 +- src/utilities/ibmgr/ibmgr.h | 2 +- src/utilities/ibmgr/srvrmgr.cpp | 12 +- 73 files changed, 512 insertions(+), 935 deletions(-) delete mode 100644 builds/install/arch-specific/linux/classic/makeInstallImage.sh.in delete mode 100644 builds/install/arch-specific/linux/super/makeInstallImage.sh.in diff --git a/builds/install/arch-specific/aix/misc/aixLibrary.sh.in b/builds/install/arch-specific/aix/misc/aixLibrary.sh.in index b7c5202687..f169e9e378 100644 --- a/builds/install/arch-specific/aix/misc/aixLibrary.sh.in +++ b/builds/install/arch-specific/aix/misc/aixLibrary.sh.in @@ -49,7 +49,7 @@ TryAddUser() { if [ -z "$testStr" ] then - useradd -d $FBRootDir -s /bin/false \ + useradd -d @FB_CONFDIR@ -s /bin/false \ -c "Firebird Database Owner" -g firebird firebird fi diff --git a/builds/install/arch-specific/aix/misc/postinstall.sh.in b/builds/install/arch-specific/aix/misc/postinstall.sh.in index f72e17275c..e4b87f48ea 100644 --- a/builds/install/arch-specific/aix/misc/postinstall.sh.in +++ b/builds/install/arch-specific/aix/misc/postinstall.sh.in @@ -35,10 +35,7 @@ origDir=`pwd` if [ "$1" = "install-embedded" ] then # remove server files not needed for embedded usage - cd $FBRootDir/bin - rm -f fb_inet_server - rm -f fb_smp_server - cd $FBRootDir + rm -f @FB_SBINDIR@/fb_inet_server @FB_SBINDIR@/fb_smp_server exit 0 fi @@ -52,12 +49,12 @@ if [ $RunUser = firebird ]; then fi # Create the fbmgr shell script. -if [ -x $FBBin/fbmgr.bin ]; then - cat > $FBBin/fbmgr < @FB_SBINDIR@/fbmgr < " @@ -141,7 +138,7 @@ checkAccessToFile() { aliasName=$1 newDB=$2 - AliasFile=$FBRootDir/aliases.conf + AliasFile=@FB_CONFDIR@/aliases.conf checkNameStartsWithSlash $newDB @@ -151,8 +148,7 @@ checkAccessToFile() { if [ ! -f $newDB ] then - #source $FBRootDir/SYSDBA.password - $FBBin/isql < fbmgr < @FB_SBINDIR@/fbmgr < /dev/null 2> /dev/null; then \ - echo Succeeded using objcopy from binutils; \ - else \ - echo Failed to set debug link for $${x}; \ - fi; \ + objcopy --add-gnu-debuglink=$${D_FIL} $${FIL}; \ echo Stripping unneeded symbols from $${x}; \ objcopy --strip-debug --strip-unneeded $${FIL}; \ fi; \ done # Work around GDB 6.0 bug - mkdir -p $(GEN_ROOT)/$(DebugDir)@libdir@/.debug - for x in `ls $(GEN_ROOT)/$(DebugDir)@prefix@/lib/.debug`; do \ - ln -f -s @prefix@/lib/.debug/`basename $$x` $(GEN_ROOT)/$(DebugDir)@libdir@/.debug; \ - done +# mkdir -p $(GEN_ROOT)/$(DebugDir)@libdir@/.debug +# for x in `ls $(GEN_ROOT)/$(DebugDir)@prefix@/lib/.debug`; do \ +# ln -f -s @prefix@/lib/.debug/`basename $$x` $(GEN_ROOT)/$(DebugDir)@libdir@/.debug; \ +# done # Use this line if you don't want to use separate debug info #buildImageDir: buildRoot diff --git a/builds/install/arch-specific/linux/classic/makeInstallImage.sh.in b/builds/install/arch-specific/linux/classic/makeInstallImage.sh.in deleted file mode 100644 index a6132bda49..0000000000 --- a/builds/install/arch-specific/linux/classic/makeInstallImage.sh.in +++ /dev/null @@ -1,257 +0,0 @@ -#!/bin/sh -# -# The contents of this file are subject to the Initial -# Developer's Public License Version 1.0 (the "License"); -# you may not use this file except in compliance with the -# License. You may obtain a copy of the License at -# http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl. -# -# Software distributed under the License is distributed AS IS, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. -# See the License for the specific language governing rights -# and limitations under the License. -# -# The Original Code was created by Mark O'Donohue -# for the Firebird Open Source RDBMS project. -# -# Copyright (c) Mark O'Donohue -# and all contributors signed below. -# -# All Rights Reserved. -# Contributor(s): ______________________________________. -# Alex Peshkoff -# - -# Script to copy install files from the build/transport area - - -# This script builds an image of the installed system into -# the gen/buildroot directory. - - -# Making an assumption that this program is being run in the gen directory -BuildRootDir=.. -BuiltFBDir=./firebird # Where the just build fb exists. - - -TargetDir=buildroot # Where we want to build the install image - -RealRootDir=@prefix@ # Where it will be installed on new machine -FBRootDir=${RealRootDir#/} # strip off leading / -DestDir=$TargetDir/$FBRootDir - - -#------------------------------------------------------------------------ -# addLibs -# Add required libraries in the beginning of script. -# Place it to target directory. - -addLibs() { - libSdir=$1 - libScript=$2 - libTdir=$3 - libTarget=$libTdir/$libScript - - rm -f $libTarget - touch $libTarget - for i in posixLibrary.sh classicLibrary.sh linuxLibrary.sh - do - echo "# $i" >>$libTarget - cat $libSdir/$i >>$libTarget - echo "" >>$libTarget # avoid missing linefeed - done - cat $libSdir/$libScript >>$libTarget -} - - -#------------------------------------------------------------------------ -# copyIfExists -# Copy file if it exists -# - -copyIfExists() { - OldFile=$1 - NewFile=$2 - - if [ -f $OldFile ] - then - cp $OldFile $NewFile - fi - -} - - -#------------------------------------------------------------------------ -# copyFiles -# This function copies all the files for a classic distribution into a -# directory heirachy mirroring the installation. - -copyFiles() { -# The guts of the tranfer of files and other directories - - if [ -d $TargetDir ] - then - rm -fr $TargetDir - fi - mkdir -p $DestDir - mkdir $DestDir/bin - mkdir $DestDir/examples - mkdir $DestDir/help - mkdir $DestDir/include - mkdir $DestDir/intl - mkdir $DestDir/lib - mkdir $DestDir/plugins - mkdir $DestDir/doc - mkdir $DestDir/doc/sql.extensions - mkdir $DestDir/UDF - mkdir $DestDir/misc - mkdir $DestDir/misc/upgrade - for i in ib_udf metadata security; do - mkdir $DestDir/misc/upgrade/$i - done - -# mkdir $TargetDir/etc -# mkdir $TargetDir/etc/init.d -# mkdir $TargetDir/var -# mkdir $TargetDir/var/adm -# mkdir $TargetDir/var/adm/fillup-templates - -# mkdir -p $TargetDir/usr/sbin - mkdir -p $TargetDir@libdir@ - mkdir -p $TargetDir/usr/include - - cp -f $BuiltFBDir/bin/fb_inet_server $DestDir/bin/fb_inet_server - cp -f $BuiltFBDir/bin/fb_smp_server $DestDir/bin/fb_smp_server - cp -f $BuiltFBDir/bin/fbguard $DestDir/bin/fbguard - - cp $BuiltFBDir/bin/gbak $DestDir/bin/gbak - cp $BuiltFBDir/bin/gdef $DestDir/bin/gdef - copyIfExists $BuiltFBDir/bin/fb_lock_print $DestDir/bin/fb_lock_print - cp $BuiltFBDir/bin/gfix $DestDir/bin/gfix - cp $BuiltFBDir/bin/gpre $DestDir/bin/gpre - cp $BuiltFBDir/bin/gsec $DestDir/bin/gsec - cp $BuiltFBDir/bin/nbackup $DestDir/bin/nbackup - copyIfExists $BuiltFBDir/bin/gsplit $DestDir/bin/gsplit - cp $BuiltFBDir/bin/gstat $DestDir/bin/gstat - copyIfExists $BuiltFBDir/bin/fbsvcmgr $DestDir/bin/fbsvcmgr - copyIfExists $BuiltFBDir/bin/fbtracemgr $DestDir/bin/fbtracemgr - cp $BuiltFBDir/bin/isql $DestDir/bin/isql - cp $BuiltFBDir/bin/qli $DestDir/bin/qli - - # Append libraries to scripts - addLibs $BuildRootDir/gen/firebird/bin changeRunUser.sh $DestDir/bin - addLibs $BuildRootDir/gen/firebird/bin restoreRootRunUser.sh $DestDir/bin - addLibs $BuildRootDir/gen/firebird/bin changeDBAPassword.sh $DestDir/bin - addLibs $BuildRootDir/gen/firebird/bin changeMultiConnectMode.sh $DestDir/bin - addLibs $BuiltFBDir/bin changeGdsLibraryCompatibleLink.sh $DestDir/bin - addLibs $BuildRootDir/gen/firebird/bin tarMainInstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuildRootDir/gen/firebird/bin tarinstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuildRootDir/gen/firebird/bin preinstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuildRootDir/gen/firebird/bin postinstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuildRootDir/gen/firebird/bin preuninstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuildRootDir/gen/firebird/bin postuninstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuildRootDir/gen/firebird/bin taruninstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuildRootDir/gen/firebird/bin tarMainUninstall.sh $BuildRootDir/gen/install/scripts - # this scripts don't need libraries - cp $BuiltFBDir/bin/createAliasDB.sh $DestDir/bin - cp $BuiltFBDir/bin/fb_config $DestDir/bin - - # Copy examples only if we have them - - exampleFiles=`find $BuiltFBDir/examples/README -type f -print` - if [ -z "$exampleFiles" ] - then - echo "Example files have not been built!" - else - (cd $BuiltFBDir/examples; tar cf - .) | (cd $DestDir/examples; tar xf -) - fi - - copyIfExists $BuiltFBDir/help/help.gbak $DestDir/help - cp $BuiltFBDir/help/help.fdb $DestDir/help - - #cp -r $BuildSrcDir/doc $DestDir - #cp -r $BuiltFBDir/doc $DestDir - - cp $BuiltFBDir/firebird.msg $DestDir/firebird.msg - cp $BuiltFBDir/$SecurityDatabase $DestDir/$SecurityDatabase - - -# cp $BuiltFBDir/include/gds.f $DestDir/include - cp $BuiltFBDir/include/*.h $DestDir/include - - - cp -df $BuiltFBDir/lib/libfbembed.so* $DestDir/lib - cp -df $BuiltFBDir/lib/libfbclient.so* $DestDir/lib - -# cp -f $BuiltFBDir/lib/gds.a @libdir@/libgds.a - cp -f $BuiltFBDir/lib/libib_util.so $DestDir/lib/libib_util.so - - cp -df $BuiltFBDir/lib/libicu*.so* $DestDir/lib/ - - cp -df $BuiltFBDir/plugins/* $DestDir/plugins/ - - cp $BuiltFBDir/intl/libfbintl.so $DestDir/intl/fbintl - cp $BuiltFBDir/UDF/ib_udf.so $DestDir/UDF/ - cp $BuiltFBDir/UDF/fbudf.so $DestDir/UDF/ - -# Note that the following items copy files from outside the build tree. - -# Copy the sql-declarations into the UDF-directory - cp $BuildRootDir/src/extlib/ib_udf.sql $DestDir/UDF/ - cp $BuildRootDir/src/extlib/ib_udf2.sql $DestDir/UDF/ - cp $BuildRootDir/src/extlib/fbudf/fbudf.sql $DestDir/UDF/ - -# Copy various documentation - cp $BuildRootDir/doc/*.pdf $DestDir/doc - cp $BuildRootDir/doc/README.* $DestDir/doc - cp $BuildRootDir/doc/sql.extensions/README* $DestDir/doc/sql.extensions - cp $BuildRootDir/doc/WhatsNew $DestDir/WhatsNew - cp $BuildRootDir/doc/README.user $DestDir/README - -# Copy various upgrade stuff - cp $BuildRootDir/src/misc/intl.sql $DestDir/misc/ - cp $BuildRootDir/src/misc/upgrade/v2/ib_udf* $DestDir/misc/upgrade/ib_udf/ - cp $BuildRootDir/src/misc/upgrade/v2/security_database* $DestDir/misc/upgrade/security/ - cp $BuildRootDir/src/misc/upgrade/v2.1/metadata_charset* $DestDir/misc/upgrade/metadata/ - -# Misc. config files - cp $BuildRootDir/gen/install/misc/firebird.xinetd $DestDir/misc/ - cp $BuildRootDir/gen/install/misc/firebird.conf $DestDir/ - cp $BuildRootDir/gen/install/misc/aliases.conf $DestDir/ - cp $BuildRootDir/gen/install/misc/fbintl.conf $DestDir/intl/ - cp $BuildRootDir/gen/install/misc/firebird.init.d.* $DestDir/misc/ - cp $BuildRootDir/gen/install/misc/rc.config.firebird $DestDir/misc - -# Create links from @libdir@ to install area. - - origDir=`pwd` - cd $DestDir/lib - for i in libfb*.so*; do ln -s /$FBRootDir/lib/$i $origDir/$TargetDir@libdir@/$i; done - cd $origDir - #ln -s ../../$FBRootDir/lib/libgds.a $TargetDir@libdir@/libgds.a - ln -s ../../$FBRootDir/lib/libib_util.so $TargetDir@libdir@/libib_util.so - - - -# link include files to /usr/include - for i in iberror.h ibase.h ib_util.h - do - ln -s ../../$FBRootDir/include/$i $TargetDir/usr/include/$i - done - -# (cd $DestDir; touch firebird.log;) - -# chmod u=rw,go= firebird.log) -# (cd $DestDir; chmod uga+rw examples/*.gdb) - -# chown -R root:root $TargetDir - -} - - - -#=== MAIN ==================================================================== - -SecurityDatabase=security2.fdb - -copyFiles diff --git a/builds/install/arch-specific/linux/misc/firebird.init.d.debian.in b/builds/install/arch-specific/linux/misc/firebird.init.d.debian.in index 0572874dcb..888d6f9ceb 100644 --- a/builds/install/arch-specific/linux/misc/firebird.init.d.debian.in +++ b/builds/install/arch-specific/linux/misc/firebird.init.d.debian.in @@ -15,13 +15,16 @@ #. /etc/rc.d/init.d/functions -FIREBIRD=@prefix@ +FIREBIRD=@FB_CONFDIR@ FBRunUser=firebird pidfile=/var/run/firebird/`basename $0`.pid FB_OPTS="-pidfile $pidfile -daemon -forever" export FIREBIRD GUARDIAN=$FIREBIRD/bin/fbguard +if [ ! -x $GUARDIAN ]; then + GUARDIAN=@FB_SBINDIR@/fbguard +fi # See how we were called. case "$1" in diff --git a/builds/install/arch-specific/linux/misc/firebird.init.d.generic.in b/builds/install/arch-specific/linux/misc/firebird.init.d.generic.in index d2e88c9110..0eda18b41f 100644 --- a/builds/install/arch-specific/linux/misc/firebird.init.d.generic.in +++ b/builds/install/arch-specific/linux/misc/firebird.init.d.generic.in @@ -8,7 +8,7 @@ # Change INSTANCE and FIREBIRD below (all instance names should be unique) # Edit the copied firebird.conf to change at least RemoteServicePort INSTANCE=default -FIREBIRD=@prefix@ +FIREBIRD=@FB_CONFDIR@ # No changes needed below for multiple instances FBRunUser=firebird @@ -19,6 +19,9 @@ LD_LIBRARY_PATH=$FIREBIRD/lib export FIREBIRD LD_LIBRARY_PATH GUARDIAN=$FIREBIRD/bin/fbguard +if [ ! -x $GUARDIAN ]; then + GUARDIAN=@FB_SBINDIR@/fbguard +fi # See how we were called. case "$1" in diff --git a/builds/install/arch-specific/linux/misc/firebird.init.d.gentoo.in b/builds/install/arch-specific/linux/misc/firebird.init.d.gentoo.in index b139715f2f..7693580384 100644 --- a/builds/install/arch-specific/linux/misc/firebird.init.d.gentoo.in +++ b/builds/install/arch-specific/linux/misc/firebird.init.d.gentoo.in @@ -16,7 +16,7 @@ # Edit the copied firebird.conf to change at least RemoteServicePort # Optionally run rc-update to autostart the new service INSTANCE=default -FIREBIRD=@prefix@ +FIREBIRD=@FB_CONFDIR@ FBRunUser=firebird pidfile=/var/run/firebird/$INSTANCE.pid @@ -27,6 +27,9 @@ FB_OPTS="-pidfile $pidfile -daemon -forever" export FIREBIRD LD_LIBRARY_PATH GUARDIAN=$FIREBIRD/bin/fbguard +if [ ! -x $GUARDIAN ]; then + GUARDIAN=@FB_SBINDIR@/fbguard +fi start(){ ebegin "Starting $FULLNAME" diff --git a/builds/install/arch-specific/linux/misc/firebird.init.d.mandrake.in b/builds/install/arch-specific/linux/misc/firebird.init.d.mandrake.in index 3c493bf188..10129a01df 100644 --- a/builds/install/arch-specific/linux/misc/firebird.init.d.mandrake.in +++ b/builds/install/arch-specific/linux/misc/firebird.init.d.mandrake.in @@ -27,7 +27,7 @@ # Edit the copied firebird.conf to change at least RemoteServicePort # Optionally run chkconfig to autostart the new service INSTANCE=default -FIREBIRD=@prefix@ +FIREBIRD=@FB_CONFDIR@ # No changes needed below for multiple instances name=$(basename `readlink -f $0`) @@ -39,6 +39,10 @@ LD_LIBRARY_PATH=$FIREBIRD/lib export FIREBIRD LD_LIBRARY_PATH GUARDIAN=$FIREBIRD/bin/fbguard +if [ ! -x $GUARDIAN ]; then + GUARDIAN=@FB_SBINDIR@/fbguard +fi + # initialize as "success" RETVAL=0 diff --git a/builds/install/arch-specific/linux/misc/firebird.init.d.slackware.in b/builds/install/arch-specific/linux/misc/firebird.init.d.slackware.in index 0970a250e9..e39e349b7f 100644 --- a/builds/install/arch-specific/linux/misc/firebird.init.d.slackware.in +++ b/builds/install/arch-specific/linux/misc/firebird.init.d.slackware.in @@ -12,7 +12,7 @@ # Edit the copied firebird.conf to change at least RemoteServicePort # Optionally run rc-update to autostart the new service INSTANCE=default -FIREBIRD=@prefix@ +FIREBIRD=@FB_CONFDIR@ # No changes needed below for multiple instances FBRunUser=firebird @@ -23,6 +23,9 @@ LD_LIBRARY_PATH=$FIREBIRD/lib export FIREBIRD LD_LIBRARY_PATH GUARDIAN=$FIREBIRD/bin/fbguard +if [ ! -x $GUARDIAN ]; then + GUARDIAN=@FB_SBINDIR@/fbguard +fi case "$1" in 'start') echo -n "Starting $FULLNAME: " diff --git a/builds/install/arch-specific/linux/misc/firebird.init.d.suse.in b/builds/install/arch-specific/linux/misc/firebird.init.d.suse.in index dc9298a40b..b863da377d 100644 --- a/builds/install/arch-specific/linux/misc/firebird.init.d.suse.in +++ b/builds/install/arch-specific/linux/misc/firebird.init.d.suse.in @@ -40,15 +40,20 @@ link=${base#*[SK][0-9][0-9]} test $link = $base && START_FIREBIRD="yes" test "$START_FIREBIRD" = yes || exit 0 -FIREBIRD=@prefix@ +FIREBIRD=@FB_CONFDIR@ FBRunUser=firebird pidfile=/var/run/firebird/firebird.pid export FIREBIRD # Check the files are there and are executable. -[ -x $FIREBIRD/bin/fbguard ] || exit 5 -[ -x $FIREBIRD/bin/fbserver ] || [ -x $FIREBIRD/bin/fb_smp_server ] || exit 5 +FBSBIN=$FIREBIRD/bin +if [ ! -x $FBSBIN/fbguard ]; then + FBSBIN=@FB_SBINDIR@ +fi + +[ -x $FBSBIN/fbguard ] || exit 5 +[ -x $FBSBIN/fbserver ] || [ -x $FBSBIN/fb_smp_server ] || exit 5 # Shell functions sourced from /etc/rc.status: # rc_check check and set local and overall rc status @@ -87,7 +92,7 @@ case "$1" in # NOTE: startproc return 0, even if service is # already running to match LSB spec. - startproc -u $FBRunUser $FIREBIRD/bin/fbguard -pidfile $pidfile -forever + startproc -u $FBRunUser $FBSBIN/fbguard -pidfile $pidfile -forever # Remember status and be verbose rc_status -v @@ -143,7 +148,7 @@ case "$1" in # 3 - service not running # NOTE: checkproc returns LSB compliant status values. - checkproc $FIREBIRD/bin/fbguard + checkproc $FBSBIN/fbguard rc_status -v ;; diff --git a/builds/install/arch-specific/linux/misc/firebird.xinetd.in b/builds/install/arch-specific/linux/misc/firebird.xinetd.in index 0bc75fe628..60fc4ee5d7 100644 --- a/builds/install/arch-specific/linux/misc/firebird.xinetd.in +++ b/builds/install/arch-specific/linux/misc/firebird.xinetd.in @@ -16,5 +16,5 @@ service gds_db # using default firewall configuration (SF#1065511) # log_on_success += USERID # log_on_failure += USERID - server = @prefix@/bin/fb_inet_server + server = @FB_SBINDIR@/fb_inet_server } diff --git a/builds/install/arch-specific/linux/misc/linuxLibrary.sh.in b/builds/install/arch-specific/linux/misc/linuxLibrary.sh.in index f6aa0ef7bd..284313fde3 100644 --- a/builds/install/arch-specific/linux/misc/linuxLibrary.sh.in +++ b/builds/install/arch-specific/linux/misc/linuxLibrary.sh.in @@ -64,7 +64,7 @@ TryAddUser() { if [ -z "$testStr" ] then - useradd $AdditionalParameter -d $FBRootDir -s /bin/false \ + useradd $AdditionalParameter -d @FB_CONFDIR@ -s /bin/false \ -c "Firebird Database Owner" -g firebird firebird fi @@ -301,7 +301,7 @@ EOF if [ "$initScript" ] then # Install the firebird init.d script - cp $FBRootDir/misc/$srcScript $initScript + cp @FB_MISCDIR@/$srcScript $initScript chown root:root $initScript chmod ug=rx,o=r $initScript @@ -332,16 +332,16 @@ EOF then if [ -x /bin/fillup ] then - /bin/fillup -q -d = /etc/rc.config $FBRootDir/misc/rc.config.firebird + /bin/fillup -q -d = /etc/rc.config @FB_MISCDIR@/rc.config.firebird fi elif [ -d /etc/sysconfig ] then - cp $FBRootDir/misc/rc.config.firebird /etc/sysconfig/firebird + cp @FB_MISCDIR@/rc.config.firebird /etc/sysconfig/firebird fi else echo "Couldn't autodetect linux type. You must select" - echo "the most appropriate startup script in $FBRootDir/misc/" + echo "the most appropriate startup script in @FB_MISCDIR@" echo "and manually register it in your OS." fi diff --git a/builds/install/arch-specific/linux/misc/postinstall.sh.in b/builds/install/arch-specific/linux/misc/postinstall.sh.in index 15f5e8a82f..7771052e28 100644 --- a/builds/install/arch-specific/linux/misc/postinstall.sh.in +++ b/builds/install/arch-specific/linux/misc/postinstall.sh.in @@ -29,11 +29,6 @@ # Detect which linux distro we are installing on detectDistro -# Make sure the links are in place -if [ -z "$FirebirdInstallPrefix" ]; then - FirebirdInstallPrefix=@prefix@ -fi - origDir=`pwd` # Update /etc/services @@ -46,12 +41,12 @@ if [ $RunUser = firebird ]; then fi # Create the fbmgr shell script. -if [ -x $FBBin/fbmgr.bin ]; then - cat > $FBBin/fbmgr < @FB_SBINDIR@/fbmgr < -# and all contributors signed below. -# -# All Rights Reserved. -# Contributor(s): ______________________________________. -# Alex Peshkoff -# - -# This library is part of the FirebirdSQL project -# Script to copy install files from the build/transport area - - -# This script builds an image of the installed system into -# the gen/buildroot directory. - - -# Making an assumption that this program is being run in the gen directory -BuildRootDir=.. -BuiltFBDir=./firebird # Where the just build fb exists. - - -TargetDir=buildroot # Where we want to build the install image - -RealRootDir=@prefix@ # Where it will be installed on new machine -FBRootDir=${RealRootDir#/} # strip off leading / -DestDir=$TargetDir/$FBRootDir -SecurityDatabase=security2.fdb - - -#------------------------------------------------------------------------ -# addLibs -# Add required libraries in the beginning of script. -# Place it to target directory. - -addLibs() { - libSdir=$1 - libScript=$2 - libTdir=$3 - libTarget=$libTdir/$libScript - - rm -f $libTarget - touch $libTarget - for i in posixLibrary.sh superLibrary.sh linuxLibrary.sh - do - echo "# $i" >>$libTarget - cat $libSdir/$i >>$libTarget - echo "" >>$libTarget # avoid missing linefeed - done - cat $libSdir/$libScript >>$libTarget -} - - -#------------------------------------------------------------------------ -# copyIfExists -# Copy file if it exists -# - -copyIfExists() { - OldFile=$1 - NewFile=$2 - - if [ -f $OldFile ] - then - cp $OldFile $NewFile - fi - -} - - -#------------------------------------------------------------------------ -# copyFiles -# This function copies all the files for a super distribution into a -# directory heirachy mirroring the installation. - -copyFiles() { -# The guts of the tranfer of files and other directories - - if [ -d $TargetDir ] - then - rm -fr $TargetDir - fi - mkdir -p $DestDir - mkdir $DestDir/bin - mkdir $DestDir/examples - mkdir $DestDir/help - mkdir $DestDir/include - mkdir $DestDir/intl - mkdir $DestDir/lib - mkdir $DestDir/plugins - mkdir $DestDir/doc - mkdir $DestDir/doc/sql.extensions - mkdir $DestDir/UDF - mkdir $DestDir/misc - mkdir $DestDir/misc/upgrade - for i in ib_udf metadata security; do - mkdir $DestDir/misc/upgrade/$i - done - - mkdir -p $TargetDir@libdir@ - mkdir -p $TargetDir/usr/include - -# mkdir $TargetDir/var -# mkdir $TargetDir/var/adm -# mkdir $TargetDir/var/adm/fillup-templates -# mkdir -p $TargetDir/usr/sbin - - cp -f $BuiltFBDir/bin/fbserver $DestDir/bin/fbserver - cp -f $BuiltFBDir/bin/fbguard $DestDir/bin/fbguard - cp -f $BuiltFBDir/bin/fbmgr.bin $DestDir/bin/fbmgr.bin - - cp $BuiltFBDir/bin/gbak $DestDir/bin/gbak - copyIfExists $BuiltFBDir/bin/gdef $DestDir/bin/gdef - copyIfExists $BuiltFBDir/bin/fb_lock_print $DestDir/bin/fb_lock_print - copyIfExists $BuiltFBDir/bin/gds_pipe $DestDir/bin/gds_pipe - cp $BuiltFBDir/bin/gfix $DestDir/bin/gfix - cp $BuiltFBDir/bin/gpre $DestDir/bin/gpre - cp $BuiltFBDir/bin/gsec $DestDir/bin/gsec - copyIfExists $BuiltFBDir/bin/gsplit $DestDir/bin/gsplit - cp $BuiltFBDir/bin/gstat $DestDir/bin/gstat - copyIfExists $BuiltFBDir/bin/fbsvcmgr $DestDir/bin/fbsvcmgr - copyIfExists $BuiltFBDir/bin/fbtracemgr $DestDir/bin/fbtracemgr - copyIfExists $BuiltFBDir/bin/security.gbak $DestDir/bin/security.gbak - cp $BuiltFBDir/bin/isql $DestDir/bin/isql - cp $BuiltFBDir/bin/nbackup $DestDir/bin/nbackup - copyIfExists $BuiltFBDir/bin/qli $DestDir/bin/qli - - # Append libraries to scripts - addLibs $BuildRootDir/gen/firebird/bin changeRunUser.sh $DestDir/bin - addLibs $BuildRootDir/gen/firebird/bin restoreRootRunUser.sh $DestDir/bin - addLibs $BuildRootDir/gen/firebird/bin changeDBAPassword.sh $DestDir/bin - addLibs $BuildRootDir/gen/firebird/bin tarMainInstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuildRootDir/gen/firebird/bin tarinstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuildRootDir/gen/firebird/bin preinstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuildRootDir/gen/firebird/bin postinstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuildRootDir/gen/firebird/bin preuninstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuildRootDir/gen/firebird/bin postuninstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuildRootDir/gen/firebird/bin taruninstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuildRootDir/gen/firebird/bin tarMainUninstall.sh $BuildRootDir/gen/install/scripts - # these scripts don't need libraries - cp $BuildRootDir/gen/firebird/bin/createAliasDB.sh $DestDir/bin - cp $BuildRootDir/gen/firebird/bin/fb_config $DestDir/bin - - # Copy examples only if we have them - - exampleFiles=`find $BuiltFBDir/examples/README -type f -print` - if [ -z "$exampleFiles" ] - then - echo "Example files have not been built!" - else - (cd $BuiltFBDir/examples; tar cf - .) | (cd $DestDir/examples; tar xf -) - fi - - copyIfExists $BuiltFBDir/help/help.gbak $DestDir/help - cp $BuiltFBDir/help/help.fdb $DestDir/help - cp $BuiltFBDir/*.msg $DestDir - cp $BuiltFBDir/$SecurityDatabase $DestDir/$SecurityDatabase - cp $BuiltFBDir/include/*.h $DestDir/include - cp -df $BuiltFBDir/lib/libfbclient.so* $DestDir/lib - cp -f $BuiltFBDir/lib/libib_util.so $DestDir/lib/libib_util.so - - cp -df $BuiltFBDir/lib/libicu*.so* $DestDir/lib/ - - cp -df $BuiltFBDir/plugins/* $DestDir/plugins/ - - cp $BuiltFBDir/intl/libfbintl.so $DestDir/intl/fbintl - cp $BuiltFBDir/UDF/ib_udf.so $DestDir/UDF/ - cp $BuiltFBDir/UDF/fbudf.so $DestDir/UDF/ - -# Note that the following items copy files from outside the build tree. - -# Copy the sql-declarations into the UDF-directory - cp $BuildRootDir/src/extlib/ib_udf.sql $DestDir/UDF/ - cp $BuildRootDir/src/extlib/ib_udf2.sql $DestDir/UDF/ - cp $BuildRootDir/src/extlib/fbudf/fbudf.sql $DestDir/UDF/ - -# Copy various documentation - cp $BuildRootDir/doc/*.pdf $DestDir/doc - cp $BuildRootDir/doc/README.* $DestDir/doc - cp $BuildRootDir/doc/sql.extensions/README* $DestDir/doc/sql.extensions - cp $BuildRootDir/doc/WhatsNew $DestDir/WhatsNew - cp $BuildRootDir/doc/README.user $DestDir/README - -# Copy various upgrade stuff - cp $BuildRootDir/src/misc/intl.sql $DestDir/misc/ - cp $BuildRootDir/src/misc/upgrade/v2/ib_udf* $DestDir/misc/upgrade/ib_udf/ - cp $BuildRootDir/src/misc/upgrade/v2/security_database* $DestDir/misc/upgrade/security/ - cp $BuildRootDir/src/misc/upgrade/v2.1/metadata_charset* $DestDir/misc/upgrade/metadata/ - -# Miscellaneous config and startup files - cp $BuildRootDir/gen/install/misc/firebird.conf $DestDir/firebird.conf - cp $BuildRootDir/gen/install/misc/fbintl.conf $DestDir/intl/fbintl.conf - cp $BuildRootDir/gen/install/misc/firebird.init.d.* $DestDir/misc - cp $BuildRootDir/gen/install/misc/rc.config.firebird $DestDir/misc - cp $BuildRootDir/gen/install/misc/aliases.conf $DestDir/ - - originalDir=`pwd` - -# Create links from @libdir@ to install area. - cd $TargetDir@libdir@ - for i in ../../$FBRootDir/lib/libfb*.so* - do - ln -s $i . - done - ln -s ../../$FBRootDir/lib/libib_util.so . - - cd $originalDir - -# link include files to /usr/include - cd $TargetDir/usr/include - for i in ../../$FBRootDir/include/*.h - do - ln -s $i . - done - - cd $originalDir -} - - - -#=== MAIN ==================================================================== - - -copyFiles diff --git a/builds/install/arch-specific/linux/super/rpmfiles.txt.in b/builds/install/arch-specific/linux/super/rpmfiles.txt.in index f235d60ae8..b498fd495d 100644 --- a/builds/install/arch-specific/linux/super/rpmfiles.txt.in +++ b/builds/install/arch-specific/linux/super/rpmfiles.txt.in @@ -1,11 +1 @@ -@prefix@ - -@libdir@/libfbclient.so.@FIREBIRD_VERSION@ -@libdir@/libfbclient.so.2 -@libdir@/libfbclient.so -@libdir@/libib_util.so - -/usr/include/ibase.h -/usr/include/iberror.h -/usr/include/ib_util.h -/usr/include/perf.h +/ diff --git a/builds/install/misc/aliases.conf.in b/builds/install/misc/aliases.conf.in index f1c8d0ab3e..a7ba81ad36 100644 --- a/builds/install/misc/aliases.conf.in +++ b/builds/install/misc/aliases.conf.in @@ -5,8 +5,8 @@ # # Example Database: # -employee.fdb = @prefix@/examples/empbuild/employee.fdb -employee = @prefix@/examples/empbuild/employee.fdb +employee.fdb = @FB_SAMPLEDBDIR@/employee.fdb +employee = @FB_SAMPLEDBDIR@/employee.fdb # # Live Databases: diff --git a/builds/install/misc/changeGdsLibraryCompatibleLink.sh.in b/builds/install/misc/changeGdsLibraryCompatibleLink.sh.in index 785edbdef3..1500e59e20 100644 --- a/builds/install/misc/changeGdsLibraryCompatibleLink.sh.in +++ b/builds/install/misc/changeGdsLibraryCompatibleLink.sh.in @@ -68,9 +68,6 @@ printStatus() { #= Main ==================================================================== - FBRootDir=@prefix@ - FBBin=$FBRootDir/bin - cat < " @@ -125,8 +121,7 @@ checkAccessToFile() { aliasName=$1 newDB=$2 - AliasFile=$FBRootDir/aliases.conf - + AliasFile=@FB_CONFDIR@/aliases.conf checkNameStartsWithSlash $newDB appendAliasEntry $aliasName $newDB @@ -135,8 +130,8 @@ checkAccessToFile() { if [ ! -f $newDB ] then - #source $FBRootDir/SYSDBA.password - $FBBin/isql <$DBAPasswordFile # Firebird generated password for user SYSDBA is: @@ -388,7 +385,7 @@ EOT cat <>$DBAPasswordFile # Your password can be changed to a more suitable one using the -# @prefix@/bin/gsec utility. +# @FB_BINDIR@/gsec utility. EOT chmod u=r,go= $DBAPasswordFile @@ -399,7 +396,7 @@ EOT if [ $NewPasswd != "masterkey" ] then - runSilent "$FBBin/gsec -user sysdba -password masterkey -modify sysdba -pw $NewPasswd" + runSilent "@FB_BINDIR@/gsec -user sysdba -password masterkey -modify sysdba -pw $NewPasswd" fi } @@ -429,14 +426,12 @@ buildUninstallFile() { return fi - cp manifest.txt $FBRootDir/misc + cp manifest.txt @FB_MISCDIR@ - cp -r scripts $FBRootDir/misc/ - [ -f scripts/tarMainUninstall.sh ] && cp scripts/tarMainUninstall.sh $FBRootDir/bin/uninstall.sh - [ -f scripts/tarmainUninstall.sh ] && cp scripts/tarmainUninstall.sh $FBRootDir/bin/uninstall.sh - [ -f $FBRootDir/bin/uninstall.sh ] && chmod u=rx,go= $FBRootDir/bin/uninstall.sh - - cd $FBRootDir + cp -r scripts @FB_MISCDIR@ + [ -f scripts/tarMainUninstall.sh ] && cp scripts/tarMainUninstall.sh @FB_SBINDIR@/$UninstallScript + [ -f scripts/tarmainUninstall.sh ] && cp scripts/tarmainUninstall.sh @FB_SBINDIR@/$UninstallScript + [ -f @FB_SBINDIR@/$UninstallScript ] && chmod u=rx,go= @FB_SBINDIR@/$UninstallScript } @@ -480,14 +475,13 @@ createLinksForBackCompatibility() { # to ensure it loads the fb equivalent. Eventually these should be # optional and in a seperate rpm install. MOD 7-Nov-2002. - cd $FBRootDir if [ "$1" ] then # Use library name from parameter - newLibrary=$FBRootDir/lib/$1 + newLibrary=@FB_LIBDIR@/$1 else # Use DefaultLibrary, set by appropriate install library - newLibrary=$FBRootDir/lib/$DefaultLibrary.so + newLibrary=@FB_LIBDIR@/$DefaultLibrary.so fi safeLink $newLibrary @libdir@/libgds.so @@ -506,23 +500,6 @@ removeLinksForBackCompatibility() { } -#------------------------------------------------------------------------ -# Set correct permissions for $FbRoot/doc tree - -fixDocPermissions() { - cd $FBRootDir - - for i in `find doc -print`; do - chown root:root $i - if [ -d $i ]; then - chmod 0755 $i - else - chmod 0644 $i - fi - done -} - - #------------------------------------------------------------------------ # Run process and check status @@ -573,16 +550,25 @@ archivePriorInstallSystemFiles() { cd / - DestFile=${FBRootDir#/} # strip off leading / - if [ -e "$DestFile" ] + if [ -f ${oldPWD}/manifest.txt ]; then + manifest=`cat ${oldPWD}/manifest.txt` + for i in $manifest; do + if [ -f $i ]; then + i=${i#/} # strip off leading / + archiveFileList="$archiveFileList $i" + fi + done + fi + + DestFile=@FB_CONFDIR@ + if [ -e "$DestFile" ] then echo "" echo "" echo "" echo "--- Warning ----------------------------------------------" - echo " The installation target directory: $FBRootDir" - echo " Already contains a prior installation of InterBase/Firebird." - echo " This and files found in /usr/include and @libdir@ will be" + echo " The installation target directory $DestFile already exists." + echo " This and other related files found will be" echo " archived in the file : ${tarArc}" echo "" @@ -601,9 +587,10 @@ archivePriorInstallSystemFiles() { for i in ibase.h ib_util.h do DestFile=usr/include/$i - if [ -e $DestFile ] - then - archiveFileList="$archiveFileList $DestFile" + if [ -e $DestFile ]; then + if [ ! "`echo $archiveFileList | grep $DestFile`" ]; then + archiveFileList="$archiveFileList $DestFile" + fi fi done @@ -611,30 +598,21 @@ archivePriorInstallSystemFiles() { do for DestFile in usr/lib/$i do - if [ -e $DestFile ] - then - archiveFileList="$archiveFileList $DestFile" + if [ -e $DestFile ]; then + if [ ! "`echo $archiveFileList | grep $DestFile`" ]; then + archiveFileList="$archiveFileList $DestFile" + fi fi done done -# for i in `cat manifest.txt` -# do -# if [ ! -d /$i ] # Ignore directories -# then -# if [ -e /$i ] -# then -# archiveFileList="$archiveFileList $i" -# fi -# fi -# done - for i in usr/sbin/rcfirebird etc/init.d/firebird etc/rc.d/init.d/firebird do DestFile=./$i - if [ -e /$DestFile ] - then - archiveFileList="$archiveFileList $DestFile" + if [ -e $DestFile ]; then + if [ ! "`echo $archiveFileList | grep $DestFile`" ]; then + archiveFileList="$archiveFileList $DestFile" + fi fi done @@ -661,9 +639,9 @@ archivePriorInstallSystemFiles() { # removeInstalledFiles() { - manifestFile=$FBRootDir/misc/manifest.txt + manifestFile=@FB_MISCDIR@/manifest.txt - if [ ! -f $manifestFile ] + if [ ! -f "$manifestFile" ] then return fi @@ -692,11 +670,9 @@ removeInstalledFiles() { removeUninstallFiles() { # remove the uninstall scripts files. - #echo $FBRootDir/misc/scripts - rm -rf $FBRootDir/misc/scripts - rm -f $FBRootDir/misc/manifest.txt - rm -f $FBRootDir/bin/uninstall.sh - + rm -rf @FB_MISCDIR@/scripts + rm -f @FB_MISCDIR@/manifest.txt + rm -f @FB_SBINDIR@/$UninstallScript } @@ -710,23 +686,24 @@ removeUninstallFiles() { removeEmptyDirs() { dirContentChanged='yes' - while [ ! -z $dirContentChanged ] - do + while [ "$dirContentChanged" ]; do dirContentChanged='' - for i in `find $FBRootDir -type d -print`; do - ls $i/* >/dev/null 2>&1 - if [ $? -ne 0 ]; then - rmdir $i - dirContentChanged=$i - fi - done - if [ ! -d $FBRootDir ] # end loop if the FBRootDir was deleted. - then - dirContentChanged='' - fi + for rootDir in @FB_BINDIR@ @FB_SBINDIR@ @FB_LIBDIR@ @FB_INCDIR@ @FB_DOCDIR@ @FB_UDFDIR@ @FB_SAMPLEDIR@ @FB_SAMPLEDBDIR@ \ + @FB_HELPDIR@ @FB_INTLDIR@ @FB_MISCDIR@ @FB_SECDBDIR@ @FB_MSGDIR@ @FB_LOGDIR@ @FB_GUARDDIR@ @FB_PLUGDIR@ \ + @FB_CONFDIR@; do - done + if [ -d $rootDir ]; then + for i in `find $rootDir -type d -print`; do + ls $i/* >/dev/null 2>&1 + if [ $? -ne 0 ]; then + rmdir $i && dirContentChanged=$i + fi + done + fi + + done + done } @@ -738,74 +715,30 @@ removeEmptyDirs() { # more work. fixFilePermissions() { - cd $FBRootDir - - # For security reasons initially force all root:root non-writable - chown -R root:root $FBRootDir - chmod -R uga-w $FBRootDir - - # Set up configuration files - make them root-writable - cd $FBRootDir - chmod u+w *.conf - - # Prepare bin - cd $FBBin - - # Everyone may execute clients - chmod a=rx * - - # Shell scripts changing security attributes are for root only - chmod u=rx,go= *.sh - # Lock files - cd $FBRootDir - for i in fb_guard + cd @FB_GUARDDIR@ + for FileName in fb_guard do - FileName=$i touch $FileName MakeFileFirebirdWritable $FileName done # Log file + cd @FB_LOGDIR@ touch firebird.log MakeFileFirebirdWritable firebird.log # Security database + cd @FB_SECDBDIR@ MakeFileFirebirdWritable $SecurityDatabase - # set up libraries & plugins - everyone may use them - cd $FBRootDir - chmod a=rx lib/lib* plugins/lib* - - # set up include files - everyone may use them - cd $FBRootDir/include - chmod a=r * - - # fix up examples' permissions - cd $FBRootDir/examples - # set a default of read all files in examples - for i in `find . -name '*' -type f -print` - do - chmod a=r $i - done - # set a default of read&search all dirs in examples - for i in `find . -name '*' -type d -print` - do - chmod a=rx $i - done # make examples DB(s) writable - for i in `find . -name '*.fdb' -print` + for i in `find @FB_SAMPLEDBDIR@ -name '*.fdb' -print` do MakeFileFirebirdWritable $i done - # fix up doc permissions - cd $FBRootDir - fixDocPermissions - # Architecture (CS/SS) specific permissions - cd $FBRootDir fixArcSpecificPermissions - cd $FBRootDir } diff --git a/builds/install/misc/restoreRootRunUser.sh.in b/builds/install/misc/restoreRootRunUser.sh.in index 089f751ca0..98ff9f18b9 100644 --- a/builds/install/misc/restoreRootRunUser.sh.in +++ b/builds/install/misc/restoreRootRunUser.sh.in @@ -34,7 +34,7 @@ checkIfServerRunning # Get confirmation echo "" -echo "Change Firebird install for $FBRootDir to uid=$RunUser gid=$RunGroup" +echo "Change Firebird install for @FB_CONFDIR@ to uid=$RunUser gid=$RunGroup" echo "(User or group options can be changed by editing this script)" echo "" AskQuestion "Press return to continue - or ^C to abort" @@ -52,7 +52,7 @@ updateInetdServiceEntry changeInitRunUser $RunUser # Update ownership and SUID bits for programs. -echo "Updating $FBRootDir" +echo "Updating permissions" fixFilePermissions # Get inetd to reread new init files, start service. diff --git a/builds/posix/Makefile.in.client.gfix b/builds/posix/Makefile.in.client.gfix index de7bc79b19..6ed81bf3f4 100644 --- a/builds/posix/Makefile.in.client.gfix +++ b/builds/posix/Makefile.in.client.gfix @@ -46,7 +46,7 @@ GFIX_Sources = $(addprefix alice/, $(GFIX_Files)) $(GFIX_Other_Sources) GFIX_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GFIX_Sources)))) AllObjects = $(GFIX_Objects) $(CLUMPLETS_Objects) $(FBCOMMON_Objects) \ - $(FBCLASSES_ClientObjects) $(FBCLASSES_MsgObjects) + $(FBCLASSES_ClientObjects) $(FBCLASSES_MsgObjects) Dependencies = $(AllObjects:.o=.d) diff --git a/builds/posix/Makefile.in.client.util b/builds/posix/Makefile.in.client.util index b72b6ce067..dfb5586b42 100644 --- a/builds/posix/Makefile.in.client.util +++ b/builds/posix/Makefile.in.client.util @@ -77,7 +77,7 @@ GSTAT_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GSTAT_Sources) FBSVCMGR_Files= fbsvcmgr.cpp FBSVCMGR_Other_Sources = common/classes/fb_string.cpp common/classes/alloc.cpp \ -common/fb_exception.cpp common/utils.cpp common/classes/locks.cpp +common/fb_exception.cpp common/utils.cpp common/classes/locks.cpp jrd/path_utils.cpp FBSVCMGR_Sources = $(addprefix utilities/, $(FBSVCMGR_Files)) $(FBSVCMGR_Other_Sources) FBSVCMGR_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBSVCMGR_Sources)))) \ @@ -87,7 +87,7 @@ $(FBCLASSES_MsgObjects) $(CLUMPLETS_Objects) $(FBCOMMON_ClientObjects) FBTRACEMGR_Files= fbtracemgr/traceMgrMain.cpp FBTRACEMGR_Other_Sources = common/classes/fb_string.cpp common/classes/alloc.cpp \ common/fb_exception.cpp common/utils.cpp common/classes/locks.cpp common/UtilSvc.cpp \ - jrd/trace/TraceCmdLine.cpp + jrd/trace/TraceCmdLine.cpp jrd/path_utils.cpp FBTRACEMGR_Sources = $(addprefix utilities/, $(FBTRACEMGR_Files)) $(FBTRACEMGR_Other_Sources) FBTRACEMGR_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBTRACEMGR_Sources)))) \ @@ -97,7 +97,7 @@ FBTRACEMGR_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBTRACEMG FBGUARD_Other_Sources = jrd/isc.cpp jrd/divorce.cpp jrd/path_utils.cpp FBGUARD_Files = guard.cpp util.cpp FBGUARD_Sources = $(addprefix utilities/guard/, $(FBGUARD_Files)) $(FBGUARD_Other_Sources) -FBGUARD_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBGUARD_Sources)))) +FBGUARD_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBGUARD_Sources)))) $(FBCLASSES_ClientObjects) IBGUARD_A_Files = cntl_guard.cpp iscguard.cpp diff --git a/builds/posix/Makefile.in.embed.gfix b/builds/posix/Makefile.in.embed.gfix index 8134bd78c5..0a379c8e3b 100644 --- a/builds/posix/Makefile.in.embed.gfix +++ b/builds/posix/Makefile.in.embed.gfix @@ -43,12 +43,12 @@ GFIX_Files = alice_meta.epp \ alice.cpp exe.cpp tdr.cpp aliceMain.cpp GFIX_Other_Sources += jrd/isc.cpp jrd/ThreadData.cpp jrd/path_utils.cpp \ - common/UtilSvc.cpp + common/UtilSvc.cpp GFIX_Sources = $(addprefix alice/, $(GFIX_Files)) $(GFIX_Other_Sources) GFIX_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GFIX_Sources)))) -AllObjects = $(GFIX_Objects) $(CLUMPLETS_Objects) +AllObjects = $(GFIX_Objects) $(CLUMPLETS_Objects) $(FBCOMMON_Objects) $(FBCLASSES_Objects) Dependencies = $(AllObjects:.o=.d) @@ -58,7 +58,7 @@ Dependencies = $(AllObjects:.o=.d) gfix : $(LIBFBEMBED_SO) $(GFIX) -$(GFIX): $(GFIX_Objects) $(CLUMPLETS_Objects) $(FBCOMMON_Objects) $(FBCLASSES_Objects) +$(GFIX): $(AllObjects) $(EXE_LINK) $(LINK_OPTS) $^ -o $@ $(FBEMBED_LINK) $(LINK_LIBS) diff --git a/builds/posix/Makefile.in.embed.util b/builds/posix/Makefile.in.embed.util index 564cfdbace..cdb18dc89b 100644 --- a/builds/posix/Makefile.in.embed.util +++ b/builds/posix/Makefile.in.embed.util @@ -90,7 +90,7 @@ GSTAT_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GSTAT_Sources) FBSVCMGR_Files= fbsvcmgr.cpp FBSVCMGR_Other_Sources = common/classes/fb_string.cpp common/classes/alloc.cpp \ -common/fb_exception.cpp common/utils.cpp common/classes/locks.cpp +common/fb_exception.cpp common/utils.cpp common/classes/locks.cpp jrd/path_utils.cpp FBSVCMGR_Sources = $(addprefix utilities/, $(FBSVCMGR_Files)) $(FBSVCMGR_Other_Sources) FBSVCMGR_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBSVCMGR_Sources)))) \ @@ -100,7 +100,7 @@ $(FBCLASSES_MsgObjects) $(CLUMPLETS_Objects) $(FBCOMMON_ClientObjects) FBTRACEMGR_Files= fbtracemgr/traceMgrMain.cpp FBTRACEMGR_Other_Sources = common/classes/fb_string.cpp common/classes/alloc.cpp \ common/fb_exception.cpp common/utils.cpp common/classes/locks.cpp common/UtilSvc.cpp \ - jrd/trace/TraceCmdLine.cpp + jrd/trace/TraceCmdLine.cpp jrd/path_utils.cpp FBTRACEMGR_Sources = $(addprefix utilities/, $(FBTRACEMGR_Files)) $(FBTRACEMGR_Other_Sources) FBTRACEMGR_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBTRACEMGR_Sources)))) \ @@ -110,7 +110,7 @@ FBTRACEMGR_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBTRACEMG FBGUARD_Other_Sources = jrd/isc.cpp jrd/divorce.cpp jrd/path_utils.cpp FBGUARD_Files = guard.cpp util.cpp FBGUARD_Sources = $(addprefix utilities/guard/, $(FBGUARD_Files)) $(FBGUARD_Other_Sources) -FBGUARD_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBGUARD_Sources)))) +FBGUARD_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBGUARD_Sources)))) $(FBCLASSES_ClientObjects) IBMGR_Files = ibmgr.cpp srvrmgr.cpp diff --git a/builds/posix/darwin.defaults b/builds/posix/darwin.defaults index 43b56bb339..11f601d3f5 100644 --- a/builds/posix/darwin.defaults +++ b/builds/posix/darwin.defaults @@ -18,7 +18,7 @@ # Wed Jan 28 2009 Alex Peshkov - moved common part of prefix.darwin* to separate file # Options -FirebirdInstallPrefix= +#FirebirdInstallPrefix= LIB_BUNDLE_OPTIONS:=$(LD_FLAGS) -bundle -flat_namespace -undefined suppress LIB_LINK_OPTIONS:=$(LD_FLAGS) -dynamiclib -flat_namespace LIB_LINK_SONAME:=-current_version @FIREBIRD_VERSION@ -compatibility_version @FIREBIRD_VERSION@ -seg1addr 0x30000000 diff --git a/builds/posix/make.defaults b/builds/posix/make.defaults index 18b6edc618..d8c537b4da 100755 --- a/builds/posix/make.defaults +++ b/builds/posix/make.defaults @@ -84,6 +84,7 @@ GLOB_OPTIONS=@CFLAGS@ #GLOB_OPTIONS+= -pg CFLAGS:= $(CFLAGS) $(GLOB_OPTIONS) +CXXFLAGS:= $(CXXFLAGS) $(GLOB_OPTIONS) #____________________________________________________________________________ @@ -91,7 +92,6 @@ IsProdTypeBuild = @PROD_BUILD_FLG@ # If this is defined then we are building a production # release with debug and optimization -FirebirdInstallPrefix = @prefix@ CpuType=@CPU_TYPE@ PLATFORM=@PLATFORM@ @@ -255,7 +255,7 @@ LINK_IBUTIL_SYMBOLS = $(LIB_LINK_MAPFILE)$(ROOT)/builds/posix/ib_util.vers LIB_PLATFORM_RPATH = -Wl,-rpath,$(1) ifeq ($(strip @BINRELOC_CFLAGS@),) -LIB_LINK_RPATH = $(call LIB_PLATFORM_RPATH,$(FirebirdInstallPrefix)/$(1)) +LIB_LINK_RPATH = $(call LIB_PLATFORM_RPATH,$(if $(subst intl,,$(1)),@FB_LIBDIR@,@FB_INTLDIR@)) else LIB_LINK_RPATH = $(call LIB_PLATFORM_RPATH,'$$$$ORIGIN/../$(1)') endif diff --git a/builds/posix/prefix.aix_powerpc b/builds/posix/prefix.aix_powerpc index 0816876344..a927a9b410 100644 --- a/builds/posix/prefix.aix_powerpc +++ b/builds/posix/prefix.aix_powerpc @@ -49,7 +49,7 @@ export LIBPATH # AIX ld option to set run-time library path is -Wl-blibpath:path1:path2 # Additional -blibpath options are not additive! All paths must be provided as a colon separated list. -LIB_PATH_OPTS= -Wl,-blibpath:$(FirebirdInstallPrefix)/lib:$(FirebirdInstallPrefix)/intl:/usr/local/lib:/usr/lib:/lib:$(GCC_RUNTIME) +LIB_PATH_OPTS= -Wl,-blibpath:@FB_LIBDIR@:@FB_INTLDIR@:/usr/local/lib:/usr/lib:/lib:$(GCC_RUNTIME) ifeq ($(STD_ICU),true) ICU_LIBS= -L/usr/local/lib -licuuc -licudata -licui18n diff --git a/builds/posix/prefix.aix_powerpc_xlc b/builds/posix/prefix.aix_powerpc_xlc index c99b6d2451..21c7d18983 100644 --- a/builds/posix/prefix.aix_powerpc_xlc +++ b/builds/posix/prefix.aix_powerpc_xlc @@ -55,7 +55,7 @@ # AIX ld option to set run-time library path is -blibpath:path1:path2 # Additional -blibpath options are not additive! All paths must be provided as a colon separated list. -LIB_PATH_OPTS= -blibpath:$(FirebirdInstallPrefix)/lib:$(FirebirdInstallPrefix)/intl:/usr/local/lib:/usr/lib:/lib +LIB_PATH_OPTS= -blibpath:@FB_LIBDIR@:@FB_INTLDIR@:/usr/local/lib:/usr/lib:/lib ifeq ($(STD_ICU),true) ICU_LIBS= -L/usr/local/lib -licuuc -licudata -licui18n diff --git a/configure.in b/configure.in index 0eefc7434c..69bab073ec 100644 --- a/configure.in +++ b/configure.in @@ -2,9 +2,11 @@ dnl ############################# INITIALISATION ############################### AC_PREREQ(2.56) AC_INIT(src) + AC_CONFIG_AUX_DIR(builds/make.new/config) AC_CACHE_VAL(ac_cv_prog_make_set, [AC_PROG_MAKE_SET]) AC_PREFIX_DEFAULT(/usr/local/firebird) + m4_ifdef([AC_CONFIG_MACRO_DIR], [], [m4_define([AC_CONFIG_MACRO_DIR], [])]) @@ -18,6 +20,18 @@ define([XE_APPEND],[[$2]="$[$2] [$1]"]) dnl XE_PREPEND(value, varname) define([XE_PREPEND],[[$2]="[$1] $[$2]"]) +dnl XE_CONF_DIR(param, help, variable, default) +define([XE_CONF_DIR],[ +AC_ARG_WITH([$1], + [AS_HELP_STRING([--with-$1], [$2])], + [[$3]=$withval + AC_DEFINE_UNQUOTED([$3], "$[$3]", [$2])], + [[$3]=[$4] + AC_DEFINE_UNQUOTED([$3], [""], [$2])] +) +AC_SUBST([$3]) +]) + sinclude(acx_pthread.m4) sinclude(binreloc.m4) @@ -470,6 +484,26 @@ AC_SUBST(FB_SERVICE_NAME) AC_SUBST(FB_SERVICE_PORT) AC_SUBST(FB_IPC_NAME) +dnl Use non-standard directory placement control +dnl Sorry - GNU standard is not Ok for us +XE_CONF_DIR(fbbin, [executables DIR (PREFIX/bin)], FB_BINDIR, $prefix/bin) +XE_CONF_DIR(fbsbin, [system admin executables DIR (PREFIX/bin)], FB_SBINDIR, $prefix/bin) +XE_CONF_DIR(fbconf, [config files DIR (PREFIX)], FB_CONFDIR, $prefix) +XE_CONF_DIR(fblib, [object code libraries DIR (PREFIX/lib)], FB_LIBDIR, $prefix/lib) +XE_CONF_DIR(fbinclude, [C/C++ header files DIR (PREFIXinclude)], FB_INCDIR, $prefix/include) +XE_CONF_DIR(fbdoc, [documentation root DIR (PREFIX/doc)], FB_DOCDIR, $prefix/doc) +XE_CONF_DIR(fbudf, [UDF DIR (PREFIX/)], FB_UDFDIR, $prefix/UDF) +XE_CONF_DIR(fbsample, [examples DIR (PREFIX/examples)], FB_SAMPLEDIR, $prefix/examples) +XE_CONF_DIR(fbsample-db, [examples database DIR (PREFIX/examples/empbuild)], FB_SAMPLEDBDIR, $prefix/examples/empbuild) +XE_CONF_DIR(fbhelp, [QLI help DIR (PREFIX/help)], FB_HELPDIR, $prefix/help) +XE_CONF_DIR(fbintl, [international DIR (PREFIX/intl)], FB_INTLDIR, $prefix/intl) +XE_CONF_DIR(fbmisc, [misc DIR (PREFIX/misc)], FB_MISCDIR, $prefix/misc) +XE_CONF_DIR(fbsecure-db, [security database DIR (PREFIX)], FB_SECDBDIR, $prefix) +XE_CONF_DIR(fbmsg, [message files DIR (PREFIX)], FB_MSGDIR, $prefix) +XE_CONF_DIR(fblog, [log files DIR (PREFIX)], FB_LOGDIR, $prefix) +XE_CONF_DIR(fbglock, [guardian lock DIR (PREFIX)], FB_GUARDDIR, $prefix) +XE_CONF_DIR(fbplugins, [plugins DIR (PREFIX)], FB_PLUGDIR, $prefix/plugins) + dnl gpre built-in language support (C/C++ are mandatory) GPRE_LANGUAGE_MODULES="" AC_ARG_WITH(gpre-ada, @@ -1149,7 +1183,7 @@ case "$PLATFORM" in mkdir -p gen/RPM/BUILD]) INSTALL_SRC_DIR=builds/install/arch-specific/linux/${FIREBIRD_ARCH_TYPE} - AC_CONFIG_FILES([gen/install/makeInstallImage.sh:${INSTALL_SRC_DIR}/makeInstallImage.sh.in + AC_CONFIG_FILES([gen/install/makeInstallImage.sh:builds/install/arch-specific/linux/misc/makeInstallImage.sh.in gen/install/scripts/rpmheader.txt:${INSTALL_SRC_DIR}/rpmheader.txt.in gen/install/scripts/rpmfiles.txt:${INSTALL_SRC_DIR}/rpmfiles.txt.in gen/firebird/bin/tarMainInstall.sh:builds/install/arch-specific/linux/misc/tarMainInstall.sh.in diff --git a/src/common/classes/MsgPrint.cpp b/src/common/classes/MsgPrint.cpp index 5b839a4549..d63c5e1add 100644 --- a/src/common/classes/MsgPrint.cpp +++ b/src/common/classes/MsgPrint.cpp @@ -390,9 +390,7 @@ int fb_msg_format(void* handle, else if (n == -2) { s += "message file "; - TEXT temp[MAXPATHLEN]; - gds__prefix_msg(temp, MSG_FILE); - s += temp; + s += fb_utils::getPrefix(fb_utils::FB_DIR_MSG, MSG_FILE).ToString(); s += " not found"; } else diff --git a/src/common/config/config.cpp b/src/common/config/config.cpp index 0389c6b9f7..dbb8d019e6 100644 --- a/src/common/config/config.cpp +++ b/src/common/config/config.cpp @@ -105,7 +105,8 @@ const ConfigImpl::ConfigEntry ConfigImpl::entries[] = {TYPE_STRING, "RemoteBindAddress", (ConfigValue) 0}, {TYPE_STRING, "ExternalFileAccess", (ConfigValue) "None"}, // location(s) of external files for tables {TYPE_STRING, "DatabaseAccess", (ConfigValue) "Full"}, // location(s) of databases - {TYPE_STRING, "UdfAccess", (ConfigValue) "Restrict UDF"}, // location(s) of UDFs +#define UDF_DEFAULT_CONFIG_VALUE "Restrict UDF" + {TYPE_STRING, "UdfAccess", (ConfigValue) UDF_DEFAULT_CONFIG_VALUE}, // location(s) of UDFs {TYPE_STRING, "TempDirectories", (ConfigValue) 0}, #ifdef DEV_BUILD {TYPE_BOOLEAN, "BugcheckAbort", (ConfigValue) true}, // whether to abort() engine when internal error is found @@ -439,7 +440,33 @@ const char *Config::getDatabaseAccess() const char *Config::getUdfAccess() { - return (const char*) sysConfig().values[KEY_UDF_ACCESS]; + static Firebird::GlobalPtr udfMutex; + static Firebird::GlobalPtr udfValue; + static const char* volatile value = 0; + + if (value) + { + return value; + } + + Firebird::MutexLockGuard guard(udfMutex); + + if (value) + { + return value; + } + + const char* v = (const char*) sysConfig().values[KEY_UDF_ACCESS]; + if (! strcmp(v, UDF_DEFAULT_CONFIG_VALUE) && FB_UDFDIR[0]) + { + udfValue->printf("Restrict %s", FB_UDFDIR); + value = udfValue->c_str(); + } + else + { + value = v; + } + return value; } const char *Config::getTempDirectories() @@ -511,3 +538,4 @@ int Config::getMaxUserTraceLogSize() { return (int) sysConfig().values[KEY_MAX_TRACELOG_SIZE]; } + diff --git a/src/common/config/config.h b/src/common/config/config.h index 226100fbc8..51ab39a81c 100644 --- a/src/common/config/config.h +++ b/src/common/config/config.h @@ -270,14 +270,4 @@ public: static int getMaxUserTraceLogSize(); }; -namespace Firebird { - -// Add appropriate file prefix. -inline void Prefix(PathName& result, const PathName& file) -{ - PathUtils::concatPath(result, Config::getRootDirectory(), file); -} - -} //namespace Firebird - #endif // COMMON_CONFIG_H diff --git a/src/common/utils.cpp b/src/common/utils.cpp index 399bad99ac..3bce5748f0 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -44,6 +44,7 @@ #include "../common/classes/locks.h" #include "../common/classes/init.h" #include "../jrd/constants.h" +#include "../jrd/os/path_utils.h" #ifdef WIN_NT #include @@ -918,4 +919,110 @@ void exactNumericToStr(SINT64 value, int scale, Firebird::string& target, bool a target.assign(buffer + iter, len); } + +Firebird::PathName getPrefix(FB_DIR prefType, const char* name) +{ +/************************************** + * + * i s c F b P r e f i x + * + ************************************** + * + * Functional description + * Build full file name in specified directory + * + **************************************/ + Firebird::PathName s; + char tmp[MAXPATHLEN]; + +#ifndef BOOT_BUILD + const char* configDir[] = { + FB_BINDIR, FB_SBINDIR, FB_CONFDIR, FB_LIBDIR, FB_INCDIR, FB_DOCDIR, FB_UDFDIR, FB_SAMPLEDIR, + FB_SAMPLEDBDIR, FB_HELPDIR, FB_INTLDIR, FB_MISCDIR, FB_SECDBDIR, FB_MSGDIR, FB_LOGDIR, + FB_GUARDDIR, FB_PLUGDIR + }; + + fb_assert(FB_NELEM(configDir) == FB_DIR_LAST); + fb_assert(prefType < FB_DIR_LAST); + + if (prefType != FB_DIR_CONF && prefType != FB_DIR_MSG && configDir[prefType][0]) + { + // Value is set explicitly and is not environment overridable + PathUtils::concatPath(s, configDir[prefType], name); + return s; + } +#endif + + switch(prefType) + { + case FB_DIR_BIN: + case FB_DIR_SBIN: + s = "bin"; + break; + + case FB_DIR_CONF: + case FB_DIR_LOG: + case FB_DIR_GUARD: + case FB_DIR_SECDB: + s = ""; + break; + + case FB_DIR_LIB: + s = "lib"; + break; + + case FB_DIR_PLUGINS: + s = "plugins"; + break; + + case FB_DIR_INC: + s = "include"; + break; + + case FB_DIR_DOC: + s = "doc"; + break; + + case FB_DIR_UDF: + s = "UDF"; + break; + + case FB_DIR_SAMPLE: + s = "examples"; + break; + + case FB_DIR_SAMPLEDB: + s = "examples/empbuild"; + break; + + case FB_DIR_HELP: + s = "help"; + break; + + case FB_DIR_INTL: + s = "intl"; + break; + + case FB_DIR_MISC: + s = "misc"; + break; + + case FB_DIR_MSG: + gds__prefix_msg(tmp, name); + return tmp; + + default: + fb_assert(false); + break; + } + + if (s.hasData() && name[0]) + { + s += '/'; + } + s += name; + gds__prefix(tmp, s.c_str()); + return tmp; +} + } // namespace fb_utils diff --git a/src/common/utils_proto.h b/src/common/utils_proto.h index fe10609472..a4189728ac 100644 --- a/src/common/utils_proto.h +++ b/src/common/utils_proto.h @@ -128,6 +128,15 @@ namespace fb_utils void exactNumericToStr(SINT64 value, int scale, Firebird::string& target, bool append = false); + enum FB_DIR { + FB_DIR_BIN = 0, FB_DIR_SBIN, FB_DIR_CONF, FB_DIR_LIB, FB_DIR_INC, FB_DIR_DOC, FB_DIR_UDF, + FB_DIR_SAMPLE, FB_DIR_SAMPLEDB, FB_DIR_HELP, FB_DIR_INTL, FB_DIR_MISC, FB_DIR_SECDB, + FB_DIR_MSG, FB_DIR_LOG, FB_DIR_GUARD, FB_DIR_PLUGINS, + FB_DIR_LAST}; + + // Add appropriate file prefix. + Firebird::PathName getPrefix(FB_DIR prefType, const char* name); + } // namespace fb_utils #endif // INCLUDE_UTILS_PROTO_H diff --git a/src/gpre/ftn.cpp b/src/gpre/ftn.cpp index 2645e99571..5352c00722 100644 --- a/src/gpre/ftn.cpp +++ b/src/gpre/ftn.cpp @@ -160,7 +160,7 @@ static adl* array_decl_list; #if (defined AIX || defined AIX_PPC) const char* const INCLUDE_ISC_FTN = " INCLUDE '%s\' \n\n"; -const char* const INCLUDE_FTN_FILE = "include/gds.f"; +const char* const INCLUDE_FTN_FILE = "gds.f"; const char* const DOUBLE_DCL = "DOUBLE PRECISION"; const char* const I2CONST_1 = "%VAL("; const char* const I2CONST_2 = ")"; @@ -177,7 +177,7 @@ const char* const INLINE_COMMENT = "!"; const char* const COMMA = ","; #elif defined(__sun) const char* const INCLUDE_ISC_FTN = " INCLUDE '%s\' \n\n"; -const char* const INCLUDE_FTN_FILE = "include/gds.f"; +const char* const INCLUDE_FTN_FILE = "gds.f"; const char* const DOUBLE_DCL = "DOUBLE PRECISION"; const char* const I2CONST_1 = ""; const char* const I2CONST_2 = ""; @@ -194,7 +194,7 @@ const char* const INLINE_COMMENT = "\n* "; const char* const COMMA = ","; #elif defined(LINUX) const char* const INCLUDE_ISC_FTN = " INCLUDE '/usr/firebird/include/gds.f\' \n\n"; -const char* const INCLUDE_FTN_FILE = "include/gds.f"; +const char* const INCLUDE_FTN_FILE = "gds.f"; const char* const DOUBLE_DCL = "DOUBLE PRECISION"; const char* const I2CONST_1 = ""; const char* const I2CONST_2 = ""; @@ -211,7 +211,7 @@ const char* const INLINE_COMMENT = "\n* "; const char* const COMMA = ","; #elif defined(WIN_NT) const char* const INCLUDE_ISC_FTN = " INCLUDE \'%s\' \n\n"; -const char* const INCLUDE_FTN_FILE = "include/gds.f"; +const char* const INCLUDE_FTN_FILE = "gds.f"; const char* const DOUBLE_DCL = "DOUBLE PRECISION"; const char* const I2CONST_1 = ""; const char* const I2CONST_2 = ""; @@ -228,7 +228,7 @@ const char* const INLINE_COMMENT = "\n* "; const char* const COMMA = ","; #elif (defined FREEBSD || defined NETBSD) const char* const INCLUDE_ISC_FTN = " INCLUDE '/usr/firebird/include/gds.f\' \n\n"; -const char* const INCLUDE_FTN_FILE = "include/gds.f"; +const char* const INCLUDE_FTN_FILE = "gds.f"; const char* const DOUBLE_DCL = "DOUBLE PRECISION"; const char* const I2CONST_1 = ""; const char* const I2CONST_2 = ""; @@ -262,7 +262,7 @@ const char* const INLINE_COMMENT = "\n* "; const char* const COMMA = ","; #elif defined(HPUX) const char* const INCLUDE_ISC_FTN = " INCLUDE '%s\' \n\n"; -const char* const INCLUDE_FTN_FILE = "include/gds.f"; +const char* const INCLUDE_FTN_FILE = "gds.f"; const char* const DOUBLE_DCL = "DOUBLE PRECISION"; const char* const I2CONST_1 = "ISC_INT2("; const char* const I2CONST_2 = ")"; @@ -1363,10 +1363,10 @@ static void gen_database() static void gen_database_data() //(const act* action) { - TEXT include_buffer[MAXPATHLEN]; + Firebird::PathName include_buffer; - gds__prefix(include_buffer, INCLUDE_FTN_FILE); - sprintf(output_buffer, INCLUDE_ISC_FTN, include_buffer); + include_buffer = fb_utils::getPrefix(fb_utils::FB_DIR_INC, INCLUDE_FTN_FILE); + sprintf(output_buffer, INCLUDE_ISC_FTN, include_buffer.c_str()); FTN_print_buffer(output_buffer); diff --git a/src/intl/utils/dtest.c b/src/intl/utils/dtest.c index f4e2889bb6..7383ba3b8e 100644 --- a/src/intl/utils/dtest.c +++ b/src/intl/utils/dtest.c @@ -48,7 +48,7 @@ typedef unsigned short SHORT; /* Name of module that implements text-type (n) */ #ifndef INTL_MODULE -#define INTL_MODULE "lib/IBLD_%03d" +#define INTL_MODULE "IBLD_%03d" #endif #ifndef INTL_INIT_ENTRY @@ -84,14 +84,14 @@ int main(int argc, char** argv) #ifdef LIKE_JRD { char module[200]; - char path[MAXPATHLEN]; + Firebird::PathName path; char entry[200]; const int t_type = atoi(vector[i]); sprintf(module, INTL_MODULE, t_type); - gds__prefix(path, module); + path = fb_utils::getPrefix(fb_utils::FB_DIR_LIB, module); sprintf(entry, INTL_INIT_ENTRY, t_type); - printf("path=%s entry=%s\n", path, entry); - func = (FPTR_INT) ISC_lookup_entrypoint(path, entry, NULL); + printf("path=%s entry=%s\n", path.c_str(), entry); + func = (FPTR_INT) ISC_lookup_entrypoint(path.c_str(), entry, NULL); } #else if (strcmp(vector[i], "ask") == 0) { diff --git a/src/jrd/IntlManager.cpp b/src/jrd/IntlManager.cpp index 4df7e31768..e7c2a3a37e 100644 --- a/src/jrd/IntlManager.cpp +++ b/src/jrd/IntlManager.cpp @@ -421,8 +421,7 @@ bool IntlManager::initialize() ObjectsArray conflicts; string builtinConfig; - Firebird::PathName intlPath; - PathUtils::concatPath(intlPath, Config::getRootDirectory(), "intl"); + Firebird::PathName intlPath = fb_utils::getPrefix(fb_utils::FB_DIR_INTL, ""); ScanDir dir(intlPath.c_str(), "*.conf"); diff --git a/src/jrd/db_alias.cpp b/src/jrd/db_alias.cpp index 3e6fd37180..ce020cc696 100644 --- a/src/jrd/db_alias.cpp +++ b/src/jrd/db_alias.cpp @@ -25,6 +25,7 @@ #include "../common/config/config_file.h" #include "../jrd/os/path_utils.h" #include "../jrd/gds_proto.h" +#include "../common/utils_proto.h" using namespace Firebird; @@ -45,8 +46,7 @@ static void replace_dir_sep(PathName& s) bool ResolveDatabaseAlias(const PathName& alias, PathName& database) { - PathName alias_filename; - Firebird::Prefix(alias_filename, ALIAS_FILE); + PathName alias_filename = fb_utils::getPrefix(fb_utils::FB_DIR_CONF, ALIAS_FILE); ConfigFile aliasConfig(false, true); aliasConfig.setConfigFilePath(alias_filename); diff --git a/src/jrd/fun.epp b/src/jrd/fun.epp index 817822fe92..ce85251f8b 100644 --- a/src/jrd/fun.epp +++ b/src/jrd/fun.epp @@ -64,7 +64,10 @@ #include "../common/utils_proto.h" #include "../common/classes/FpeControl.h" -#ifndef WIN_NT +#ifdef WIN_NT +#define LIBNAME "ib_util" +#else +#define LIBNAME "libib_util" #include // dladdr #endif @@ -80,21 +83,44 @@ namespace IbUtilStartup(MemoryPool& p) : libUtilPath(p) { #if defined(WIN_NT) - libUtilPath.assign("ib_util"); + libUtilPath.assign(LIBNAME); #elif defined(DARWIN) - libUtilPath = "/Library/Frameworks/Firebird.framework/Versions/A/Libraries/libib_util"; + libUtilPath = "/Library/Frameworks/Firebird.framework/Versions/A/Libraries/" LIBNAME; #else const PathName id(Config::getInstallDirectory()); - PathUtils::concatPath(libUtilPath, id, "lib/libib_util"); + PathUtils::concatPath(libUtilPath, id, "lib/" LIBNAME); #endif // WIN_NT - - ModuleLoader::doctorModuleExtention(libUtilPath); } PathName libUtilPath; }; InitInstance ibUtilStartup; + bool volatile initDone = false; + + bool tryLibrary(PathName libName, string& message) + { + ModuleLoader::doctorModuleExtention(libName); + + ModuleLoader::Module* module = ModuleLoader::loadModule(libName); + if (!module) + { + message.printf("%s library has not been found", libName.c_str()); + return false; + } + + void (*ibUtilUnit)(void* (*)(long)); + if (!module->findSymbol("ib_util_init", ibUtilUnit)) + { + message.printf("ib_util_init not found in %s", libName.c_str()); + delete module; + return false; + } + + ibUtilUnit(IbUtil::alloc); + initDone = true; + return true; + } } #endif @@ -102,19 +128,31 @@ namespace void IbUtil::initialize() { #ifndef BOOT_BUILD - ModuleLoader::Module* module = ModuleLoader::loadModule(ibUtilStartup().libUtilPath); + if (initDone) + return; - if (module) - { - void (*ibUtilUnit)(void* (*)(long)); + string message[4]; // To suppress logs when correct library is found - if (module->findSymbol("ib_util_init", ibUtilUnit)) - ibUtilUnit(alloc); - else - gds__log("ib_util_init not found in %s", ibUtilStartup().libUtilPath.c_str()); - } - else - gds__log("%s library has not been found", ibUtilStartup().libUtilPath.c_str()); + // using install directory + if (tryLibrary(ibUtilStartup().libUtilPath, message[0])) + return; + + // using firebird root (takes into an account environment settings) + if (tryLibrary(fb_utils::getPrefix(fb_utils::FB_DIR_CONF, "lib/" LIBNAME), message[1])) + return; + + // using libraries directory + if (tryLibrary(fb_utils::getPrefix(fb_utils::FB_DIR_LIB, LIBNAME), message[2])) + return; + + // using default paths + if (tryLibrary(LIBNAME, message[3])) + return; + + // all failed - log error + gds__log("ib_util init failed, UDFs can't be used - looks like firebird misconfigured\n" + "\t%s\n\t%s\n\t%s\n\t%s", message[0].c_str(), message[1].c_str(), + message[2].c_str(), message[3].c_str()); #endif // !BOOT_BUILD } @@ -276,6 +314,13 @@ void FUN_evaluate(thread_db* tdbb, UserFunction* function, jrd_nod* node, impure * Evaluate a function. * **************************************/ +#ifndef BOOT_BUILD + // We may be in danger of AV in UDF if ib_util init failed + if (!initDone) + { + ERR_post(Arg::Gds(isc_random) << "ib_util init failed - UDF usage disabled"); + } +#endif UDF_ARG args[MAX_UDF_ARGUMENTS + 1]; HalfStaticArray temp; diff --git a/src/jrd/gds.cpp b/src/jrd/gds.cpp index 348382044f..ed9daf1891 100644 --- a/src/jrd/gds.cpp +++ b/src/jrd/gds.cpp @@ -664,11 +664,10 @@ void API_ROUTINE gds_alloc_report(ULONG flags, const char* filter_filename, int * **************************************/ // Skidder: Calls to this function must be replaced with MemoryPool::print_contents - char report_name[MAXPATHLEN]; - gds__prefix(report_name, "fbsrvreport.txt"); + Firebird::PathName report_name = fb_utils::getPrefix(fb_utils::FB_DIR_LOG, "fbsrvreport.txt"); // Our new facilities don't expose flags for reporting. const bool used_only = !(flags & ALLOC_verbose); - getDefaultMemoryPool()->print_contents(report_name, used_only, filter_filename); + getDefaultMemoryPool()->print_contents(report_name.c_str(), used_only, filter_filename); } @@ -1032,7 +1031,6 @@ void API_ROUTINE gds__trace_raw(const char* text, unsigned int length) * * Functional description * Write trace event to a log file - * This function tries to be async-signal safe * **************************************/ if (!length) @@ -1047,11 +1045,10 @@ void API_ROUTINE gds__trace_raw(const char* text, unsigned int length) { if (CleanupTraceHandles::trace_file_handle == INVALID_HANDLE_VALUE) { - TEXT name[MAXPATHLEN]; - gds__prefix(name, LOGFILE); + Firebird::PathName name = fb_utils::getPrefix(fb_utils::FB_DIR_LOG, LOGFILE); // We do not care to close this file. // It will be closed automatically when our process terminates. - CleanupTraceHandles::trace_file_handle = CreateFile(name, GENERIC_WRITE, + CleanupTraceHandles::trace_file_handle = CreateFile(name.c_str(), GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (CleanupTraceHandles::trace_file_handle == INVALID_HANDLE_VALUE) @@ -1072,11 +1069,8 @@ void API_ROUTINE gds__trace_raw(const char* text, unsigned int length) } ReleaseMutex(CleanupTraceHandles::trace_mutex_handle); #else - TEXT name[MAXPATHLEN]; - - // Note: signal-safe code - gds__prefix(name, LOGFILE); - int file = open(name, O_CREAT | O_APPEND | O_WRONLY, 0660); + Firebird::PathName name = fb_utils::getPrefix(fb_utils::FB_DIR_LOG, LOGFILE); + int file = open(name.c_str(), O_CREAT | O_APPEND | O_WRONLY, 0660); if (file == -1) return; @@ -1179,7 +1173,6 @@ void API_ROUTINE gds__log(const TEXT* text, ...) **************************************/ va_list ptr; time_t now; - TEXT name[MAXPATHLEN]; #ifdef HAVE_GETTIMEOFDAY struct timeval tv; @@ -1189,12 +1182,12 @@ void API_ROUTINE gds__log(const TEXT* text, ...) now = time((time_t *)0); #endif - gds__prefix(name, LOGFILE); + Firebird::PathName name = fb_utils::getPrefix(fb_utils::FB_DIR_LOG, LOGFILE); #ifdef WIN_NT WaitForSingleObject(CleanupTraceHandles::trace_mutex_handle, INFINITE); #endif - FILE* file = fopen(name, "a"); + FILE* file = fopen(name.c_str(), "a"); if (file != NULL) { #ifndef WIN_NT @@ -1215,7 +1208,8 @@ void API_ROUTINE gds__log(const TEXT* text, ...) fseek(file, 0, SEEK_END); #endif - fprintf(file, "\n%s%s\t%.25s\t", ISC_get_host(name, MAXPATHLEN), gdslogid, ctime(&now)); + TEXT buffer[MAXPATHLEN]; + fprintf(file, "\n%s%s\t%.25s\t", ISC_get_host(buffer, MAXPATHLEN), gdslogid, ctime(&now)); va_start(ptr, text); vfprintf(file, text, ptr); va_end(ptr); @@ -1244,7 +1238,6 @@ void API_ROUTINE gds__print_pool(MemoryPool* pool, const TEXT* text, ...) **************************************/ va_list ptr; time_t now; - TEXT name[MAXPATHLEN]; #ifdef HAVE_GETTIMEOFDAY struct timeval tv; @@ -1254,16 +1247,17 @@ void API_ROUTINE gds__print_pool(MemoryPool* pool, const TEXT* text, ...) now = time((time_t *)0); #endif - gds__prefix(name, LOGFILE); + Firebird::PathName name = fb_utils::getPrefix(fb_utils::FB_DIR_LOG, LOGFILE); const int oldmask = umask(0111); #ifdef WIN_NT WaitForSingleObject(CleanupTraceHandles::trace_mutex_handle, INFINITE); #endif - FILE* file = fopen(name, "a"); + FILE* file = fopen(name.c_str(), "a"); if (file != NULL) { - fprintf(file, "\n%s%s\t%.25s\t", ISC_get_host(name, MAXPATHLEN), gdslogid, ctime(&now)); + TEXT buffer[MAXPATHLEN]; + fprintf(file, "\n%s%s\t%.25s\t", ISC_get_host(buffer, MAXPATHLEN), gdslogid, ctime(&now)); va_start(ptr, text); vfprintf(file, text, ptr); va_end(ptr); @@ -3637,13 +3631,13 @@ public: { prefix = Config::getRootDirectory(); if (prefix.isEmpty() && !GetProgramFilesDir(prefix)) - prefix = FB_PREFIX; + prefix = FB_CONFDIR[0] ? FB_CONFDIR : FB_PREFIX; } catch (Firebird::fatal_exception&) { // CVC: Presumably here we failed because the config file can't be located. if (!GetProgramFilesDir(prefix)) - prefix = FB_PREFIX; + prefix = FB_CONFDIR[0] ? FB_CONFDIR : FB_PREFIX; } prefix.copyTo(fb_prefix_val, sizeof(fb_prefix_val)); fb_prefix = fb_prefix_val; @@ -3722,7 +3716,7 @@ public: Firebird::PathName msgPrefix; if (!fb_utils::readenv(FB_MSG_ENV, msgPrefix)) { - msgPrefix = prefix; + msgPrefix = FB_MSGDIR[0] ? FB_MSGDIR : prefix; } msgPrefix.copyTo(fb_prefix_msg_val, sizeof(fb_prefix_msg_val)); fb_prefix_msg = fb_prefix_msg_val; diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index b3fc5a09dc..e79a89226a 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -3970,11 +3970,11 @@ void JRD_print_procedure_info(thread_db* tdbb, const char* mesg) ******************************************************/ TEXT fname[MAXPATHLEN]; - gds__prefix(fname, "proc_info.log"); - FILE* fptr = fopen(fname, "a+"); + Firebird::string fname = fb_utils::getPrefix(fb_utils::FB_DIR_LOG, "proc_info.log"); + FILE* fptr = fopen(fname.c_str(), "a+"); if (!fptr) { - gds__log("Failed to open %s\n", fname); + gds__log("Failed to open %s\n", fname.c_str()); return; } diff --git a/src/jrd/jrd_pwd.h b/src/jrd/jrd_pwd.h index e670f29625..358f17d671 100644 --- a/src/jrd/jrd_pwd.h +++ b/src/jrd/jrd_pwd.h @@ -28,6 +28,7 @@ #define JRD_PWD_H #include "../jrd/ibase.h" +#include "../common/utils_proto.h" #include "../jrd/sha.h" #include "gen/iberror.h" #ifdef HAVE_STDLIB_H @@ -56,7 +57,8 @@ public: static void getPath(TEXT* path_buffer) { static const char* USER_INFO_NAME = "security2.fdb"; - gds__prefix(path_buffer, USER_INFO_NAME); + Firebird::PathName name = fb_utils::getPrefix(fb_utils::FB_DIR_SECDB, USER_INFO_NAME); + name.copyTo(path_buffer, MAXPATHLEN); } static void initialize(); diff --git a/src/jrd/os/posix/config_root.cpp b/src/jrd/os/posix/config_root.cpp index 5ebebb9e4e..4dc5f88425 100644 --- a/src/jrd/os/posix/config_root.cpp +++ b/src/jrd/os/posix/config_root.cpp @@ -66,6 +66,17 @@ static string getRootPathFromExePath() void ConfigRoot::osConfigRoot() { + // Try to use value set at configure time + if (FB_CONFDIR[0]) + { + root_dir = FB_CONFDIR; + if (root_dir[root_dir.length() - 1] != PathUtils::dir_sep) + { + root_dir += PathUtils::dir_sep; + } + return; + } + #ifdef SUPERSERVER // Try getting the root path from the executable root_dir = getRootPathFromExePath(); diff --git a/src/jrd/svc.cpp b/src/jrd/svc.cpp index 084f5351fa..4ca2b69b06 100644 --- a/src/jrd/svc.cpp +++ b/src/jrd/svc.cpp @@ -2062,9 +2062,8 @@ void Service::readFbLog() { bool svc_started = false; - TEXT name[MAXPATHLEN]; - gds__prefix(name, LOGFILE); - FILE* file = fopen(name, "r"); + Firebird::PathName name = fb_utils::getPrefix(fb_utils::FB_DIR_LOG, LOGFILE); + FILE* file = fopen(name.c_str(), "r"); try { diff --git a/src/jrd/trace/TraceManager.cpp b/src/jrd/trace/TraceManager.cpp index 80e7b938cb..f386357ca0 100644 --- a/src/jrd/trace/TraceManager.cpp +++ b/src/jrd/trace/TraceManager.cpp @@ -138,9 +138,8 @@ void TraceManager::load_modules() init_modules = true; - char plugdir[MAXPATHLEN]; - gds__prefix(plugdir, "plugins"); - ScanDir plugins(plugdir, "*.*"); + PathName plugdir = fb_utils::getPrefix(fb_utils::FB_DIR_PLUGINS, ""); + ScanDir plugins(plugdir.c_str(), "*.*"); while (plugins.next()) { diff --git a/src/qli/help.epp b/src/qli/help.epp index 74573f3643..42078e04da 100644 --- a/src/qli/help.epp +++ b/src/qli/help.epp @@ -35,6 +35,8 @@ #include "../qli/help_proto.h" #include "../qli/lex_proto.h" #include "../jrd/gds_proto.h" +#include "../common/utils_proto.h" +#include "../common/classes/fb_string.h" using MsgFormat::SafeArg; @@ -43,11 +45,7 @@ const char* INDENT = " "; const int COLUMN_WIDTH = 20; const int RIGHT_MARGIN = 70; -#ifdef UNIX -const char* const TARGET = "help/help.fdb"; -#elif defined(WIN_NT) -const char* const TARGET = "help\\help.fdb"; -#endif +const char* const TARGET = "help.fdb"; DATABASE HELP_DB = STATIC "help.fdb" RUNTIME target; @@ -89,11 +87,11 @@ void HELP_help( qli_syntax* node) * Give the poor sucker help. * **************************************/ - TEXT target[MAXPATHLEN]; - if (!HELP_DB) { - gds__prefix(target, TARGET); + Firebird::PathName name = fb_utils::getPrefix(fb_utils::FB_DIR_HELP, TARGET); + TEXT target[MAXPATHLEN]; + name.copyTo(target, sizeof target); READY ON_ERROR ERRQ_database_error(NULL, gds_status); diff --git a/src/remote/inet_server.cpp b/src/remote/inet_server.cpp index f466ed4981..18eb793c04 100644 --- a/src/remote/inet_server.cpp +++ b/src/remote/inet_server.cpp @@ -458,9 +458,8 @@ int FB_EXPORTED server_main( int argc, char** argv) // In Debug mode - this will report all server-side memory leaks due to remote access //gds_alloc_report(0, __FILE__, __LINE__); - char name[MAXPATHLEN]; - gds__prefix(name, "memdebug.log"); - FILE* file = fopen(name, "w+t"); + Firebird::PathName name = fb_utils::getPrefix(fb_utils::FB_DIR_LOG, "memdebug.log"); + FILE* file = fopen(name.c_str(), "w+t"); if (file) { fprintf(file, "Global memory pool allocated objects\n"); diff --git a/src/remote/os/win32/srvr_w32.cpp b/src/remote/os/win32/srvr_w32.cpp index 84a59bdef6..36b4876a23 100644 --- a/src/remote/os/win32/srvr_w32.cpp +++ b/src/remote/os/win32/srvr_w32.cpp @@ -318,9 +318,8 @@ int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE /*hPrevInst*/, LPSTR lpszArgs, // due to remote access //gds_alloc_report(0, __FILE__, __LINE__); - char name[MAXPATHLEN]; - gds__prefix(name, "memdebug.log"); - FILE* file = fopen(name, "w+t"); + Firebird::PathName name = fb_utils::getPrefix(fb_utils::FB_DIR_LOG, "memdebug.log"); + FILE* file = fopen(name.c_str(), "w+t"); if (file) { fprintf(file, "Global memory pool allocated objects\n"); diff --git a/src/utilities/guard/guard.cpp b/src/utilities/guard/guard.cpp index 1cbbfedf20..8387605f69 100644 --- a/src/utilities/guard/guard.cpp +++ b/src/utilities/guard/guard.cpp @@ -61,8 +61,8 @@ const USHORT ONETIME = 2; const USHORT IGNORE = 3; const USHORT NORMAL_EXIT= 0; -const char* const SUPER_SERVER_BINARY = "bin/fbserver"; -const char* const SUPER_CLASSIC_BINARY = "bin/fb_smp_server"; +const char* const SUPER_SERVER_BINARY = "fbserver"; +const char* const SUPER_CLASSIC_BINARY = "fb_smp_server"; const char* const INTERBASE_USER = "interbase"; const char* const FIREBIRD_USER = "firebird"; diff --git a/src/utilities/guard/util.cpp b/src/utilities/guard/util.cpp index a3a115b8b8..14f48caf05 100644 --- a/src/utilities/guard/util.cpp +++ b/src/utilities/guard/util.cpp @@ -60,6 +60,7 @@ #include "../utilities/guard/util_proto.h" #include "../jrd/gds_proto.h" #include "../jrd/isc_proto.h" +#include "../common/utils_proto.h" pid_t UTIL_start_process(const char* process, const char* process2, char** argv, const char* prog_name) @@ -83,28 +84,26 @@ pid_t UTIL_start_process(const char* process, const char* process2, char** argv, * expanded process name. (MAXPATHLEN recommended) * **************************************/ - TEXT string[MAXPATHLEN]; - fb_assert(process != NULL); fb_assert(argv != NULL); // prepend Firebird home directory to the program name // choose correct (super/superclassic) image - to be removed in 3.0 - gds__prefix(string, process); - if (access(string, X_OK) < 0) { - gds__prefix(string, process2); + Firebird::PathName string = fb_utils::getPrefix(fb_utils::FB_DIR_SBIN, process); + if (access(string.c_str(), X_OK) < 0) { + string = fb_utils::getPrefix(fb_utils::FB_DIR_SBIN, process2); } if (prog_name) { - gds__log("%s: guardian starting %s\n", prog_name, string); + gds__log("%s: guardian starting %s\n", prog_name, string.c_str()); } // add place in argv for visibility to "ps" - strcpy(argv[0], string); + strcpy(argv[0], string.c_str()); #if (defined SOLARIS) pid_t pid = fork1(); if (!pid) { - if (execv(string, argv) == -1) { + if (execv(string.c_str(), argv) == -1) { //ib_fprintf(ib_stderr, "Could not create child process %s with args %s\n", string, argv); } exit(FINI_ERROR); @@ -115,7 +114,7 @@ pid_t UTIL_start_process(const char* process, const char* process2, char** argv, pid_t pid = vfork(); if (!pid) { - execv(string, argv); + execv(string.c_str(), argv); _exit(FINI_ERROR); } #endif @@ -250,16 +249,14 @@ int UTIL_ex_lock(const TEXT* file) * **************************************/ - TEXT expanded_filename[MAXPATHLEN]; - // get the file name and prepend the complete path etc - gds__prefix(expanded_filename, file); + Firebird::PathName expanded_filename = fb_utils::getPrefix(fb_utils::FB_DIR_GUARD, file); // file fd for the opened and locked file - int fd_file = open(expanded_filename, O_RDWR | O_CREAT, 0666); + int fd_file = open(expanded_filename.c_str(), O_RDWR | O_CREAT, 0666); if (fd_file == -1) { - fprintf(stderr, "Could not open %s for write\n", expanded_filename); + fprintf(stderr, "Could not open %s for write\n", expanded_filename.c_str()); return (-1); } diff --git a/src/utilities/ibmgr/ibmgr.h b/src/utilities/ibmgr/ibmgr.h index 8c166f71ac..1b4929b0a5 100644 --- a/src/utilities/ibmgr/ibmgr.h +++ b/src/utilities/ibmgr/ibmgr.h @@ -32,7 +32,7 @@ static const char* const FIREBIRD_USER_NAME = "firebird"; static const char* const INTERBASE_USER_NAME = "interbase"; static const char* const INTERBASE_USER_SHORT = "interbas"; -static const char* const SERVER_GUARDIAN = "bin/fbguard"; +static const char* const SERVER_GUARDIAN = "fbguard"; const USHORT MSG_FAC = 18; const int MSG_LEN = 128; diff --git a/src/utilities/ibmgr/srvrmgr.cpp b/src/utilities/ibmgr/srvrmgr.cpp index 7058a615c8..c42a3390d0 100644 --- a/src/utilities/ibmgr/srvrmgr.cpp +++ b/src/utilities/ibmgr/srvrmgr.cpp @@ -44,6 +44,7 @@ #include "../common/stuff.h" #include "../utilities/ibmgr/ibmgr.h" #include "../utilities/ibmgr/srvrmgr_proto.h" +#include "../common/utils_proto.h" const int SPB_BUFLEN = 128; // service params buffer length //#define SEND_BUFLEN 32 // length of send and resp @@ -481,8 +482,7 @@ static bool start_server( ibmgr_data_t* data) // We failed to attach to service, thus server might not be running // You know what? We'll try to start it. - TEXT path[MAXPATHLEN]; - gds__prefix(path, SERVER_GUARDIAN); + Firebird::PathName path = fb_utils::getPrefix(fb_utils::FB_DIR_SBIN, SERVER_GUARDIAN); // CVC: Newer compilers won't accept assigning literal strings to non-const // char pointers, so this code prevents changing argv's type to const TEXT* argv[4] @@ -493,7 +493,7 @@ static bool start_server( ibmgr_data_t* data) static char option_p[] = "-p"; TEXT *argv[5]; - argv[0] = path; + argv[0] = path.begin(); switch (data->suboperation) { case SOP_START_ONCE: @@ -525,8 +525,8 @@ static bool start_server( ibmgr_data_t* data) if (!(pid = fork1())) { - if (execv(path, argv) == -1) { - printf("Could not create child process %s with args %s \n", path, argv[1]); + if (execv(path.c_str(), argv) == -1) { + printf("Could not create child process %s with args %s \n", path.c_str(), argv[1]); } _exit(FINI_ERROR); } @@ -535,7 +535,7 @@ static bool start_server( ibmgr_data_t* data) if (!(pid = vfork())) { - execv(path, argv); + execv(path.c_str(), argv); _exit(FINI_ERROR); } #endif