Bug 681478

Summary: ( ) compound list is altering environment
Product: Red Hat Enterprise Linux 6 Reporter: Wolf-Dietrich <wolf-dietrich>
Component: kshAssignee: Michal Hlavinka <mhlavink>
Status: CLOSED ERRATA QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 6.0CC: mfranc, ovasik, prc
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Previously, a ( ) compound list did not always use a copy of the environment which caused the original environment to be altered. Scripts could behave unexpectedly because their variables could be changed. With this update, a copy of the environment is always used for a ( ) compound list; thus, the original environment is not affected by commands from the ( ) compound list.
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-05-19 13:50:27 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
mini scripts to be sourced and Readme (description) none

Description Wolf-Dietrich 2011-03-02 10:05:46 UTC
Created attachment 481832 [details]
mini scripts to be sourced and Readme (description)

Description of problem:

( . ./xx )  ##### first call modifies local environment
( . ./xx )  ##### secon call core dump sigsev 

Version-Release number of selected component:
Name        : ksh                          
Relocations : (not relocatable)
Version     : 20100621                          
Vendor      : Red Hat, Inc.
Release     : 2.el6                         
Build Date  : Tue Jun 29 14:40:26 2010
Install Date: Fri Jan 28 16:03:02 2011         
Build Host  : ls20-bc2-13.build.redhat.com
Group       : System Environment/Shells     
Source RPM  : ksh-20100621-2.el6.src.rpm
Size        : 1478609                          
Signature   : RSA/8, Mon Aug 16 17:39:17 2010, Key ID 199e2f91fd431d51
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>


How reproducible:
unpack attachment (tar)
see Readme
call ksh and follow instructions from Readme


Expected results:
current environemnt must not be modified


Additional info:
works in redhat 5.5 
ubuntu all versions
SunOS 9,10
....

Comment 2 Michal Hlavinka 2011-03-02 12:35:35 UTC
(In reply to comment #0)
> ( . ./xx )  ##### first call modifies local environment
> ( . ./xx )  ##### secon call core dump sigsev 

this is already fixed in new ksh package prepared for next rhel6 update

> How reproducible:
> unpack attachment (tar)
> see Readme
> call ksh and follow instructions from Readme

the "y1" reproducer is not fixed yet, I'll look at it

> Additional info:
> works in redhat 5.5 
> ubuntu all versions
> SunOS 9,10
> ....

it works there because they use older ksh versions which suffer from other bugs

"y1" reproducer bug got introduced between 2010-03-09 (working) and 2010-05-27 (broken)

Comment 3 Michal Hlavinka 2011-03-02 13:02:46 UTC
simplified reproducers for "y1" bug:
a) 
RET=$(ksh -c '( function fx { export X=123;  } ; fx; ); echo $X')
[ -z "$RET" ] && echo "works fine" || echo "bug present"

b)
RET=$(ksh -c 'echo "/bin/true; function fx { export X=123; } ; fx;" >/tmp/kshtest; ( . /tmp/kshtest >/dev/null  ); echo $X; rm -f /tmp/kshtest')
[ -z "$RET" ] && echo "works fine" || echo "bug present"

Comment 9 Martin Prpič 2011-03-16 16:01:16 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Previously, a ( ) compound list did not always use a copy of the environment which caused the original environment to be altered. Scripts could behave unexpectedly because their variables could be changed. With this update, a copy of the environment is always used for a ( ) compound list; thus, the original environment is not affected by commands from the ( ) compound list.

Comment 10 errata-xmlrpc 2011-05-19 13:50:27 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0645.html