Bug 1233223

Summary: createmodule scripts incorrectly handles env vars prefixed/suffixed without colon
Product: Red Hat Enterprise Linux 7 Reporter: Karel Srot <ksrot>
Component: environment-modulesAssignee: Jan Synacek <jsynacek>
Status: CLOSED ERRATA QA Contact: Stefan Kremen <skremen>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: skremen
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: Helper scripts shipped with environment-modules incorrectly handled environmental variables that were prefixed or suffixed with other delimiter than a colon. Consequence: Generated modules contained environment variables with incorrect values. Fix: Logic of the helper scripts was enhanced. Result: Modules are now generated with correct environment variables.
Story Points: ---
Clone Of: 1180139 Environment:
Last Closed: 2015-11-19 04:39:26 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1180139    

Description Karel Srot 2015-06-18 13:23:44 UTC
Seems to be present in RHEL-7 too, environment-modules-3.2.10-8.el7

+++ This bug was initially created as a clone of Bug #1180139 +++

RHEL6 clone of bug 1079341
Tested with environment-modules-3.2.10-2.el6

Description of problem:

createmodule scripts incorrectly handle the variables which old value is prefixed/suffixed with other than colon delimiter in the new env. It could cause problems when updating paths in environment:

# export TESTVAR2=origvalue
# export TESTVAR3=origvalue
# export TESTVAR8=origvalue
# export TESTVAR9=origvalue

# cat testscript.sh
export TESTVAR2=origvalue/suffix
export TESTVAR3=prefix/origvalue
### The following is not so crucial, but still:
export TESTVAR8=prefix/origvalue:
export TESTVAR9=prefix:origvalue:

# /usr/share/Modules/bin/createmodule.sh testscript.sh | tee mymodule
#%Module 1.0
append-path	TESTVAR2	origvalue/suffix
prepend-path	TESTVAR3	prefix/origvalue
prepend-path	TESTVAR8	prefix/
prepend-path	TESTVAR9	prefix:

# module load ./mymodule
# env | grep TESTVAR
TESTVAR3=prefix/origvalue:origvalue
TESTVAR2=origvalue:origvalue/suffix
TESTVAR8=prefix/:origvalue
TESTVAR9=prefix::origvalue



And then the same scenario using the Python script:

In the module:
append-path 	TESTVAR2 		/suffix
prepend-path 	TESTVAR3 		prefix
prepend-path 	TESTVAR8 		prefix
append-path 	TESTVAR8 		.
prepend-path 	TESTVAR8 		prefix
append-path 	TESTVAR8 		.
prepend-path 	TESTVAR9 		prefix
append-path 	TESTVAR9 		.
prepend-path 	TESTVAR9 		prefix
append-path 	TESTVAR9 		.


Expected:
TESTVAR2=origvalue/suffix
TESTVAR3=prefix/origvalue
TESTVAR8=prefix/origvalue:
TESTVAR9=prefix:origvalue:

Given:
TESTVAR2=origvalue:/suffix
TESTVAR3=prefix:origvalue
TESTVAR8=prefix:origvalue:.
TESTVAR9=prefix:origvalue:.



Version-Release number of selected component (if applicable):
environment-modules-3.2.10-8.fc21.x86_64
(applies for all 3.2.10-* )



Expected results:
Either implement better logic to handle these or mark prefixed/suffixed variables without colon as unhandled

Comment 6 errata-xmlrpc 2015-11-19 04:39:26 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2193.html