File: 25_udev_relabel.py

package info (click to toggle)
selinux-basics 0.6.0
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 144 kB
  • sloc: python: 280; sh: 120; perl: 95; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 621 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
class TestRestoreconUdev(TestBase):
	"""
	Check that there is a restorecon call in /etc/init.d/udev
	"""
	class ErrorUdevRelabel(ErrorBase):
		def __str__(self):
			return "udev will create nodes not labeled correctly"

	@staticmethod
	def test():
		import os, re
		r = re.compile(r'(restorecon|relabel)')

		if os.access("/etc/init.d/udev", os.F_OK):
			udevrelabel = False
			f = open("/etc/init.d/udev","r")
			for line in f.readlines():
				if r.search(line):
					udevrelabel = True
			f.close()
			if not udevrelabel:
				return [TestRestoreconUdev.ErrorUdevRelabel()]
		return []
register_test(TestRestoreconUdev)