-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
profile.sh misdetects login shell #473
Comments
Many thanks for your detailed report and for the reproducer. As spotted, issue comes from the following lines of sh profile script: Code may be fixed by restraining the possibilities when detecting that the --- orig 2022-09-13 06:55:10.807140403 +0200
+++ /etc/profile.d/modules.sh 2022-09-13 06:55:42.119445769 +0200
@@ -1,7 +1,11 @@
# get current shell name by querying shell variables or looking at parent
# process name
if [ -n "${BASH:-}" ]; then
- shell=${BASH##*/}
+ if [ "${BASH##*/}" = 'sh' ]; then
+ shell='sh'
+ else
+ shell='bash'
+ fi
elif [ -n "${ZSH_NAME:-}" ]; then
shell=$ZSH_NAME
else |
Thanks for the quick response and sorry for not responding as quickly. I have now tested the proposed fix in our setup and can confirm that it fixes the problem with the minimal reproducer as well as for PBS jobs. Thank you! |
@mw-a, thank you for this detailed report! I've already fixed it in CentOS Stream 8 & 9 so this will be fixed in upcoming RHEL releases. |
Describe the bug
We're seeing error messages from OpenPBS jobs as generated by the reproducer further down. This happens for users whose login shell is
/bin/tcsh
but override their job to use/bin/bash
for executing the job script. It can be traced to/etc/profile.d/modules.sh
which sources/usr/share/Modules/init/tcsh
because it wrongly detects the executing shell to betcsh
. Further investigation reveals this to be caused by the optimisation/fix introduced in #173 to use the$BASH
variable to make detection more efficient and robust. Unfortunately this runs afoul of two very specific circumstances in our scenario:/bin/bash
withargv[0]
set to-bash
in order to get it to behave like a login shell and then feeds the path to the job script to execute to it via stdingetpwent()
when called as a login shell (without further information)To Reproduce
Steps to reproduce the behavior:
tcsh
:No modulerc or modulefiles are involved in this problem because it's the initialisation process that's failing.
Expected behavior
The shell should execute the command without error messages.
Error and debugging information
It could be argued whether bash's or PBS's behaviour are strictly correct here. On the other hand, changing their established behaviour, particularly that of bash, is likely to break other things. So any ideas how to work around this problem on the modules level would be very much appreciated.
Modules version and configuration
Additional context
The text was updated successfully, but these errors were encountered: