From c741c6fc3aaa8b75a434faa143c06dd059970d41 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 29 Nov 2011 08:52:12 +0100 Subject: [PATCH] Make sure HOME et al have no unsafe characters. --- ChangeLog | 4 ++++ autogen.sh | 20 ++++++++++++++++++++ scripts/ChangeLog | 4 ++++ scripts/build-all.sh | 18 +++++++++++++++++- 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7e17ba8b1..5e5a0149d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-11-29 Werner Koch + + * autogen.sh: Make sure HOME et al have no unsafe characters. + 2011-11-28 Jim Meyering accept --with-libgpg-error-prefix as well as --with-gpg-error-prefix diff --git a/autogen.sh b/autogen.sh index f4a1de70f..8a424bce5 100755 --- a/autogen.sh +++ b/autogen.sh @@ -47,6 +47,26 @@ if test x"$1" = x"--force"; then shift fi +# Reject unsafe characters in $HOME, $tsdir and cwd. We consider spaces +# as unsafe because it is too easy to get scripts wrong in this regard. +am_lf=' +' +case `pwd` in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + echo "unsafe working directory name"; DIE=yes;; +esac +case $tsdir in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + echo "unsafe source directory: \`$tsdir'"; DIE=yes;; +esac +case $HOME in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + echo "unsafe home directory: \`$HOME'"; DIE=yes;; +esac +if test "$DIE" = "yes"; then + exit 1 +fi + # Begin list of optional variables sourced from ~/.gnupg-autogen.rc w32_toolprefixes= w32_extraoptions= diff --git a/scripts/ChangeLog b/scripts/ChangeLog index fec54059d..1a664ca68 100644 --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2011-11-29 Werner Koch + + * build-all.sh: Make sure HOME has no unsafe characters. + 2011-11-28 Werner Koch , Jim Meyering diff --git a/scripts/build-all.sh b/scripts/build-all.sh index 3cd4f303c..23af6203d 100755 --- a/scripts/build-all.sh +++ b/scripts/build-all.sh @@ -17,6 +17,23 @@ p=$HOME/tmp/gpg-tmp parts="libgpg-error libassuan libksba libgcrypt gnupg" die=no +here="`pwd`" + +# Reject unsafe characters in $PWD and $HOME. We consider spaces as +# unsafe because it is too easy to get scripts wrong in this regard. +am_lf=' +' +case $here in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + echo "unsafe working directory: \`$here'"; die=yes;; +esac +case $HOME in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + echo "unsafe home directory: \`$HOME'"; die=yes;; +esac +test $die = yes && exit 1 + +# Check that all components are available for i in $parts; do if test -d $i ; then : @@ -35,7 +52,6 @@ done export PATH=$p/bin:$PATH export LD_LIBRARY_PATH=$p/lib -here="$(pwd)" prev= cfg="configure --enable-maintainer-mode --prefix=$p"