Sandro Bonazzola has uploaded a new change for review.

Change subject: packaging: setup: handle ssh selinux context
......................................................................

packaging: setup: handle ssh selinux context

Restore ~/.ssh selinux context if selinux is enabled
on the system.

Change-Id: I4ffe0a5f5509a74318b73ee2c4d72cb2bd9a6ddf
Bug-Url: https://bugzilla.redhat.com/1034786
Signed-off-by: Sandro Bonazzola <sbona...@redhat.com>
---
M src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
1 file changed, 36 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup 
refs/changes/43/21843/1

diff --git a/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py 
b/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
index b107dde..e8d975b 100644
--- a/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
+++ b/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
@@ -140,6 +140,24 @@
                                 ],
                             )
                         )
+        if self._selinux_enabled:
+            path = os.path.join(
+                os.path.expanduser('~root'),
+                '.ssh'
+            )
+            rc, stdout, stderr = self.execute(
+                (
+                    self.command.get('restorecon'),
+                    '-r',
+                    path
+                )
+            )
+            if rc != 0:
+                self.logger.error(
+                    _('Failed to refresh SELINUX context for {path}').format(
+                        path=path
+                    )
+                )
 
     def _getIPAddress(self):
         address = None
@@ -235,12 +253,15 @@
             ohostedcons.EngineEnv.APP_HOST_NAME,
             None
         )
+        self._selinux_enabled = False
 
     @plugin.event(
         stage=plugin.Stages.STAGE_SETUP,
     )
     def _setup(self):
         self.command.detect('ip')
+        self.command.detect('selinuxenabled')
+        self.command.detect('restorecon')
 
     @plugin.event(
         stage=plugin.Stages.STAGE_CUSTOMIZATION,
@@ -324,6 +345,21 @@
         )
 
     @plugin.event(
+        stage=plugin.Stages.STAGE_VALIDATION,
+    )
+    def _validation(self):
+        if self.command.get('selinuxenabled', optional=True) is None:
+            self._selinux_enabled = False
+        else:
+            rc, stdout, stderr = self.execute(
+                (
+                    self.command.get('selinuxenabled'),
+                ),
+                raiseOnError=False,
+            )
+            self._selinux_enabled = rc == 0
+
+    @plugin.event(
         stage=plugin.Stages.STAGE_CLOSEUP,
         after=(
             ohostedcons.Stages.ENGINE_ALIVE,


-- 
To view, visit http://gerrit.ovirt.org/21843
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4ffe0a5f5509a74318b73ee2c4d72cb2bd9a6ddf
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-setup
Gerrit-Branch: master
Gerrit-Owner: Sandro Bonazzola <sbona...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to