The current spolgen code uses the following code: """ rc, output = subprocess.getstatusoutput(command) """ This is not supported by the subprocess module anymore. Improved code should be: """ pipe = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True, universal_newlines=True) output = "".join(pipe.stdout.readlines()) rc = pipe.wait() """ If not changed, then audit2allow fails with the following error: """ File /usr/lib64/python2.7/site-packages/sepolgen/module.py", line 133, in run rc, output = subprocess.getstatusoutput(command) AttributeError: 'module' object has no attribute 'getstatusoutput' """ Reproducible: Always
This can be reproduced when using audit2allow with the "-M" option
Fixed with sepolgen-1.1.8-r1, now in main tree (~arch)
(In reply to comment #0) > The current spolgen code uses the following code: > > """ > rc, output = subprocess.getstatusoutput(command) > """ > > This is not supported by the subprocess module anymore. This diagnosis is wrong. Python 2 has commands module with commands.getoutput() and commands.getstatusoutput() functions (and other functions), and does not have any subprocess.get*() functions. commands module has been deleted in Python 3, and 2 functions were moved from commands module to subprocess module: subprocess.getoutput() and subprocess.getstatusoutput(). Patchset created by Swift for sepolgen contains 0001-2to3-updates.patch, which unconditionally replaces Python-2-specific commands.getstatusoutput() with Python-3-specific subprocess.getstatusoutput().
So we should use commands.getstatusoutput() for python-2 and subprocess.getstatusoutput() for python-3? Is there a method that works for both python versions? The code below is copied from a bugreport elsewhere that had a similar problem, and seems to work with both python-2 and python-3, but looks a bit like over-engineering a solution for a simple problem.
You might continue using subprocess.Popen().
Stabilized