[PATCH] trac#522 : abrt vmcore plugin verbosity correction
by Jakub Filak
---
src/plugins/abrt-action-analyze-vmcore.in | 7 +++++--
src/plugins/abrt-action-install-debuginfo.in | 2 ++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/plugins/abrt-action-analyze-vmcore.in b/src/plugins/abrt-action-analyze-vmcore.in
index af606c4..c3f2e2e 100644
--- a/src/plugins/abrt-action-analyze-vmcore.in
+++ b/src/plugins/abrt-action-analyze-vmcore.in
@@ -25,7 +25,7 @@ if __name__ == "__main__":
vmlinux_di_path = ""
tmpdir = ""
vmcore = ""
- global verbose
+
help_text = _("Usage: {0} [-v[v]] [--core=VMCORE] [--tmpdir=TMPDIR] [--cache=CACHEDIR]").format(PROGNAME)
try:
opts, args = getopt.getopt(sys.argv[1:], "hvd", ["help", "tmpdir=", "cache=", "core="])
@@ -114,7 +114,10 @@ if __name__ == "__main__":
error_msg_and_die(_("Can't download required debuginfo"))
vmlinux_di_path = "{0}/usr/lib/debug/lib/modules/{1}/vmlinux".format(vmlinux_di_cachedir, ver)
else: # we need to use the suid wrapper, if we use the default cache
- downloader = Popen(["/usr/libexec/abrt-action-install-debuginfo-to-abrt-cache", "--size_mb=4096", "--exact={0}".format(vmlinux_di_path)], bufsize = -1)
+ downloader_args = ["/usr/libexec/abrt-action-install-debuginfo-to-abrt-cache", "--size_mb=4096", "--exact={0}".format(vmlinux_di_path)]
+ if verbose > 0:
+ downloader_args.append("-{0}".format("v"*verbose))
+ downloader = Popen(downloader_args, bufsize = -1)
res = downloader.wait()
if res != 0:
error_msg_and_die(_("Can't download required debuginfo"))
diff --git a/src/plugins/abrt-action-install-debuginfo.in b/src/plugins/abrt-action-install-debuginfo.in
index a6c39f3..a061fa6 100644
--- a/src/plugins/abrt-action-install-debuginfo.in
+++ b/src/plugins/abrt-action-install-debuginfo.in
@@ -134,6 +134,8 @@ if __name__ == "__main__":
missing=arg.split(':')
exact_fls = True
+ set_verbosity(verbose)
+
if not cachedirs:
try:
fp = open("@sysconfdir@/@PACKAGE_NAME(a)/plugins/CCpp.conf", "r")
--
1.7.7.6
11 years, 10 months
[PATCH 1/2] reporter-bugzilla: fixed memory leak in find_best_bt_rating_in_comments() function
by Jakub Filak
---
src/plugins/rhbz.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
index 2e7d62c..b5f73b0 100644
--- a/src/plugins/rhbz.c
+++ b/src/plugins/rhbz.c
@@ -131,6 +131,11 @@ static unsigned find_best_bt_rating_in_comments(GList *comments)
errno = 0;
char *e;
long rating = strtoul(rating_srt, &e, 10);
+
+ /* rating_str can be safely freed here because the following code
+ * works only with memory address and not with the memory itself */
+ free(rating_srt);
+
if (errno || rating_srt == e || *e != '\0' || rating > UINT_MAX)
{
/* error / no digits / illegal trailing chars */
--
1.7.7.6
11 years, 11 months
[PATCH libreport] ureport: ureport introduction
by Nikola Pajkovsky
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
.gitignore | 1 +
configure.ac | 1 +
libreport.spec.in | 15 +++
src/include/internal_libreport.h | 2 +
src/lib/Makefile.am | 6 +-
src/lib/json.c | 257 ++++++++++++++++++++++++++++++++++++++
src/plugins/Makefile.am | 16 ++-
src/plugins/ureport.c | 52 ++++++++
8 files changed, 348 insertions(+), 2 deletions(-)
create mode 100644 src/lib/json.c
create mode 100644 src/plugins/ureport.c
diff --git a/.gitignore b/.gitignore
index 88419e9..5492e17 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,6 +16,7 @@ src/plugins/reporter-mailx
src/plugins/reporter-print
src/plugins/reporter-rhtsupport
src/plugins/reporter-upload
+src/plugins/reporter-ureport
src/plugins/report
src/plugins/abrt-bodhi
src/report-newt/report-newt
diff --git a/configure.ac b/configure.ac
index 851cc89..2d5dd25 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,6 +76,7 @@ PKG_CHECK_MODULES([CURL], [libcurl])
PKG_CHECK_MODULES([GNOME_KEYRING], [gnome-keyring-1])
PKG_CHECK_MODULES([JSON_C], [json])
PKG_CHECK_MODULES([RPM], [rpm])
+PKG_CHECK_MODULES([BTPARSER], [btparser])
# Just PKG_CHECK_MODULES([PYTHON], [python]) works only with python2.7+
# Below, if python is not found, we set up for python2.6 w/o checking:
diff --git a/libreport.spec.in b/libreport.spec.in
index b7d5550..fc40192 100644
--- a/libreport.spec.in
+++ b/libreport.spec.in
@@ -27,6 +27,7 @@ BuildRequires: asciidoc
BuildRequires: xmlto
BuildRequires: newt-devel
BuildRequires: libproxy-devel
+BuildRequires: btparser-devel
Requires: libreport-filesystem
# required for update from old report library, otherwise we obsolete report-gtk
# and all it's plugins, but don't provide the python bindings and the sealert
@@ -170,6 +171,15 @@ BuildRequires: rpm-devel
%description plugin-bodhi
Search for a new updates in bodhi server
+%package plugin-ureport
+Summary: %{name}'s bodhi plugin
+BuildRequires: json-c-devel
+Group: System Environment/Libraries
+Requires: %{name} = %{version}-%{release}
+
+%description plugin-ureport
+Uploads micro-report to abrt server
+
%description plugin-bugzilla
Plugin to report bugs into the bugzilla.
@@ -343,6 +353,11 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%{_bindir}/abrt-bodhi
%{_mandir}/man1/abrt-bodhi.1.gz
+%files plugin-ureport
+%defattr(-,root,root,-)
+%{_bindir}/reporter-ureport
+#%{_mandir}/man1/reporter-ureport.1.gz
+
%files plugin-bugzilla
%defattr(-,root,root,-)
%config(noreplace) %{_sysconfdir}/libreport/plugins/bugzilla.conf
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
index c46a525..94482af 100644
--- a/src/include/internal_libreport.h
+++ b/src/include/internal_libreport.h
@@ -788,6 +788,8 @@ unsigned parse_opts(int argc, char **argv, const struct options *opt,
#define show_usage_and_die libreport_show_usage_and_die
void show_usage_and_die(const char *usage, const struct options *opt) NORETURN;
+#define post_ureport libreport_post_ureport
+int post_ureport(problem_data_t *pd);
#ifdef __cplusplus
}
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index cffabb2..6315591 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -94,7 +94,7 @@ libabrt_dbus_la_LIBADD = \
libabrt_web_la_SOURCES = \
abrt_curl.h abrt_curl.c \
abrt_xmlrpc.h abrt_xmlrpc.c \
- proxies.h proxies.c
+ proxies.h proxies.c json.c
libabrt_web_la_CPPFLAGS = \
-Wall -Wwrite-strings -Werror \
-I$(srcdir)/../include \
@@ -109,6 +109,8 @@ libabrt_web_la_CPPFLAGS = \
$(LIBXML_CFLAGS) \
$(XMLRPC_CFLAGS) $(XMLRPC_CLIENT_CFLAGS) \
$(LIBREPORT_CFLAGS) \
+ $(JSON_C_CFLAGS) \
+ $(BTPARSER_CFLAGS) \
-D_GNU_SOURCE
libabrt_web_la_LDFLAGS = \
-version-info 0:1:0
@@ -117,6 +119,8 @@ libabrt_web_la_LIBADD = \
$(CURL_LIBS) \
$(PROXY_LIBS) \
$(LIBXML_LIBS) \
+ $(JSON_C_LIBS) \
+ $(BTPARSER_LIBS) \
$(XMLRPC_LIBS) $(XMLRPC_CLIENT_LIBS)
$(DESTDIR)/$(DEBUG_DUMPS_DIR):
diff --git a/src/lib/json.c b/src/lib/json.c
new file mode 100644
index 0000000..935eadf
--- /dev/null
+++ b/src/lib/json.c
@@ -0,0 +1,257 @@
+/*
+ Copyright (C) 2012 ABRT team
+ Copyright (C) 2012 RedHat Inc
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include <json/json.h>
+#include <btparser/thread.h>
+#include <btparser/core-backtrace.h>
+
+#include "internal_libreport.h"
+#include "abrt_curl.h"
+
+
+static const char *ureport_url = "10.34.24.254/cgi-bin/json.cgi";
+
+/* on success 1 returned, on error zero is returned and appropriate value
+ * is returned as third argument. You should never read third argument when
+ * function fails
+ *
+ * json-c library doesn't have any json_object_new_long,
+ * thus we have to use only int
+ */
+static int get_pd_int_item(problem_data_t *pd, const char *key, int *result)
+{
+ if (!pd || !key)
+ return 0;
+
+ char *pd_item = get_problem_item_content_or_NULL(pd, key);
+ if (!pd_item)
+ {
+ VERB1 log("warning: '%s' is not an item in problem directory", key);
+ return 0;
+ }
+
+ int old_errno = errno;
+ errno = 0;
+ char *e;
+ long i = strtol(pd_item, &e, 10);
+ if (errno || pd_item == e || *e != '\0' || (int) i != i)
+ return 0;
+
+ *result = i;
+
+ errno = old_errno;
+ return 1;
+}
+
+static void ureport_add_int(struct json_object *ur, const char *key, int i)
+{
+ struct json_object *jint = json_object_new_int(i);
+ if (!jint)
+ return;
+
+ json_object_object_add(ur, key, jint);
+}
+
+static void ureport_add_str(struct json_object *ur, const char *key,
+ const char *s)
+{
+ struct json_object *jstring = json_object_new_string(s);
+ if (!jstring)
+ return;
+
+ json_object_object_add(ur, key, jstring);
+}
+
+static void ureport_add_os(struct json_object *ur, problem_data_t *pd)
+{
+ struct json_object *jobject = json_object_new_object();
+
+ char *pd_item = get_problem_item_content_or_NULL(pd, FILENAME_OS_RELEASE);
+ if (!pd_item)
+ return;
+
+ char *name, *version;
+ parse_release_for_rhts(pd_item, &name, &version);
+
+ ureport_add_str(jobject, "name", name);
+ ureport_add_str(jobject, "version", version);
+
+ json_object_object_add(ur, "os", jobject);
+}
+
+static void ureport_add_type(struct json_object *ur, problem_data_t *pd)
+{
+ char *pd_item = get_problem_item_content_or_NULL(pd, "analyzer");
+ if (!pd_item)
+ return;
+
+ const char type[] = "type";
+ if (!strcmp(pd_item, "CCpp"))
+ ureport_add_str(ur, type, "USERSPACE");
+ if (!strcmp(pd_item, "Python"))
+ ureport_add_str(ur, type, "PYTHON");
+ if (!strcmp(pd_item, "Kerneloops"))
+ ureport_add_str(ur, type, "KERNELOOPS");
+}
+
+static void ureport_add_core_backtrace(struct json_object *ur, problem_data_t *pd)
+{
+ char *pd_item = get_problem_item_content_or_NULL(pd, FILENAME_CORE_BACKTRACE);
+ if (!pd_item)
+ return;
+
+ struct json_object *jarray = json_object_new_array();
+ if (!jarray)
+ return;
+
+ struct btp_thread *core_bt = btp_load_core_backtrace(pd_item);
+ if (!core_bt)
+ return;
+
+ struct btp_frame *frame;
+ unsigned frame_nr = 0;
+ for (frame = core_bt->frames; frame; frame = frame->next)
+ {
+ struct frame_aux *aux = frame->user_data;
+
+ struct json_object *item = json_object_new_object();
+ log("funcname '%s'", frame->function_name);
+ if (frame->function_name)
+ ureport_add_str(item, "funcname", frame->function_name);
+
+ log("buildid '%s'", aux->build_id);
+ if (aux->build_id)
+ ureport_add_str(item, "buildid", aux->build_id);
+
+ log("fingerprint '%s'", aux->fingerprint);
+ if (aux->fingerprint)
+ ureport_add_str(item, "funchash", aux->fingerprint);
+
+ if ((uintmax_t)frame->address)
+ ureport_add_int(item, "offset", (uintmax_t)frame->address);
+
+ ureport_add_int(item, "frame", frame_nr++);
+ ureport_add_int(item, "thread", 0);
+
+
+ json_object_array_add(jarray, item);
+ }
+
+
+ json_object_object_add(ur, FILENAME_CORE_BACKTRACE, jarray);
+}
+
+#define ureport_add_id_str(name) \
+ static inline void ureport_add_##name(struct json_object *ur, \
+ problem_data_t *pd, \
+ const char *skip_pfx) \
+ { \
+ char *pd_item = get_problem_item_content_or_NULL(pd, #name); \
+ if (!pd_item) \
+ return; \
+ \
+ const char *name = skip_pfx ? #name + strlen(skip_pfx): #name; \
+ ureport_add_str(ur, name, pd_item); \
+ }
+
+#define ureport_add_id_int(name) \
+ static inline void ureport_add_##name(struct json_object *ur, \
+ problem_data_t *pd, \
+ const char *skip_pfx) \
+ { \
+ int nr; \
+ int stat = get_pd_int_item(pd, #name, &nr); \
+ if (!stat) \
+ return; \
+ \
+ const char *name = skip_pfx ? #name + strlen(skip_pfx): #name; \
+ ureport_add_int(ur, name, nr); \
+ }
+
+ureport_add_id_str(architecture);
+ureport_add_id_str(executable);
+ureport_add_id_str(reason);
+ureport_add_id_str(user_type);
+ureport_add_id_str(pkg_name);
+ureport_add_id_str(pkg_version);
+ureport_add_id_str(pkg_release);
+ureport_add_id_str(pkg_arch);
+
+ureport_add_id_int(uptime);
+ureport_add_id_int(crash_thread);
+ureport_add_id_int(pkg_epoch);
+
+static void ureport_add_pkg(struct json_object *ur, problem_data_t *pd)
+{
+ struct json_object *jobject = json_object_new_object();
+ if (!jobject)
+ return;
+
+ ureport_add_pkg_epoch(jobject, pd, "pkg_");
+ ureport_add_pkg_name(jobject, pd, "pkg_");
+ ureport_add_pkg_version(jobject, pd, "pkg_");
+ ureport_add_pkg_release(jobject, pd, "pkg_");
+ ureport_add_pkg_arch(jobject, pd, "pkg_");
+
+ json_object_object_add(ur, "installed_package", jobject);
+
+}
+
+const char *new_json_ureport(problem_data_t *pd)
+{
+ struct json_object *ureport = json_object_new_object();
+
+ ureport_add_user_type(ureport, pd, NULL);
+ ureport_add_crash_thread(ureport, pd, NULL);
+ ureport_add_uptime(ureport, pd, NULL);
+ ureport_add_architecture(ureport, pd, NULL);
+ ureport_add_executable(ureport, pd, NULL);
+ ureport_add_reason(ureport, pd, NULL);
+
+ ureport_add_type(ureport, pd);
+
+ ureport_add_pkg(ureport, pd);
+ ureport_add_os(ureport, pd);
+
+ ureport_add_core_backtrace(ureport, pd);
+
+ return json_object_to_json_string(ureport);
+}
+
+int post_ureport(problem_data_t *pd)
+{
+ abrt_post_state_t *post_state;
+ post_state = new_abrt_post_state(ABRT_POST_WANT_BODY
+ | ABRT_POST_WANT_SSL_VERIFY
+ | ABRT_POST_WANT_ERROR_MSG);
+
+ const char *headers[] = {
+ "Accept: application/json",
+ "Connection: close",
+ "X-Task-Type: 1",
+ NULL,
+ };
+
+ const char *json_ureport = new_json_ureport(pd);
+
+ abrt_post_string(post_state, ureport_url, "text/plain",
+ headers, json_ureport);
+
+ return 0;
+}
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 6514ff6..476a59d 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -8,7 +8,8 @@ bin_PROGRAMS = \
reporter-mailx \
reporter-print \
report \
- abrt-bodhi
+ abrt-bodhi \
+ reporter-ureport
pluginsconfdir = $(PLUGINS_CONF_DIR)
@@ -218,4 +219,17 @@ abrt_bodhi_LDADD = \
../lib/libreport.la \
../lib/libabrt_web.la
+reporter_ureport_SOURCES = \
+ ureport.c
+reporter_ureport_CPPFLAGS = \
+ -I$(srcdir)/../include \
+ -I$(srcdir)/../lib \
+ $(GLIB_CFLAGS) \
+ $(LIBREPORT_CFLAGS) \
+ -D_GNU_SOURCE \
+ -Wall -Wwrite-strings -Werror
+reporter_ureport_LDADD = \
+ ../lib/libreport.la \
+ ../lib/libabrt_web.la
+
DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
diff --git a/src/plugins/ureport.c b/src/plugins/ureport.c
new file mode 100644
index 0000000..a9f85fc
--- /dev/null
+++ b/src/plugins/ureport.c
@@ -0,0 +1,52 @@
+/*
+ Copyright (C) 2012 ABRT Team
+ Copyright (C) 2012 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include "internal_libreport.h"
+
+int main(int argc, char **argv)
+{
+ abrt_init(argv);
+
+ const char *dump_dir_path = ".";
+ struct options program_options[] = {
+ OPT__VERBOSE(&g_verbose),
+ OPT__DUMP_DIR(&dump_dir_path),
+ OPT_END(),
+ };
+
+ const char *program_usage_string = _(
+ "& [-v] -d DIR\n"
+ "\n"
+ "Upload micro report"
+ );
+
+ parse_opts(argc, argv, program_options, program_usage_string);
+ struct dump_dir *dd = dd_opendir(dump_dir_path, DD_OPEN_READONLY);
+ if (!dd)
+ xfunc_die();
+
+ problem_data_t *pd = create_problem_data_from_dump_dir(dd);
+ dd_close(dd);
+ if (!pd)
+ xfunc_die(); /* create_problem_data_for_reporting already emitted error msg */
+
+ post_ureport(pd);
+
+ return 0;
+}
--
1.7.9.3
11 years, 12 months
[PATCH] trac#527 : include locale.h where it is required
by Jakub Filak
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
configure.ac | 2 ++
src/applet/applet.c | 7 ++++---
src/cli/abrt-cli.c | 5 +++++
src/daemon/abrt-action-save-package-data.c | 5 +++++
src/daemon/abrt-handle-event.c | 4 ++++
src/daemon/abrt-server.c | 5 +++++
src/daemon/abrtd.c | 6 +++---
src/dbus/abrt-dbus.c | 3 +++
src/gui-gtk/main.c | 8 +++++---
src/plugins/abrt-action-analyze-backtrace.c | 4 ++++
src/plugins/abrt-action-analyze-c.c | 4 ++++
src/plugins/abrt-action-analyze-oops.c | 3 +++
src/plugins/abrt-action-analyze-python.c | 4 ++++
src/plugins/abrt-action-generate-backtrace.c | 3 +++
src/plugins/abrt-action-generate-core-backtrace.c | 4 ++++
src/plugins/abrt-action-trim-files.c | 4 ++++
src/plugins/abrt-dump-oops.c | 3 +++
src/plugins/abrt-dump-xorg.c | 4 ++++
src/plugins/abrt-watch-log.c | 4 ++++
19 files changed, 73 insertions(+), 9 deletions(-)
diff --git a/configure.ac b/configure.ac
index 987cacd..ed0331e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -96,6 +96,8 @@ AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir"])
AC_CHECK_HEADER([sys/inotify.h], [],
[AC_MSG_ERROR([sys/inotify.h is needed to build abrt])])
+AC_CHECK_HEADERS([locale.h])
+
CONF_DIR='${sysconfdir}/${PACKAGE_NAME}'
VAR_RUN='${localstatedir}/run'
PLUGINS_CONF_DIR='${sysconfdir}/${PACKAGE_NAME}/plugins'
diff --git a/src/applet/applet.c b/src/applet/applet.c
index 414ccb3..2c620e7 100644
--- a/src/applet/applet.c
+++ b/src/applet/applet.c
@@ -16,9 +16,6 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#if HAVE_LOCALE_H
-# include <locale.h>
-#endif
#include <gtk/gtk.h>
#include <libnotify/notify.h>
#include <dbus/dbus-shared.h>
@@ -28,6 +25,10 @@
#include <internal_abrt_dbus.h>
#include "libabrt.h"
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif /* HAVE_LOCALE_H */
+
#define ABRTD_DBUS_NAME "com.redhat.abrt"
#define ABRTD_DBUS_PATH "/com/redhat/abrt"
#define ABRTD_DBUS_IFACE "com.redhat.abrt"
diff --git a/src/cli/abrt-cli.c b/src/cli/abrt-cli.c
index 894ab25..1961bd7 100644
--- a/src/cli/abrt-cli.c
+++ b/src/cli/abrt-cli.c
@@ -18,6 +18,11 @@
*/
#include "libabrt.h"
+
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif /* HAVE_LOCALE_H */
+
#include "builtin-cmd.h"
#define USAGE_OPTS_WIDTH 12
diff --git a/src/daemon/abrt-action-save-package-data.c b/src/daemon/abrt-action-save-package-data.c
index f2258d0..13f9512 100644
--- a/src/daemon/abrt-action-save-package-data.c
+++ b/src/daemon/abrt-action-save-package-data.c
@@ -18,6 +18,11 @@
*/
#include <fnmatch.h>
#include "libabrt.h"
+
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif /* HAVE_LOCALE_H */
+
#include "rpm.h"
static bool settings_bOpenGPGCheck = false;
diff --git a/src/daemon/abrt-handle-event.c b/src/daemon/abrt-handle-event.c
index 58c4a84..cf6d625 100644
--- a/src/daemon/abrt-handle-event.c
+++ b/src/daemon/abrt-handle-event.c
@@ -20,6 +20,10 @@
#include "libabrt.h"
#include "run_event.h"
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif /* HAVE_LOCALE_H */
+
#include <btparser/frame.h>
#include <btparser/thread.h>
#include <btparser/normalize.h>
diff --git a/src/daemon/abrt-server.c b/src/daemon/abrt-server.c
index 15f3370..0d7dd53 100644
--- a/src/daemon/abrt-server.c
+++ b/src/daemon/abrt-server.c
@@ -18,6 +18,11 @@
#include <syslog.h>
#include "libabrt.h"
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif /* HAVE_LOCALE_H */
+
+
/* Maximal length of backtrace. */
#define MAX_BACKTRACE_SIZE (1024*1024)
/* Amount of data received from one client for a message before reporting error. */
diff --git a/src/daemon/abrtd.c b/src/daemon/abrtd.c
index e2ace8e..dfa66c8 100644
--- a/src/daemon/abrtd.c
+++ b/src/daemon/abrtd.c
@@ -16,9 +16,6 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#if HAVE_LOCALE_H
-# include <locale.h>
-#endif
#include <sys/un.h>
#include <syslog.h>
#include <sys/inotify.h>
@@ -26,6 +23,9 @@
#include "libabrt.h"
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif
/* I want to use -Werror, but gcc-4.4 throws a curveball:
* "warning: ignoring return value of 'ftruncate', declared with attribute warn_unused_result"
diff --git a/src/dbus/abrt-dbus.c b/src/dbus/abrt-dbus.c
index 37c9d69..7a0b0c5 100644
--- a/src/dbus/abrt-dbus.c
+++ b/src/dbus/abrt-dbus.c
@@ -4,6 +4,9 @@
#include <pwd.h>
#include <grp.h>
#include "libabrt.h"
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif /* HAVE_LOCALE_H */
#include "abrt-polkit.h"
#include "abrt-dbus.h"
#include "dump_dir.h"
diff --git a/src/gui-gtk/main.c b/src/gui-gtk/main.c
index e80d1c7..1e3c13e 100644
--- a/src/gui-gtk/main.c
+++ b/src/gui-gtk/main.c
@@ -20,11 +20,13 @@
#include <gdk/gdkkeysyms.h>
#include <sys/inotify.h>
#include <gio/gio.h> //dbus
-#if HAVE_LOCALE_H
-# include <locale.h>
-#endif
#include <internal_libreport_gtk.h>
#include "libabrt.h"
+
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif /* HAVE_LOCALE_H */
+
#include "abrt-dbus.h"
#if GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 22
diff --git a/src/plugins/abrt-action-analyze-backtrace.c b/src/plugins/abrt-action-analyze-backtrace.c
index 3333c7e..15f3e29 100644
--- a/src/plugins/abrt-action-analyze-backtrace.c
+++ b/src/plugins/abrt-action-analyze-backtrace.c
@@ -20,6 +20,10 @@
#include <btparser/location.h>
#include "libabrt.h"
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif /* HAVE_LOCALE_H */
+
static const char *dump_dir_name = ".";
diff --git a/src/plugins/abrt-action-analyze-c.c b/src/plugins/abrt-action-analyze-c.c
index 28ddf4a..53e1420 100644
--- a/src/plugins/abrt-action-analyze-c.c
+++ b/src/plugins/abrt-action-analyze-c.c
@@ -18,6 +18,10 @@
*/
#include "libabrt.h"
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif /* HAVE_LOCALE_H */
+
static void create_hash(char hash_str[SHA1_RESULT_LEN*2 + 1], const char *pInput)
{
char hash_bytes[SHA1_RESULT_LEN];
diff --git a/src/plugins/abrt-action-analyze-oops.c b/src/plugins/abrt-action-analyze-oops.c
index 3eb0a61..eb35aae 100644
--- a/src/plugins/abrt-action-analyze-oops.c
+++ b/src/plugins/abrt-action-analyze-oops.c
@@ -18,6 +18,9 @@
*/
#include "libabrt.h"
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif /* HAVE_LOCALE_H */
int main(int argc, char **argv)
{
diff --git a/src/plugins/abrt-action-analyze-python.c b/src/plugins/abrt-action-analyze-python.c
index aeab349..9000873 100644
--- a/src/plugins/abrt-action-analyze-python.c
+++ b/src/plugins/abrt-action-analyze-python.c
@@ -18,6 +18,10 @@
*/
#include "libabrt.h"
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif /* HAVE_LOCALE_H */
+
int main(int argc, char **argv)
{
/* I18n */
diff --git a/src/plugins/abrt-action-generate-backtrace.c b/src/plugins/abrt-action-generate-backtrace.c
index 71be7d1..16a4674 100644
--- a/src/plugins/abrt-action-generate-backtrace.c
+++ b/src/plugins/abrt-action-generate-backtrace.c
@@ -18,6 +18,9 @@
*/
#include "libabrt.h"
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif /* HAVE_LOCALE_H */
static const char *dump_dir_name = ".";
/* 60 seconds was too limiting on slow machines */
diff --git a/src/plugins/abrt-action-generate-core-backtrace.c b/src/plugins/abrt-action-generate-core-backtrace.c
index f6640b3..b6fee14 100644
--- a/src/plugins/abrt-action-generate-core-backtrace.c
+++ b/src/plugins/abrt-action-generate-core-backtrace.c
@@ -18,6 +18,10 @@
*/
#include "libabrt.h"
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif /* HAVE_LOCALE_H */
+
#ifdef ENABLE_DISASSEMBLY
#include <libelf.h>
#include <gelf.h>
diff --git a/src/plugins/abrt-action-trim-files.c b/src/plugins/abrt-action-trim-files.c
index 78c7cd3..8ed6972 100644
--- a/src/plugins/abrt-action-trim-files.c
+++ b/src/plugins/abrt-action-trim-files.c
@@ -18,6 +18,10 @@
*/
#include "libabrt.h"
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif /* HAVE_LOCALE_H */
+
/* We remember N worst files and their sizes, not just one:
* if DIR is deep, scanning it takes *a few seconds* even if it's in cache.
* If we rescan it after each single file deletion, it can be VERY slow.
diff --git a/src/plugins/abrt-dump-oops.c b/src/plugins/abrt-dump-oops.c
index cd4ef70..9c5b019 100644
--- a/src/plugins/abrt-dump-oops.c
+++ b/src/plugins/abrt-dump-oops.c
@@ -19,6 +19,9 @@
#include <syslog.h>
#include "libabrt.h"
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif /* HAVE_LOCALE_H */
static bool world_readable_dump = false;
static const char *debug_dumps_dir = ".";
diff --git a/src/plugins/abrt-dump-xorg.c b/src/plugins/abrt-dump-xorg.c
index a548732..b59b2fe 100644
--- a/src/plugins/abrt-dump-xorg.c
+++ b/src/plugins/abrt-dump-xorg.c
@@ -19,6 +19,10 @@
#include <syslog.h>
#include "libabrt.h"
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif /* HAVE_LOCALE_H */
+
/* I want to use -Werror, but gcc-4.4 throws a curveball:
* "warning: ignoring return value of 'ftruncate', declared with attribute warn_unused_result"
* and (void) cast is not enough to shut it up! Oh God...
diff --git a/src/plugins/abrt-watch-log.c b/src/plugins/abrt-watch-log.c
index 0b15eee..dbe8a98 100644
--- a/src/plugins/abrt-watch-log.c
+++ b/src/plugins/abrt-watch-log.c
@@ -20,6 +20,10 @@
#include <sys/inotify.h>
#include "libabrt.h"
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif /* HAVE_LOCALE_H */
+
#define MAX_SCAN_BLOCK (4*1024*1024)
#define READ_AHEAD (10*1024)
--
1.7.7.6
12 years
[PATCH abrt v2] a-a-save-package-data: store package epoch, name, version, release and arch in separate files
by Nikola Pajkovsky
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
src/daemon/abrt-action-save-package-data.c | 46 ++++++++--------
src/daemon/rpm.c | 82 +++++++++++++++++++++++++---
src/daemon/rpm.h | 13 ++++-
3 files changed, 111 insertions(+), 30 deletions(-)
diff --git a/src/daemon/abrt-action-save-package-data.c b/src/daemon/abrt-action-save-package-data.c
index 00b2843..8921b6c 100644
--- a/src/daemon/abrt-action-save-package-data.c
+++ b/src/daemon/abrt-action-save-package-data.c
@@ -181,8 +181,7 @@ static bool is_path_blacklisted(const char *path)
return false;
}
-static int get_script_name(const char *cmdline, char **executable,
- char **package_full_name)
+static struct pkg_envra *get_script_name(const char *cmdline, char **executable)
{
// TODO: we don't verify that python executable is not modified
// or that python package is properly signed
@@ -191,7 +190,7 @@ static int get_script_name(const char *cmdline, char **executable,
* This will work only if the cmdline contains the whole path.
* Example: python /usr/bin/system-control-network
*/
- char *script_pkg = NULL;
+ struct pkg_envra *script_pkg = NULL;
char *script_name = get_argv1_if_full_path(cmdline);
if (script_name)
{
@@ -203,24 +202,22 @@ static int get_script_name(const char *cmdline, char **executable,
* Replace interpreter's package_full_name and executable
* with data pertaining to the script.
*/
- free(*package_full_name);
- *package_full_name = script_pkg;
*executable = script_name;
/* executable has changed, check it again */
if (is_path_blacklisted(*executable))
{
log("Blacklisted executable '%s'", *executable);
- return 1;
+ return NULL;
}
}
}
if (!script_pkg && !settings_bProcessUnpackaged)
{
log("Interpreter crashed, but no packaged script detected: '%s'", cmdline);
- return 1;
+ return NULL;
}
- return 0;
+ return script_pkg;
}
static int SavePackageDescriptionToDebugDump(const char *dump_dir_name)
@@ -243,9 +240,8 @@ static int SavePackageDescriptionToDebugDump(const char *dump_dir_name)
char *cmdline = NULL;
char *executable = NULL;
char *rootdir = NULL;
- char *script_name = NULL; /* only if "interpreter /path/to/script" */
char *package_short_name = NULL;
- char *package_full_name = NULL;
+ struct pkg_envra *pkg_name = NULL;
char *component = NULL;
int error = 1;
/* note: "goto ret" statements below free all the above variables,
@@ -266,8 +262,8 @@ static int SavePackageDescriptionToDebugDump(const char *dump_dir_name)
goto ret; /* return 1 (failure) */
}
- package_full_name = rpm_get_package_nvr(executable, rootdir);
- if (!package_full_name)
+ pkg_name = rpm_get_package_nvr(executable, rootdir);
+ if (!pkg_name)
{
if (settings_bProcessUnpackaged)
{
@@ -289,13 +285,16 @@ static int SavePackageDescriptionToDebugDump(const char *dump_dir_name)
if (!strcmp(basename, "python")
|| !strcmp(basename, "perl"))
{
- int r = get_script_name(cmdline, &executable, &package_full_name);
- if (r)
+ struct pkg_envra *script_pkg = get_script_name(cmdline, &executable);
+ if (!script_pkg)
goto ret;
+
+ free_pkg_envra(pkg_name);
+ pkg_name = script_pkg;
}
- package_short_name = get_package_name_from_NVR_or_NULL(package_full_name);
- VERB2 log("Package:'%s' short:'%s'", package_full_name, package_short_name);
+ package_short_name = xasprintf("%s", pkg_name->p_name);
+ VERB2 log("Package:'%s' short:'%s'", pkg_name->p_nvr, package_short_name);
GList *li;
@@ -329,14 +328,18 @@ static int SavePackageDescriptionToDebugDump(const char *dump_dir_name)
if (!dd)
goto ret; /* return 1 (failure) */
- if (package_full_name)
+ if (pkg_name)
{
- dd_save_text(dd, FILENAME_PACKAGE, package_full_name);
+ dd_save_text(dd, FILENAME_PACKAGE, pkg_name->p_nvr);
+ dd_save_text(dd, FILENAME_PKG_EPOCH, pkg_name->p_epoch);
+ dd_save_text(dd, FILENAME_PKG_NAME, pkg_name->p_name);
+ dd_save_text(dd, FILENAME_PKG_VERSION, pkg_name->p_version);
+ dd_save_text(dd, FILENAME_PKG_RELEASE, pkg_name->p_release);
+ dd_save_text(dd, FILENAME_PKG_ARCH, pkg_name->p_arch);
}
+
if (component)
- {
dd_save_text(dd, FILENAME_COMPONENT, component);
- }
dd_close(dd);
@@ -346,9 +349,8 @@ static int SavePackageDescriptionToDebugDump(const char *dump_dir_name)
free(cmdline);
free(executable);
free(rootdir);
- free(script_name);
free(package_short_name);
- free(package_full_name);
+ free_pkg_envra(pkg_name);
free(component);
return error;
diff --git a/src/daemon/rpm.c b/src/daemon/rpm.c
index 2fe57b8..a1f9532 100644
--- a/src/daemon/rpm.c
+++ b/src/daemon/rpm.c
@@ -219,14 +219,34 @@ char* rpm_get_component(const char *filename, const char *rootdir_or_NULL)
return ret;
}
+#define pkg_add_id(name) \
+ static inline int pkg_add_##name(Header header, struct pkg_envra *p) \
+ { \
+ const char *errmsg = NULL; \
+ p->p_##name = headerFormat(header, "%{"#name"}", &errmsg); \
+ if (p->p_##name || !errmsg) \
+ return 0; \
+ \
+ error_msg("cannot get "#name": %s", errmsg); \
+ \
+ return -1; \
+ } \
+
+pkg_add_id(epoch);
+pkg_add_id(name);
+pkg_add_id(version);
+pkg_add_id(release);
+pkg_add_id(arch);
+
// caller is responsible to free returned value
-char* rpm_get_package_nvr(const char *filename, const char *rootdir_or_NULL)
+struct pkg_envra *rpm_get_package_nvr(const char *filename, const char *rootdir_or_NULL)
{
- char *nvr = NULL;
rpmts ts;
rpmdbMatchIterator iter;
Header header;
+ struct pkg_envra *p = NULL;
+
ts = rpmtsCreate();
/* This loop executes once (normally) or twice (if we detect chroot) */
while (1)
@@ -254,14 +274,62 @@ char* rpm_get_package_nvr(const char *filename, const char *rootdir_or_NULL)
rootdir_or_NULL = NULL;
}
- const char *errmsg = NULL;
- nvr = headerFormat(header, "%{NAME}-%{VERSION}-%{RELEASE}", &errmsg);
- if (!nvr && errmsg)
- error_msg("cannot get nvr. reason: %s", errmsg);
+
+
+ p = xzalloc(sizeof(*p));
+ int r;
+ r = pkg_add_epoch(header, p);
+ if (r)
+ goto error;
+ /*
+ * <npajkovs> hello, what's the difference between epoch '0' and '(none)'?
+ * <Panu> nothing really, a missing epoch is considered equal to zero epoch
+ */
+ if (!strncmp(p->p_epoch, "(none)", strlen("(none)")))
+ {
+ free(p->p_epoch);
+ p->p_epoch = xstrdup("0");
+ }
+
+ r = pkg_add_name(header, p);
+ if (r)
+ goto error;
+
+ r = pkg_add_version(header, p);
+ if (r)
+ goto error;
+
+ r = pkg_add_release(header, p);
+ if (r)
+ goto error;
+
+ r = pkg_add_arch(header, p);
+ if (r)
+ goto error;
+
+ p->p_nvr = xasprintf("%s-%s-%s", p->p_name, p->p_version, p->p_release);
+
+ return p;
error:
+ free_pkg_envra(p);
+
rpmdbFreeIterator(iter);
error1:
rpmtsFree(ts);
- return nvr;
+ return NULL;
+}
+
+void free_pkg_envra(struct pkg_envra *p)
+{
+ if (!p)
+ return;
+
+ free(p->p_epoch);
+ free(p->p_name);
+ free(p->p_version);
+ free(p->p_release);
+ free(p->p_arch);
+ free(p->p_nvr);
+ free(p);
}
diff --git a/src/daemon/rpm.h b/src/daemon/rpm.h
index bd17bec..1b90368 100644
--- a/src/daemon/rpm.h
+++ b/src/daemon/rpm.h
@@ -31,6 +31,17 @@
extern "C" {
#endif
+struct pkg_envra {
+ char *p_nvr;
+ char *p_epoch;
+ char *p_name;
+ char *p_version;
+ char *p_release;
+ char *p_arch;
+};
+
+void free_pkg_envra(struct pkg_envra *p);
+
/**
* Checks if an application is modified by third party.
* @param pPackage A package name. The package contains the application.
@@ -64,7 +75,7 @@ int rpm_chk_fingerprint(const char* pkg);
* @param filename A file name.
* @return A package name (malloc'ed string)
*/
-char* rpm_get_package_nvr(const char *filename, const char *rootdir_or_NULL);
+struct pkg_envra *rpm_get_package_nvr(const char *filename, const char *rootdir_or_NULL);
/**
* Finds a main package for given file. This package contains particular
* file. If the file doesn't belong to any package, empty string is
--
1.7.9.3
12 years
[PATCH abrt] a-a-save-package-data: store package epoch, name, version, release and arch in separate files
by Nikola Pajkovsky
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
src/daemon/abrt-action-save-package-data.c | 46 +++++++++--------
src/daemon/rpm.c | 75 +++++++++++++++++++++++++---
src/daemon/rpm.h | 13 ++++-
3 files changed, 105 insertions(+), 29 deletions(-)
diff --git a/src/daemon/abrt-action-save-package-data.c b/src/daemon/abrt-action-save-package-data.c
index 00b2843..8921b6c 100644
--- a/src/daemon/abrt-action-save-package-data.c
+++ b/src/daemon/abrt-action-save-package-data.c
@@ -181,8 +181,7 @@ static bool is_path_blacklisted(const char *path)
return false;
}
-static int get_script_name(const char *cmdline, char **executable,
- char **package_full_name)
+static struct pkg_envra *get_script_name(const char *cmdline, char **executable)
{
// TODO: we don't verify that python executable is not modified
// or that python package is properly signed
@@ -191,7 +190,7 @@ static int get_script_name(const char *cmdline, char **executable,
* This will work only if the cmdline contains the whole path.
* Example: python /usr/bin/system-control-network
*/
- char *script_pkg = NULL;
+ struct pkg_envra *script_pkg = NULL;
char *script_name = get_argv1_if_full_path(cmdline);
if (script_name)
{
@@ -203,24 +202,22 @@ static int get_script_name(const char *cmdline, char **executable,
* Replace interpreter's package_full_name and executable
* with data pertaining to the script.
*/
- free(*package_full_name);
- *package_full_name = script_pkg;
*executable = script_name;
/* executable has changed, check it again */
if (is_path_blacklisted(*executable))
{
log("Blacklisted executable '%s'", *executable);
- return 1;
+ return NULL;
}
}
}
if (!script_pkg && !settings_bProcessUnpackaged)
{
log("Interpreter crashed, but no packaged script detected: '%s'", cmdline);
- return 1;
+ return NULL;
}
- return 0;
+ return script_pkg;
}
static int SavePackageDescriptionToDebugDump(const char *dump_dir_name)
@@ -243,9 +240,8 @@ static int SavePackageDescriptionToDebugDump(const char *dump_dir_name)
char *cmdline = NULL;
char *executable = NULL;
char *rootdir = NULL;
- char *script_name = NULL; /* only if "interpreter /path/to/script" */
char *package_short_name = NULL;
- char *package_full_name = NULL;
+ struct pkg_envra *pkg_name = NULL;
char *component = NULL;
int error = 1;
/* note: "goto ret" statements below free all the above variables,
@@ -266,8 +262,8 @@ static int SavePackageDescriptionToDebugDump(const char *dump_dir_name)
goto ret; /* return 1 (failure) */
}
- package_full_name = rpm_get_package_nvr(executable, rootdir);
- if (!package_full_name)
+ pkg_name = rpm_get_package_nvr(executable, rootdir);
+ if (!pkg_name)
{
if (settings_bProcessUnpackaged)
{
@@ -289,13 +285,16 @@ static int SavePackageDescriptionToDebugDump(const char *dump_dir_name)
if (!strcmp(basename, "python")
|| !strcmp(basename, "perl"))
{
- int r = get_script_name(cmdline, &executable, &package_full_name);
- if (r)
+ struct pkg_envra *script_pkg = get_script_name(cmdline, &executable);
+ if (!script_pkg)
goto ret;
+
+ free_pkg_envra(pkg_name);
+ pkg_name = script_pkg;
}
- package_short_name = get_package_name_from_NVR_or_NULL(package_full_name);
- VERB2 log("Package:'%s' short:'%s'", package_full_name, package_short_name);
+ package_short_name = xasprintf("%s", pkg_name->p_name);
+ VERB2 log("Package:'%s' short:'%s'", pkg_name->p_nvr, package_short_name);
GList *li;
@@ -329,14 +328,18 @@ static int SavePackageDescriptionToDebugDump(const char *dump_dir_name)
if (!dd)
goto ret; /* return 1 (failure) */
- if (package_full_name)
+ if (pkg_name)
{
- dd_save_text(dd, FILENAME_PACKAGE, package_full_name);
+ dd_save_text(dd, FILENAME_PACKAGE, pkg_name->p_nvr);
+ dd_save_text(dd, FILENAME_PKG_EPOCH, pkg_name->p_epoch);
+ dd_save_text(dd, FILENAME_PKG_NAME, pkg_name->p_name);
+ dd_save_text(dd, FILENAME_PKG_VERSION, pkg_name->p_version);
+ dd_save_text(dd, FILENAME_PKG_RELEASE, pkg_name->p_release);
+ dd_save_text(dd, FILENAME_PKG_ARCH, pkg_name->p_arch);
}
+
if (component)
- {
dd_save_text(dd, FILENAME_COMPONENT, component);
- }
dd_close(dd);
@@ -346,9 +349,8 @@ static int SavePackageDescriptionToDebugDump(const char *dump_dir_name)
free(cmdline);
free(executable);
free(rootdir);
- free(script_name);
free(package_short_name);
- free(package_full_name);
+ free_pkg_envra(pkg_name);
free(component);
return error;
diff --git a/src/daemon/rpm.c b/src/daemon/rpm.c
index 2fe57b8..33075a5 100644
--- a/src/daemon/rpm.c
+++ b/src/daemon/rpm.c
@@ -220,13 +220,14 @@ char* rpm_get_component(const char *filename, const char *rootdir_or_NULL)
}
// caller is responsible to free returned value
-char* rpm_get_package_nvr(const char *filename, const char *rootdir_or_NULL)
+struct pkg_envra *rpm_get_package_nvr(const char *filename, const char *rootdir_or_NULL)
{
- char *nvr = NULL;
rpmts ts;
rpmdbMatchIterator iter;
Header header;
+ struct pkg_envra *p = NULL;
+
ts = rpmtsCreate();
/* This loop executes once (normally) or twice (if we detect chroot) */
while (1)
@@ -255,13 +256,75 @@ char* rpm_get_package_nvr(const char *filename, const char *rootdir_or_NULL)
}
const char *errmsg = NULL;
- nvr = headerFormat(header, "%{NAME}-%{VERSION}-%{RELEASE}", &errmsg);
- if (!nvr && errmsg)
- error_msg("cannot get nvr. reason: %s", errmsg);
+
+ p = xzalloc(sizeof(*p));
+ p->p_epoch = headerFormat(header, "%{epoch}", &errmsg);
+ if (!p->p_epoch && errmsg)
+ {
+ error_msg("cannot get epoch. reason: %s", errmsg);
+ goto error;
+ }
+
+ /*
+ * <npajkovs> hello, what's the difference between epoch '0' and '(none)'?
+ * <Panu> nothing really, a missing epoch is considered equal to zero epoch
+ */
+ if (!strncmp(p->p_epoch, "(none)", strlen("(none)")))
+ {
+ free(p->p_epoch);
+ p->p_epoch = xstrdup("0");
+ }
+
+ p->p_name = headerFormat(header, "%{name}", &errmsg);
+ if (!p->p_name && errmsg)
+ {
+ error_msg("cannot get name. reason: %s", errmsg);
+ goto error;
+ }
+
+ p->p_version = headerFormat(header, "%{version}", &errmsg);
+ if (!p->p_version && errmsg)
+ {
+ error_msg("cannot get version. reason: %s", errmsg);
+ goto error;
+ }
+
+ p->p_release = headerFormat(header, "%{release}", &errmsg);
+ if (!p->p_version && errmsg)
+ {
+ error_msg("cannot get release. reason: %s", errmsg);
+ goto error;
+ }
+
+ p->p_arch = headerFormat(header, "%{arch}", &errmsg);
+ if (!p->p_arch && errmsg)
+ {
+ error_msg("cannot get arch. reason: %s", errmsg);
+ goto error;
+ }
+
+ p->p_nvr = xasprintf("%s-%s-%s", p->p_name, p->p_version, p->p_release);
+
+ return p;
error:
+ free_pkg_envra(p);
+
rpmdbFreeIterator(iter);
error1:
rpmtsFree(ts);
- return nvr;
+ return NULL;
+}
+
+void free_pkg_envra(struct pkg_envra *p)
+{
+ if (!p)
+ return;
+
+ free(p->p_epoch);
+ free(p->p_name);
+ free(p->p_version);
+ free(p->p_release);
+ free(p->p_arch);
+ free(p);
}
diff --git a/src/daemon/rpm.h b/src/daemon/rpm.h
index bd17bec..1b90368 100644
--- a/src/daemon/rpm.h
+++ b/src/daemon/rpm.h
@@ -31,6 +31,17 @@
extern "C" {
#endif
+struct pkg_envra {
+ char *p_nvr;
+ char *p_epoch;
+ char *p_name;
+ char *p_version;
+ char *p_release;
+ char *p_arch;
+};
+
+void free_pkg_envra(struct pkg_envra *p);
+
/**
* Checks if an application is modified by third party.
* @param pPackage A package name. The package contains the application.
@@ -64,7 +75,7 @@ int rpm_chk_fingerprint(const char* pkg);
* @param filename A file name.
* @return A package name (malloc'ed string)
*/
-char* rpm_get_package_nvr(const char *filename, const char *rootdir_or_NULL);
+struct pkg_envra *rpm_get_package_nvr(const char *filename, const char *rootdir_or_NULL);
/**
* Finds a main package for given file. This package contains particular
* file. If the file doesn't belong to any package, empty string is
--
1.7.9.3
12 years
[PATCH libreport] internal_libreport: add FILENAME_* for storing package informations
by Nikola Pajkovsky
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
src/include/internal_libreport.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
index 42c94f7..c46a525 100644
--- a/src/include/internal_libreport.h
+++ b/src/include/internal_libreport.h
@@ -709,6 +709,11 @@ bool make_dir_recursive(char *dir, mode_t dir_mode);
#define FILENAME_NOT_REPORTABLE "not-reportable"
#define FILENAME_CORE_BACKTRACE "core_backtrace"
#define FILENAME_REMOTE_RESULT "remote_result"
+#define FILENAME_PKG_EPOCH "pkg_epoch"
+#define FILENAME_PKG_NAME "pkg_name"
+#define FILENAME_PKG_VERSION "pkg_version"
+#define FILENAME_PKG_RELEASE "pkg_release"
+#define FILENAME_PKG_ARCH "pkg_arch"
// Not stored as files, added "on the fly":
#define CD_DUMPDIR "Directory"
--
1.7.9.3
12 years
[PATCH 0/1] rhbz#747410 : reporter-bugzilla creates bugzillas according to rh bugzilla default template
by Jakub Filak
Hello,
I've changed the way of creating bugzillas as I wrote in the previous e-mail
sent on 2012-04-20. The goal of this patch is to create reading of bug reports
created by abrt more comfortable.
The full description (comment 0) of a bug is now created according to the
default template. The additional info section contains only short texts from
files not present in AlwaysAttached nor ExcludeList new configuration
variables. The new configuration variables are placed in
/etc/libreport/plugins/bugzilla.conf file.
Defintion of configuration variables:
* ExcludeList : files from this csv list are NEVER used for full description
and are NEVER attached
* AlwaysAttached : files from this csv list are NEVER used for full but
description are ALWAYS attached
A sample bug is on partner bugzilla:
https://partner-bugzilla.redhat.com//show_bug.cgi?id=782935
Jakub Filak (1):
rhbz#747410 : reporter-bugzilla creates bugzillas according to rh
bugzilla default template
src/include/internal_libreport.h | 11 ++++
src/lib/Makefile.am | 1 +
src/lib/is_in_string_list.c | 51 ++++++++++++++++
src/lib/problem_data.c | 42 +-------------
src/lib/string_list.c | 109 +++++++++++++++++++++++++++++++++
src/plugins/bugzilla.conf | 5 ++
src/plugins/reporter-bugzilla.c | 25 +++++++-
src/plugins/rhbz.c | 124 +++++++++++++++++++++++++++++++++-----
src/plugins/rhbz.h | 23 ++++++-
9 files changed, 329 insertions(+), 62 deletions(-)
create mode 100644 src/lib/string_list.c
--
1.7.7.6
12 years
[v2] new version of abrt-server.c
by Vratislav Podzimek
This is the new version of my patches for abrt-server allowing more information to be provided from handlers.
I've applied or replied to all Denys' comments. My comment below still applies. :)
This set of patches introduce a new version of abrt-server.c that can parse more messages and thus save more
information about the crashes handled by Python exception handler (and in future, hopefully, python-meh).
I've tested it and it seems to be working well. I know the changes are not ideal as they cannot be applied
separately (abrt-server.c is not compilable if they are), but I really do not see any reason why I should
remove printable_str() function in one commit and add it back in the following one. If you really need the
commits to change the code from one compilable and working state to another, I can squash all these patches
to one for you. :)
--
Vratislav Podzimek
12 years
new version of abrt-server.c
by Vratislav Podzimek
This set of patches introduce a new version of abrt-server.c that can parse more messages and thus save more
information about the crashes handled by Python exception handler (and in future, hopefully, python-meh).
I've tested it and it seems to be working well. I know the changes are not ideal as they cannot be applied
separately (abrt-server.c is not compilable if they are), but I really do not see any reason why I should
remove printable_str() function in one commit and add it back in the following one. If you really need the
commits to change the code from one compilable and working state to another, I can squash all these patches
to one for you. :)
--
Vratislav Podzimek
12 years