|
From: Jeff S. <jsq...@us...> - 2002-05-24 05:20:09
|
Update of /cvsroot/env-switcher/modules-oscar/src
In directory usw-pr-cvs1:/tmp/cvs-serv26624/src
Modified Files:
00-modules.csh 00-modules.sh
Log Message:
addressing env-switcher bug 559634:
If we switch users (e.g., "su") or shells, we need to do a hard reset of
the entire modules package. This means unsetting a whole schload of
environment variables so that modules will completely re-initialize itself.
If these env vars are not unset, modules will only "soft" reset itself,
which can have some undesired side-effects, such as attemping to modify
the $HOME/.modulesbeginenv of the *old* user (i.e., the pre-su user).
Index: 00-modules.csh
===================================================================
RCS file: /cvsroot/env-switcher/modules-oscar/src/00-modules.csh,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** 00-modules.csh 23 Apr 2002 06:04:52 -0000 1.1
--- 00-modules.csh 24 May 2002 05:20:06 -0000 1.2
***************
*** 12,28 ****
set MODULE_OSCAR=foo
! # The "su" problem. If user with one default shell does "su" to a
! # user with a different shell, we have to force modules to
! # re-initialize. So we keep a special $MODULE_SHELL variable set to
! # the major flavor of shell that we came from (sh or csh).
! # In this file, if we see that $MODULE_SHELL is not "csh", then
! # unsetenv MODULE_VERSION, which will trigger modules to be setup
! # again.
! if ($?MODULE_SHELL == 1) then
if ("$MODULE_SHELL" != "csh") then
! unsetenv MODULE_VERSION
endif
endif
setenv MODULE_SHELL "csh"
--- 12,43 ----
set MODULE_OSCAR=foo
! # If we change users (e.g., "su") or change shells, we need to
! # reset everything.
! set MODULE_OSCAR_NEED_RESET=0
! # Keep a record of who the user who is that we setup for. If it
! # changed, set MODULE_OSCAR_NEED_RESET. Likewise, if MODULE_SHELL
! # is not "csh", then we also need a full reset.
!
! set MODULE_OSCAR_USER_NOW="`whoami`"
! if ($?MODULE_OSCAR_USER == 0) set MODULE_OSCAR_USER=
! if ("$MODULE_OSCAR_USER" != "$MODULE_OSCAR_USER_NOW") then
! setenv MODULE_OSCAR_USER "$MODULE_OSCAR_USER_NOW"
! set MODULE_OSCAR_NEED_RESET=1
! else if ($?MODULE_SHELL == 1) then
if ("$MODULE_SHELL" != "csh") then
! set MODULE_OSCAR_NEED_RESET=1
endif
+ endif
+
+ # This list of variables to unset is highly specific to version
+ # 3.1.6 of modules. If there is ever a new version of modules,
+ # we'll need to ensure that this list of variables is still
+ # correct.
+
+ if ("$MODULE_OSCAR_NEED_RESET" == "1") then
+ unsetenv MODULE_VERSION MODULEPATH LOADEDMODULES MODULESHOME \
+ _LMFILES_ MODULE_VERSION_STACK MODULE_VERSION _MODULESBEGINENV_
endif
setenv MODULE_SHELL "csh"
Index: 00-modules.sh
===================================================================
RCS file: /cvsroot/env-switcher/modules-oscar/src/00-modules.sh,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** 00-modules.sh 23 Apr 2002 06:04:52 -0000 1.1
--- 00-modules.sh 24 May 2002 05:20:06 -0000 1.2
***************
*** 12,29 ****
MODULE_OSCAR=foo
! # The "su" problem. If user with one default shell does "su" to a
! # user with a different shell, we have to force modules to
! # re-initialize. So we keep a special $MODULE_SHELL variable set to
! # the major flavor of shell that we came from (sh or csh).
!
! # In this file, if we see that $MODULE_SHELL is not "sh", then
! # unsetenv MODULE_VERSION, which will trigger modules to be setup
! # again.
! if test "$MODULE_SHELL" != "sh"; then
! MODULE_VERSION=
fi
! MODULE_SHELL=sh
! export MODULE_SHELL
# NOTE: Because the RH 7.x /etc/bashrc sucks, the csh init file
--- 12,42 ----
MODULE_OSCAR=foo
! # If we change users (e.g., "su") or change shells, we need to
! # reset everything.
! MODULE_OSCAR_NEED_RESET=0
!
! # Keep a record of who the user who is that we setup for. If it
! # changed, set MODULE_OSCAR_NEED_RESET. Likewise, if MODULE_SHELL
! # is not "csh", then we also need a full reset.
!
! MODULE_OSCAR_USER_NOW="`whoami`"
! if test "$MODULE_OSCAR_USER" != "$MODULE_OSCAR_USER_NOW"; then
! export MODULE_OSCAR_USER="$MODULE_OSCAR_USER_NOW"
! MODULE_OSCAR_NEED_RESET=1
! elif test "$MODULE_SHELL" != "sh"; then
! MODULE_OSCAR_NEED_RESET=1
! fi
!
! # This list of variables to unset is highly specific to version
! # 3.1.6 of modules. If there is ever a new version of modules,
! # we'll need to ensure that this list of variables is still
! # correct.
!
! if test "$MODULE_OSCAR_NEED_RESET" = "1"; then
! unset MODULE_VERSION MODULEPATH LOADEDMODULES MODULESHOME \
! _LMFILES_ MODULE_VERSION_STACK MODULE_VERSION _MODULESBEGINENV_
fi
! export MODULE_SHELL=sh
# NOTE: Because the RH 7.x /etc/bashrc sucks, the csh init file
|