tests: fix group membership check in sbang tests. (#33658)

Fixes an issue on the RHEL8 UBI container where this test would fail because `gr_mem`
was empty for every entry in the `grp` DB.

You have to check *both* the `pwd` database (which has primary groups) and `grp` (which
has other gorups) to do this correctly.

- [x] update `llnl.util.filesystem.group_ids()` to do this
- [x] use it in the `sbang` test
This commit is contained in:
Todd Gamblin
2022-11-02 03:00:16 -07:00
committed by GitHub
parent 4bad9f9b13
commit a4d978be59
2 changed files with 13 additions and 4 deletions

View File

@@ -7,7 +7,6 @@
Test that Spack's shebang filtering works correctly.
"""
import filecmp
import getpass
import os
import shutil
import stat
@@ -273,6 +272,9 @@ def configure_group_perms():
# and grp does not act on remote groups.
# To ensure we find a group we can operate on, we get take the first group
# listed which has the current user as a member.
gid = fs.group_ids(os.getuid())[0]
group_name = grp.getgrgid(gid).gr_name
conf = syaml.load_config(
"""\
all:
@@ -281,7 +283,7 @@ def configure_group_perms():
write: group
group: {0}
""".format(
[g.gr_name for g in grp.getgrall() if getpass.getuser() in g.gr_mem][0]
group_name
)
)
spack.config.set("packages", conf, scope="user")