From: Iain Patterson Date: Fri, 9 May 2014 11:00:31 +0000 (+0100) Subject: Export PROFILE_HOME. X-Git-Url: http://git.iain.cx/?p=profile.git;a=commitdiff_plain;h=fe75e01fb1409059b32d37b0464651d2852d8340 Export PROFILE_HOME. Export PROFILE_HOME in the environment so that become can be run from became without losing settings. --- diff --git a/.profile.d/BECOME.bashrc b/.profile.d/BECOME.bashrc index 32a69ed..50cb97a 100644 --- a/.profile.d/BECOME.bashrc +++ b/.profile.d/BECOME.bashrc @@ -1,3 +1,8 @@ +# Export PROFILE_HOME to the environment if we need to preserve it. +if [ -n "$PROFILE_HOME" ]; then + [ "$PROFILE_HOME" = "$HOME" ] || export PROFILE_HOME +fi + # Find a path, preferring the target user's version. function find_target_profile() { local path="$1"; shift diff --git a/opt/bin/become b/opt/bin/become index 0825bd6..a7ad44a 100755 --- a/opt/bin/become +++ b/opt/bin/become @@ -47,7 +47,7 @@ builtin umask 077 if exec 3>"$file" && exec <"$file" && rm "$file"; then builtin $umask echo >&3 "cd" - echo >&3 "PROFILE_HOME='$HOME'" + echo >&3 "PROFILE_HOME='${PROFILE_HOME:-$HOME}'" if [ -n "$PRINCIPAL" ]; then echo >&3 "PRINCIPAL='$PRINCIPAL'" if [ $kerberos = 1 ]; then @@ -71,7 +71,7 @@ else exit 111 fi -echo >&3 ". $HOME/.bash_profile" +echo >&3 ". ${PROFILE_HOME:-$HOME}/.bash_profile" [ -f "$BECOME/all" ] && cat >&3 2>/dev/null "$BECOME/all" [ -f "$BECOME/$user" ] && cat >&3 2>/dev/null "$BECOME/$user" [ $chdir = 1 ] && echo >&3 2>/dev/null "cd - &>/dev/null"