From 7eb0669dd711b57eda839de65b59ac5501cb1fe2 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sun, 16 Sep 2001 23:29:17 -0400 Subject: [PATCH] Make compile_et and mk_cmds safe from directory pathnames that contain spaces. --- lib/et/ChangeLog | 5 +++++ lib/et/compile_et.sh.in | 14 +++++++------- lib/ss/ChangeLog | 5 +++++ lib/ss/mk_cmds.sh.in | 28 ++++++++++++++-------------- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/lib/et/ChangeLog b/lib/et/ChangeLog index c1104a3..b70be6c 100644 --- a/lib/et/ChangeLog +++ b/lib/et/ChangeLog @@ -1,3 +1,8 @@ +2001-09-16 Theodore Tso + + * compile_et.sh.in: Make the shell script safe from directory + pathnames with spaces. + 2001-09-10 Theodore Tso * com_err.texinfo: Add appropriate @node and @menu lines so that diff --git a/lib/et/compile_et.sh.in b/lib/et/compile_et.sh.in index ccc2434..ad445fa 100644 --- a/lib/et/compile_et.sh.in +++ b/lib/et/compile_et.sh.in @@ -3,17 +3,17 @@ # AWK=@AWK@ DIR="${DIR-@datadir@/et}" -ET_DIR=@ET_DIR@ +ET_DIR="@ET_DIR@" if test "x$1" = x ; then echo "Usage: compile_et file" exit 1 fi -if test ! -f $DIR/et_h.awk -o ! -f $DIR/et_c.awk ; then - DIR=$ET_DIR +if test ! -f "$DIR/et_h.awk" -o ! -f "$DIR/et_c.awk" ; then + DIR="$ET_DIR" # echo "Falling back to $DIR..." - if test ! -f $DIR/et_h.awk -o ! -f $DIR/et_c.awk ; then + if test ! -f "$DIR/et_h.awk" -o ! -f "$DIR/et_c.awk" ; then echo "compile_et: Couldn't find compile_et's template files." exit 1 fi @@ -22,10 +22,10 @@ fi ROOT=`echo $1 | sed -e s/.et$//` BASE=`basename $ROOT` -if test ! -f $ROOT.et ; then +if test ! -f "$ROOT.et" ; then echo "compile_et: $ROOT.et: File not found" exit 1; fi -$AWK -f ${DIR}/et_h.awk outfile=${BASE}.h $ROOT.et -$AWK -f ${DIR}/et_c.awk outfile=${BASE}.c $ROOT.et +$AWK -f "${DIR}/et_h.awk" "outfile=${BASE}.h" "$ROOT.et" +$AWK -f "${DIR}/et_c.awk" "outfile=${BASE}.c" "$ROOT.et" diff --git a/lib/ss/ChangeLog b/lib/ss/ChangeLog index c768b7b..3c1c290 100644 --- a/lib/ss/ChangeLog +++ b/lib/ss/ChangeLog @@ -1,3 +1,8 @@ +2001-09-16 Theodore Tso + + * mk_cmds.sh.in: Make the shell script safe from directory + pathnames with spaces. + 2001-09-02 Theodore Tso * Release of E2fsprogs 1.24a diff --git a/lib/ss/mk_cmds.sh.in b/lib/ss/mk_cmds.sh.in index cc74274..c35d6b0 100644 --- a/lib/ss/mk_cmds.sh.in +++ b/lib/ss/mk_cmds.sh.in @@ -3,7 +3,7 @@ # DIR="${DIR-@datadir@/ss}" -SS_DIR=@SS_DIR@ +SS_DIR="@SS_DIR@" AWK=@AWK@ SED=@SED@ @@ -13,36 +13,36 @@ if test "x$1" = x ; then fi if test -n "$_SS_DIR_OVERRIDE" ; then - DIR=$_SS_DIR_OVERRIDE; + DIR="$_SS_DIR_OVERRIDE"; fi if test ! -f $DIR/ct_c.sed -o ! -f $DIR/ct_c.awk ; then - DIR=$SS_DIR + DIR="$SS_DIR" # echo "Falling back to $DIR..." - if test ! -f $DIR/ct_c.sed -o ! -f $DIR/ct_c.awk ; then + if test ! -f "$DIR/ct_c.sed" -o ! -f "$DIR/ct_c.awk" ; then echo "mk_cmds: Couldn't find mk_cmds's template files." exit 1 fi fi -FILE=$1 +FILE="$1" ROOT=`echo $1 | sed -e s/.ct$//` -BASE=`basename $ROOT` -TMP=ct$$.c +BASE=`basename "$ROOT"` +TMP="ct$$.c" -if test ! -f $FILE ; then +if test ! -f "$FILE" ; then echo "$FILE: File not found" exit 1; fi -${SED} -f ${DIR}/ct_c.sed ${FILE} \ - | ${AWK} -f ${DIR}/ct_c.awk rootname=${ROOT} outfile=${TMP} - +${SED} -f "${DIR}/ct_c.sed" "${FILE}" \ + | ${AWK} -f "${DIR}/ct_c.awk" "rootname=${ROOT}" "outfile=${TMP}" - -if grep "^#__ERROR_IN_FILE" ${TMP} > /dev/null; then - rm ${TMP} +if grep "^#__ERROR_IN_FILE" "${TMP}" > /dev/null; then + rm "${TMP}" exit 1 else - rm -f ${BASE}.c - mv ${TMP} ${BASE}.c + rm -f "${BASE}.c" + mv "${TMP}" "${BASE}.c" exit 0 fi -- 1.8.3.1