[Libguestfs] Weird results from g.sh()

Sam Eiderman sameid at google.com
Thu Aug 27 07:50:12 UTC 2020


Hi,

I'm using libguestfs 1.42,

When I run the following python3 commands on a rhel7.8:

print(g.ls('/sys'))
print(g.sh('ls /sys'))

I get:

[]
block
bus
class
dev
devices
firmware
fs
hypervisor
kernel
module
power

It seems that g.ls('/sys') is chrooted correctly.
But g.sh('ls /sys') isn't.

I came across this behavior when I used g.command(['grub2-mkconfig', '-o',
'....']) on rhel7.8 and it didn't produce the correct linuxefi/initrdefi
entries in grub, since in rhel7.8 the uefi detection algorithm is checking
in bash '[ -d /sys/firmware/efi ]'.
https://src.fedoraproject.org/rpms/grub2/blob/71e0fb4ea646071ec86e4a65bb24241e31c156bb/f/0106-Make-10_linux-work-with-our-changes-for-linux16-and-.patch

I thought I could simply g.mkdir_p('/sys/firmware/efi') - but that created
a fake dir in my chrooted environment, where grub2-mkconfig somehow was
inspecting the real /sys as demonstrated in the above 'ls' example.

Any ideas on why sh jailbreaks the chroot? is /sys set through some
environment variable?

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20200827/79aee018/attachment.htm>


More information about the Libguestfs mailing list