RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1033795 - Augeas lens bug: shellvars and multivariable export lines
Summary: Augeas lens bug: shellvars and multivariable export lines
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: augeas
Version: 6.5
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Dominic Cleal
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 1043815 1056252
TreeView+ depends on / blocked
 
Reported: 2013-11-22 23:17 UTC by Andrew Sanders
Modified: 2018-12-06 15:29 UTC (History)
5 users (show)

Fixed In Version: augeas-1.0.0-6.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1043815 (view as bug list)
Environment:
Last Closed: 2014-10-14 07:15:21 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Diff of changes to shellvars.aug (909 bytes, patch)
2013-11-22 23:19 UTC, Andrew Sanders
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1517 0 normal SHIPPED_LIVE augeas bug fix and enhancement update 2014-10-14 01:22:17 UTC

Description Andrew Sanders 2013-11-22 23:17:47 UTC
Description of problem:
The "shellvars" lens for augeas fails to load an environment file that contains an "export" command with multiple variables on the same line.

Version-Release number of selected component (if applicable):
augeas-1.0.0-5

How reproducible:
consistent

Steps to Reproduce:
1. Create a file with multiple variables on a single export line:

root@test:/u/test $ cat test_multi_export.shellvars
#!/bin/sh
TestVar1="test1"
TestVar2="test2"
export TestVar1 TestVar2

2. Then run "augtool --noautoload", load the file, and print the variables:

root@test:/u/test $ augtool --noautoload
augtool> set /augeas/load/test/lens "Shellvars.lns"
augtool> set /augeas/load/test/incl /u/test/test_multi_export.shellvars
augtool> load
augtool> print /files/u/test/test_multi_export.shellvars
augtool>



Actual results:
The variables TestVar1 and TestVar2 are not printed.

Expected results:
The variables TestVar1 and TestVar2 are printed.

Additional info:
Exporting the variables on their own separate "export" line works:

root@test:/u/test $ cat  test_single_export.shellvars 
#!/bin/sh
TestVar1="test1"
TestVar2="test2"
export TestVar1 
export TestVar2

Then run "augtool --noautoload", load the file, and print the variables:

root@test:/u/test $ augtool --noautoload
augtool> set /augeas/load/test/lens "Shellvars.lns"
augtool> set /augeas/load/test/incl /u/test/test_single_export.shellvars
augtool> load
augtool> print /files/u/test/test_single_export.shellvars
/files/u/test/test_single_export.shellvars
/files/u/test/test_single_export.shellvars/#comment = "!/bin/sh"
/files/u/test/test_single_export.shellvars/TestVar1 = "\"test1\""
/files/u/test/test_single_export.shellvars/TestVar2 = "\"test2\""
/files/u/test/test_single_export.shellvars/@export[1] = "TestVar1"
/files/u/test/test_single_export.shellvars/@export[2] = "TestVar2"
augtool>

Comment 1 Andrew Sanders 2013-11-22 23:19:36 UTC
Created attachment 828034 [details]
Diff of changes to shellvars.aug

Diff of changes to shellvars.aug to handle multiple variables on the same export line.  However, this may break backwards compatibility because it needs to handle the structure differently.

Comment 4 Dominic Cleal 2013-11-27 09:20:20 UTC
We can include multiple exports within a single node to avoid breaking compatibility in 1.0.0, e.g.

/files/u/test/test_single_export.shellvars/@export = "TestVar1 TestVar2"

Retargeting to 6.6.0 as this is a 6.5 package.

Comment 7 Lingfei Kong 2013-12-19 00:30:01 UTC
Can reproduce with augeas-1.0.0-5.el6,  the same steps and results with 'Description'

Steps to reproduce:
1. Create a script with multiple variables on a single export line:
[host]#cat test.sh 
#!/bin/sh
TestVar1="test1"
TestVar2="test2"
export TestVar1 TestVar2

2. Run "augtool --noautoload", load the file, and print the variables:
[host]#augtool --noautoload
augtool> set /augeas/load/test/lens "Shellvars.lns"
augtool> set /augeas/load/test/incl /root/test.sh
augtool> load
augtool> print /files/root/test.sh
augtool> 


Additional info:
Exporting the variables on their own separate "export" line works:
[host]#cat test.sh 
#!/bin/sh
TestVar1="test1"
TestVar2="test2"
#export TestVar1 TestVar2
export TestVar1
export TestVar1

Run "augtool --noautoload", load the file, and print the variables:
[host]#augtool --noautoload
augtool> set /augeas/load/test/lens "Shellvars.lns"
augtool> set /augeas/load/test/incl /root/test.sh
augtool> load
augtool> print /files/root/test.sh
/files/root/test.sh
/files/root/test.sh/#comment[1] = "!/bin/sh"
/files/root/test.sh/TestVar1 = "\"test1\""
/files/root/test.sh/TestVar2 = "\"test2\""
/files/root/test.sh/#comment[2] = "export TestVar1 TestVar2"
/files/root/test.sh/@export[1] = "TestVar1"
/files/root/test.sh/@export[2] = "TestVar1"
augtool>

Comment 11 Lingfei Kong 2014-06-04 09:23:32 UTC
Verified with augeas-1.0.0-6.el6

Steps to verify:
1. Create a script with multiple variables on a single export line:
#cat test.sh 
#!/bin/sh
TestVar1="test1"
TestVar2="test2"
export TestVar1 TestVar2

2. Run "augtool --noautoload", load the file, and print the variables:
#augtool --noautoload
augtool> set /augeas/load/test/lens "Shellvars.lns"
augtool> set /augeas/load/test/incl /root/test.sh
augtool> load
augtool> print /files/root/test.sh
/files/root/test.sh
/files/root/test.sh/#comment = "!/bin/sh"
/files/root/test.sh/TestVar1 = "\"test1\""
/files/root/test.sh/TestVar2 = "\"test2\""
/files/root/test.sh/@export = "TestVar1 TestVar2"

-------------------------------------------------
Exporting the variables on their own separate "export" line works:
#cat test.sh 
#!/bin/sh
TestVar1="test1"
TestVar2="test2"
#export TestVar1 TestVar2
export TestVar1
export TestVar1

Run "augtool --noautoload", load the file, and print the variables:
#augtool --noautoload
augtool> set /augeas/load/test/lens "Shellvars.lns"
augtool> set /augeas/load/test/incl /root/test.sh
augtool> load
augtool> print /files/root/test.sh
/files/root/test.sh
/files/root/test.sh/#comment[1] = "!/bin/sh"
/files/root/test.sh/TestVar1 = "\"test1\""
/files/root/test.sh/TestVar2 = "\"test2\""
/files/root/test.sh/#comment[2] = "export TestVar1 TestVar2"
/files/root/test.sh/@export[1] = "TestVar1"
/files/root/test.sh/@export[2] = "TestVar1"


Augeas works well with the above two method, so this bug is fixed

Comment 12 errata-xmlrpc 2014-10-14 07:15:21 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.

http://rhn.redhat.com/errata/RHBA-2014-1517.html


Note You need to log in before you can comment on or make changes to this bug.