cea-hpc / modules

Environment Modules: provides dynamic modification of a user's environment
http://modules.sourceforge.net/
GNU General Public License v2.0
668 stars 102 forks source link

The test suite fails when the user is a member of a non-existent supplementary group #476

Closed lzaoral closed 1 year ago

lzaoral commented 1 year ago

Describe the bug

The test suite fails when the user is a member of a non-existent supplementary group. I've come across this behaviour when I wanted to fix #473 in CentOS Stream 9 because Zuul bot (part of the CI) runs a scratch build under such user [1][2].

[1] https://gitlab.com/redhat/centos-stream/rpms/environment-modules/-/merge_requests/7 [2] https://centos.softwarefactory-project.io/zuul/t/centos/build/55639b7b988e4f928e451408431dd5b4/console

To Reproduce

These command should recreate a similar environment to the one that Zuul uses.

  1. Get a Fedora physical machine/VM and install Fedora Toolbox.
  2. $ toolbox create
  3. $ toolbox enter
  4. $ sudo dnf install -y centpkg # install centpkg into the toolbox container
  5. $ centpkg clone -a environment-modules
  6. $ cd environment-modules
  7. $ centpkg mockbuild

The same holds also for your Fedora package. Just use centpkg instead of fedpkg.

Error and debugging information

The 005-init_ts.exp test fails to complete which subsequently breaks other tests that depend on it. This is caused by the fact that id -G -n fails because when mock is run inside a container the mockbuild user in the build chroot inherits all supplementary groups from the user that executed the mock command. Even though, not all such groups might be defined in /etc/group for this user in the given build chroot.

Running /builddir/build/BUILD/modules-5.0.1/testsuite/modules.00-init/005-init_ts.exp ...
Fail to detect terminal column number.
Fail to set specific terminal size: stty: 'standard input': Inappropriate ioctl for device
Fallback to 80 columns
id output is 'uid=1000(mockbuild) gid=135(mock) groups=135(mock),4(adm),10(wheel),190'
Current username is 'mockbuild'
ERROR: tcl error sourcing /builddir/build/BUILD/modules-5.0.1/testsuite/modules.00-init/005-init_ts.exp.
ERROR: tcl error code CHILDSTATUS 12527 1
ERROR: mock adm wheel 190
id: cannot find name for group ID 190
    while executing
"exec id -G -n"
    (file "/builddir/build/BUILD/modules-5.0.1/testsuite/modules.00-init/005-init_ts.exp" line 651)
    invoked from within
"source /builddir/build/BUILD/modules-5.0.1/testsuite/modules.00-init/005-init_ts.exp"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 source /builddir/build/BUILD/modules-5.0.1/testsuite/modules.00-init/005-init_ts.exp"
    invoked from within
"catch "uplevel #0 source $test_file_name" msg"

Expected behaviour

The test suite completes successfully.

Additional context

I'm not quite sure if such configuration should actually be supported by environment modules so feel free to close this issue if that's the case. I'm also in touch with mock developers and they are not against adding a supplementary group filter so that mockbuild will never be a member of non-existent supplementary groups that were inherited from the "outside" of the buildroot.

Also, fixing this is not really urgent because I got an exception on the given CentOS Stream 9 MR and #473 should be already fixed there.

xdelaruelle commented 1 year ago

Many thanks @lzaoral for this detailed report. I have fixed the testsuite to be able to run through mockbuild and cope with unresolved group name.