Bug 1616395

Summary: grub2 doesn't handle relative paths correctly for UEFI HTTP Boot
Product: Red Hat Enterprise Linux 7 Reporter: Stephen Benjamin <stbenjam>
Component: grub2Assignee: Peter Jones <pjones>
Status: NEW --- QA Contact: Release Test Team <release-test-team>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.6CC: lzap, swadeley, tborcin, tbowling
Target Milestone: rcKeywords: Reopened
Target Release: ---Flags: stbenjam: needinfo? (pjones)
lzap: needinfo? (pjones)
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-04-05 12:59:10 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:
Bug Depends On:    
Bug Blocks: 1619274, 1619291    

Description Stephen Benjamin 2018-08-15 19:20:11 UTC
Description of problem:

grub2 UEFI HTTP boot fails to resolve relative paths correctly.  

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

How reproducible:

Steps to Reproduce:
1. Boot grub via UEFI HTTP
2. Configure grub.cfg to use a relative path, for example, given a menu entry like this:

menuentry 'Foreman Discovery Image' --id discovery {
  linuxefi boot/fdi-image/vmlinuz0 rootflags=loop root=live:/fdi.iso rootfstype=auto ro rd.live.image acpi=force rd.luks=0 rd.md=0 rd.dm=0 rd.lvm=0 rd.bootif=0 rd.neednet=0 nomodeset proxy.url=http://centos7-devel.astriaporta.example.com proxy.type=foreman BOOTIF=01-$mac
  initrdefi boot/fdi-image/initrd0.img

where boot/fdi-image/vmlinuz0 is relative to the location of the grubx64.efi image.

3. Try to boot

Actual results:
Grub immediately fails with:
 Fail to send a request! status=0xe

Expected results:
Host boots

Additional info:
- Using /pub/boot/fdi-image/vmlinuz0 works
- If looking at a tcpdump, grub is trying to do a DNS query for ""

Comment 2 Peter Jones 2019-04-05 12:59:10 UTC
This was fixed in 7.6 as part of a different bz.  Here's the relevant commit message:

From: Stephen Benjamin <stephen@redhat.com>
Date: Thu, 16 Aug 2018 16:58:51 -0400
Subject: [PATCH] Prepend prefix when HTTP path is relative

This sets a couple of variables.  With the url http://www.example.com/foo/bar :
http_path: /foo/bar
http_url: http://www.example.com/foo/bar

Related: rhbz#1490981

Comment 3 Stephen Benjamin 2019-04-12 13:06:56 UTC
This patch doesn't appear to be in any 7.6 builds, or even any builds I can find in Brew.

$ rpm -q --changelog grub2-efi-x64 | grep Prepend

$ rpm -q grub2-efi-x64

$ cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.6 (Maipo)

Comment 4 Stephen Benjamin 2019-04-12 14:50:47 UTC
There's also a really dumb mistake of mine in that patch, there's a PR to fix it: https://github.com/rhboot/grub2/pull/53