Skip to content

module-info usergroups returns error if gid cannot be mapped #604

Description

@gsell

Describe the bug

In certain cases, a user may have a group ID that cannot be mapped to a name. This is for example the case if the user is in an AFS process authentication group (PAG). The PAG is identified by a random (?) group id. All processes with this GID are in the same PAG. This GID has no mapping to a name.

In this case id -G -n returns with an error respectively getgrgid(groups[i]) (in envmodules.c) returns a NULL pointer.

To Reproduce

Create a modulefile printgroups with the following content:

#%Module

set s [module-info usergroups]
puts stderr $s

Start a shell with a GID which cannot be mapped to a name and try to load the modulefile:

sudo setpriv --ruid $USER --groups 1234567 bash
# Re-initialise Modules (with PREFIX = prefix of Modules installation)
source $PREFIX/init/bash
module load ./printgroups

The error will be something like:

$ module ./printgroupinfo 
Loading ./printgroupinfo
  Module ERROR: couldn't find name for group id "1234567": no such file or directory
        while executing
    "module-info usergroups"
        (file "/opt/modules/modulefiles/printgroupinfo" line 3)
    Please contact <root@localhost

Expected behavior

Either ignore this GID or print it as number.

Error and debugging information

$ module --debug load ./printgroupinfo
DEBUG setState: cmdline set to '/opt/modules/libexec/modulecmd.tcl bash --debug load ./printgroupinfo'
DEBUG setConf: tcl_ext_lib set to '/opt/modules/lib/libtclenvmodules.so'
DEBUG Load Tcl extension library (/opt/modules/lib/libtclenvmodules.so)
DEBUG setState: tcl_ext_lib_loaded set to '1'
DEBUG setConf: siteconfig set to '/opt/modules/etc/siteconfig.tcl'
DEBUG sourceSiteConfig: Source site configuration (/opt/modules/etc/siteconfig.tcl)
DEBUG setState: siteconfig_loaded set to '1'
DEBUG setConf: locked_configs set to ''
DEBUG setState: supported_shells set to 'sh bash ksh zsh csh tcsh fish cmd tcl perl python ruby lisp cmake r pwsh'
DEBUG setState: shell set to 'bash'
DEBUG setState: subcmd set to 'load'
DEBUG setState: subcmd_args set to './printgroupinfo'
DEBUG setState: init_error_report set to '1'
DEBUG setConf: verbosity set to 'debug'
DEBUG setState: is_stderr_tty set to '1'
DEBUG setConf: term_background set to 'dark'
DEBUG setConf: colors set to 'hi=1:db=2:tr=2:se=2:er=91:wa=93:me=95:in=94:mp=1;94:di=94:al=96:va=93:sy=95:de=4:cm=92:aL=100:L=90;47:H=2:F=41:nF=31;43:S=46:sS=44:kL=30;48;5;109:W=30;43'
DEBUG setConf: color set to '1'
DEBUG setConf: pager set to '/usr/bin/less -eFKRX'
DEBUG setState: shelltype set to 'sh'
DEBUG setState: paginate set to '1'
DEBUG setState: report_format set to 'regular'
DEBUG setState: reportfd set to 'file4'
DEBUG setState: timer set to '0'
DEBUG parseModuleCommandName: (command=load, cmdvalid=1, cmdempty=0)
DEBUG lappendState: always_read_full_file appended with '1'
DEBUG lappendState: commandname appended with 'load'
DEBUG setConf: icase set to 'search'
DEBUG setConf: extended_default set to '1'
DEBUG setConf: implicit_default set to '1'
DEBUG setConf: advanced_version_spec set to '1'
DEBUG setConf: variant_shortcut set to ''
DEBUG setState: is_win set to '0'
DEBUG setState: path_separator set to ':'
DEBUG setState: sub1_separator set to '&'
DEBUG setState: sub2_separator set to '|'
DEBUG cacheCurrentModules: 0 loaded
DEBUG setConf: avail_indepth set to '1'
DEBUG setConf: search_match set to 'starts_with'
DEBUG setModuleVersSpec: Set module './printgroupinfo' (escglob './printgroupinfo'),  module name '.' (re '\.'), module root '.', version cmp 'eq', version(s) '', variant(s) '' and module name version spec './printgroupinfo' for argument './printgroupinfo' (raw './printgroupinfo'), extra specifier(s) '' and matching available module(s) ''
DEBUG parseModuleCommandArgs: (show_oneperline=0, show_mtime=0, show_filter=, search_filter=, search_match=starts_with, dump_state=0, addpath_pos=prepend, not_req=0, tag_list=, otherargs=./printgroupinfo)
DEBUG setConf: logged_events set to ''
DEBUG setState: rc_running set to '1'
DEBUG setConf: ignore_user_rc set to '0'
DEBUG unsetState: rc_running unset
DEBUG cmdModuleLoad: loading ./printgroupinfo (context=load, uasked=1, tryload=0, loadany=0, tag_list=, modulepath_list=)
DEBUG lappendState: mode appended with 'load'
DEBUG lappendState: eval_context appended with 'load'
DEBUG getPathToModule: finding './printgroupinfo' in '' (report_issue=0, look_loaded=exact, excdir='')
DEBUG setConf: unload_match_order set to 'returnlast'
DEBUG setState: cwd set to '/opt/modules/modulefiles'
DEBUG getLoadedMatchingName: '' matches './printgroupinfo'
DEBUG getPathToModule: finding './printgroupinfo' in '' (report_issue=1, look_loaded=no, excdir='')
DEBUG setConf: mcookie_check set to 'always'
DEBUG setState: inhibit_errreport set to '0'
Select module: '/opt/modules/modulefiles/printgroupinfo' (/opt/modules/modulefiles/printgroupinfo) matching '/opt/modules/modulefiles/printgroupinfo'
DEBUG lappendState: evalid appended with 'load-/opt/modules/modulefiles/printgroupinfo-0'
DEBUG lappendState: msgrecordid appended with 'load-/opt/modules/modulefiles/printgroupinfo-0'
DEBUG getLoadedMatchingName: '' matches '/opt/modules/modulefiles/printgroupinfo'
DEBUG pushSettings: settings saved (#1)
DEBUG setConf: auto_handling set to '1'
DEBUG setConf: conflict_unload set to '0'
DEBUG resolvStringWithEnv: '/opt/modules/modulefiles' resolved to '/opt/modules/modulefiles'
DEBUG resolvStringWithEnv: '/opt/modules/modulefiles' resolved to '/opt/modules/modulefiles'
DEBUG getModuleLoadedConflict: '/opt/modules/modulefiles/printgroupinfo' conflicts with ''
DEBUG getDependentLoadedModuleList: get loaded mod dependent of '' (strong=0, direct=0, nporeq=0, loading=0, sat_constraint=1, being_unload=0)
DEBUG getDependentLoadedModuleList: got ''
DEBUG getUnmetDependentLoadedModuleList: got ''
DEBUG cmdModuleLoad: depre mod list is ''
DEBUG lappendState: modulefile appended with '/opt/modules/modulefiles/printgroupinfo'
DEBUG lappendState: modulename appended with '/opt/modules/modulefiles/printgroupinfo'
DEBUG lappendState: modulenamevr appended with '/opt/modules/modulefiles/printgroupinfo'
DEBUG lappendState: specifiedname appended with './printgroupinfo'
DEBUG lappendState: modulepath appended with '{}'
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] lappendState: debug_msg_prefix appended with '{[#1:load:/opt/modules/modulefiles/printgroupinfo] }'
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] setState: inhibit_interp set to '0'
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] setConf: source_cache set to '0'
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] setState: modules_release set to '5.6.1'
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] createInterp: creating interp __modfile_load_1_1
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] dumpInterpState: saving for __modfile var tcl_version
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] dumpInterpState: saving for __modfile var tcl_interactive
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] dumpInterpState: saving for __modfile var ModuleToolVersion
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] dumpInterpState: saving for __modfile var ModuleTool
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] dumpInterpState: saving for __modfile var auto_path
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] dumpInterpState: saving for __modfile var tcl_pkgPath
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] dumpInterpState: saving for __modfile var tcl_patchLevel
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] dumpInterpState: saving for __modfile var tcl_platform
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] dumpInterpState: saving for __modfile var tcl_library
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] dumpInterpState: saving for __modfile proc list auto_load unknown tclLog auto_qualify auto_execok auto_import auto_load_index
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] resetInterpState: saving for __modfile_load_1_1 command list modulepath-label module-version tell socket subst conflict open eof add-property pwd glob list module-hide pid exec lsb-release auto_load_index time unknown eval module-forbid lassign lrange module-virtual module-user append-path depends-on-any reportWarning is-loaded fblocked lsearch auto_import gets report case lappend proc throw setenv hide-version break reportTraceExecEnter variable llength set-function prereq incrErrorCount module-info _append auto_execok extensions return linsert is-used error haveDynamicMPATH catch unique-name-conflict module-help clock info split variant hide-modulefile array if fconfigure coroutine concat join lreplace source fcopy global switch auto_qualify update prereq-any module-log unset-alias reportError close reportCmdTrace cd for append auto_load file lreverse source-sh getenv format getModuleHelpLines lmap unload read package set namespace binary scan always-load versioncmp apply module-tag trace remove-property unsetenv seek getModuleContent complete provide zlib while isWin chan flush after vwait is-saved dict getvariant system uplevel continue is-avail require-fullname try remove-path foreach lset rename pushenv chdir fileevent yieldto module-whatis regexp uncomplete module-alias x-resource lrepeat upvar tailcall encoding expr unset prepend-path load regsub exit family module-trace module-verbosity unset-function interp module-warn set-alias _puts puts incr lindex lsort depends-on prereq-all tclLog uname module string yield
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] evaluateModulefile: unique-name-conflict
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] setConf: unique_name_loaded set to '0'
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] evaluateModulefile: getModuleContent /opt/modules/modulefiles/printgroupinfo
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] evaluateModulefile: module-info usergroups
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] setConf: contact set to 'root@localhost'
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] setState: error_count set to '0'
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] setState: error_count set to '1'
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] resolvStringWithEnv: '/opt/modules/modulefiles' resolved to '/opt/modules/modulefiles'
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] resolvStringWithEnv: '/opt/modules/modulefiles' resolved to '/opt/modules/modulefiles'
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] getModuleLoadedConflict: '/opt/modules/modulefiles/printgroupinfo' conflicts with ''
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] setModuleVersSpec: Set module '/opt/modules/modulefiles/printgroupinfo' (escglob '/opt/modules/modulefiles/printgroupinfo'),  module name '/opt/modules/modulefiles' (re ''), module root '/', version cmp 'eq', version(s) '', variant(s) '' and module name version spec '/opt/modules/modulefiles/printgroupinfo' for argument '/opt/modules/modulefiles/printgroupinfo' (raw '/opt/modules/modulefiles/printgroupinfo'), extra specifier(s) '' and matching available module(s) ''
DEBUG [#1:load:/opt/modules/modulefiles/printgroupinfo] execute-modulefile: exiting /opt/modules/modulefiles/printgroupinfo
DEBUG lpopState: debug_msg_prefix removed last item
DEBUG lpopState: modulepath removed last item
DEBUG lpopState: specifiedname removed last item
DEBUG lpopState: modulename removed last item
DEBUG lpopState: modulenamevr removed last item
DEBUG lpopState: modulefile removed last item
DEBUG restoreSettings: previously saved settings restored (#1)
DEBUG popSettings: previously saved settings flushed (#0)
DEBUG setConf: tag_abbrev set to 'auto-loaded=aL:loaded=L:hidden=H:hidden-loaded=H:forbidden=F:nearly-forbidden=nF:sticky=S:super-sticky=sS:keep-loaded=kL:warning=W'
DEBUG setConf: tag_color_name set to ''
DEBUG setConf: term_width set to '0'
DEBUG setState: term_columns set to '224'
DEBUG unsetState: report_sep_next unset

DEBUG setState: report_sep_next set to '1'
Loading /opt/modules/modulefiles/printgroupinfo
  Evaluate modulefile: '/opt/modules/modulefiles/printgroupinfo' as '/opt/modules/modulefiles/printgroupinfo'
  Module ERROR: couldn't find name for group id "1234567": no such file or directory
        while executing
    "module-info usergroups"
        (file "/opt/modules/modulefiles/printgroupinfo" line 3)
    Please contact <root@localhost>
DEBUG unsetState: report_sep_next unset

DEBUG setState: report_sep_next set to '1'
DEBUG lpopState: evalid removed last item
DEBUG lpopState: msgrecordid removed last item
DEBUG setConf: abort_on_error set to 'ml:reload:switch_unload'
DEBUG setState: force set to '0'
DEBUG lpopState: eval_context removed last item
DEBUG lpopState: mode removed last item
DEBUG lpopState: commandname removed last item
DEBUG lpopState: always_read_full_file removed last item
DEBUG setState: autoinit set to '0'
DEBUG renderSettings: 1 error(s) detected.
DEBUG setState: false_rendered set to '1'
DEBUG setConf: logger set to '/usr/bin/logger -t modules'
DEBUG setState: logging set to '0'
DEBUG setState: logfd set to ''

Modules version and configuration

Current main branch. Default configuration after installation:

$ module --version 
Modules Release 5.6.1+67-gd3f4c221 (2026-01-06)
$ bash-5.2$ module config  --dump-state
Modules Release 5.6.1+67-gd3f4c221 (2026-01-06)

- Config. name ---------.- Value (set by if default overridden) ---------------
abort_on_error            ml:reload:switch_unload
advanced_version_spec     1
auto_handling             1
avail_indepth             1
avail_output              modulepath:alias:dirwsym:sym:tag:variantifspec:key
avail_terse_output        modulepath:alias:dirwsym:sym:tag:variantifspec
cache_buffer_bytes        32768
cache_expiry_secs         0
collection_pin_tag        0
collection_pin_version    0
collection_target         <undef>
color                     auto
colors                    hi=1:db=2:tr=2:se=2:er=91:wa=93:me=95:in=94:mp=1;94:di=94:al=96:va=93:sy=95:de=4:cm=92:aL=100:L=90;47:H=2:F=41:nF=31;43:S=46:sS=44:kL=30;48;5;109:W=30;43
conflict_unload           0
contact                   root@localhost
csh_limit                 4000
editor                    vi
extended_default          1
extra_siteconfig          <undef>
hide_auto_loaded          0
home                      /opt/modules (env-var)
icase                     search
ignore_cache              0
ignore_user_rc            0
ignored_dirs              CVS RCS SCCS .svn .git .SYNC .sos
implicit_default          1
implicit_requirement      1
list_output               header:idx:variant:sym:tag:key
list_terse_output         header
locked_configs            
logged_events             
logger                    /usr/bin/logger -t modules
mcookie_check             always
mcookie_version_check     1
ml                        1
nearly_forbidden_days     14
pager                     none (env-var)
protected_envvars         <undef>
quarantine_support        0
rcfile                    <undef>
redirect_output           1
require_via               0
reset_target_state        __init__
run_quarantine            <undef>
search_match              starts_with
set_shell_startup         0
shells_with_ksh_fpath     
silent_shell_debug        0
siteconfig                /opt/modules/etc/siteconfig.tcl
source_cache              0
spider_indepth            1
spider_output             modulepath:alias:dirwsym:sym:tag:variantifspec:via:key
spider_terse_output       modulepath:alias:dirwsym:sym:tag:variantifspec
sticky_purge              error
tag_abbrev                auto-loaded=aL:loaded=L:hidden=H:hidden-loaded=H:forbidden=F:nearly-forbidden=nF:sticky=S:super-sticky=sS:keep-loaded=kL:warning=W
tag_color_name            
tcl_ext_lib               /opt/modules/lib/libtclenvmodules.so
tcl_linter                nagelfar.tcl
term_background           dark
term_width                0
unique_name_loaded        0
unload_match_order        returnlast
variant_shortcut          
verbosity                 normal
wa_277                    0

- State name -----------.- Value ----------------------------------------------
WARNING: couldn't find name for group id "1234567": no such file or directory
always_read_full_file     1
autoinit                  0
cache_mcookie_version     5.3
clock_seconds             1767735957
cmdline                   /opt/modules/libexec/modulecmd.tcl bash config --dump-state
commandname               config
domainname                (none)
error_count               0
extra_siteconfig_loaded   0
false_rendered            0
force                     0
hiding_threshold          0
inhibit_errreport         0
inhibit_interp            0
init_error_report         1
is_stderr_tty             1
is_win                    0
kernelversion             #37~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 20 10:25:38 UTC 2
logfd                     
logging                   0
lsb_codename              noble
lsb_id                    Ubuntu
lsb_release               24.04
machine                   x86_64
modules_release           5.6.1
nodename                  Korra
os                        Linux
osversion                 6.14.0-37-generic
paginate                  1
path_separator            :
report_format             regular
reportfd                  stderr
return_false              0
shell                     bash
shelltype                 sh
siteconfig_loaded         1
sub1_separator            &
sub2_separator            |
subcmd                    config
subcmd_args               --dump-state
supported_shells          sh bash ksh zsh csh tcsh fish cmd tcl perl python ruby lisp cmake r pwsh
tcl_ext_lib_loaded        1
tcl_version               8.6.14
term_columns              224
timer                     0
usergroups                <undef>
username                  gsell

- Env. variable --------.- Value ----------------------------------------------
BASH_FUNC__module_raw%%   () {  eval "$(/usr/bin/tclsh '/opt/modules/libexec/modulecmd.tcl' bash "$@")";
 _mlstatus=$?;
 return $_mlstatus
}
BASH_FUNC_module%%        () {  local _mlredir=1;
 if [ -n "${MODULES_REDIRECT_OUTPUT+x}" ]; then
 if [ "$MODULES_REDIRECT_OUTPUT" = '0' ]; then
 _mlredir=0;
 else
 if [ "$MODULES_REDIRECT_OUTPUT" = '1' ]; then
 _mlredir=1;
 fi;
 fi;
 fi;
 case " $@ " in 
 *' --no-redirect '*)
 _mlredir=0
 ;;
 *' --redirect '*)
 _mlredir=1
 ;;
 esac;
 if [ $_mlredir -eq 0 ]; then
 _module_raw "$@";
 else
 _module_raw "$@" 2>&1;
 fi
}
LOADEDMODULES             
MODULEPATH                /opt/modules/modulefiles
MODULESHOME               /opt/modules
MODULES_CMD               /opt/modules/libexec/modulecmd.tcl
MODULES_PAGER             none
__MODULES_LMINIT          module use --append /opt/modules/modulefiles
__MODULES_SHARE_MANPATH   :1

Additional context

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions