Module magic cookie check
A file should start with a specific string as header line to be considered as
a modulefile. This specific string is called the magic cookie and is equal to
#%Module optionally followed by a version number to indicate the minimum
modulecmd.tcl required to interpret this file.
Magic cookie applies to modulefiles and module RC files. More recently it also
applies to the
initrc configuration file and collections.
Magic cookie is checked in two different situations:
When searching for a modulefile: all files located under a directory used as a modulepath are checked to determine if they are modulefiles to take them into account in the module search.
When evaluating a modulefile: when reading file to pass it down to the modulefile or modulerc interpreter, the magic cookie is checked to ensure file can be evaluated.
mcookie_check configuration option is introduced to be able to
disable the magic cookie check. Option accepts the following values:
always: This is the default value, magic cookie is checked in both situations described above
eval: magic cookie is only checked prior evaluating file, not when searching for modulefiles
FUTURE: a third value,
never, may be interesting to disable the magic
cookie check in all situations.
Skipping check when searching modules
eval, module magic cookie is not
checked when analyzing the files located under an enabled modulepath. This
mode significantly diminishes the I/O load when looking at the content of a
modulepath as files are not opened and header read for the check.
This mode requires a perfect control on the files located within the hierarchy of the modulepath directories as:
non-modulefiles will be considered modulefiles and will be reported in module search results and used to locate a module corresponding to a query
files hidden through restrictive permissions are reported in search results and used to locate a module corresponding to a query
For these non-modulefiles or read-protected files an error is obtained when trying to evaluate them, as the magic cookie is checked at this step.
Also the files specified full path are not checked prior evaluation if
mcookie_check is set to
eval, so if these files are not modulefile an
error will be obtained when trying to evaluate them.
eval mode of
mcookie_check configuration option has no impact on
initrc configuration file and collections as such files are not
searched like modulefiles. Their header is only checked at evaluation time.
Modulefiles or modulercs are read through the
which is called by:
execute-modulefileprocedures when files need to get fully read to get evaluated
checkValidModuleprocedure to verify file is a readable modulefile when search for modules
checkValidModule procedure is the one to update when
configuration option is not set to
always as this procedure is called by
all module search contexts. It is called by:
findModulesto check files in directories within modulepaths
getModulesto check files pointed by mfcmd:module-virtual
getPathToModuleto check files transmitted as full path file
File readability (permission check) is not verified when
mcookie_check option is set to
eval to keep the full benefit of
this mode regarding the I/O load optimization.