From 2b1bb959c787b61de4e0e8270f465e09568bd3f1 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Tue, 28 Jul 2020 06:39:23 -0400 Subject: [PATCH] import scl-utils-2.0.2-12.el8 --- ...dapt-env-parser-to-new-module-output.patch | 76 +++++++++++++++++++ SPECS/scl-utils.spec | 6 +- 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 SOURCES/BZ-1618803-adapt-env-parser-to-new-module-output.patch diff --git a/SOURCES/BZ-1618803-adapt-env-parser-to-new-module-output.patch b/SOURCES/BZ-1618803-adapt-env-parser-to-new-module-output.patch new file mode 100644 index 0000000..f50070d --- /dev/null +++ b/SOURCES/BZ-1618803-adapt-env-parser-to-new-module-output.patch @@ -0,0 +1,76 @@ +commit 98fe4dcef136eaaa323f1729c11f38b2b19b3a42 +Author: Michal Domonkos +Date: Mon Jan 13 17:04:41 2020 +0100 + + Adapt env parser to newer module(1) versions. BZ 1618803 + + With module(1) version 4.x and later (tcl-based), the command + + MODULE_CMD sh load + + prints a newline after each export line, breaking our parsing logic in + get_env_vars() which just tokenizes the output by semicolons and does + not anticipate newlines. As a result, we would end up with + "\nKEY=VALUE" pairs and pass them as such to putenv(3) which then has no + effect. + + The fix is easy; just strip the leading newline from the KEY=VALUE pairs + if present. This ensures we stay compatible with the older module(1) + versions as well. + + A simple reproducer follows: + + 1) Make scl(1) run in "modulefile" mode by creating a modulefile in + /etc/scl/modulefiles corresponding to a collection, for example: + + $ /usr/share/Modules/bin/createmodule.sh /opt/rh/eap7/enable \ + > /etc/scl/modulefiles/eap7 + + 2) Run a simple scl(1) command to detect the presence of an env var + that we know should be set in the target collection, for example: + + $ scl enable eap7 'echo $LOADEDMODULES' + + Previously, there would be no output. With this commit, the output + should be "eap7". + +diff --git a/src/scllib.c b/src/scllib.c +index 3c32d65..a182194 100644 +--- a/src/scllib.c ++++ b/src/scllib.c +@@ -52,7 +52,7 @@ static scl_rc get_env_vars(const char *colname, char ***_vars) + char *argv[] = {MODULE_CMD, MODULE_CMD, "sh", "add", "", NULL}; + char *output = NULL; + int i = 0; +- char **parts, **vars; ++ char **parts, *part, **vars; + scl_rc ret = EOK; + + ret = initialize_env(); +@@ -73,16 +73,21 @@ static scl_rc get_env_vars(const char *colname, char ***_vars) + * Expected format of string stored in variable output is following: + * var1=value1 ;export value1 ; var2=value2 ;export value2; + * var3=value\ with\ spaces ++ * NOTE: Newer (tcl-based) versions of MODULE_CMD put a newline after each ++ * export command so we need to take that into account. + */ + + vars = parts = split(output, ';'); + + /* Filter out strings without "=" i. e. strings with export. */ +- while (*parts != NULL) { +- if (strchr(*parts, '=')) { +- strip_trailing_chars(*parts, ' '); +- unescape_string(*parts); +- vars[i++] = xstrdup(*parts); ++ while (*parts != NULL) { ++ part = *parts; ++ if (part[0] == '\n') ++ part++; ++ if (strchr(part, '=')) { ++ strip_trailing_chars(part, ' '); ++ unescape_string(part); ++ vars[i++] = xstrdup(part); + } + parts++; + } diff --git a/SPECS/scl-utils.spec b/SPECS/scl-utils.spec index b9d166f..44b1ada 100644 --- a/SPECS/scl-utils.spec +++ b/SPECS/scl-utils.spec @@ -3,7 +3,7 @@ Name: scl-utils Epoch: 1 Version: 2.0.2 -Release: 11%{?dist} +Release: 12%{?dist} Summary: Utilities for alternative packaging License: GPLv2+ @@ -18,6 +18,7 @@ Requires: %{_bindir}/modulecmd Patch1: 0003-Scl-utils-layout-patch-from-fedora-famillecollet.com.patch Patch2: 0004-define-macro-python-explicitly.patch +Patch3: BZ-1618803-adapt-env-parser-to-new-module-output.patch %description Run-time utility for alternative packaging. @@ -80,6 +81,9 @@ ln -s prefixes conf %{_rpmconfigdir}/brp-scl-python-bytecompile %changelog +* Mon Feb 17 2020 Michal Domonkos - 1:2.0.2-12 +- Adapt env parser to new module(1) output (#1618803) + * Fri Aug 16 2019 Pavlina Moravcova Varekova - 1:2.0.2-11 - reverted sci-utils-build own the pkgconfig directory (#1431962)