Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 462234 - sepolgen-1.1.8 uses subprocess.getstatusoutput which is not supported anymore
Summary: sepolgen-1.1.8 uses subprocess.getstatusoutput which is not supported anymore
Status: VERIFIED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Sven Vermeulen (RETIRED)
URL:
Whiteboard: selinux-utils
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-18 19:43 UTC by Sven Vermeulen (RETIRED)
Modified: 2013-04-11 17:52 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Vermeulen (RETIRED) gentoo-dev 2013-03-18 19:43:23 UTC
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
Comment 1 Sven Vermeulen (RETIRED) gentoo-dev 2013-03-18 19:44:54 UTC
This can be reproduced when using audit2allow with the "-M" option
Comment 2 Sven Vermeulen (RETIRED) gentoo-dev 2013-03-18 19:46:35 UTC
Fixed with sepolgen-1.1.8-r1, now in main tree (~arch)
Comment 3 Arfrever Frehtes Taifersar Arahesis 2013-03-18 23:26:30 UTC
(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().
Comment 4 Sven Vermeulen (RETIRED) gentoo-dev 2013-03-19 19:21:40 UTC
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.
Comment 5 Arfrever Frehtes Taifersar Arahesis 2013-03-19 20:13:46 UTC
You might continue using subprocess.Popen().
Comment 6 Sven Vermeulen (RETIRED) gentoo-dev 2013-04-11 17:52:25 UTC
Stabilized