Commit Graph

60 Commits

Author SHA1 Message Date
Xavier Delaruelle
b9215747bc install: include generated config.{guess,sub} in dist
Include the lib/config.guess and lib/config.sub scripts in distribution
tarball if generated by autoreconf
2022-05-31 07:03:38 +02:00
Xavier Delaruelle
b7bd5aa56c Release of version 5.1.0 2022-04-30 08:13:22 +02:00
Xavier Delaruelle
e45eb859a1 ts/lib: test tcl ext lib against a failed sysconf call
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.
2022-03-31 13:06:26 +02:00
Lukáš Zaoral
14eabbd047 lib: handle sysconf failure in InitStateUsergroupsObjCmd
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
2022-03-31 13:06:26 +02:00
Xavier Delaruelle
b7d46f47d2 install: split lib build in two steps for coverage
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.
2021-08-01 16:18:20 +02:00
Xavier Delaruelle
8b05770867 lib: Tcl requirement moved to version 8.5+
Update Tcl Envmodules library to clean specific code required to raise
error on Tcl 8.4.

Bump version of Tcl Envmodules library to 1.4.0.
2021-07-25 10:17:18 +02:00
Xavier Delaruelle
2d4a7f9584 lib: re-license envmodules lib from GPLv3+ to GPLv2+
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
2021-02-28 19:11:03 +01:00
Xavier Delaruelle
1e7a098e7e ts: re-license test libraries from GPLv3+ to GPLv2+
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
2021-02-28 19:09:44 +01:00
Xavier Delaruelle
5cf1a53043 install: import new version of lib/tcl.m4
Import new version of tcl.m4 for compatibility with autoconf >=2.69.

File is imported from https://github.com/tcltk/tclconfig.
2021-02-17 16:04:04 +01:00
Xavier Delaruelle
9e5ea5d028 install: fix lib/configure.ac syntax for autoconf>=2.69 2021-02-17 16:04:04 +01:00
Xavier Delaruelle
94df593f4a install: pretty print on makefile build targets
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.
2021-02-17 16:04:03 +01:00
Xavier Delaruelle
a756e3034e lib: add must_have_cookie arg to readFile proc
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.
2021-01-10 20:42:05 +01:00
Xavier Delaruelle
3b9e293955 lib: bump version to 1.2.0 2020-09-23 06:50:49 +02:00
Xavier Delaruelle
b9cfc4d1bb lib: include missing stdio.h/_ISOC99_SOURCE for snprintf 2020-09-23 06:50:31 +02:00
Xavier Delaruelle
72ef59f412 ts/lib: test tcl ext lib against a failed mktime call
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.
2020-09-18 22:41:32 +02:00
Xavier Delaruelle
0e4e8caecc lib: implement parseDateTimeArg
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.
2020-09-18 06:50:26 +02:00
Xavier Delaruelle
f868cc2d11 ts/lib: test tcl ext lib against a failed time call
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.
2020-09-16 22:32:22 +02:00
Xavier Delaruelle
19353c1304 lib: implement initStateClockSeconds
Add function in libtclenvmodules to implement 'initStateClockSeconds' as
a Tcl command, which provides a more efficient way to retrieve current
Epoch time.
2020-09-16 22:32:22 +02:00
Xavier Delaruelle
7fac70834a Remove fetch_hidden arg on getFilesInDirectory proc
Always return hidden directory entries.

Update both pure-Tcl and C version of getFilesInDirectory procedure
2020-08-10 09:00:17 +02:00
Xavier Delaruelle
d72eb251ea ts/lib: test tcl ext lib against a dup ent res getgroups call
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.
2020-08-10 08:06:09 +02:00
Xavier Delaruelle
e4a3b4443d lib: remove dup from getgroups result
`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.
2020-08-10 08:06:09 +02:00
Xavier Delaruelle
87f8e51823 ts/lib: test tcl ext lib against a zero res getgroups call
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.
2020-07-16 21:53:51 +02:00
Xavier Delaruelle
1675363e0e ts/lib: test tcl ext lib against a failed getgrgid call
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.
2020-07-16 21:53:51 +02:00
Xavier Delaruelle
166096f4d8 ts/lib: test tcl ext lib against a failed getgroups call
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.
2020-07-16 21:53:51 +02:00
Xavier Delaruelle
4542008335 ts/lib: test tcl ext lib against a failed getpwuid call
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.
2020-07-16 21:53:51 +02:00
Xavier Delaruelle
452b3ffb25 lib: implement initStateUsergroups
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.
2020-07-16 21:53:51 +02:00
Xavier Delaruelle
11e6099aec lib: Implement initStateUsername
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.
2020-07-16 21:53:51 +02:00
Xavier Delaruelle
c26486718b lib: bump Envmodules lib version to 1.0.1
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
2019-08-09 21:17:56 +02:00
Xavier Delaruelle
a5d0c0e3c5 lib: bump copyright year mention 2019-08-09 21:15:10 +02:00
Xavier Delaruelle
dbea39b5bd ts/lib: test tcl ext lib against a failed closedir call
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.
2019-08-09 20:50:58 +02:00
Xavier Delaruelle
40477f8a3b lib: Tcl_GetBooleanFromObj already set err msg
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.
2019-08-08 21:16:43 +02:00
Xavier Delaruelle
31eafcf860 lib: directly return res of Envmodules_Init last op 2019-08-06 13:24:48 +02:00
Felix Neumärker
a220a7184c install: fix typo on CFLAGS definition in lib/Makefile
Fixes #287.
2019-08-05 17:42:21 +02:00
Xavier Delaruelle
1fc1c01615 install/ts: enable gcov on Modules Tcl ext lib
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).
2019-05-03 14:01:42 +02:00
Xavier Delaruelle
afeae10ec0 Take .modulerc at modulepath root into account
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.
2019-04-30 08:12:47 +02:00
Xavier Delaruelle
9b8e5981a7 Implement getFilesInDirectory in Tcl extension library
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.
2019-04-29 16:02:13 +02:00
Xavier Delaruelle
0356384fb8 install: fix lib/Makefile to ensure CFLAGS is applied
Which is required on FreeBSD to pass include location directives.
2019-04-29 16:02:13 +02:00
Xavier Delaruelle
3b3534089e lib: adapt error report to support Tcl8.4
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.
2019-04-29 16:02:13 +02:00
Xavier Delaruelle
6228cc661a install: adapt lib makefile to build with Tcl8.5
Add @TCL_SHLIB_CFLAGS@ flag to the CFLAGS_DEFAULT to ensure to obtain
the '-fPIC' directive on the resulting compiling command.
2019-04-29 16:02:13 +02:00
Xavier Delaruelle
b7c399c19a Add autotools configs to build libtclenvmodules
Build this extension library against Tcl stub library to be able to
'load' it in modulecmd.tcl script.
2019-04-29 15:56:23 +02:00
Xavier Delaruelle
3c360a9937 Introduce Modules Tcl extension library
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.
2019-04-29 15:56:23 +02:00
rkowen
86f2b63fc0 Merged in the modules_3_2_predeep_branch branch to the main trunk.
Removed the hash library.
2005-11-14 23:51:08 +00:00
harlan
005966c958 * Makefile.am (modulecmd_CFLAGS): Use X_CFLAGS and TCL_INCLUDES.
* lib/tests/Makefile.am (EXTRA_PROGRAMS): Renamed from
noinst_PROGRAMS.  Lose the .x suffixes.

* lib/Makefile.am (ACLOCAL_AMFLAGS): Look in ../config/ .
2002-09-18 05:47:48 +00:00
rkowen
a64995805f 2002-09-16 R.K. Owen <rk@owen.sj.ca.us>
* colcomp.c: removed
	* utility.c: added colcomp.c contents
	* Makefile.am: removed colcomp.c
	* main.c: Added DEF_COLLATE_BY_NUMBER output for --version
	* configure.ac: changed USE_COLCOMP to DEF_COLLATE_BY_NUMBER,
	  and added memdebug
	* locate_module.c: changed USE_COLCOMP and GetModuleName for deep dirs.
	* modules_def.h: check for HAVE_CONFIG_H, and added memdebug
	* ModuleCmd_List.c: Simplified using uvec objects
2002-09-16 16:49:28 +00:00
rkowen
6968b739c5 2002-09-12 R.K. Owen <rk@owen.sj.ca.us>
* .cvsignore: Ignore autogenerated files.
	* doc/.cvsignore: Ignore autogenerated files.
	* etc/.cvsignore: Ignore autogenerated files.
	* ext/.cvsignore: Ignore autogenerated files.
	* lib/.cvsignore: Ignore autogenerated files.
	* lib/tests/.cvsignore: Ignore autogenerated files.
	* modulefiles/.cvsignore: Ignore autogenerated files.
	* lib/tests/Makefile.am: Tweeked for autoreconf
2002-09-13 04:50:41 +00:00
rkowen
7c1163b194 2002-09-12 R.K. Owen <rk@owen.sj.ca.us>
* README: Updated the anonymous CVS invocation.
	* lib/aclocal.m4: Deleted auto* generated file.
	* lib/configure.ac: Tweeked to autoreconf
	* lib/Makefile.am: Tweeked to autoreconf
	* lib/uvec.h: Added uvec_strfree
	* lib/uvec/uvec_copy_str.c: Uses uvec string fns
	* lib/uvec/uvec_copy_vec.c: Uses uvec string fns
	* lib/uvec/uvec_strfree.c: New file: to dealloc uvec2str()
	generated strings
	* lib/tests/tuvec.c: Updated for uvec changes
2002-09-13 04:36:21 +00:00
harlan
a1c4dac800 * doc/Makefile.am: Added file.
* lib/configure: Remove auto*-generated file.
* lib/config.h.in: Ditto.
2002-09-12 06:50:08 +00:00
harlan
12b49d7233 * README: Update the instructions for using the CVS version of
modules.

* modulefiles/Makefile.in: Deleted auto* generated file.
* lib/tests/Makefile.in: Ditto.
* lib/Makefile.in: Ditto.
* init/Makefile.in: Ditto.
* ext/Makefile.in: Ditto.
* etc/Makefile.in: Ditto.
* doc/Makefile.in: Ditto.
* config/mkinstalldirs: Ditto.
* config/missing: Ditto.
* config/install-sh: Ditto.
* config/depcomp: Ditto.
* config/compile: Ditto.
* configure: Ditto.
* config.h.in: Ditto.
* aclocal.m4: Ditto.
* Makefile.in: Ditto.
2002-09-12 06:16:31 +00:00
harlan
200eb4e424 * colcomp.c: New file. Alternative collating algorithm that sorts
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 .
2002-09-12 05:59:26 +00:00
rkowen
c753d5a204 Added the memdebug headerfile and sources. 2002-08-27 21:07:44 +00:00