← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~gholms/cloud-init/selinux-enabled into lp:cloud-init

 

Garrett Holmstrom has proposed merging lp:~gholms/cloud-init/selinux-enabled into lp:cloud-init.

Requested reviews:
  cloud init development team (cloud-init-dev)
Related bugs:
  Bug #1228441 in cloud-init: "restorecon blows up when selinux is disabled"
  https://bugs.launchpad.net/cloud-init/+bug/1228441

For more details, see:
https://code.launchpad.net/~gholms/cloud-init/selinux-enabled/+merge/186898

When libselinux-python is installed, but selinux is disabled on the instance, calls to restorecon blow up.  This fixes it by checking what is_selinux_enabled() returns first.
-- 
https://code.launchpad.net/~gholms/cloud-init/selinux-enabled/+merge/186898
Your team cloud init development team is requested to review the proposed merge of lp:~gholms/cloud-init/selinux-enabled into lp:cloud-init.
=== modified file 'cloudinit/util.py'
--- cloudinit/util.py	2013-09-11 12:30:35 +0000
+++ cloudinit/util.py	2013-09-21 00:08:25 +0000
@@ -161,13 +161,13 @@
         self.recursive = recursive
 
     def __enter__(self):
-        if self.selinux:
+        if self.selinux and self.selinux.is_selinux_enabled():
             return True
         else:
             return False
 
     def __exit__(self, excp_type, excp_value, excp_traceback):
-        if self.selinux:
+        if self.selinux and self.selinux.is_selinux_enabled():
             path = os.path.realpath(os.path.expanduser(self.path))
             do_restore = False
             try: