TACC / Lmod

Lmod: An Environment Module System based on Lua, Reads TCL Modules, Supports a Software Hierarchy
http://lmod.readthedocs.org
Other
475 stars 122 forks source link

With `bash` as Login Shell, access restricted Shell Scripts throw Error Messages when Lmod < 8.7.5 is installed #620

Closed e4t closed 1 year ago

e4t commented 1 year ago

Describe the bug Since updating Lmod to a version >= 8.7.5 on openSUSE Tumbleweed we get error messages when running unrelated shell scripts which have certain access restrictions enforced - such as under apparmor.

To Reproduce Steps to reproduce the behavior:

  1. Install openSUSE Tumbleweed (version 20230107 or later) .
  2. Install the package lua-lmod
  3. log in, make sure 'bash' is the login shell (default).
  4. run less/usr/share/lmod/8.7.15/init/csh`

This will cause

/usr/share/lmod/8.7.15/init/bash: line 57: /usr/bin/readlink: Permission denied
/usr/share/lmod/8.7.15/init/bash: line 61: /usr/bin/expr: Permission denied
/usr/share/lmod/8.7.15/init/bash: line 62: /usr/bin/basename: Permission denied

to be written to stderr.

Expected behavior A clear and concise description of what you expected to happen.

Desktop:

Additional context The problem is triggered when /usr/bin/lessopen.sh is executed. This script has certain apparmor restrictions set. Since the Lmod init script sets BASH_ENV to /usr/share/lmod/8.7.15/init/bash, this script is run every time a shell script is executed.

A possible solution would be to reduce the 'access surface' of init/bash when sourced by delaying determining LMOD_SHELL_PRGM until module is called for the first time.

rtmclay commented 1 year ago

Thanks for reporting this issue and the patch (Issue #621). Your patch might solve your issue but it doesn't always pick the right shell. A zsh user would instead be a bash user. Not the end of the world but it matters in a few cases.

For various reasons, I have moved the determination of the "shell" into Lmod itself. Please test Lmod version 8.7.17 to see if it fixes your issue as well. Thanks!

e4t commented 1 year ago

Thanks for picking up my patch so quickly and looking into it! I did test zsh and ksh and didn't see any issues - ie. LMOD_SHELL_PRGM was set to the correct shell after calling module. Version 8.7.17 works well. Moving shell detection into the Lmod seems to be a good solution. Thank you!

rtmclay commented 1 year ago

Great! I'm glad that works for you. Closing this issue