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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Mike Frysinger
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

2007-06-01  Mike Frysinger  <[hidden email]>

        * 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

signature.asc (844 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

Ulrich Drepper
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I checked in something slightly different.

- --
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFGaMps2ijCOnn/RHQRAkTQAJ4hDgcBSv89QTg/uqhnzWt5XbJhXACggnwV
Z99l5kulDPxXSU5lEIIlLog=
=GeKM
-----END PGP SIGNATURE-----
Reply | Threaded
Open this post in threaded view
|

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

Mike Frysinger
On Thursday 07 June 2007, Ulrich Drepper wrote:
> I checked in something slightly different.

the reason i did BASH=$BASH_SHELL was so that files that use @BASH@ wouldnt
have to be changed to use @BASH_SHELL@ ...
-mike

Index: ChangeLog
===================================================================
RCS file: /cvs/glibc/libc/ChangeLog,v
retrieving revision 1.10667
diff -u -p -r1.10667 ChangeLog
--- ChangeLog 8 Jun 2007 03:17:15 -0000 1.10667
+++ ChangeLog 8 Jun 2007 04:46:47 -0000
@@ -1,6 +1,7 @@
 2007-06-07  Ulrich Drepper  <[hidden email]>
 
  * configure.in: Avoid variable named BASH.
+ * config.make.in: Likewise.
  Patch in part by Mike Frysinger.
 
 2007-06-06  Jakub Jelinek  <[hidden email]>
Index: config.make.in
===================================================================
RCS file: /cvs/glibc/libc/config.make.in,v
retrieving revision 1.121
diff -u -p -r1.121 config.make.in
--- config.make.in 17 Mar 2007 17:02:00 -0000 1.121
+++ config.make.in 8 Jun 2007 04:46:47 -0000
@@ -117,7 +117,7 @@ LN_S = @LN_S@
 MSGFMT = @MSGFMT@
 
 # Script execution tools.
-BASH = @BASH@
+BASH = @BASH_SHELL@
 KSH = @KSH@
 AWK = @AWK@
 PERL = @PERL@