Skip to content

Commit

Permalink
cmdmod: add sysfs into the chroot
Browse files Browse the repository at this point in the history
Some commands executed inside the chroot require access to the /sys
information. For example, /sys/firmware is used to get to information
from UEFI systems.

This patch mount a sysfs file system inside the chroot.

Also normalize the name for devtmpfs, replacing the old udev one.
  • Loading branch information
aplanas committed Jan 15, 2019
1 parent bb9d52b commit 2b5d45a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion salt/modules/cmdmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -3231,12 +3231,16 @@ def run_chroot(root,
'''
__salt__['mount.mount'](
os.path.join(root, 'dev'),
'udev',
'devtmpfs',
fstype='devtmpfs')
__salt__['mount.mount'](
os.path.join(root, 'proc'),
'proc',
fstype='proc')
__salt__['mount.mount'](
os.path.join(root, 'sys'),
'sysfs',
fstype='sysfs')

# Execute chroot routine
sh_ = '/bin/sh'
Expand Down Expand Up @@ -3290,6 +3294,7 @@ def run_chroot(root,
log.error('Processes running in chroot could not be killed, '
'filesystem will remain mounted')

__salt__['mount.umount'](os.path.join(root, 'sys'))
__salt__['mount.umount'](os.path.join(root, 'proc'))
__salt__['mount.umount'](os.path.join(root, 'dev'))
if hide_output:
Expand Down

0 comments on commit 2b5d45a

Please sign in to comment.