summaryrefslogtreecommitdiff
path: root/ironic/drivers/modules/image_utils.py
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2023-02-01 12:56:26 +0000
committerGerrit Code Review <review@openstack.org>2023-02-01 12:56:26 +0000
commit3c248bbb89ad8fc193279bd2052ed70f919f4b8f (patch)
tree12b993daf9bff1af01df765b9a7757b65e8cba7d /ironic/drivers/modules/image_utils.py
parent68efd7970d8db84d9127284294dda895c3b382ad (diff)
parent6210cae144d3b8fad48581065f74262e5d895282 (diff)
downloadironic-xena-em.tar.gz
Merge "Fix selinux context of published image hardlink" into stable/xenaxena-em18.3.0
Diffstat (limited to 'ironic/drivers/modules/image_utils.py')
-rw-r--r--ironic/drivers/modules/image_utils.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/ironic/drivers/modules/image_utils.py b/ironic/drivers/modules/image_utils.py
index 85834157b..424ecd37a 100644
--- a/ironic/drivers/modules/image_utils.py
+++ b/ironic/drivers/modules/image_utils.py
@@ -207,6 +207,16 @@ class ImageHandler(object):
try:
os.link(image_file, published_file)
os.chmod(image_file, self._file_permission)
+ try:
+ utils.execute(
+ '/usr/sbin/restorecon', '-i', '-R', 'v', public_dir)
+ except FileNotFoundError as exc:
+ LOG.debug(
+ "Could not restore SELinux context on "
+ "%(public_dir)s, restorecon command not found.\n"
+ "Error: %(error)s",
+ {'public_dir': public_dir,
+ 'error': exc})
except OSError as exc:
LOG.debug(