Add an utility library that supersedes the sysconf function from libc.
The sysconf function from this added library always returns an error
(-1). It is used for coverage test of the sysconf call made within the
Envmodules_InitStateUsergroupsObjCmd function of the Tcl extension
library.
sysconf may fail to obtain the value of the NGROUPS_MAX variable. In
such case, it returns -1 and sets errno to indicate the error.
Let's handle this situation as the size argument of ckalloc is an
unsigned int so the size of the allocated memory would be UINT_MAX instead.
Subsequently, getgroups would fail with EINVAL as maxgroupsize is non-zero
but less than the number of GIDs that would have been returned.
Note that if sysconf returns -1 and leaves errno intact, the given
variable has no limit. However, that does not seem to be the case on
any reasonable operating system [1].
Found by Coverity.
Resolves:
modules-5.0.1/lib/envmodules.c:355: negative_return_fn: Function "sysconf(_SC_NGROUPS_MAX)" returns a negative number.
modules-5.0.1/lib/envmodules.c:355: assign: Assigning: "maxgroups" = "sysconf(_SC_NGROUPS_MAX)".
modules-5.0.1/lib/envmodules.c:368: negative_returns: "maxgroups" is passed to a parameter that cannot be negative.
366|
367| #if defined (HAVE_GETGROUPS)
368|-> if ((ngroups = getgroups(maxgroups, groups)) == -1) {
369| Tcl_SetErrno(errno);
370| Tcl_SetObjResult(interp,
[1] https://www.j3e.de/ngroups.html
To ensure the coverage files are correctly named after the .c source
file name, first build the object file then process it with linker to
build the shared library.
Change license of the Modules Tcl extension library from GPLv3+ to
GPLv2+.
Align this way all files from the Modules project under the GPLv2+
license.
Consent has been obtained from copyright holder to perform such move (I
hold the full copyright for this library).
Related to #389
Change license of all testutil-* libraries, used to test Modules Tcl
extension library, from GPLv3+ to GPLv2+.
Align this way all files from the Modules project under the GPLv2+
license.
Consent has been obtained from copyright holder to perform such move (I
hold the full copyright for these librairies).
Related to #389
Print generated file names rather commands executed to generate these
files on makefile build targets. Output when making Modules is this way
simplified. When option `V=1` is passed to make verbose mode is enabled
and executed commands are shown.
Simplified make output does not apply to the install, uninstall, test,
clean, distclean targets and their relatives.
Update C-version of the readFile procedure to add it the
`must_have_cookie` argument that tells if the Modules magic cookie
(#%Module) has to be checked when reading file to abort reading as soon
as possible if read file must be a modulefile.
Bump version of Tcl Envmodules library to 1.3.0.
Fixes#375.
Add an utility library that supersedes the mktime function from libc.
The mktime function from this added library always returns an error
(-1). It is used for coverage test of the mktime call made within the
Envmodules_ParseDateTimeArgObjCmd function of the Tcl extension library.
Add function in libtclenvmodules to implement 'parseDateTimeArg' as a
Tcl command, which provides a more efficient way to convert a datetime
string into an Epoch time.
Add an utility library that supersedes the time function from libc. The
time function from this added library always returns an error (-1). It
is used for coverage test of the time call made within the
Envmodules_InitStateClockSecondsObjCmd function of the Tcl extension
library.
Add function in libtclenvmodules to implement 'initStateClockSeconds' as
a Tcl command, which provides a more efficient way to retrieve current
Epoch time.
Add an utility library that supersedes the getgroups function from libc.
The getgroups function from this added library always returns a list
with 3 elements that all correspond to user's primary group. It is used
for coverage test of the getgroups call made within the
Envmodules_InitStateUsergroupsObjCmd function of the Tcl extension
library.
`getgroups` system call may return a group list with duplicate entries,
so these duplicates need to be removed from result list. Use a *sort
then skip consecutive identical entries* strategy for this cleanup task.
Sort is performed with `qsort` system call therefore a
`+__Envmodules_IntCmp` function is introduced for it.
Add an utility library that supersedes the getgroups function from libc.
The getgroups function from this added library always returns an empty
result (0). It is used for coverage test of the getgroups call made
within the Envmodules_InitStateUsergroupsObjCmd function of the Tcl
extension library.
Add an utility library that supersedes the getgrgid function from libc.
The getgrgid function from this added library always returns an error
(NULL). It is used for coverage test of the getgrgid call made within the
Envmodules_InitStateUsergroupsObjCmd function of the Tcl extension
library.
Add an utility library that supersedes the getgroups function from libc.
The getgroups function from this added library always returns an error
(-1). It is used for coverage test of the getgroups call made within the
Envmodules_InitStateUsergroupsObjCmd function of the Tcl extension
library.
Add an utility library that supersedes the getpwuid function from libc.
The getpwuid function from this added library always returns an error
(NULL). It is used for coverage test of the getpwuid call made within
the Envmodules_InitStateUsernameObjCmd function of the Tcl extension
library.
Add function in libtclenvmodules to implement `initStateUsergroups` as a
Tcl command, which provides a more efficient way to retrieve current
groups of running process, rather forking to execute `id` external
binary.
Note that if current system does not support the `getgroups` system
call, only the primary group name of current user will be returned.
Add function in libtclenvmodules to implement `initStateUsername` as a
Tcl command, which provides a more efficient way to retrieve current
username, rather forking to execute `id` external binary.
Bump version of Envmodules library after the small changes made:
- directly return result of Envmodules_Init last operation
- Tcl_GetBooleanFromObj already set error message, no need to rewrite an
error message in case boolean argument is not boolean
Add an utility library that supersedes the closedir function from libc.
The closedir function from this added library always returns an error
(-1). It is used for coverage test of the closedir call made withing the
Envmodules_GetFilesInDirectoryObjCmd function of the Tcl extension
library.
No need to craft an error message when a non-boolean value is passed to
procedures as the Tcl_GetBooleanFromObj function already set the
accurate message when it returns non-OK.
When coverage is asked (COVERAGE=y) also check lib/envmodules.c (Modules
Tcl extension library) and report obtained coverage result (Codecov
script automatically finds Gcov coverage results).
When looking for modulefiles in enabled modulepaths, take .modulerc file
found at the root of a modulepath directory into account. Which means
these RC files are now evaluated like global rc files and can be used to
define module aliases targeting modulefiles stored in the underlying
file tree.
findModules procedure has been adapted to return any .modulerc file
found at the root of the directory. Code that look at modulepath root
has been adapted to use the getFilesInDirectory procedure or command.
A fetch_dotversion argument is added to the getFilesInDirectory Tcl
procedure and its libtclenvmodules counterpart. This argument is
disabled when looking at modulepath root content to avoid returning
eventual .version file stored there.
Shorthand version notation (ex: /1.0) cannot be used in a modulepath rc
file as a module name cannot be determined from this location.
Add function in libtclenvmodules to implement getFilesInDirectory as a
command, which provides a more IO-optimized way than native Tcl commands
perform by avoiding specific additional queries to get hidden files like
.modulerc and .version. As a result 1 stat and 2 access syscalls are
saved per directory read.
Add code to Tcl extension library to report error specifically when
built against Tcl8.4. This version of Tcl does not propose a
Tcl_ObjPrintf function, so the Tcl_AppendResult function is used instead
when the library is built against this version.
Introduce Modules Tcl extension library (written in C) to extend Tcl
language in order to provide more optimized I/O commands than native Tcl
commands do.
This library first provides a 'readFile' command which performs an open,
read, close of a given modulefile to fetch its content. Compared to the
Tcl native open, read, close commands it saves 1 ioctl + 1 fcntl + N
lstat system calls per modulefile.
numeric substrings numerically (mostly).
* lib/Makefile: Remove auto*-generated file.
* locate_module.c (SortedDirList): Ignore SCCS/ subdirs, too.
* configure.ac: Disable our "look" for RUNTEST; it drives auto*
crazy. Added the --with-file-collate={string,number} test, which
provides a way to enable USE_COLCOMP.
* ModuleCmd_Avail.c (fi_ent_cmp): USE_COLCOMP when told to do so.
* locate_module.c (filename_compare): Ditto.
* Makefile.am (modulecmd_LDFLAGS): lib is in the builddir, not the
srcdir.
(modulecmd_SOURCES): Added colcomp.c .