Browse Source

Merged revisions 12536,12546,12552-12554 via svnmerge from
svn+ssh://[email protected]/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: branches/release_2_2_4_rc1@12559 -

joost 16 years ago
parent
commit
361c43e9d5
1 changed files with 47 additions and 40 deletions
  1. 47 40
      compiler/utils/samplecfg

+ 47 - 40
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