aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/sos/plugins/selinux.py9
-rw-r--r--src/lib/sos/plugintools.py35
-rwxr-xr-xsrc/lib/sos/policyredhat.py23
3 files changed, 34 insertions, 33 deletions
diff --git a/src/lib/sos/plugins/selinux.py b/src/lib/sos/plugins/selinux.py
index 2e56964a..925c2ad7 100644
--- a/src/lib/sos/plugins/selinux.py
+++ b/src/lib/sos/plugins/selinux.py
@@ -13,6 +13,7 @@
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import sos.plugintools
+import commands
class selinux(sos.plugintools.PluginBase):
"""This plugin gathers selinux related information
@@ -25,3 +26,11 @@ class selinux(sos.plugintools.PluginBase):
self.collectExtOutput("/bin/rpm -q -V selinux-policy-strict")
return
+ def checkenabled(self):
+ # is selinux enabled ?
+ try:
+ if commands.getoutput("/usr/sbin/sestatus").split(":")[1].strip() == "disabled":
+ return False
+ except:
+ pass
+ return True
diff --git a/src/lib/sos/plugintools.py b/src/lib/sos/plugintools.py
index 3d80df44..15fccfdf 100644
--- a/src/lib/sos/plugintools.py
+++ b/src/lib/sos/plugintools.py
@@ -85,7 +85,7 @@ class PluginBase:
except KeyboardInterrupt:
raise KeyboardInterrupt
except Exception, e:
- self.cInfo['soslog'].error("Problem at path %s (%s)\n" % (abspath,e))
+ self.cInfo['soslog'].warning("Problem at path %s (%s)\n" % (abspath,e))
break
return False
@@ -141,7 +141,7 @@ class PluginBase:
except KeyboardInterrupt:
raise KeyboardInterrupt
except Exception, e:
- self.cInfo['soslog'].error("Problem at path %s (%s)" % (srcpath+'/'+afile, e))
+ self.cInfo['soslog'].warning("Problem at path %s (%s)" % (srcpath+'/'+afile, e))
# if on forbidden list, abspath is null
if not abspath == '':
dstslname = sosRelPath(self.cInfo['rptdir'], abspath)
@@ -156,22 +156,8 @@ class PluginBase:
except KeyboardInterrupt:
raise KeyboardInterrupt
except Exception, e:
- self.cInfo['soslog'].error("Problem at path %s (%s)" % (srcpath, e))
+ self.cInfo['soslog'].debug("Problem at path %s (%s)" % (srcpath, e))
-
- # Recurse to copy whatever it points to
- newpath = os.path.normpath(os.path.join(os.path.dirname(srcpath), link))
- try:
- self.doCopyFileOrDir(newpath)
- except SystemExit:
- raise SystemExit
- except KeyboardInterrupt:
- raise KeyboardInterrupt
- except EnvironmentError, (errno, strerror):
- if (errno != 17):
- # we ignore 'file exists' errors
- self.cInfo['soslog'].error("Problem at path %s ([%d] %s)" % (newpath, errno, strerror))
-
return abspath
else:
@@ -195,7 +181,7 @@ class PluginBase:
"""
try:
# pylint: disable-msg = W0612
- status, shout, sherr, runtime = sosGetCommandOutput("/bin/cp --parents -p " + src +" " + self.cInfo['dstroot'])
+ status, shout, sherr, runtime = sosGetCommandOutput("/bin/cp --parents -P --preserve=mode,ownership,timestamps,links " + src +" " + self.cInfo['dstroot'])
if status:
self.cInfo['soslog'].debug(shout)
self.cInfo['soslog'].debug(sherr)
@@ -272,10 +258,9 @@ class PluginBase:
""" Execute a command independantly of the output gathering part of
sosreport
"""
- # First check to make sure the binary exists and is runnable.
+ # Log if binary is not runnable or does not exist
if not os.access(prog.split()[0], os.X_OK):
- self.cInfo['soslog'].log(logging.VERBOSE2, "Binary '%s' does not exist or is not runnable" % prog.split()[0])
- return
+ self.cInfo['soslog'].log(logging.VERBOSE, "binary '%s' does not exist or is not runnable" % prog.split()[0])
# pylint: disable-msg = W0612
status, shout, sherr, runtime = sosGetCommandOutput(prog)
@@ -333,6 +318,7 @@ class PluginBase:
outfd.close()
if root_symlink:
+ # FIXME: use python's internal commands
os.system('cd "%s" && ln -s "%s" "%s"' % (self.cInfo['dstroot'], outfn[len(self.cInfo['dstroot'])+1:], root_symlink))
if len(sherr) > 0:
@@ -422,6 +408,13 @@ class PluginBase:
except:
self.cInfo['soslog'].log(logging.VERBOSE, "Error collecting output of '%s'" % prog,)
+ def get_description(self):
+ """ This function will return the description for the plugin"""
+ try:
+ return self.__doc__.strip()
+ except:
+ return "<no description available>"
+
def checkenabled(self):
""" This function can be overidden to let the plugin decide whether
it should run or not.
diff --git a/src/lib/sos/policyredhat.py b/src/lib/sos/policyredhat.py
index 80643576..34177347 100755
--- a/src/lib/sos/policyredhat.py
+++ b/src/lib/sos/policyredhat.py
@@ -18,6 +18,7 @@
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import os
+import commands
import sys
import string
from tempfile import gettempdir
@@ -75,16 +76,11 @@ class SosPolicy:
return (name, version, release, arch)
def packageResults(self):
- print "Packaging results to send to support..."
+ localname = commands.getoutput("/bin/uname -n").split(".")[0]
+ name = raw_input("Please enter your first initial and last name [%s]: " % localname)
+ if len(name) == 0: name = localname
- name=""
- while len(name)==0:
- print "Please enter your first initial and last name (jsmith): ",
- name = sys.stdin.readline()[:-1]
-
- print "Please enter the case number that you are generating this",
- print "report for: ",
- ticketNumber = sys.stdin.readline()[:-1]
+ ticketNumber = raw_input("Please enter the case number that you are generating this report for: ")
if len(ticketNumber):
namestr = name + "." + ticketNumber
@@ -92,7 +88,7 @@ class SosPolicy:
namestr = name
ourtempdir = gettempdir()
- tarballName = os.path.join(ourtempdir, namestr + ".tar.bz2")
+ tarballName = os.path.join(ourtempdir, "sosreport-" + namestr + ".tar.bz2")
namestr = namestr + "-" + str(random.randint(1, 999999))
@@ -100,12 +96,13 @@ class SosPolicy:
tarcmd = "/bin/tar -jcf %s %s" % (tarballName, namestr)
+ print
print "Creating compressed tar archive..."
if not os.access(string.split(tarcmd)[0], os.X_OK):
print "Unable to create tarball"
return
- # gotta be a better way...
+ # FIXME: gotta be a better way...
os.system("/bin/mv %s %s" % (self.cInfo['dstroot'], aliasdir))
curwd = os.getcwd()
os.chdir(ourtempdir)
@@ -117,7 +114,9 @@ class SosPolicy:
os.system("/bin/mv %s %s" % (aliasdir, self.cInfo['dstroot']))
sys.stdout.write("\n")
- print "Your sosreport has been generated and saved in %s" % tarballName
+ print "Your sosreport has been generated and saved in %s" % tarballName
+ print "Please send this file to your support representative."
sys.stdout.write("\n")
+
return