
from OSEncryptionState import *

class SelinuxState(OSEncryptionState):
    def __init__(self, context):
        super(SelinuxState, self).__init__('SelinuxState', context)

    def enter(self):
        if not super(SelinuxState, self).should_enter():
            return

        self.context.logger.log("Entering selinux state")

    def should_exit(self):
        self.context.logger.log("Verifying if machine should exit selinux state")

        return super(SelinuxState, self).should_exit()


from OSEncryptionState import *

class SelinuxState(OSEncryptionState):
    def __init__(self, context):
        super(SelinuxState, self).__init__('SelinuxState', context)

    def enter(self):
        if not super(SelinuxState, self).should_enter():
            return

        self.context.logger.log("Entering selinux state")

        se_linux_status = self.context.encryption_environment.get_se_linux()
        if(se_linux_status.lower() == 'enforcing'):
            self.context.logger.log("SELinux is in enforcing mode, disabling")
            self.context.encryption_environment.disable_se_linux()

    def should_exit(self):
        self.context.logger.log("Verifying if machine should exit selinux state")

        return super(SelinuxState, self).should_exit()

Disable SELinux before OS disk encryption
Disable SELinux before OS disk encryption

  
  from OSEncryptionState import *
  
  class SelinuxState(OSEncryptionState):
      def __init__(self, context):
          super(SelinuxState, self).__init__('SelinuxState', context)
  
      def enter(self):
          if not super(SelinuxState, self).should_enter():
              return
  
          self.context.logger.log("Entering selinux state")
  
+         se_linux_status = self.context.encryption_environment.get_se_linux()
+         if(se_linux_status.lower() == 'enforcing'):
+             self.context.logger.log("SELinux is in enforcing mode, disabling")
+             self.context.encryption_environment.disable_se_linux()
+ 
      def should_exit(self):
          self.context.logger.log("Verifying if machine should exit selinux state")
  
          return super(SelinuxState, self).should_exit()
  
Disable SELinux before OS disk encryption
## Code Before:

from OSEncryptionState import *

class SelinuxState(OSEncryptionState):
    def __init__(self, context):
        super(SelinuxState, self).__init__('SelinuxState', context)

    def enter(self):
        if not super(SelinuxState, self).should_enter():
            return

        self.context.logger.log("Entering selinux state")

    def should_exit(self):
        self.context.logger.log("Verifying if machine should exit selinux state")

        return super(SelinuxState, self).should_exit()

## Instruction:
Disable SELinux before OS disk encryption
## Code After:

from OSEncryptionState import *

class SelinuxState(OSEncryptionState):
    def __init__(self, context):
        super(SelinuxState, self).__init__('SelinuxState', context)

    def enter(self):
        if not super(SelinuxState, self).should_enter():
            return

        self.context.logger.log("Entering selinux state")

        se_linux_status = self.context.encryption_environment.get_se_linux()
        if(se_linux_status.lower() == 'enforcing'):
            self.context.logger.log("SELinux is in enforcing mode, disabling")
            self.context.encryption_environment.disable_se_linux()

    def should_exit(self):
        self.context.logger.log("Verifying if machine should exit selinux state")

        return super(SelinuxState, self).should_exit()
