Author: olivier
Date: 2007-02-01 20:41:46 +0000 (Thu, 01 Feb 2007)
New Revision: 24803

Modified:
   xfce-utils/branches/xfce_4_4/scripts/xinitrc
Log:
Fix insecure use of temporary file in startup script

Modified: xfce-utils/branches/xfce_4_4/scripts/xinitrc
===================================================================
--- xfce-utils/branches/xfce_4_4/scripts/xinitrc        2007-02-01 20:41:34 UTC 
(rev 24802)
+++ xfce-utils/branches/xfce_4_4/scripts/xinitrc        2007-02-01 20:41:46 UTC 
(rev 24803)
@@ -9,47 +9,45 @@
        fi
 fi
 
-# create temp file for X resources
-XRESOURCES="/tmp/xrdb-$UID.$$"
-
-# Has to go prior to merging Xft.xrdb, as its the "Defaults" file
-test -r $HOME/.Xdefaults && cat $HOME/.Xdefaults >> $XRESOURCES
-
-# Check if the user wants to override the above defaults (set by
-# mcs ui plugin)
+# $XDG_CONFIG_HOME defines the base directory relative to which user specific 
+# configuration files should be stored. If $XDG_CONFIG_HOME is either not set 
+# or empty, a default equal to $HOME/.config should be used.
 if test "x$XDG_CONFIG_HOME" = "x" ; then
   XDG_CONFIG_HOME=$HOME/.config
 fi
-BASEDIR=$XDG_CONFIG_HOME/xfce4
+[ -d "$XDG_CONFIG_HOME" ] || mkdir "$XDG_CONFIG_HOME"
 
-if test -r $BASEDIR/Xft.xrdb; then
-  cat $BASEDIR/Xft.xrdb >> $XRESOURCES
-elif test -r $XFCE4HOME/Xft.xrdb; then
-  mkdir -p $BASEDIR
-  cp $XFCE4HOME/Xft.xrdb $BASEDIR/
-  cat $BASEDIR/Xft.xrdb >> $XRESOURCES
-else
-  # Those are fallback settings, use the ui plugin to change it
-  # or add your overrides to ~/.Xresources
-  # Xft DPI: 96
-  # Xft.hintstyle: hintnone/hintslight/hintmedium/hintfull
-  # Xft hinting: 1/0
-  cat >> $XRESOURCES << EOF
-Xft.dpi: 96
-Xft.hinting: 1
-Xft.hintstyle: hintmedium
-EOF
+# $XDG_CACHE_HOME defines the base directory relative to which user specific 
+# non-essential data files should be stored. If $XDG_CACHE_HOME is either not 
+# set or empty, a default equal to $HOME/.cache should be used.
+if test "x$XDG_CACHE_HOME" = "x" ; then
+  XDG_CACHE_HOME=$HOME/.cache
 fi
+[ -d "$XDG_CACHE_HOME" ] || mkdir "$XDG_CACHE_HOME"
 
+# For now, start with an empty list
+XRESOURCES=""
+
+# Has to go prior to merging Xft.xrdb, as its the "Defaults" file
+test -r $HOME/.Xdefaults && XRESOURCES=$HOME/.Xdefaults
+
+BASEDIR=$XDG_CONFIG_HOME/xfce4
+if test -r "$BASEDIR/Xft.xrdb"; then
+  XRESOURCES="$XRESOURCES $BASEDIR/Xft.xrdb"
+elif test -r "$XFCE4HOME/Xft.xrdb"; then
+  mkdir -p "$BASEDIR"
+  cp "$XFCE4HOME/Xft.xrdb" "$BASEDIR"/
+  XRESOURCES="$XRESOURCES $BASEDIR/Xft.xrdb"
+fi
+
 # merge in X cursor settings
-test -r $BASEDIR/Xcursor.xrdb && cat $BASEDIR/Xcursor.xrdb >> $XRESOURCES
+test -r "$BASEDIR/Xcursor.xrdb" && XRESOURCES="$XRESOURCES 
$BASEDIR/Xcursor.xrdb"
 
 # ~/.Xresources contains overrides to the above
-test -r $HOME/.Xresources && cat $HOME/.Xresources >> $XRESOURCES
+test -r "$HOME/.Xresources" && XRESOURCES="$XRESOURCES $HOME/.Xresources"
 
-# load all X resources
-xrdb -nocpp -merge $XRESOURCES
-rm -f $XRESOURCES
+# load all X resources (adds /dev/null to avoid an empty list that would hang 
the process)
+cat /dev/null $XRESOURCES | xrdb -nocpp -merge -
 
 # load local modmap
 test -r $HOME/.Xmodmap && xmodmap $HOME/.Xmodmap

_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to