File: 00_selinuxenabled.py

package info (click to toggle)
selinux-basics 0.5.0
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 140 kB
  • sloc: python: 279; sh: 217; perl: 43; makefile: 26
file content (25 lines) | stat: -rw-r--r-- 618 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class TestSELinuxEnabled(TestBase):
	"""
	Test that selinux is enabled, by calling selinuxenabled
	"""
	class ErrorNotEnabled(ErrorBase):
		def __str__(self):
			return "SELinux is not enabled."

	class ErrorCouldNotTest(ErrorBase):
		def __str__(self):
			return "Couldn't test if selinux is enabled."

	@staticmethod
	def test():
		import os
		status = os.system("selinuxenabled")
		if not os.WIFEXITED(status):
			return [TestSELinuxEnabled.ErrorCouldNotTest()]

		exitcode = os.WEXITSTATUS(status)
		if exitcode != 0:
			return [TestSELinuxEnabled.ErrorNotEnabled()]
		return []

register_test(TestSELinuxEnabled)