This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Remove . from $PATH


Hi,

On Thu, Jul 29, 2010 at 11:19 AM, Johannes Stezenbach <js@sig21.net> wrote:
> Remove . from $PATH
>
> Add CT_SanitizePath function which removes entries referring to ., /tmp
> and non-existing directories from $PATH, and call it early in the
> build script.
>
> If . is in PATH, gcc-4.4.4 build breaks:
>
> [ALL ?] ? ?checking what assembler to use...
> /tmp/build/targets/arm-unknown-linux-uclibcgnueabi/build/gcc-core-static/arm-unknown-linux-uclibcgnueabi/bin/as
> ...
> [ALL ?] ? ?config.status: creating as
>
> i.e. "as" is supposed to be the arm-unknown-linux-uclibcgnueabi cross assembler,
> but config.status creates a local "as" script which is calling the
> host assembler.
>
> Signed-off-by: Johannes Stezenbach <js@sig21.net>
>
> diff -r c5a2e4ee7fb8 scripts/crosstool-NG.sh.in
> --- a/scripts/crosstool-NG.sh.in ? ? ? ?Mon Jul 26 00:07:17 2010 +0200
> +++ b/scripts/crosstool-NG.sh.in ? ? ? ?Thu Jul 29 15:34:42 2010 +0200
> @@ -28,6 +28,9 @@
> ?# Overide the locale early, in case we ever translate crosstool-NG messages
> ?[ -z "${CT_NO_OVERIDE_LC_MESSAGES}" ] && export LC_ALL=C
>
> +# remove . from PATH since it can cause gcc build failures
> +CT_SanitizePath
> +
> ?# Some sanity checks in the environment and needed tools
> ?CT_DoLog INFO "Performing some trivial sanity checks"
> ?CT_TestAndAbort "Don't set LD_LIBRARY_PATH. It screws up the build." -n "${LD_LIBRARY_PATH}"
> diff -r c5a2e4ee7fb8 scripts/functions
> --- a/scripts/functions Mon Jul 26 00:07:17 2010 +0200
> +++ b/scripts/functions Thu Jul 29 15:34:42 2010 +0200
> @@ -137,6 +137,22 @@
> ? ? CT_DoLog ${level:-INFO} "(elapsed: ${elapsed_min}:${elapsed_sec}.${elapsed_csec})"
> ?}
>
> +# Remove entries referring to ., /tmp and non-existing directories from $PATH
> +# Usage: CT_SanitizePath
> +CT_SanitizePath() {
> + ? ?local new
> + ? ?local tmp
> + ? ?local IFS=:
> + ? ?for p in $PATH; do
> + ? ? ? ?tmp=`(cd /tmp; cd $p 2>/dev/null || :; pwd -P)`
this is broken... If you refer to POSIX description of PATH (see [0]),
"::" stands as synonym for ":.:" which is translated to the current
directory. In your script, you will end up in doing a chdir to the
HOME directory (if "set to a non-empty value") and still accepting the
(empty) value.

Why not only accepting absolute directory or directory starting with "~":

test -n "${var}" -a -z "${var%%[~/]*}" && new=...

should do the job.

 - Arnaud

[0]: http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03

> + ? ? ? ?if [ "$tmp" != "/tmp" ]; then
> + ? ? ? ? ? ?new="$new${new:+:}$p"
> + ? ? ? ?fi
> + ? ?done
> + ? ?PATH="$new"
> + ? ?return 0
> +}
> +
> ?# Abort the execution with an error message
> ?# Usage: CT_Abort <message>
> ?CT_Abort() {
>
> --
> For unsubscribe information see http://sourceware.org/lists.html#faq
>
>

--
For unsubscribe information see http://sourceware.org/lists.html#faq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]