Bug 920707

Summary: Certain included scripts can cause shlex to abort parsing
Product: [Fedora] Fedora Reporter: fedora.dm0
Component: pykickstartAssignee: Chris Lumens <clumens>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: 19CC: bcl, clumens
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: pykickstart-1.99.26-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-01-29 20:35:13 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:
Attachments:
Description Flags
parser.py: Allow shlex to strip lines none

Description fedora.dm0 2013-03-12 15:16:25 UTC
Created attachment 709024 [details]
parser.py: Allow shlex to strip lines

Description of problem:
I had a long command in a %post section, which I moved to a separate file to be included.  The command spanned multiple lines.

In parser.py, rstrip is performed on the first command line in an included file, and the result is run through shlex.split.  However, with the newline stripped, shlex sees a dangling escape character and aborts.  (After looking at the code, another abort condition would be a quoted comment character: `echo 'this # explodes'`.)

Version-Release number of selected component (if applicable):
git master

How reproducible:
always

Steps to Reproduce:
1. Write a kickstart file that uses %include in a %post section.
2. Have the included file's first command line end with "\" or contain "'#'".
3. Run livecd-creator on the kickstart.

Actual results:
Direct string manipulation causes shlex to abort parsing.

Expected results:
It should successfully include the script file and parse the kickstart file.

Additional info:
The attached patch is a workaround I've been using.  I believe it should provide equivalent behavior for any lines that do not contain a quoted comment character or line continuation, but it will not longer abort when kickstart commands use line continuations either (in case that was intentional).

Comment 1 Chris Lumens 2013-03-12 15:25:54 UTC
Do you have a couple examples I could use as test cases in the future?

Comment 2 fedora.dm0 2013-03-12 15:46:05 UTC
Here is a bash session to reproduce both errors with Fedora's kickstarts.

cp -a /usr/share/spin-kickstarts wd
cd wd
sed -i -e '/%post/a%include test.sh' fedora-livecd-desktop.ks
echo $': this is a \\\n long command' > test.sh
sudo livecd-creator fedora-livecd-desktop.ks
echo ": 'quoted # comment'" > test.sh
sudo livecd-creator fedora-livecd-desktop.ks

Comment 3 Chris Lumens 2013-03-22 13:58:21 UTC
Thanks for the patch.

Comment 4 Fedora End Of Life 2013-04-03 20:24:20 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle.
Changing version to '19'.

(As we did not run this process for some time, it could affect also pre-Fedora 19 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.)

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora19