[abrt] [PATCH] Fix pyhook test to reflect changes made in write_dump
by Vratislav Podzimek
write_dump now takes two arguments
Signed-off-by: Vratislav Podzimek <vpodzime(a)redhat.com>
---
tests/pyhook.at | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/pyhook.at b/tests/pyhook.at
index f736e3a..92a23bd 100644
--- a/tests/pyhook.at
+++ b/tests/pyhook.at
@@ -9,8 +9,8 @@ import sys
sys.path.insert(0, "../../../src/hooks")
import abrt_exception_handler
sys.argv[0]="/...testsuite.../$1.py"
-def write_dump(tb):
- print tb.splitlines()[0]
+def write_dump(tb_text, tb):
+ print tb_text.splitlines()[0]
abrt_exception_handler.write_dump = write_dump
$2
]])
--
1.7.11.4
11 years, 7 months
Re: [PATCH] trac#333: Add code generating dso_list to the python hook
by Jiri Moskovcak
- ack
On 09/21/2012 06:43 PM, Vratislav Podzimek wrote:
> On Thu, 2012-09-20 at 13:54 +0200, Jiri Moskovcak wrote:
>> - doesn't work
>> - the python exception are caught fine, but the file dso_list is not created
> I've tested this today and dso_list file has been correctly created in
> the dump directory. Did you try the case, where there actually were some
> other packages involved? Empty dso_list file shouldn't be created with
> that patch. My test case was modifying /usr/bin/phatch by adding
>
> import subprocess
> subprocess.call("nonexisting_binary")
>
> which resulted in dso_file containing python-libs package listed.
>
11 years, 7 months
[PATCH] trac#333: Add code generating dso_list to the python hook
by Vratislav Podzimek
Signed-off-by: Vratislav Podzimek <vpodzime(a)redhat.com>
---
src/hooks/abrt_exception_handler.py.in | 84 ++++++++++++++++++++++++++++++++--
1 file changed, 80 insertions(+), 4 deletions(-)
diff --git a/src/hooks/abrt_exception_handler.py.in b/src/hooks/abrt_exception_handler.py.in
index 6c0659a..ecdb175 100644
--- a/src/hooks/abrt_exception_handler.py.in
+++ b/src/hooks/abrt_exception_handler.py.in
@@ -24,8 +24,22 @@ Module for the ABRT exception handling hook
import sys
import os
+import inspect
-def write_dump(tb):
+try:
+ import rpm
+ HAVE_RPM = True
+except ImportError as imperr:
+ HAVE_RPM = False
+ import syslog
+ syslog.syslog("RPM module not available, cannot query RPM db for package "\
+ "names")
+
+class RPMinfoError(Exception):
+ """Exception class for RPMdb-querying related errors"""
+ pass
+
+def write_dump(tb_text, tb):
if sys.argv[0][0] == "/":
executable = os.path.abspath(sys.argv[0])
else:
@@ -33,6 +47,11 @@ def write_dump(tb):
# (BTW, we *can't* assume the script is in current directory.)
executable = sys.argv[0]
+ if HAVE_RPM:
+ dso_list = get_dso_list(tb)
+ else:
+ dso_list = None
+
# Open ABRT daemon's socket and write data to it
try:
import socket
@@ -48,8 +67,12 @@ def write_dump(tb):
# This handler puts a short(er) crash descr in 1st line of the backtrace.
# Example:
# CCMainWindow.py:1:<module>:ZeroDivisionError: integer division or modulo by zero
- s.sendall("REASON=%s\0" % tb.splitlines()[0])
- s.sendall("BACKTRACE=%s\0" % tb)
+ s.sendall("REASON=%s\0" % tb_text.splitlines()[0])
+ s.sendall("BACKTRACE=%s\0" % tb_text)
+
+ if dso_list:
+ s.sendall("dso_list=%s\0" % "\n".join(dso_list))
+
s.shutdown(socket.SHUT_WR)
@@ -77,6 +100,59 @@ def write_dump(tb):
import syslog
syslog.syslog("can't communicate with ABRT daemon, is it running? %s" % str(ex))
+def get_package_for_file(fpath):
+ """
+ Returns package name for a given file.
+
+ @param fpath: filename
+ @type fpath: str
+ @return: package name for the file
+ @rtype: str
+ @throws RPMinfoError: if package for the file cannot be found
+
+ """
+
+ ts = rpm.TransactionSet()
+ mi = ts.dbMatch("basenames", fpath)
+ try:
+ header = mi.next()
+ except StopIteration:
+ raise RPMinfoError("Cannot get package and component for file "+
+ fpath)
+ package = "{0}-{1}-{2}.{3}".format(header["name"], header["version"],
+ header["release"], header["arch"])
+
+ return package
+
+def get_dso_list(tb):
+ """
+ Get the list of names of the packages whose files appear in the traceback.
+
+ @param tb: traceback
+ @type tb: traceback
+ @return: list of package names
+ @rtype: list
+
+ """
+
+ if inspect.istraceback(tb):
+ tb = inspect.getinnerframes(tb)
+
+ packages = set()
+ for (frame, fpath, lineno, func, ctx, idx) in tb:
+ try:
+ packages.add(get_package_for_file(fpath))
+ except RPMinfoError as rpmerr:
+ continue
+
+ # remove the package name of the executable itself
+ try:
+ packages.discard(get_package_for_file(sys.argv[0]))
+ except RPMinfoError as rpmerr:
+ pass
+
+ return list(packages)
+
def conf_enabled(var_name):
try:
file = open(@CONF_DIR@ + "/plugins/python.conf", "r")
@@ -187,7 +263,7 @@ def handleMyException((etype, value, tb)):
text += "".join(elist)
# Send data to the daemon
- write_dump(text)
+ write_dump(text, tb)
except:
# Silently ignore any error in this hook,
--
1.7.11.2
11 years, 7 months
[PATCH] reporter-ureport: respect chrooted os_release
by Michal Toman
---
src/lib/json.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/src/lib/json.c b/src/lib/json.c
index cd30575..e0d5548 100644
--- a/src/lib/json.c
+++ b/src/lib/json.c
@@ -76,7 +76,13 @@ static void ureport_add_str(struct json_object *ur, const char *key,
static void ureport_add_os(struct json_object *ur, problem_data_t *pd)
{
- char *pd_item = problem_data_get_content_or_NULL(pd, FILENAME_OS_RELEASE);
+ char *pd_item = problem_data_get_content_or_NULL(pd, FILENAME_ROOTDIR);
+ if (pd_item)
+ pd_item = problem_data_get_content_or_NULL(pd, FILENAME_OS_RELEASE_IN_ROOTDIR);
+
+ if (!pd_item)
+ pd_item = problem_data_get_content_or_NULL(pd, FILENAME_OS_RELEASE);
+
if (!pd_item)
return;
--
1.7.1
11 years, 7 months
[ABRT PATCH] trac#682: emit Crash DBus signal on org.freedesktop.problems bus
by Jakub Filak
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
doc/design | 4 ++--
src/applet/applet.c | 10 +++-------
src/daemon/com.redhat.abrt.service | 7 -------
src/dbus/dbus_event.conf | 8 ++++----
tests/runtests/dbus-message/runtest.sh | 2 +-
5 files changed, 10 insertions(+), 21 deletions(-)
delete mode 100644 src/daemon/com.redhat.abrt.service
diff --git a/doc/design b/doc/design
index 05a96cd..9044529 100644
--- a/doc/design
+++ b/doc/design
@@ -79,9 +79,9 @@ or to query list of possible events for a directory.
When user (admin) wants to see the list of dumped crashes and
process them, he runs abrt-gui or abrt-cli. These programs
-perform a dbus call to "com.redhat.abrt" on a system dbus.
+perform a dbus call to "org.freedesktop.problems" on a system dbus.
If there is no program with this name on it, dbus autostart
-will invoke abrtd, which registers "com.redhat.abrt"
+will invoke abrtd, which registers "org.freedesktop.problems"
and processes the call(s).
The key dbus calls served by abrtd are:
diff --git a/src/applet/applet.c b/src/applet/applet.c
index 752ba8c..c34e4c6 100644
--- a/src/applet/applet.c
+++ b/src/applet/applet.c
@@ -28,10 +28,6 @@
#include <libreport/internal_abrt_dbus.h>
#include "libabrt.h"
-#define ABRTD_DBUS_NAME "com.redhat.abrt"
-#define ABRTD_DBUS_PATH "/com/redhat/abrt"
-#define ABRTD_DBUS_IFACE "com.redhat.abrt"
-
static gboolean persistent_notification;
static GtkStatusIcon *ap_status_icon;
@@ -680,10 +676,10 @@ int main(int argc, char** argv)
attach_dbus_conn_to_glib_main_loop(system_conn, NULL, NULL);
if (!dbus_connection_add_filter(system_conn, handle_message, NULL, NULL))
error_msg_and_die("Can't add dbus filter");
- //signal sender=:1.73 -> path=/com/redhat/abrt; interface=com.redhat.abrt; member=Crash
+ //signal sender=:1.73 -> path=/org/freedesktop/problems; interface=org.freedesktop.problems; member=Crash
// string "coreutils-7.2-3.fc11"
// string "0"
- dbus_bus_add_match(system_conn, "type='signal',path='/com/redhat/abrt'", &err);
+ dbus_bus_add_match(system_conn, "type='signal',path='"ABRT_DBUS_OBJECT"'", &err);
die_if_dbus_error(false, &err, "Can't add dbus match");
/* dbus_abrt cannot handle more than one bus, and we don't really need to.
@@ -691,7 +687,7 @@ int main(int argc, char** argv)
DBusConnection* session_conn = dbus_bus_get(DBUS_BUS_SESSION, &err);
die_if_dbus_error(session_conn == NULL, &err, "Can't connect to session dbus");
int r = dbus_bus_request_name(session_conn,
- "com.redhat.abrt.applet",
+ ABRT_DBUS_NAME".applet",
/* flags */ DBUS_NAME_FLAG_DO_NOT_QUEUE, &err);
die_if_dbus_error(r != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER, &err,
"Problem connecting to dbus, or applet is already running");
diff --git a/src/daemon/com.redhat.abrt.service b/src/daemon/com.redhat.abrt.service
deleted file mode 100644
index ca25960..0000000
--- a/src/daemon/com.redhat.abrt.service
+++ /dev/null
@@ -1,7 +0,0 @@
-[D-BUS Service]
-Name=com.redhat.abrt
-# For testing, you may use -t5 to use small timeout of 5 seconds.
-# This will make "abrtd exited while clients existed but were idle"
-# situations easier to trigger
-Exec=/usr/sbin/abrt-dbus -t133
-User=root
diff --git a/src/dbus/dbus_event.conf b/src/dbus/dbus_event.conf
index f943147..4d24fef 100644
--- a/src/dbus/dbus_event.conf
+++ b/src/dbus/dbus_event.conf
@@ -1,16 +1,16 @@
EVENT=notify package!= uid!=
- dbus-send --system --type=signal /com/redhat/abrt com.redhat.abrt.Crash \
+ dbus-send --system --type=signal /org/freedesktop/problems org.freedesktop.problems.Crash \
string:"`cat package`" string:"$DUMP_DIR" string:"`cat uid`"
EVENT=notify package!= uid=
- dbus-send --system --type=signal /com/redhat/abrt com.redhat.abrt.Crash \
+ dbus-send --system --type=signal /org/freedesktop/problems org.freedesktop.problems.Crash \
string:"`cat package`" string:"$DUMP_DIR"
EVENT=notify-dup package!= uid!=
- dbus-send --system --type=signal /com/redhat/abrt com.redhat.abrt.Crash \
+ dbus-send --system --type=signal /org/freedesktop/problems org.freedesktop.problems.Crash \
string:"`cat package`" string:"$DUMP_DIR" string:"`cat uid`"
EVENT=notify-dup package!= uid=
- dbus-send --system --type=signal /com/redhat/abrt com.redhat.abrt.Crash \
+ dbus-send --system --type=signal /org/freedesktop/problems org.freedesktop.problems.Crash \
string:"`cat package`" string:"$DUMP_DIR"
diff --git a/tests/runtests/dbus-message/runtest.sh b/tests/runtests/dbus-message/runtest.sh
index 1a6d007..01caea2 100755
--- a/tests/runtests/dbus-message/runtest.sh
+++ b/tests/runtests/dbus-message/runtest.sh
@@ -40,7 +40,7 @@ rlJournalStart
TmpDir=$(mktemp -d)
pushd $TmpDir
rlRun "dbus-monitor --system \
- \"type='signal',interface='com.redhat.abrt',path='/com/redhat/abrt'\" \
+ \"type='signal',interface='org.freedesktop.problems',path='/org/freedesktop/problems'\" \
> dbus.log &" 0 "Running dbus-monitor"
rlPhaseEnd
--
1.7.11.4
11 years, 7 months
[PATCH] retrace-client: respect chrooted os_release in pkgcheck
by Michal Toman
---
src/plugins/abrt-retrace-client.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/src/plugins/abrt-retrace-client.c b/src/plugins/abrt-retrace-client.c
index db3023f..9a5ad6b 100644
--- a/src/plugins/abrt-retrace-client.c
+++ b/src/plugins/abrt-retrace-client.c
@@ -510,7 +510,12 @@ static int create(bool delete_temp_archive,
char *package = dd_load_text(dd, FILENAME_PACKAGE);
char *arch = dd_load_text(dd, FILENAME_ARCHITECTURE);
- char *release = dd_load_text(dd, FILENAME_OS_RELEASE);
+ char *release;
+ if (dd_exist(dd, FILENAME_ROOTDIR) &&
+ dd_exist(dd, FILENAME_OS_RELEASE_IN_ROOTDIR))
+ release = dd_load_text(dd, FILENAME_OS_RELEASE_IN_ROOTDIR);
+ else
+ release = dd_load_text(dd, FILENAME_OS_RELEASE);
dd_close(dd);
--
1.7.1
11 years, 7 months