From bf66b44453f866733ac7c070b396fee081d446d7 Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: May 14 2012 16:44:06 +0000 Subject: fixed compatibility with new bugzilla rhbz#820985 --- diff --git a/0001-fixed-memory-leak-in-comment-dup.patch b/0001-fixed-memory-leak-in-comment-dup.patch new file mode 100644 index 0000000..6e1dcfe --- /dev/null +++ b/0001-fixed-memory-leak-in-comment-dup.patch @@ -0,0 +1,43 @@ +commit f737cd88eef6c8cde03b3a317cd5ef390f0138e4 +Author: Jakub Filak +Date: Wed Apr 18 15:09:02 2012 +0200 + + trac#480 : fixed memory leak in is_comment_dup() function + + Signed-off-by: Jakub Filak + +diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c +index a3aa2ef..2e7d62c 100644 +--- a/src/plugins/rhbz.c ++++ b/src/plugins/rhbz.c +@@ -88,20 +88,19 @@ static char *trim_all_whitespace(const char *str) + + int is_comment_dup(GList *comments, const char *comment) + { +- for (GList *l = comments; l; l = l->next) ++ char * const trim_comment = trim_all_whitespace(comment); ++ bool same_comments = false; ++ ++ for (GList *l = comments; l && !same_comments; l = l->next) + { +- char *comment_body = (char *) l->data; +- char *trim_comment_body = trim_all_whitespace(comment_body); +- char *trim_comment = trim_all_whitespace(comment); +- if (!strcmp(trim_comment_body, trim_comment)) +- { +- free(trim_comment_body); +- free(trim_comment); +- return 1; +- } ++ const char * const comment_body = (const char *) l->data; ++ char * const trim_comment_body = trim_all_whitespace(comment_body); ++ same_comments = !strcmp(trim_comment_body, trim_comment); ++ free(trim_comment_body); + } + +- return 0;; ++ free(trim_comment); ++ return same_comments; + } + + static unsigned find_best_bt_rating_in_comments(GList *comments) diff --git a/0001-rhbz-820985-bz-4.2-doesn-t-have-bug_id-member-it-s-i.patch b/0001-rhbz-820985-bz-4.2-doesn-t-have-bug_id-member-it-s-i.patch new file mode 100644 index 0000000..461287f --- /dev/null +++ b/0001-rhbz-820985-bz-4.2-doesn-t-have-bug_id-member-it-s-i.patch @@ -0,0 +1,237 @@ +From 386bcecdff5eeea2f0855e9b91b73f862fa11860 Mon Sep 17 00:00:00 2001 +From: Nikola Pajkovsky +Date: Mon, 14 May 2012 13:03:25 +0200 +Subject: [PATCH 1/3] rhbz#820985 - bz 4.2 doesn't have 'bug_id' member; it's + 'id' + +Signed-off-by: Nikola Pajkovsky +--- + src/plugins/rhbz.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 55 insertions(+), 1 deletion(-) + +diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c +index 2e7d62c..24bec16 100644 +--- a/src/plugins/rhbz.c ++++ b/src/plugins/rhbz.c +@@ -22,8 +22,20 @@ + + #define MAX_HOPS 5 + ++ ++//#define DEBUG ++#ifdef DEBUG ++#define func_entry() log("-- %s", __func__) ++#define func_entry_str(x) log("-- %s\t%s", __func__, (x)) ++#else ++#define func_entry() ++#define func_entry_str(x) ++#endif ++ + struct bug_info *new_bug_info() + { ++ func_entry(); ++ + struct bug_info *bi = xzalloc(sizeof(struct bug_info)); + bi->bi_dup_id = -1; + +@@ -32,6 +44,8 @@ struct bug_info *new_bug_info() + + void free_bug_info(struct bug_info *bi) + { ++ func_entry(); ++ + if (!bi) + return; + +@@ -47,6 +61,8 @@ void free_bug_info(struct bug_info *bi) + + static GList *parse_comments(xmlrpc_value *result_xml) + { ++ func_entry(); ++ + GList *comments = NULL; + xmlrpc_value *comments_memb = rhbz_get_member("longdescs", result_xml); + if (!comments_memb) +@@ -74,6 +90,8 @@ static GList *parse_comments(xmlrpc_value *result_xml) + + static char *trim_all_whitespace(const char *str) + { ++ func_entry(); ++ + char *trim = xzalloc(sizeof(char) * strlen(str) + 1); + int i = 0; + while (*str) +@@ -88,6 +106,8 @@ static char *trim_all_whitespace(const char *str) + + int is_comment_dup(GList *comments, const char *comment) + { ++ func_entry(); ++ + char * const trim_comment = trim_all_whitespace(comment); + bool same_comments = false; + +@@ -105,6 +125,8 @@ int is_comment_dup(GList *comments, const char *comment) + + static unsigned find_best_bt_rating_in_comments(GList *comments) + { ++ func_entry(); ++ + if (!comments) + return 0; + +@@ -148,6 +170,8 @@ static unsigned find_best_bt_rating_in_comments(GList *comments) + + void rhbz_login(struct abrt_xmlrpc *ax, struct bugzilla_struct *b) + { ++ func_entry(); ++ + xmlrpc_value* result = abrt_xmlrpc_call(ax, "User.login", "({s:s,s:s})", + "login", b->b_login, "password", b->b_password); + +@@ -162,6 +186,8 @@ void rhbz_login(struct abrt_xmlrpc *ax, struct bugzilla_struct *b) + xmlrpc_value *rhbz_search_duphash(struct abrt_xmlrpc *ax, const char *component, + const char *product, const char *duphash) + { ++ func_entry(); ++ + struct strbuf *query = strbuf_new(); + strbuf_append_strf(query, "ALL whiteboard:\"%s\"", duphash); + +@@ -181,6 +207,8 @@ xmlrpc_value *rhbz_search_duphash(struct abrt_xmlrpc *ax, const char *component, + + xmlrpc_value *rhbz_get_member(const char *member, xmlrpc_value *xml) + { ++ func_entry_str(member); ++ + xmlrpc_env env; + xmlrpc_env_init(&env); + +@@ -203,6 +231,8 @@ xmlrpc_value *rhbz_get_member(const char *member, xmlrpc_value *xml) + */ + int rhbz_array_size(xmlrpc_value *xml) + { ++ func_entry(); ++ + xmlrpc_env env; + xmlrpc_env_init(&env); + +@@ -216,6 +246,8 @@ int rhbz_array_size(xmlrpc_value *xml) + /* die or return bug id; each bug must have bug id otherwise xml is corrupted */ + int rhbz_bug_id(xmlrpc_value* xml) + { ++ func_entry(); ++ + xmlrpc_env env; + xmlrpc_env_init(&env); + +@@ -227,7 +259,7 @@ int rhbz_bug_id(xmlrpc_value* xml) + if (env.fault_occurred) + abrt_xmlrpc_die(&env); + +- bug = rhbz_get_member("bug_id", item); ++ bug = rhbz_get_member("id", item); + xmlrpc_DECREF(item); + if (!bug) + abrt_xmlrpc_die(&env); +@@ -247,6 +279,8 @@ int rhbz_bug_id(xmlrpc_value* xml) + // TODO: npajkovs: add flag to read xmlrpc_read_array_item first + void *rhbz_bug_read_item(const char *memb, xmlrpc_value *xml, int flags) + { ++ func_entry(); ++ + xmlrpc_env env; + xmlrpc_env_init(&env); + +@@ -293,6 +327,8 @@ die: + + GList *rhbz_bug_cc(xmlrpc_value* result_xml) + { ++ func_entry(); ++ + xmlrpc_env env; + xmlrpc_env_init(&env); + +@@ -335,6 +371,8 @@ GList *rhbz_bug_cc(xmlrpc_value* result_xml) + + struct bug_info *rhbz_bug_info(struct abrt_xmlrpc *ax, int bug_id) + { ++ func_entry(); ++ + struct bug_info *bz = new_bug_info(); + xmlrpc_value *xml_bug_response = abrt_xmlrpc_call(ax, "bugzilla.getBug", + "(i)", bug_id); +@@ -384,6 +422,8 @@ struct bug_info *rhbz_bug_info(struct abrt_xmlrpc *ax, int bug_id) + int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t *problem_data, + const char *release) + { ++ func_entry(); ++ + const char *package = get_problem_item_content_or_NULL(problem_data, + FILENAME_PACKAGE); + const char *component = get_problem_item_content_or_NULL(problem_data, +@@ -483,6 +523,8 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t *problem_data, + int rhbz_attach_blob(struct abrt_xmlrpc *ax, const char *filename, + const char *bug_id, const char *data, int data_len, int flags) + { ++ func_entry(); ++ + char *encoded64 = encode_base64(data, data_len); + char *fn = xasprintf("File: %s", filename); + xmlrpc_value* result; +@@ -509,6 +551,8 @@ int rhbz_attach_blob(struct abrt_xmlrpc *ax, const char *filename, + int rhbz_attach_fd(struct abrt_xmlrpc *ax, const char *filename, + const char *bug_id, int fd, int flags) + { ++ func_entry(); ++ + off_t size = lseek(fd, 0, SEEK_END); + if (size < 0) + { +@@ -547,6 +591,8 @@ int rhbz_attach_fd(struct abrt_xmlrpc *ax, const char *filename, + int rhbz_attach_big_files(struct abrt_xmlrpc *ax, const char *bug_id, + problem_data_t *problem_data, int flags) + { ++ func_entry(); ++ + GHashTableIter iter; + char *name; + struct problem_item *value; +@@ -600,6 +646,8 @@ int rhbz_attach_big_files(struct abrt_xmlrpc *ax, const char *bug_id, + + void rhbz_logout(struct abrt_xmlrpc *ax) + { ++ func_entry(); ++ + xmlrpc_value* result = abrt_xmlrpc_call(ax, "User.logout", "(s)", ""); + if (result) + xmlrpc_DECREF(result); +@@ -608,6 +656,8 @@ void rhbz_logout(struct abrt_xmlrpc *ax) + struct bug_info *rhbz_find_origin_bug_closed_duplicate(struct abrt_xmlrpc *ax, + struct bug_info *bi) + { ++ func_entry(); ++ + struct bug_info *bi_tmp = new_bug_info(); + bi_tmp->bi_id = bi->bi_id; + bi_tmp->bi_dup_id = bi->bi_dup_id; +@@ -634,6 +684,8 @@ struct bug_info *rhbz_find_origin_bug_closed_duplicate(struct abrt_xmlrpc *ax, + /* suppress mail notify by {s:i} (nomail:1) */ + void rhbz_mail_to_cc(struct abrt_xmlrpc *ax, int bug_id, const char *mail, int flags) + { ++ func_entry(); ++ + xmlrpc_value *result; + int nomail_notify = IS_NOMAIL_NOTIFY(flags); + result = abrt_xmlrpc_call(ax, "Bug.update", "({s:i,s:{s:(s),s:i}})", +@@ -647,6 +699,8 @@ void rhbz_mail_to_cc(struct abrt_xmlrpc *ax, int bug_id, const char *mail, int f + void rhbz_add_comment(struct abrt_xmlrpc *ax, int bug_id, const char *comment, + int flags) + { ++ func_entry(); ++ + int private = IS_PRIVATE(flags); + int nomail_notify = IS_NOMAIL_NOTIFY(flags); + +-- +1.7.10.1 + diff --git a/0001-rhbz795548-opt-out-smolt.patch b/0001-rhbz795548-opt-out-smolt.patch new file mode 100644 index 0000000..c54beb4 --- /dev/null +++ b/0001-rhbz795548-opt-out-smolt.patch @@ -0,0 +1,134 @@ +commit f01bb3bc293f91eacb9196229746ab95580f8b58 +Author: Nikola Pajkovsky +Date: Tue Apr 3 16:31:10 2012 +0200 + + rhbz#795548 - opt kernel out of showing smolt information in abrt bug reports + + Signed-off-by: Nikola Pajkovsky + +diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h +index d99d84c..892a70f 100644 +--- a/src/include/internal_libreport.h ++++ b/src/include/internal_libreport.h +@@ -572,6 +572,7 @@ enum { + MAKEDESC_SHOW_FILES = (1 << 0), + MAKEDESC_SHOW_MULTILINE = (1 << 1), + MAKEDESC_SHOW_ONLY_LIST = (1 << 2), ++ MAKEDESC_WHITELIST = (1 << 3), + }; + #define make_description libreport_make_description + char *make_description(problem_data_t *problem_data, char **names_to_skip, unsigned max_text_size, unsigned desc_flags); +@@ -579,6 +580,8 @@ char *make_description(problem_data_t *problem_data, char **names_to_skip, unsig + char* make_description_bz(problem_data_t *problem_data, unsigned max_text_size); + #define make_description_logger libreport_make_description_logger + char* make_description_logger(problem_data_t *problem_data, unsigned max_text_size); ++#define make_description_koops libreport_make_description_koops ++char* make_description_koops(problem_data_t *problem_data, unsigned max_text_size); + //UNUSED + //#define make_description_mailx libreport_make_description_mailx + //char* make_description_mailx(problem_data_t *problem_data); +diff --git a/src/lib/make_descr.c b/src/lib/make_descr.c +index a1a9234..68133a2 100644 +--- a/src/lib/make_descr.c ++++ b/src/lib/make_descr.c +@@ -18,7 +18,16 @@ + */ + #include "internal_libreport.h" + +-char *make_description(problem_data_t *problem_data, char **names_to_skip, unsigned max_text_size, unsigned desc_flags) ++static bool rejected_name(const char *name, char **v, int flags) ++{ ++ bool r = is_in_string_list(name, v); ++ if (flags & MAKEDESC_WHITELIST) ++ r = !r; ++ return r; ++} ++ ++char *make_description(problem_data_t *problem_data, char **names_to_skip, ++ unsigned max_text_size, unsigned desc_flags) + { + struct strbuf *buf_dsc = strbuf_new(); + +@@ -42,7 +51,8 @@ char *make_description(problem_data_t *problem_data, char **names_to_skip, unsig + + /* Skip items we are not interested in */ + //TODO: optimize by doing this once, not 3 times: +- if (names_to_skip && is_in_string_list(key, names_to_skip)) ++ if (names_to_skip ++ && rejected_name(key, names_to_skip, desc_flags)) + continue; + + struct problem_item *item = g_hash_table_lookup(problem_data, key); +@@ -87,7 +97,8 @@ char *make_description(problem_data_t *problem_data, char **names_to_skip, unsig + l = l->next; + + /* Skip items we are not interested in */ +- if (names_to_skip && is_in_string_list(key, names_to_skip)) ++ if (names_to_skip ++ && rejected_name(key, names_to_skip, desc_flags)) + continue; + + struct problem_item *item = g_hash_table_lookup(problem_data, key); +@@ -144,7 +155,8 @@ char *make_description(problem_data_t *problem_data, char **names_to_skip, unsig + l = l->next; + + /* Skip items we are not interested in */ +- if (names_to_skip && is_in_string_list(key, names_to_skip)) ++ if (names_to_skip ++ && rejected_name(key, names_to_skip, desc_flags)) + continue; + + struct problem_item *item = g_hash_table_lookup(problem_data, key); +@@ -251,11 +263,6 @@ static const char *const blacklisted_items[] = { + NULL + }; + +-/* +- * npajkovs: implement second part of problem (not so important) +- * https://bugzilla.redhat.com/show_bug.cgi?id=711591 +- */ +- + char* make_description_bz(problem_data_t *problem_data, unsigned max_text_size) + { + return make_description( +@@ -275,3 +282,22 @@ char* make_description_logger(problem_data_t *problem_data, unsigned max_text_si + MAKEDESC_SHOW_FILES | MAKEDESC_SHOW_MULTILINE + ); + } ++ ++/* Items we want to include to bz */ ++static const char *const whitelisted_items[] = { ++ FILENAME_CMDLINE, ++ FILENAME_BACKTRACE, ++ NULL ++}; ++ ++char* make_description_koops(problem_data_t *problem_data, unsigned max_text_size) ++{ ++ return make_description( ++ problem_data, ++ (char**)whitelisted_items, ++ max_text_size, ++ MAKEDESC_SHOW_FILES ++ | MAKEDESC_SHOW_MULTILINE ++ | MAKEDESC_WHITELIST ++ ); ++} +diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c +index 9ed3154..a3aa2ef 100644 +--- a/src/plugins/rhbz.c ++++ b/src/plugins/rhbz.c +@@ -438,7 +438,12 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t *problem_data, + } + char *status_whiteboard = xasprintf("abrt_hash:%s", duphash); + +- char *bz_dsc = make_description_bz(problem_data, CD_TEXT_ATT_SIZE_BZ); ++ char *bz_dsc; ++ if (analyzer && !strcmp(analyzer, "Kerneloops")) ++ bz_dsc = make_description_koops(problem_data, CD_TEXT_ATT_SIZE_BZ); ++ else ++ bz_dsc = make_description_bz(problem_data, CD_TEXT_ATT_SIZE_BZ); ++ + char *full_dsc = xasprintf("libreport version: "VERSION"\n%s", bz_dsc); + free(bz_dsc); + diff --git a/0002-bugzilla-query-bz-version-and-for-4.2-use-id-element.patch b/0002-bugzilla-query-bz-version-and-for-4.2-use-id-element.patch new file mode 100644 index 0000000..984cb2c --- /dev/null +++ b/0002-bugzilla-query-bz-version-and-for-4.2-use-id-element.patch @@ -0,0 +1,113 @@ +From add5f6eed5cae2f0618707ed9c642f692426d8d7 Mon Sep 17 00:00:00 2001 +From: Nikola Pajkovsky +Date: Mon, 14 May 2012 13:53:51 +0200 +Subject: [PATCH 2/3] bugzilla: query bz version and for 4.2 use 'id' element + for getting bug number, for others use 'bug_id' + +Signed-off-by: Nikola Pajkovsky +--- + src/plugins/reporter-bugzilla.c | 8 ++++++-- + src/plugins/rhbz.c | 28 ++++++++++++++++++++++++++-- + src/plugins/rhbz.h | 3 ++- + 3 files changed, 34 insertions(+), 5 deletions(-) + +diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c +index 6584f0f..3b6d168 100644 +--- a/src/plugins/reporter-bugzilla.c ++++ b/src/plugins/reporter-bugzilla.c +@@ -168,8 +168,10 @@ int main(int argc, char **argv) + int all_bugs_size = rhbz_array_size(all_bugs); + if (all_bugs_size > 0) + { +- int bug_id = rhbz_bug_id(all_bugs); ++ char *rhbz_ver = rhbz_version(client); ++ int bug_id = rhbz_bug_id(all_bugs, rhbz_ver); + printf("%i", bug_id); ++ free(rhbz_ver); + } + + exit(EXIT_SUCCESS); +@@ -357,9 +359,11 @@ int main(int argc, char **argv) + } + else + { +- int bug_id = rhbz_bug_id(all_bugs); ++ char *rhbz_ver = rhbz_version(client); ++ int bug_id = rhbz_bug_id(all_bugs, rhbz_ver); + xmlrpc_DECREF(all_bugs); + bz = rhbz_bug_info(client, bug_id); ++ free(rhbz_ver); + } + } + else +diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c +index 24bec16..df2838f 100644 +--- a/src/plugins/rhbz.c ++++ b/src/plugins/rhbz.c +@@ -243,8 +243,26 @@ int rhbz_array_size(xmlrpc_value *xml) + return size; + } + ++ ++char *rhbz_version(struct abrt_xmlrpc *ax) ++{ ++ func_entry(); ++ ++ xmlrpc_value *result; ++ result = abrt_xmlrpc_call(ax, "Bugzilla.version", "()"); ++ ++ char *version = NULL; ++ if (result) ++ { ++ version = rhbz_bug_read_item("version", result, RHBZ_READ_STR); ++ xmlrpc_DECREF(result); ++ } ++ ++ return version; ++} ++ + /* die or return bug id; each bug must have bug id otherwise xml is corrupted */ +-int rhbz_bug_id(xmlrpc_value* xml) ++int rhbz_bug_id(xmlrpc_value* xml, const char *ver) + { + func_entry(); + +@@ -259,7 +277,13 @@ int rhbz_bug_id(xmlrpc_value* xml) + if (env.fault_occurred) + abrt_xmlrpc_die(&env); + +- bug = rhbz_get_member("id", item); ++ char *id; ++ if (!prefixcmp(ver, "4.2")) ++ id = "id"; ++ else ++ id = "bug_id"; ++ ++ bug = rhbz_get_member(id, item); + xmlrpc_DECREF(item); + if (!bug) + abrt_xmlrpc_die(&env); +diff --git a/src/plugins/rhbz.h b/src/plugins/rhbz.h +index c9023e9..85bcca1 100644 +--- a/src/plugins/rhbz.h ++++ b/src/plugins/rhbz.h +@@ -97,7 +97,7 @@ xmlrpc_value *rhbz_get_member(const char *member, xmlrpc_value *xml); + + int rhbz_array_size(xmlrpc_value *xml); + +-int rhbz_bug_id(xmlrpc_value *xml); ++int rhbz_bug_id(xmlrpc_value *xml, const char *ver); + + int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t *problem_data, + const char *release); +@@ -120,6 +120,7 @@ struct bug_info *rhbz_bug_info(struct abrt_xmlrpc *ax, int bug_id); + + struct bug_info *rhbz_find_origin_bug_closed_duplicate(struct abrt_xmlrpc *ax, + struct bug_info *bi); ++char *rhbz_version(struct abrt_xmlrpc *ax); + + #ifdef __cplusplus + } +-- +1.7.10.1 + diff --git a/libreport.spec b/libreport.spec index 9955492..693429f 100644 --- a/libreport.spec +++ b/libreport.spec @@ -5,12 +5,16 @@ Summary: Generic library for reporting various problems Name: libreport Version: 2.0.10 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2+ Group: System Environment/Libraries URL: https://fedorahosted.org/abrt/ Source: https://fedorahosted.org/released/abrt/%{name}-%{version}.tar.gz Patch0: 0001-Add-cgroup-information-filename.patch +Patch1: 0001-rhbz795548-opt-out-smolt.patch +Patch2: 0001-fixed-memory-leak-in-comment-dup.patch +Patch3: 0001-rhbz-820985-bz-4.2-doesn-t-have-bug_id-member-it-s-i.patch +Patch4: 0002-bugzilla-query-bz-version-and-for-4.2-use-id-element.patch BuildRequires: dbus-devel BuildRequires: gtk2-devel BuildRequires: curl-devel @@ -212,6 +216,10 @@ Plugin to report bugs into anonymous FTP site associated with ticketing system. %prep %setup -q %patch0 -p1 -b .cgroups +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 %build autoconf @@ -376,6 +384,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : %config(noreplace) %{_sysconfdir}/libreport/events.d/uploader_event.conf %changelog +* Mon May 14 2012 Jiri Moskovcak 2.0.10-3 +- fixed compatibility with bugzilla 4.2 + * Mon Apr 02 2012 Jiri Moskovcak 2.0.10-2 - added cgroups filename define