diff options
author | joost <joost@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2009-01-18 14:15:52 +0000 |
---|---|---|
committer | joost <joost@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2009-01-18 14:15:52 +0000 |
commit | 249e7cb85b25be47c641e89d9c09b77af9a31785 (patch) | |
tree | 454fe219fa476dedc219930ad7a270ef849b24b6 | |
parent | e71b9092de919470912e7c8236b8f1327ed4a1e3 (diff) | |
download | fpc-release_2_2_4_rc1.tar.gz |
Merged revisions 12536,12546,12552-12554 via svnmerge from release_2_2_4_rc1
svn+ssh://joost@svn.freepascal.org/FPC/svn/fpc/trunk
........
r12536 | hajny | 2009-01-11 00:42:03 +0100 (Sun, 11 Jan 2009) | 1 line
* fix for potential security issue with ~/.fp directory owned by root
........
r12552 | joost | 2009-01-16 17:53:27 +0100 (Fri, 16 Jan 2009) | 1 line
* Fixed script
........
r12554 | hajny | 2009-01-17 10:55:25 +0100 (Sat, 17 Jan 2009) | 1 line
* additional safeguards - double quotes around environment variables plus avoid checking for $fpcfgfile and $fpinifile if no $FPBIN found
........
git-svn-id: http://svn.freepascal.org/svn/fpc/branches/release_2_2_4_rc1@12559 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r-- | compiler/utils/samplecfg | 87 |
1 files changed, 47 insertions, 40 deletions
diff --git a/compiler/utils/samplecfg b/compiler/utils/samplecfg index 98de0ec180..1a32ef35ab 100644 --- a/compiler/utils/samplecfg +++ b/compiler/utils/samplecfg @@ -62,36 +62,41 @@ else fi # +# Don't mess with IDE configuration if fp binary does not exist +if [ -f "$FPBIN" ] ; then + # Assume local FP IDE configuration unless writing system-wide version possible -fpinifile="$HOME"/.fp/fp.ini -fpcfgfile="$HOME"/.fp/fp.cfg - -# Detect if we have write permission in sysfpdirbase (and fp binary exists). -if [ -f "$FPBIN" -a -w "$sysfpdirbase" ] ; then - echo Write permission in $sysfpdirbase. - if ! [ -d "$sysfpdirbase2" ] ; then - echo Directory $sysfpdirbase2 did not exist, attempting to create it now - mkdir $sysfpdirbase2 >/dev/null 2>&1 - echo Attempting to create directory $sysfpdir - mkdir $sysfpdir >/dev/null 2>&1 - elif ! [ -d "$sysfpdir" ] ; then - echo Directory $sysfpdir did not exist, attempting to create it now - mkdir $sysfpdir >/dev/null 2>&1 - fi - if [ -w "$sysfpdir" ] ; then - fpinifile="$sysfpdir"/fp.ini - fpcfgfile="$sysfpdir"/fp.cfg + fpinifile="$HOME"/.fp/fp.ini + fpcfgfile="$HOME"/.fp/fp.cfg + +# Detect if we have write permission in sysfpdirbase. + if [ -w "$sysfpdirbase" ] ; then + echo Write permission in $sysfpdirbase. + if ! [ -d "$sysfpdirbase2" ] ; then + echo Directory $sysfpdirbase2 did not exist, attempting to create it now + mkdir $sysfpdirbase2 >/dev/null 2>&1 + echo Attempting to create directory $sysfpdir + mkdir $sysfpdir >/dev/null 2>&1 + elif ! [ -d "$sysfpdir" ] ; then + echo Directory $sysfpdir did not exist, attempting to create it now + mkdir $sysfpdir >/dev/null 2>&1 + fi + if [ -w "$sysfpdir" ] ; then + fpinifile="$sysfpdir"/fp.ini + fpcfgfile="$sysfpdir"/fp.cfg + fi fi -fi # # When the local FP IDE configuration is used, check if the directory exists -if [ $fpcfgfile = "$HOME"/.fp/fp.cfg -a ! -d "$HOME"/.fp ] ; then - echo Directory $HOME/.fp did not exist, attempting to create it now - mkdir "$HOME"/.fp >/dev/null 2>&1 + if [ $fpcfgfile = "$HOME"/.fp/fp.cfg -a ! -d "$HOME"/.fp ] ; then + echo Directory $HOME/.fp did not exist, attempting to create it now + mkdir "$HOME"/.fp >/dev/null 2>&1 + fi fi +# -if [ -f $fpccfgfile ] ; then +if [ -f "$fpccfgfile" ] ; then mv "$fpccfgfile" "$fpccfgfile.orig" >/dev/null 2>&1 if [ $? = 0 ]; then echo Saved old compiler config to $fpccfgfile.orig @@ -101,23 +106,25 @@ if [ -f $fpccfgfile ] ; then fi fi -if [ -f $fpinifile -a -f "$FPBIN" ] ; then - mv "$fpinifile" "$fpinifile.orig" >/dev/null 2>&1 - if [ $? = 0 ]; then - echo Saved old fp.ini to $fpinifile.orig - else - echo Could not save old fp.ini. Bailing out... - exit +if [ -f "$FPBIN" ] ; then + if [ -f "$fpinifile" ] ; then + mv "$fpinifile" "$fpinifile.orig" >/dev/null 2>&1 + if [ $? = 0 ]; then + echo Saved old fp.ini to $fpinifile.orig + else + echo Could not save old fp.ini. Bailing out... + exit + fi fi -fi -if [ -f $fpcfgfile -a -f "$FPBIN" ] ; then - mv "$fpcfgfile" "$fpcfgfile.orig" >/dev/null 2>&1 - if [ $? = 0 ]; then - echo Saved old fp.cfg to $fpcfgfile.orig - else - echo Could not save old fp.cfg. Bailing out... - exit + if [ -f "$fpcfgfile" ] ; then + mv "$fpcfgfile" "$fpcfgfile.orig" >/dev/null 2>&1 + if [ $? = 0 ]; then + echo Saved old fp.cfg to $fpcfgfile.orig + else + echo Could not save old fp.cfg. Bailing out... + exit + fi fi fi @@ -134,7 +141,7 @@ singlearch() { } # include ports tree dir for FreeBSDers. -case $HOSTOS in +case "$HOSTOS" in freebsd) GCCDIR=-Fl/usr/local/lib ;; @@ -204,7 +211,7 @@ case `"$FPCBIN" -PP` in esac # darwin->darwin does not need cross binutils -case $HOSTOS in +case "$HOSTOS" in darwin) CPUCROSSIFDEF2=" #ifdef darwin |