Browse Source

* fix for potential security issue with ~/.fp directory owned by root

git-svn-id: trunk@12536 -
Tomas Hajny 16 years ago
parent
commit
d8827829d6
1 changed files with 27 additions and 22 deletions
  1. 27 22
      compiler/utils/samplecfg

+ 27 - 22
compiler/utils/samplecfg

@@ -62,34 +62,39 @@ 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
   mv "$fpccfgfile" "$fpccfgfile.orig"  >/dev/null 2>&1