Bug 920707 - Certain included scripts can cause shlex to abort parsing
Summary: Certain included scripts can cause shlex to abort parsing
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: pykickstart
Version: 19
Hardware: All
OS: All
unspecified
low
Target Milestone: ---
Assignee: Chris Lumens
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-03-12 15:16 UTC by fedora.dm0
Modified: 2014-01-29 20:35 UTC (History)
2 users (show)

Fixed In Version: pykickstart-1.99.26-1
Clone Of:
Environment:
Last Closed: 2014-01-29 20:35:13 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
parser.py: Allow shlex to strip lines (1.10 KB, text/plain)
2013-03-12 15:16 UTC, fedora.dm0
no flags Details

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


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