|
|
69165ba |
From c511c8cf4289c1a561102cfa78ea2827c517991f Mon Sep 17 00:00:00 2001
|
|
|
69165ba |
From: Matej Habrnal <mhabrnal@redhat.com>
|
|
|
69165ba |
Date: Thu, 1 Jun 2017 09:59:53 +0200
|
|
|
69165ba |
Subject: [PATCH] abrt addon python3 fixes
|
|
|
69165ba |
|
|
|
69165ba |
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
|
|
|
69165ba |
---
|
|
|
69165ba |
configure.ac | 37 ++++++++++++++++++++++++
|
|
|
69165ba |
doc/Makefile.am | 2 ++
|
|
|
69165ba |
doc/abrt-python3.conf.txt | 24 ++++++++++++++++
|
|
|
69165ba |
doc/python3_event.conf.5 | 1 +
|
|
|
69165ba |
src/hooks/Makefile.am | 2 +-
|
|
|
69165ba |
src/hooks/abrt_exception_handler3.py.in | 50 ++++++++++++++++++++-------------
|
|
|
69165ba |
src/plugins/Makefile.am | 1 +
|
|
|
69165ba |
src/plugins/python3_event.conf | 32 +++++++++++++++++++++
|
|
|
69165ba |
8 files changed, 128 insertions(+), 21 deletions(-)
|
|
|
69165ba |
create mode 100644 doc/abrt-python3.conf.txt
|
|
|
69165ba |
create mode 100644 doc/python3_event.conf.5
|
|
|
69165ba |
create mode 100644 src/plugins/python3_event.conf
|
|
|
69165ba |
|
|
|
69165ba |
diff --git a/configure.ac b/configure.ac
|
|
|
69165ba |
index 02d7e0e..90316e6 100644
|
|
|
69165ba |
--- a/configure.ac
|
|
|
69165ba |
+++ b/configure.ac
|
|
|
69165ba |
@@ -92,6 +92,43 @@ PYTHON_LIBS=`python-config --libs 2> /dev/null`
|
|
|
69165ba |
AC_SUBST(PYTHON_CFLAGS)
|
|
|
69165ba |
AC_SUBST(PYTHON_LIBS)
|
|
|
69165ba |
|
|
|
69165ba |
+AM_CONDITIONAL(BUILD_PYTHON3, true)
|
|
|
69165ba |
+AC_PATH_PROG([PYTHON3], [python3], [no])
|
|
|
69165ba |
+[if test "$PYTHON3" == "no"]
|
|
|
69165ba |
+[then]
|
|
|
69165ba |
+ [echo "The python3 program was not found in the search path. Please ensure"]
|
|
|
69165ba |
+ [echo "that it is installed and its directory is included in the search path or"]
|
|
|
69165ba |
+ [echo "pass --without-python3 to ./configure."]
|
|
|
69165ba |
+ [echo "Then run configure again before attempting to build ABRT."]
|
|
|
69165ba |
+ [exit 1]
|
|
|
69165ba |
+[fi]
|
|
|
69165ba |
+
|
|
|
69165ba |
+AC_PATH_PROG([PYTHON3_CONFIG], [python3-config], [no])
|
|
|
69165ba |
+[if test "$PYTHON3_CONFIG" = "no"]
|
|
|
69165ba |
+[then]
|
|
|
69165ba |
+ [echo "The python3-config program was not found in the search path. Please ensure"]
|
|
|
69165ba |
+ [echo "that it is installed and its directory is included in the search path or"]
|
|
|
69165ba |
+ [echo "pass --without-python3 to ./configure."]
|
|
|
69165ba |
+ [echo "Then run configure again before attempting to build ABRT."]
|
|
|
69165ba |
+ [exit 1]
|
|
|
69165ba |
+[fi]
|
|
|
69165ba |
+
|
|
|
69165ba |
+PYTHON3_CFLAGS=`python3-config --cflags 2> /dev/null`
|
|
|
69165ba |
+PYTHON3_LIBS=`python3-config --libs 2> /dev/null`
|
|
|
69165ba |
+
|
|
|
69165ba |
+AC_SUBST([PYTHON3_PREFIX], ['${prefix}'])
|
|
|
69165ba |
+AC_SUBST([PYTHON3_EXEC_PREFIX], ['${exec_prefix}'])
|
|
|
69165ba |
+
|
|
|
69165ba |
+PYTHON3_DIR=`$PYTHON3 -c "import distutils.sysconfig; \
|
|
|
69165ba |
+ print(distutils.sysconfig.get_python_lib(0,0,prefix='$PYTHON3_PREFIX'))"`
|
|
|
69165ba |
+PYTHON3_EXECDIR=`$PYTHON3 -c "import distutils.sysconfig; \
|
|
|
69165ba |
+ print(distutils.sysconfig.get_python_lib(1,0,prefix='$PYTHON3_EXEC_PREFIX'))"`
|
|
|
69165ba |
+
|
|
|
69165ba |
+AC_SUBST(PYTHON3_CFLAGS)
|
|
|
69165ba |
+AC_SUBST(PYTHON3_LIBS)
|
|
|
69165ba |
+AC_SUBST(python3dir, $PYTHON3_DIR)
|
|
|
69165ba |
+AC_SUBST(py3execdir, $PYTHON3_EXECDIR)
|
|
|
69165ba |
+
|
|
|
69165ba |
PKG_CHECK_MODULES([XICE], [ice])
|
|
|
69165ba |
PKG_CHECK_MODULES([XSMP], [sm])
|
|
|
69165ba |
PKG_CHECK_MODULES([GTK], [gtk+-3.0])
|
|
|
69165ba |
diff --git a/doc/Makefile.am b/doc/Makefile.am
|
|
|
69165ba |
index d95d9fb..ae05327 100644
|
|
|
69165ba |
--- a/doc/Makefile.am
|
|
|
69165ba |
+++ b/doc/Makefile.am
|
|
|
69165ba |
@@ -46,6 +46,7 @@ MAN5_TXT += abrt.conf.txt
|
|
|
69165ba |
MAN5_TXT += abrt-action-save-package-data.conf.txt
|
|
|
69165ba |
MAN5_TXT += abrt-xorg.conf.txt
|
|
|
69165ba |
MAN5_TXT += abrt-python.conf.txt
|
|
|
69165ba |
+MAN5_TXT += abrt-python3.conf.txt
|
|
|
69165ba |
MAN5_TXT += abrt-CCpp.conf.txt
|
|
|
69165ba |
MAN5_TXT += abrt-oops.conf.txt
|
|
|
69165ba |
MAN5_TXT += gpg_keys.conf.txt
|
|
|
69165ba |
@@ -58,6 +59,7 @@ MAN5_PREFORMATTED += ccpp_retrace_event.conf.5
|
|
|
69165ba |
MAN5_PREFORMATTED += gconf_event.conf.5
|
|
|
69165ba |
MAN5_PREFORMATTED += koops_event.conf.5
|
|
|
69165ba |
MAN5_PREFORMATTED += python_event.conf.5
|
|
|
69165ba |
+MAN5_PREFORMATTED += python3_event.conf.5
|
|
|
69165ba |
MAN5_PREFORMATTED += smart_event.conf.5
|
|
|
69165ba |
MAN5_PREFORMATTED += vimrc_event.conf.5
|
|
|
69165ba |
MAN5_PREFORMATTED += vmcore_event.conf.5
|
|
|
69165ba |
diff --git a/doc/abrt-python3.conf.txt b/doc/abrt-python3.conf.txt
|
|
|
69165ba |
new file mode 100644
|
|
|
69165ba |
index 0000000..a8f3913
|
|
|
69165ba |
--- /dev/null
|
|
|
69165ba |
+++ b/doc/abrt-python3.conf.txt
|
|
|
69165ba |
@@ -0,0 +1,24 @@
|
|
|
69165ba |
+abrt-python3.conf(5)
|
|
|
69165ba |
+===================
|
|
|
69165ba |
+
|
|
|
69165ba |
+NAME
|
|
|
69165ba |
+----
|
|
|
69165ba |
+abrt-python3.conf - Configuration file for ABRT's python 3 crash hook
|
|
|
69165ba |
+
|
|
|
69165ba |
+DESCRIPTION
|
|
|
69165ba |
+-----------
|
|
|
69165ba |
+Currently, only one item exists:
|
|
|
69165ba |
+
|
|
|
69165ba |
+RequireAbsolutePath = 'yes' / 'no' ...::
|
|
|
69165ba |
+ If set to 'no', unhandled python 3 exceptions will be caught
|
|
|
69165ba |
+ and saved even in scripts which are run without full path
|
|
|
69165ba |
+ in sys.argv[0].
|
|
|
69165ba |
+ Default is 'yes': do not save them.
|
|
|
69165ba |
+
|
|
|
69165ba |
+SEE ALSO
|
|
|
69165ba |
+--------
|
|
|
69165ba |
+abrt.conf(5)
|
|
|
69165ba |
+
|
|
|
69165ba |
+AUTHORS
|
|
|
69165ba |
+-------
|
|
|
69165ba |
+* ABRT team
|
|
|
69165ba |
diff --git a/doc/python3_event.conf.5 b/doc/python3_event.conf.5
|
|
|
69165ba |
new file mode 100644
|
|
|
69165ba |
index 0000000..71c3fcb
|
|
|
69165ba |
--- /dev/null
|
|
|
69165ba |
+++ b/doc/python3_event.conf.5
|
|
|
69165ba |
@@ -0,0 +1 @@
|
|
|
69165ba |
+.so man5/report_event.conf.5
|
|
|
69165ba |
diff --git a/src/hooks/Makefile.am b/src/hooks/Makefile.am
|
|
|
69165ba |
index 85502a0..091e322 100644
|
|
|
69165ba |
--- a/src/hooks/Makefile.am
|
|
|
69165ba |
+++ b/src/hooks/Makefile.am
|
|
|
69165ba |
@@ -7,7 +7,7 @@ pluginsconfdir = $(PLUGINS_CONF_DIR)
|
|
|
69165ba |
dist_pluginsconf_DATA = \
|
|
|
69165ba |
CCpp.conf \
|
|
|
69165ba |
python.conf \
|
|
|
69165ba |
- oops.conf
|
|
|
69165ba |
+ oops.conf \
|
|
|
69165ba |
python3.conf \
|
|
|
69165ba |
vmcore.conf
|
|
|
69165ba |
|
|
|
69165ba |
diff --git a/src/hooks/abrt_exception_handler3.py.in b/src/hooks/abrt_exception_handler3.py.in
|
|
|
69165ba |
index b20e6f5..e80a7ac 100644
|
|
|
69165ba |
--- a/src/hooks/abrt_exception_handler3.py.in
|
|
|
69165ba |
+++ b/src/hooks/abrt_exception_handler3.py.in
|
|
|
69165ba |
@@ -27,16 +27,12 @@ import os
|
|
|
69165ba |
def syslog(msg):
|
|
|
69165ba |
"""Log message to system logger (journal)"""
|
|
|
69165ba |
|
|
|
69165ba |
- from systemd import journal
|
|
|
69165ba |
-
|
|
|
69165ba |
- # required as a workaround for rhbz#1023041
|
|
|
69165ba |
- # where journal tries to log into non-existent log
|
|
|
69165ba |
- # and fails (during %check in mock)
|
|
|
69165ba |
- #
|
|
|
69165ba |
- # try/except block should be removed when the bug is fixed
|
|
|
69165ba |
+ import syslog
|
|
|
69165ba |
|
|
|
69165ba |
try:
|
|
|
69165ba |
- journal.send(msg)
|
|
|
69165ba |
+ syslog.openlog(ident="python3")
|
|
|
69165ba |
+ syslog.syslog(syslog.LOG_ERR, msg)
|
|
|
69165ba |
+ syslog.closelog()
|
|
|
69165ba |
except:
|
|
|
69165ba |
pass
|
|
|
69165ba |
|
|
|
69165ba |
@@ -51,11 +47,17 @@ def send(data):
|
|
|
69165ba |
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
|
|
69165ba |
s.settimeout(5)
|
|
|
69165ba |
s.connect(@VAR_RUN@ + "/abrt/abrt.socket")
|
|
|
69165ba |
- pre = "POST / HTTP/1.1\r\n\r\ntype=Python\0"
|
|
|
69165ba |
+ pre = "POST / HTTP/1.1\r\n\r\n"
|
|
|
69165ba |
+ pre += "type=Python3\0"
|
|
|
69165ba |
+ # Using analyzer=Python intentionally.
|
|
|
69165ba |
+ # This causes the some workflow as for Python
|
|
|
69165ba |
+ # will be used so we don't need to add a new
|
|
|
69165ba |
+ # workflow for Python 3 into libreport due to added
|
|
|
69165ba |
+ # abrt-addon-python3 package to epel7
|
|
|
69165ba |
+ pre += "analyzer=Python\0"
|
|
|
69165ba |
s.sendall(pre.encode())
|
|
|
69165ba |
s.sendall(data.encode())
|
|
|
69165ba |
|
|
|
69165ba |
- s.sendall("\0".encode())
|
|
|
69165ba |
s.shutdown(socket.SHUT_WR)
|
|
|
69165ba |
|
|
|
69165ba |
while True:
|
|
|
69165ba |
@@ -89,9 +91,11 @@ def write_dump(tb_text, tb):
|
|
|
69165ba |
data += "reason={0}\0".format(tb_text.splitlines()[0])
|
|
|
69165ba |
data += "backtrace={0}\0".format(tb_text)
|
|
|
69165ba |
|
|
|
69165ba |
+ # add environ element
|
|
|
69165ba |
data += "environ="
|
|
|
69165ba |
- for k, v in os.environ.items():
|
|
|
69165ba |
- data += "{0}={1}\n".format(k, v)
|
|
|
69165ba |
+ for k,v in os.environ.items():
|
|
|
69165ba |
+ data += "{0}={1}\n".format(k,v)
|
|
|
69165ba |
+ data += "\0"
|
|
|
69165ba |
|
|
|
69165ba |
response = send(data)
|
|
|
69165ba |
parts = response.split()
|
|
|
69165ba |
@@ -102,14 +106,20 @@ def write_dump(tb_text, tb):
|
|
|
69165ba |
syslog("error sending data to ABRT daemon: {0}".format(response))
|
|
|
69165ba |
|
|
|
69165ba |
|
|
|
69165ba |
-def conf_enabled(var_name):
|
|
|
69165ba |
+def require_abs_path():
|
|
|
69165ba |
+ """
|
|
|
69165ba |
+ Return True if absolute path requirement is enabled
|
|
|
69165ba |
+ in configuration
|
|
|
69165ba |
+ """
|
|
|
69165ba |
+
|
|
|
69165ba |
import problem
|
|
|
69165ba |
+
|
|
|
69165ba |
try:
|
|
|
69165ba |
conf = problem.load_plugin_conf_file("python3.conf")
|
|
|
69165ba |
- except:
|
|
|
69165ba |
- return -1
|
|
|
69165ba |
- else:
|
|
|
69165ba |
- conf.get(var_name, -1)
|
|
|
69165ba |
+ except OsError:
|
|
|
69165ba |
+ return False
|
|
|
69165ba |
+
|
|
|
69165ba |
+ return conf.get("RequireAbsolutePath", "yes") == "yes"
|
|
|
69165ba |
|
|
|
69165ba |
|
|
|
69165ba |
def handle_exception(etype, value, tb):
|
|
|
69165ba |
@@ -158,7 +168,7 @@ def handle_exception(etype, value, tb):
|
|
|
69165ba |
.format(sys.argv[0]))
|
|
|
69165ba |
|
|
|
69165ba |
if sys.argv[0][0] != "/":
|
|
|
69165ba |
- if conf_enabled("RequireAbsolutePath") != 0:
|
|
|
69165ba |
+ if require_abs_path():
|
|
|
69165ba |
raise Exception
|
|
|
69165ba |
|
|
|
69165ba |
import traceback
|
|
|
69165ba |
@@ -167,8 +177,8 @@ def handle_exception(etype, value, tb):
|
|
|
69165ba |
|
|
|
69165ba |
if tb is not None and etype != IndentationError:
|
|
|
69165ba |
tblast = traceback.extract_tb(tb, limit=None)
|
|
|
69165ba |
- if len(tblast):
|
|
|
69165ba |
- tblast = tblast[len(tblast) - 1]
|
|
|
69165ba |
+ if tblast:
|
|
|
69165ba |
+ tblast = tuple(tblast[-1])
|
|
|
69165ba |
extxt = traceback.format_exception_only(etype, value)
|
|
|
69165ba |
if tblast and len(tblast) > 3:
|
|
|
69165ba |
ll = []
|
|
|
69165ba |
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
|
|
|
69165ba |
index 6dde4b7..557d218 100644
|
|
|
69165ba |
--- a/src/plugins/Makefile.am
|
|
|
69165ba |
+++ b/src/plugins/Makefile.am
|
|
|
69165ba |
@@ -65,6 +65,7 @@ dist_eventsconf_DATA = \
|
|
|
69165ba |
xorg_event.conf \
|
|
|
69165ba |
vmcore_event.conf \
|
|
|
69165ba |
python_event.conf \
|
|
|
69165ba |
+ python3_event.conf \
|
|
|
69165ba |
smart_event.conf \
|
|
|
69165ba |
gconf_event.conf \
|
|
|
69165ba |
vimrc_event.conf
|
|
|
69165ba |
diff --git a/src/plugins/python3_event.conf b/src/plugins/python3_event.conf
|
|
|
69165ba |
new file mode 100644
|
|
|
69165ba |
index 0000000..9d1e955
|
|
|
69165ba |
--- /dev/null
|
|
|
69165ba |
+++ b/src/plugins/python3_event.conf
|
|
|
69165ba |
@@ -0,0 +1,32 @@
|
|
|
69165ba |
+EVENT=post-create type=Python3 remote!=1
|
|
|
69165ba |
+ # (For now this has no effect since python hook doesn't save environ)
|
|
|
69165ba |
+ if grep -q ^ABRT_IGNORE_ALL=1 environ \
|
|
|
69165ba |
+ || grep -q ^ABRT_IGNORE_PYTHON=1 environ \
|
|
|
69165ba |
+ ; then
|
|
|
69165ba |
+ echo "ABRT_IGNORE variable is 1 - not saving the crash"
|
|
|
69165ba |
+ # abrtd will delete the problem directory when we exit nonzero:
|
|
|
69165ba |
+ exit 1
|
|
|
69165ba |
+ fi
|
|
|
69165ba |
+ abrt-action-analyze-python
|
|
|
69165ba |
+
|
|
|
69165ba |
+EVENT=report_Bugzilla type=Python3 component!=anaconda
|
|
|
69165ba |
+ test -f component || abrt-action-save-package-data
|
|
|
69165ba |
+ reporter-bugzilla -b \
|
|
|
69165ba |
+ -c /etc/libreport/plugins/bugzilla.conf \
|
|
|
69165ba |
+ -F /etc/libreport/plugins/bugzilla_format.conf \
|
|
|
69165ba |
+ -A /etc/libreport/plugins/bugzilla_formatdup.conf
|
|
|
69165ba |
+
|
|
|
69165ba |
+# Send micro report
|
|
|
69165ba |
+EVENT=report_uReport type=Python3
|
|
|
69165ba |
+ /usr/libexec/abrt-action-ureport
|
|
|
69165ba |
+
|
|
|
69165ba |
+# update ABRT database after successful report to bugzilla
|
|
|
69165ba |
+EVENT=post_report type=Python3
|
|
|
69165ba |
+ reporter-ureport -A -B
|
|
|
69165ba |
+
|
|
|
69165ba |
+# Reporting of python exceptions
|
|
|
69165ba |
+EVENT=report-gui type=Python3 component!=anaconda
|
|
|
69165ba |
+ report-gtk -- "$DUMP_DIR"
|
|
|
69165ba |
+
|
|
|
69165ba |
+EVENT=report-cli type=Python3 component!=anaconda
|
|
|
69165ba |
+ report-cli -- "$DUMP_DIR"
|
|
|
69165ba |
--
|
|
|
69165ba |
1.8.3.1
|
|
|
69165ba |
|