Skip to content

Commit

Permalink
chroot: add missing sys directory
Browse files Browse the repository at this point in the history
  • Loading branch information
aplanas committed Sep 12, 2019
1 parent 705e8cc commit 6b5ca46
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion salt/modules/chroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def exist(name):
'''
dev = os.path.join(name, 'dev')
proc = os.path.join(name, 'proc')
return all(os.path.isdir(i) for i in (name, dev, proc))
sys = os.path.join(name, 'sys')
return all(os.path.isdir(i) for i in (name, dev, proc, sys))


def create(name):
Expand All @@ -80,9 +81,11 @@ def create(name):
if not exist(name):
dev = os.path.join(name, 'dev')
proc = os.path.join(name, 'proc')
sys = os.path.join(name, 'sys')
try:
os.makedirs(dev, mode=0o755)
os.makedirs(proc, mode=0o555)
os.makedirs(sys, mode=0o555)
except OSError as e:
log.error('Error when trying to create chroot directories: %s', e)
return False
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/modules/test_chroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ def test_exist(self, isdir):
'''
Test if the chroot environment exist.
'''
isdir.side_effect = (True, True, True)
isdir.side_effect = (True, True, True, True)
self.assertTrue(chroot.exist('/chroot'))

isdir.side_effect = (True, True, False)
isdir.side_effect = (True, True, True, False)
self.assertFalse(chroot.exist('/chroot'))

@patch('os.makedirs')
Expand Down

0 comments on commit 6b5ca46

Please sign in to comment.