Package: selinux-basics
Version: 0.3.7
Severity: minor
Tags: patch
os.popen2() and os.popen3() are deprecated. The attached patch replaces these
in two test scripts.
--- /tmp/10_test_kernel_processes.py 2012-01-04 10:20:19.000000000 +0100
+++ /usr/share/selinux-basics/tests/10_test_kernel_processes.py 2012-01-04
15:13:49.000000000 +0100
@@ -16,13 +16,13 @@
@staticmethod
def test():
- import os
+ from subprocess import Popen, PIPE
badprocs = []
- (getin, getout) = os.popen2("getfilecon /proc/[0-9]*")
- getin.close()
- for line in getout.readlines():
+ pipe = Popen("getfilecon /proc/[0-9]*", shell=True, stdin=PIPE,
stdout=PIPE, close_fds=True)
+ pipe.stdin.close()
+ for line in pipe.stdout.readlines():
(dir, context) = line.split()
components = dir.split("/")
pid = components[-1]
@@ -34,7 +34,7 @@
file.close()
if badproc:
badprocs.append(pid)
- getout.close()
+ pipe.stdout.close()
if len(badprocs) > 0:
return [TestNoKernelT.ErrorBadKernelProcesses(badprocs)]
return []
--- /tmp/01_verify_init.py 2012-01-04 12:37:34.000000000 +0100
+++ /usr/share/selinux-basics/tests/01_verify_init.py 2012-01-04
15:13:14.000000000 +0100
@@ -12,14 +12,14 @@
@staticmethod
def test():
- import os
+ from subprocess import Popen, PIPE
contextok = False
- (getin, getout, geterr) = os.popen3("getfilecon /proc/1")
- getin.close()
+ pipe = Popen("getfilecon /proc/1", shell=True, stdin=PIPE,
stdout=PIPE, stderr=PIPE, close_fds=True)
+ pipe.stdin.close()
- for line in getout.readlines():
+ for line in pipe.stdout.readlines():
line = line.rstrip()
if line == "": continue
if line.endswith(":system_r:init_t") \
@@ -27,12 +27,12 @@
contextok = True
else:
print "..%s.." % line
- getout.close()
+ pipe.stdout.close()
- for line in geterr.readlines():
+ for line in pipe.stderr.readlines():
if line.find("failed") >= 0:
contextok = "failed"
- geterr.close()
+ pipe.stderr.close()
if contextok == "failed":
return [TestInitDomain.ErrorGetfileconFailed()]
HTH
--
Robert Bihlmeyer ASSIST Arrow ECS Internet Security AG
<[email protected]> A-1100 Wien, Wienerbergstraße 11
Tel: +43 1 370 94 40 Fax: +43 1 370 94 40-333