Non imported environment variable with shellshock fixed bash version

166 Views Asked by At

I have a simple bash script which modifies a environment variable that will be used by subsequent binary. Bellow my basic script:

#!/bin/bash
export DBROOT="NEW_DIRECTORY" 
export TERM=xterm
su  -c " <test_process> " - omni

DBROOT variable is used by "test_process" as environment variable. Also, DBROOT is defined with another value "OLD_DIRECTORY" as a global environment variable. The goal of the script is to force the "test_process" to use NEW_DIRECTORY value (exported value).

With the non patched bash version, the test worked. However, after patching the shellshock bug on the bash, test_process does not read the exported value of DBROOT neither the global environment variables. It's as if the "test_process" ignores exported and global variables.

I don't have the source code of "test_process". The bash version is version 2.05b.0(1)-release (rpm version is bash-2.05b-41.7.i386.rpm ) and I'm running on Red Hat Enterprise Linux AS release 3

Update: After recompiling the bash 2.05b last sources by setting compile-time definition

#define NON_INTERACTIVE_LOGIN_SHELLS

the script worked again. Without this define bash misinterpreted the - character after su command

1

There are 1 best solutions below

1
Jonathan Leffler On

That's pretty ancient software you're using.

I suggest trying:

su -c "DBROOT='NEW_DIRECTORY' TERM='xterm' <test_process> " - omni

This moves the environment setting into the shell run by su, rather than relying on su to relay the environment.