[omd-commits] OMD Git: omd: base: Added source of .profile when user used su <site> ( fixes #203)

git version control git at mathias-kettner.de
Sat Jul 9 12:56:33 CEST 2011


Module:   omd
Branch:   master
Commit:   a4f3a4cbd4837f75a95bad0576aa2e36c728913d
URL:      http://omdistro.org/projects/omd/repository/revisions/a4f3a4cbd4837f75a95bad0576aa2e36c728913d

Author:   Lars Michelsen <lm at mathias-kettner.de>
Date:     Sat Jul  9 12:47:50 2011 +0200
Commiter: Lars Michelsen <lm at mathias-kettner.de>
Date:     Sat Jul  9 12:47:50 2011 +0200

base: Added source of .profile when user used su <site> (fixes #203)

---

 packages/omd/skel/.bashrc  |   14 ++++++++++++++
 packages/omd/skel/.profile |    5 +++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/packages/omd/skel/.bashrc b/packages/omd/skel/.bashrc
index 444bbd7..0259189 100644
--- a/packages/omd/skel/.bashrc
+++ b/packages/omd/skel/.bashrc
@@ -1,3 +1,17 @@
+# When a user switches to the site user using "su <site>" instead
+# of "su - <site>" the .profile is not loaded. This checks the 
+# situation and sources the .profile when it has not been executed
+# yet.
+# The .profile file tries to execute the .bashrc script on it's
+# own. This is needed in "su - <site>" mode. But must be prevented
+# in the "su <site>" mode. So we define the variable BASHRC here
+# and check it in .profile.
+BASHRC=1
+if [ -z $OMD_ROOT ]; then
+    . ~/.profile
+    cd ~
+fi
+
 # pointless unless running interactively
 if [ "$PS1" ]; then
   PS1='OMD[\u]:\w$ '
diff --git a/packages/omd/skel/.profile b/packages/omd/skel/.profile
index 95c6dab..a952c36 100644
--- a/packages/omd/skel/.profile
+++ b/packages/omd/skel/.profile
@@ -21,7 +21,8 @@ then
     eval $(egrep -v '^[[:space:]]*(#|$)' < ~/etc/environment | sed 's/^/export /')
 fi
 
-# Only load bashrc when in a bash shell
-if [ "$BASH" -a -s ~/.bashrc ]; then
+# Only load bashrc when in a bash shell and not loaded yet.
+# The load once is ensured by the variable $BASHRC.
+if [ "$BASH" -a -s ~/.bashrc -a -z "$BASHRC" ]; then
     . ~/.bashrc
 fi



More information about the omd-commits mailing list