summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2009-12-07 17:55:02 +0100
committerJiri Moskovcak <jmoskovc@redhat.com>2009-12-07 17:55:02 +0100
commit4fd4c946bd991b0414b0a037b3940369485ced1f (patch)
tree0ca4c49e289327ca1a489ee82b336271214d1b5f /src
parent6a110acc7f2c0413ba856619b4257f66268ec956 (diff)
downloadabrt-4fd4c946bd991b0414b0a037b3940369485ced1f.tar.gz
abrt-4fd4c946bd991b0414b0a037b3940369485ced1f.tar.xz
abrt-4fd4c946bd991b0414b0a037b3940369485ced1f.zip
PyHook: better logic for checking if abrtd is running rhbz#539987
Diffstat (limited to 'src')
-rw-r--r--src/Hooks/Makefile.am5
-rw-r--r--src/Hooks/abrt_exception_handler.py.in4
-rw-r--r--src/Hooks/sitecustomize.py65
3 files changed, 34 insertions, 40 deletions
diff --git a/src/Hooks/Makefile.am b/src/Hooks/Makefile.am
index 21569570..af51d99a 100644
--- a/src/Hooks/Makefile.am
+++ b/src/Hooks/Makefile.am
@@ -45,14 +45,9 @@ abrt_pyhook_helper_CPPFLAGS = \
abrt_pyhook_helper_LDADD = \
../../lib/Utils/libABRTUtils.la
-man_MANS = pyhook.conf.5
-
python_PYTHON = sitecustomize.py abrt_exception_handler.py
EXTRA_DIST = abrt_exception_handler.py.in $(man_MANS)
-pyhookconfdir = $(CONF_DIR)
-dist_pyhookconf_DATA = pyhook.conf
-
CLEANFILES := $(notdir $(wildcard *~)) $(notdir $(wildcard *\#)) $(notdir $(wildcard \.\#*)) $(notdir $(wildcard *.pyc))
abrt_exception_handler.py:
diff --git a/src/Hooks/abrt_exception_handler.py.in b/src/Hooks/abrt_exception_handler.py.in
index 6933ac00..a8da9808 100644
--- a/src/Hooks/abrt_exception_handler.py.in
+++ b/src/Hooks/abrt_exception_handler.py.in
@@ -133,10 +133,6 @@ def __dump_exception(out, text, tracebk):
except:
pass
-
-def __exception_window(title, text, component_name):
- pass
-
__ACTION_STR = ""
def action(what):
"""Describe what you want to do actually.
diff --git a/src/Hooks/sitecustomize.py b/src/Hooks/sitecustomize.py
index 71d8c4e1..97941e87 100644
--- a/src/Hooks/sitecustomize.py
+++ b/src/Hooks/sitecustomize.py
@@ -5,38 +5,41 @@
# and python interpreter runs it automatically everytime
# some python script is executed.
-config = None
-conf = {}
-try:
- config = open("/etc/abrt/pyhook.conf","r")
-except:
- # Silently ignore if file doesn't exist.
- pass
-
-try:
- if config:
- # we expect config in form
- # key = value
- # Enabled = yes
- # this should strip
- line = config.readline().lower().replace(' ','').strip('\n').split('=')
- conf[line[0]] = line[1]
- config.close()
-except:
- # Ignore silently everything, because we don't want to bother user
- # if this hook doesn't work.
- pass
+def abrt_daemon_ok():
+ try:
+ #FIXME: make it relocable! this will work only when installed in default path
+ #pidfile = open(VAR_RUN_PID_FILE, "r");
+ pidfile = open("/var/run/abrt.pid", "r")
+ except Exception, ex:
+ # log the exception?
+ return False
+
+ pid = pidfile.readline()
+ pidfile.close()
+ if not pid:
+ return False
+
+ try:
+ # pid[:-1] strips the trailing '\n'
+ cmdline = open("/proc/%s/cmdline" % pid[:-1], "r").readline()
+ except Exception, ex:
+ # can't read cmdline
+ return False
+ if not ("abrtd" in cmdline):
+ return False
+
+ return True
-if conf.has_key("enabled"):
+if abrt_daemon_ok():
# Prevent abrt exception handler from running when the abrtd daemon is
# not active.
- # abrtd sets the value to "no" when deactivated and vice versa.
- if conf["enabled"] == "yes":
- try:
- from abrt_exception_handler import *
+ try:
+ from abrt_exception_handler import installExceptionHandler
- installExceptionHandler(debug = 1)
- except Exception, e:
- # FIXME don't print anything, write it to some log file
- print e
- pass
+ installExceptionHandler(debug = 1)
+ except Exception, e:
+ # FIXME: log errors?
+ pass
+else:
+ #FIXME: log something?
+ pass