aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/sos/plugins/selinux.py7
-rw-r--r--src/lib/sos/plugintools.py8
-rwxr-xr-xsrc/sosreport49
3 files changed, 16 insertions, 48 deletions
diff --git a/src/lib/sos/plugins/selinux.py b/src/lib/sos/plugins/selinux.py
index 62def4fd..7aaa6755 100644
--- a/src/lib/sos/plugins/selinux.py
+++ b/src/lib/sos/plugins/selinux.py
@@ -18,13 +18,14 @@ import commands
class selinux(sos.plugintools.PluginBase):
"""selinux related information
"""
+ optionList = [("fixfiles", 'Print incorrect file context labels', 'slow', False)]
def setup(self):
# sestatus is always collected in checkenabled()
self.addCopySpec("/etc/selinux")
self.collectExtOutput("/usr/bin/selinuxconfig")
- self.eta_weight += 120 # this plugins takes 120x longer (for ETA)
- self.collectExtOutput("/sbin/fixfiles check")
-
+ self.eta_weight += 240 # this plugins takes 240x longer (for ETA)
+ if self.getOption('fixfiles'):
+ self.collectExtOutput("/sbin/fixfiles check")
self.addForbiddenPath("/etc/selinux/targeted")
return
diff --git a/src/lib/sos/plugintools.py b/src/lib/sos/plugintools.py
index 684cd9eb..9121db69 100644
--- a/src/lib/sos/plugintools.py
+++ b/src/lib/sos/plugintools.py
@@ -29,11 +29,11 @@
This is the base class for sosreport plugins
"""
from sos.helpers import *
-from threading import Thread, activeCount
import os, os.path, sys, string, glob, re, traceback
import shutil
from stat import *
from time import time
+from multiprocessing import Process
class PluginException(Exception): pass
@@ -426,7 +426,7 @@ class PluginBase:
"""
if threaded, is thread running ?
"""
- if self.thread: return self.thread.isAlive()
+ if self.thread: return self.thread.is_alive()
return None
def wait(self,timeout=None):
@@ -434,14 +434,14 @@ class PluginBase:
wait for a thread to complete - only called for threaded execution
"""
self.thread.join(timeout)
- return self.thread.isAlive()
+ return self.thread.is_alive()
def copyStuff(self, threaded = False, semaphore = None):
"""
Collect the data for a plugin
"""
if threaded and self.thread == None:
- self.thread = Thread(target=self.copyStuff, name=self.piName+'-thread', args = [True, semaphore] )
+ self.thread = Process(target=self.copyStuff, name=self.piName+'-thread', args = [True, semaphore] )
self.thread.start()
return self.thread
diff --git a/src/sosreport b/src/sosreport
index 2edc2b90..f84c2f2a 100755
--- a/src/sosreport
+++ b/src/sosreport
@@ -31,61 +31,27 @@ from optparse import OptionParser, Option
import ConfigParser
import sos.policyredhat
from sos.helpers import *
-from threading import Thread, activeCount
import signal
from stat import *
from time import strftime, localtime, time
from pwd import getpwuid
import gettext
-from threading import Semaphore
+from multiprocessing import Semaphore
__version__ = 1.8
-__breakHits__ = 0 # Use this to track how many times we enter the exit routine
-
## Set up routines to be linked to signals for termination handling
def exittermhandler(signum, frame):
doExitCode()
def doExitCode():
- from threading import enumerate
- global __breakHits__, loadedplugins, dstroot
-
- __breakHits__ += 1
- if ( ( activeCount() > 1 ) and ( __breakHits__ == 1 ) ):
- print "SIGTERM received, multiple threads detected, waiting " \
- "for all threads to exit"
+ global loadedplugins, dstroot
- for plugname, plug in loadedplugins:
- plug.exit_please()
+ for plugname, plug in loadedplugins:
+ plug.exit_please()
- for thread in enumerate():
- if thread.getName() == "MainThread":
- continue
- # until we find a way to kill threads in
- # case of > 1 CTRL+C, ignore KeyboardInterrupt
- while thread.isAlive():
- try:
- thread.join()
- except KeyboardInterrupt:
- doExitCode()
- else:
- print "All threads ended, cleaning up."
- doExit(1)
-
- if ( ( activeCount() > 1 ) and ( __breakHits__ > 1 ) ):
- print "Multiple SIGTERMs, multiple threads, attempting to " \
- "signal threads to die immediately."
- ## FIXME: Add thread-kill code (see FIXME below)
- return
- elif ( ( activeCount() > 1 ) and ( __breakHits__ > 2 ) ):
- print "Multiple SIGTERMs, multiple threads, process suicides."
- os.kill(os.getpid(), signal.SIGKILL)
- elif ( ( activeCount() == 1 ) and ( __breakHits__ > 2 ) ):
- print "Multiple SIGTERMs, single thread, exiting without cleaning up."
- doExit(3)
-
- doExit("Abnormal exit")
+ print "All processes ended, cleaning up."
+ doExit(1)
def doExit(error=0):
global policy
@@ -583,7 +549,8 @@ def sosreport():
for plugname in opts.keys():
soslog.error('unable to set option for disabled or non-existing ' \
'plugin (%s)' % (plugname))
- doExit(1)
+ # Do not want to exit on invalid opts due to a misconfiguration in sos.conf
+ # doExit(1)
del opt,opts,val
# error if the user references a plugin which does not exist