aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2013-08-21 17:11:49 +0100
committerBryn M. Reeves <bmr@redhat.com>2013-08-21 17:11:49 +0100
commit5356d086ec9714fd636c2970d9c58a5dfb8bfdca (patch)
treeca0cc70b229b18763a4680eb330cb499b73929b2
parent80ad174d5d7c712dff9a3781e02ecfa5f8e9e368 (diff)
downloadsos-5356d086ec9714fd636c2970d9c58a5dfb8bfdca.tar.gz
Add Plugin method to build command output paths
Add a convenience method to construct an absolute path for command output from a relative path or file name. This can be used for e.g. to pass an output path to an external program that produces output at a named path rather than on stdout and can be used internally by the Plugin.make_cmd_dirs() method. Convert the SELinux plug-in to use the new method when passing output paths to the semanage command. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/__init__.py16
-rw-r--r--sos/plugins/selinux.py5
2 files changed, 15 insertions, 6 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index 0e9e4c3d..2eb160e1 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -498,14 +498,24 @@ class Plugin(object):
def get_cmd_path(self):
"""Return a path into which this module should store collected
- command output"""
+ command output
+ """
return os.path.join(self.archive.get_tmp_dir(),
'sos_commands', self.name())
+ def make_cmd_path(self, path):
+ """Return a string representing an absolute path within this
+ plug-in's command output directory by apending the relative path
+ name 'path'.
+ """
+ return os.path.join(self.get_cmd_path(), path)
+
+
def make_cmd_dirs(self, path):
"""Recursively create new subdirectories under this plug-in's
- command output path."""
- os.makedirs(self.get_cmd_path(), path)
+ command output path.
+ """
+ os.makedirs(self.make_cmd_path(path))
def file_grep(self, regexp, *fnames):
"""Returns lines matched in fnames, where fnames can either be
diff --git a/sos/plugins/selinux.py b/sos/plugins/selinux.py
index daa1bf77..b5aff468 100644
--- a/sos/plugins/selinux.py
+++ b/sos/plugins/selinux.py
@@ -34,9 +34,8 @@ class SELinux(Plugin, RedHatPlugin):
self.add_cmd_output("selinuxconlist root")
self.add_cmd_output("selinuxexeccon /bin/passwd")
self.add_cmd_output("ausearch -m avc,user_avc -ts today")
- semanage_custom_dest = join(self.get_cmd_path(),
- "selinux.custom")
- self.add_cmd_output("semanage -o %s" % semanage_custom_dest)
+ self.add_cmd_output("semanage -o %s"
+ % self.make_cmd_path("selinux.custom"))
if self.get_option('fixfiles'):
self.add_cmd_output("fixfiles -v check")
if self.get_option('list'):