1 |
#!/bin/sh |
2 |
|
3 |
function unwrap_env () { |
4 |
# Setting new break characters |
5 |
PRESERVED_IFS=$IFS |
6 |
IFS=`echo -en "\n\b"` |
7 |
for i in `printenv`; do |
8 |
# Unwrap the GLEXEC_WRAP_ environment variables |
9 |
if [ "`expr substr $i 1 12`" == "GLEXEC_WRAP_" ]; then # substring match and compare to "GLEXEC_WRAP_" |
10 |
# D=`echo "$i" | sed -e 's/^GLEXEC_WRAP_\([a-zA-Z0-9_]*\)=\(.*\)/\1=\2/'` |
11 |
# E=`echo "$i" | sed -e 's/\(^GLEXEC_WRAP_[a-zA-Z0-9_][a-zA-Z0-9_]*\)=.*/\1/'` |
12 |
D=`echo "$i" | expr match "$i" 'GLEXEC_WRAP_\([a-zA-Z0-9_]*=.*\)'` # Match string excluding the GLEXEC_WRAP_ prefix |
13 |
E=`echo "$i" | expr match "$i" '\(GLEXEC_WRAP_[a-zA-Z0-9_]*\)'` # Match string including the GLEXEC_WRAP_ prefix |
14 |
|
15 |
# Clean the environment option prefixed by GLEXEC_WRAP_ |
16 |
unset $E |
17 |
|
18 |
# Prevent this list of environment variables which are set by gLExec to be overwritten by the wrapped environment variables |
19 |
if [ "$E" == "GLEXEC_WRAP_HOME" ]; then continue; fi # The $HOME is set by gLExec to the mapped account |
20 |
if [ "$E" == "GLEXEC_WRAP_X509_USER_PROXY" ]; then continue; fi # The $X509_USER_PROXY is set by gLExec to the default target location of the proxy or to the $GLEXEC_TARGET_PROXY |
21 |
|
22 |
# Export the unwrapped environment variables |
23 |
export $D |
24 |
fi |
25 |
done |
26 |
IFS=$PRESERVED_IFS |
27 |
} |
28 |
|
29 |
echo "----- fire $0 : unwrap_env -------" |
30 |
unwrap_env |
31 |
|
32 |
echo "----- fire $0 : printenv -------" |
33 |
printenv |