Skip to content
This repository has been archived by the owner on Oct 10, 2020. It is now read-only.

Commit

Permalink
Do not call any selinux methods if selinux is disabled
Browse files Browse the repository at this point in the history
Closes: #1213
Approved by: giuseppe
  • Loading branch information
dirkboye authored and rh-atomic-bot committed Mar 27, 2018
1 parent 56c32ae commit cf17675
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Atomic/syscontainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,15 @@ def _create_rootfs(self, rootfs):
:param rootfs: The root file system path.
:type rootfs: str
"""
if os.getuid() == 0 and selinux.is_selinux_enabled() != 0:
if os.getuid() == 0 and selinux.is_selinux_enabled():
label = selinux.getfilecon("/")[1]
selinux.setfscreatecon_raw(label)

try:
os.makedirs(rootfs)
finally:
selinux.setfscreatecon_raw(None)
if selinux.is_selinux_enabled():
selinux.setfscreatecon_raw(None)

def build_rpm(self, repo, name, image, values, destination):
"""
Expand Down

0 comments on commit cf17675

Please sign in to comment.