Bug 1787584

Summary: [BUG] Grubby prints sed error given some arguments
Product: Red Hat Enterprise Linux 8 Reporter: Oliver Falk <ofalk>
Component: grubbyAssignee: Bootloader engineering team <bootloader-eng-team>
Status: CLOSED ERRATA QA Contact: Release Test Team <release-test-team-automation>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 8.1CC: fmartine, peter.vreman, pjanda, pzatko
Target Milestone: rcKeywords: TestCaseNeeded
Target Release: 8.0Flags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: grubby-8.40-41.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 01:51:12 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: 1122832    
Attachments:
Description Flags
grubby-8.40-39.el8.x86_64.rpm none

Description Oliver Falk 2020-01-03 14:22:04 UTC
Description of problem:
The same command line used to work on RHEL6 and RHEL7, but now on RHEL 8 it doesn't any longer.

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


How reproducible: Always.


Steps to Reproduce:
1. # grubby --add-kernel=foo --initrd=bar --copy-default --title 'rebuild' --bad-image-okay 
2. # grubby --update-kernel=foo --args="ks=https://sat/unattended/provision?token="
sed: -e expression #1, char 29: unknown option to `s'


Actual results:
Sed error printed. See step 2 above.


Expected results:
No sed error.


Additional info:
grubby --update-kernel=foo --args="ks=https://sat/unattended/provision?token" => does NOT print any sed error.

It seems to be a combination of slash ('/') + equal sign ('='). Therefore, basically, all kickstart URLs will probably trigger this.

Running grubby-bls under bash -x reveals the following:
# bash -x /usr/libexec/grubby/grubby-bls --update-kernel=foo --args="ks=https://sat/unattended/provision?token="
[ ... ]
++ for arg in ${add_args[*]}
++ arg='ks=https://sat/unattended/provision?token'
+++ echo 'ks=https://sat/unattended/provision?token='
+++ sed -E 's/(^|[[:space:]])ks=https://sat/unattended/provision?token(([[:space:]]|$)|([=][^ ]*([$]*)))/ /g'
sed: -e expression #1, char 29: unknown option to `s'
[ ... ]


Customer case linked.

Comment 2 Petr Janda 2020-05-04 11:31:12 UTC
can be reproduced by reported args, but some issue is hidden on more lines

grubby --update-kernel=$KERNEL --args="/haha"
sed: -e expression #1, char 59: unknown option to `s'
or 
grubby --update-kernel=$KERNEL --args="x=/haha="
sed: -e expression #1, char 61: unknown option to `s'

Comment 5 Javier Martinez Canillas 2020-05-04 13:16:50 UTC
Created attachment 1684818 [details]
grubby-8.40-39.el8.x86_64.rpm

Could you please test with the attached test build?

Comment 6 Petr Janda 2020-05-04 14:08:16 UTC
with test build most errors disappeared (I did'n check if it works correctly though)
But I've foud one which prints error. I don't know how to fix it

# grubby --update-kernel=$KERNEL --args="some\/escaped\/slashes"
sed: -e expression #1, char 35: unknown option to `s'
sed: -e expression #1, char 30: unknown option to `s'

grubby --update-kernel=$KERNEL --args="\1"
sed: -e expression #1, char 30: invalid reference \1 on `s' command's RHS

using sed looks pretty fragile - but the attached build probably fixed Oliver's issue

Comment 7 Javier Martinez Canillas 2020-05-04 14:25:36 UTC
(In reply to Petr Janda from comment #6)
> with test build most errors disappeared (I did'n check if it works correctly
> though)
> But I've foud one which prints error. I don't know how to fix it
> 
> # grubby --update-kernel=$KERNEL --args="some\/escaped\/slashes"
> sed: -e expression #1, char 35: unknown option to `s'
> sed: -e expression #1, char 30: unknown option to `s'
> 
> grubby --update-kernel=$KERNEL --args="\1"
> sed: -e expression #1, char 30: invalid reference \1 on `s' command's RHS
>
> using sed looks pretty fragile - but the attached build probably fixed
> Oliver's issue

Agreed, this has gotten complex enough that needs to be written in a proper language.

Yes, the attached test package should contain fixes for Oliver's issue and also the first issue that you described.

Comment 15 errata-xmlrpc 2020-11-04 01:51:12 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 (grubby bug fix and enhancement update), 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://access.redhat.com/errata/RHBA-2020:4502