This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


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

[patch] prevent BASH env pollution from corrupting AC_PATH_PROG(bash) search


the configure script searches for `bash` so that it can put it into bash 
scripts (like ldd) via @BASH@:
AC_PATH_PROG(BASH, bash, no)
this means try to locate the program "bash" in $PATH and set the variable 
$BASH to it when found.  but if the variable $BASH is already set, skip any 
search and just use that.

bash has a neat feature where it automatically sets the variable $BASH to how 
it was invoked:
$ /bin/sh -c 'echo $BASH'
/bin/sh
$ /bin/bash -c 'echo $BASH'
/bin/bash
$ ln -s /bin/bash mooooooo
$ ./mooooooo -c 'echo $BASH'
/home/vapier/mooooooo

this causes the aforementioned test to be troublesome when:
 - /bin/sh is set to /bin/bash
 - glibc is compiled and /bin/sh is recorded in /usr/bin/ldd
 - /bin/sh is switched to say /bin/dash
 - ldd fails due to it not being POSIX compliant shell code

i'd propose ldd be tweaked to be POSIX compliant, but that idea was shot down 
back in January of this year ... so instead, i'll propose tweaking the 
configure script so that the internal bash env pollution doesnt break the 
intent of the AC_PATH_PROG(bash) test
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.

2007-06-01  Mike Frysinger  <vapier@gentoo.org>

	* configure.in (AC_PATH_PROG(BASH)): Change BASH to BASH_SHELL
	and set BASH to BASH_SHELL.
	* configure: Rebuilt.

--- libc/configure.in
+++ libc/configure.in
@@ -980,7 +980,9 @@
 fi])
 AC_SUBST(libc_cv_gcc_static_libgcc)
 
-AC_PATH_PROG(BASH, bash, no)
+dnl bash will set $BASH automatically to $0, so use $BASH_SHELL
+AC_PATH_PROG(BASH_SHELL, bash, no)
+BASH=$BASH_SHELL
 if test "$BASH" != no &&
    $BASH -c 'test "$BASH_VERSINFO" \
 	     && test "$BASH_VERSINFO" -ge 2 >&/dev/null'; then

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