Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/include/internal_libreport.h | 2 +
src/lib/make_descr.c | 19 ------
src/plugins/reporter-bugzilla.c | 2 +-
src/plugins/rhbz.c | 122 +++++++++++++++++++++++++++++++------
4 files changed, 105 insertions(+), 40 deletions(-)
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
index c57bd5f..5e117d7 100644
--- a/src/include/internal_libreport.h
+++ b/src/include/internal_libreport.h
@@ -716,6 +716,8 @@ struct dump_dir *steal_directory(const char *base_dir, const char
*dump_dir_name
#define FILENAME_PKG_VERSION "pkg_version"
#define FILENAME_PKG_RELEASE "pkg_release"
#define FILENAME_PKG_ARCH "pkg_arch"
+#define FILENAME_USERNAME "username"
+#define FILENAME_ABRT_VERSION "abrt_version"
// Not stored as files, added "on the fly":
#define CD_DUMPDIR "Directory"
diff --git a/src/lib/make_descr.c b/src/lib/make_descr.c
index 68133a2..01251ab 100644
--- a/src/lib/make_descr.c
+++ b/src/lib/make_descr.c
@@ -282,22 +282,3 @@ 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/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
index b96549d..bb59ac7 100644
--- a/src/plugins/reporter-bugzilla.c
+++ b/src/plugins/reporter-bugzilla.c
@@ -349,7 +349,7 @@ int main(int argc, char **argv)
int flags = RHBZ_NOMAIL_NOTIFY;
if (opts & OPT_b)
flags |= RHBZ_ATTACH_BINARY_FILES;
- rhbz_attach_big_files(client, bug_id_str, problem_data, flags);
+ rhbz_attach_files(client, bug_id_str, problem_data, flags);
bz = new_bug_info();
bz->bi_status = xstrdup("NEW");
diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
index 39bde75..f73e85f 100644
--- a/src/plugins/rhbz.c
+++ b/src/plugins/rhbz.c
@@ -32,6 +32,76 @@
#define func_entry_str(x)
#endif
+/******************************************************************************/
+/* Global lists used in process of creation a new Bugzilla bug
+ * New bug logic:
+ * 1. 'Description of problem' is FILENAME_COMMENT
+ * 2. 'Version-Release number of selected component' is FILENAME_PACKAGE
+ * 3. 'Additional info' is a concatenation of files listed in
ADDITIONAL_INFO_FILES_LIST
+ * 4. Attached files are the ONLY files which ARE NOT present in g_not_attached_files
+ * As you can see g_not_attached_files consist from some hardcoded files and
+ * files from ADDITIONAL_INFO_FILES_LIST.
+ * Black list for attached files allows us to attach all of files added to
+ * a problem directory by a user.
+ */
+#define ADDITIONAL_INFO_FILES_LIST\
+ FILENAME_ABRT_VERSION,\
+ FILENAME_RATING,\
+ FILENAME_TIME,\
+ FILENAME_KERNEL,\
+ FILENAME_CRASH_FUNCTION,\
+ FILENAME_EXECUTABLE,\
+ FILENAME_CMDLINE,\
+ FILENAME_TAINTED_LONG,\
+ FILENAME_BACKTRACE
+
+/* Items we want to use in additional info */
+static const char *const g_additional_info_files[] = {
+ /* ! a bunch of file names */
+ ADDITIONAL_INFO_FILES_LIST,
+ NULL
+};
+
+/* Items we don't want to attach to bz */
+static const char *const g_not_attached_files[] = {
+ CD_DUMPDIR,
+ FILENAME_ANALYZER,
+ FILENAME_PID,
+ FILENAME_PWD,
+ FILENAME_ROOTDIR,
+ FILENAME_BINARY,
+ FILENAME_COREDUMP,
+ FILENAME_DUPHASH,
+ FILENAME_ARCHITECTURE,
+ FILENAME_OS_RELEASE,
+ FILENAME_OS_RELEASE_IN_ROOTDIR,
+ FILENAME_PACKAGE,
+ FILENAME_COMPONENT,
+ FILENAME_COMMENT,
+ FILENAME_HOSTNAME,
+ FILENAME_REASON,
+ FILENAME_UID,
+ FILENAME_REMOTE,
+ FILENAME_TAINTED,
+ FILENAME_TAINTED_SHORT,
+ FILENAME_VMCORE,
+ FILENAME_UUID,
+ FILENAME_COUNT,
+ FILENAME_REPORTED_TO,
+ FILENAME_NOT_REPORTABLE,
+ FILENAME_PKG_EPOCH,
+ FILENAME_PKG_NAME,
+ FILENAME_PKG_VERSION,
+ FILENAME_PKG_RELEASE,
+ FILENAME_PKG_ARCH,
+ FILENAME_REMOTE_RESULT,
+ FILENAME_USERNAME,
+ /* ! a bunch of file names */
+ ADDITIONAL_INFO_FILES_LIST,
+ NULL
+};
+/******************************************************************************/
+
struct bug_info *new_bug_info()
{
func_entry();
@@ -495,6 +565,8 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t
*problem_data,
FILENAME_ANALYZER);
const char *tainted_short = get_problem_item_content_or_NULL(problem_data,
FILENAME_TAINTED_SHORT);
+ const char *comment = get_problem_item_content_or_NULL(problem_data,
+ FILENAME_COMMENT);
struct strbuf *buf_summary = strbuf_new();
if (analyzer && strcmp(analyzer, "libreport") == 0)
@@ -522,13 +594,26 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t
*problem_data,
}
char *status_whiteboard = xasprintf("abrt_hash:%s", duphash);
- 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);
+ /* A special handling of Kerneloops was removed because we met their
+ * requirements with default format
+ */
+
+ /* CD_MAX_TEXT_SIZE is used because we want to attach all text files
+ * listed in g_additional_info_files
+ */
+ char *bz_dsc = make_description(problem_data, (char**)g_additional_info_files,
+ CD_MAX_TEXT_SIZE,
+ MAKEDESC_SHOW_MULTILINE | MAKEDESC_WHITELIST);
+
+ /* Generating of a description according to the RH bugzilla default format:
+ *
https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora
+ */
+ char *full_dsc = xasprintf("Description of problem:\n%s\n\n"
+ "Version-Release number of selected
component:\n%s\n\n"
+ "Additional info:\n"
+ "libreport version: "VERSION"\n%s\n",
+ comment, package, bz_dsc);
- char *full_dsc = xasprintf("libreport version: "VERSION"\n%s",
bz_dsc);
free(bz_dsc);
char *product = NULL;
@@ -633,7 +718,7 @@ int rhbz_attach_fd(struct abrt_xmlrpc *ax, const char *filename,
}
/* suppress mail notify by {s:i} (nomail:1) (driven by flag) */
-int rhbz_attach_big_files(struct abrt_xmlrpc *ax, const char *bug_id,
+int rhbz_attach_files(struct abrt_xmlrpc *ax, const char *bug_id,
problem_data_t *problem_data, int flags)
{
func_entry();
@@ -648,23 +733,20 @@ int rhbz_attach_big_files(struct abrt_xmlrpc *ax, const char
*bug_id,
g_hash_table_iter_init(&iter, problem_data);
while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
{
+ /* The not attached list should contain files used in the description,
+ * the bug fields and the files which nobody is interested in.
+ */
+ if (is_in_string_list(name, g_not_attached_files))
+ continue;
+
+ /* All other files are to be attached.
+ */
if (value->flags & CD_FLAG_TXT)
{
const char *content = value->content;
- if (!strcmp(analyzer, "Kerneloops") && !strcmp(name,
FILENAME_BACKTRACE))
- continue;
+ const unsigned len = strlen(content);
- unsigned len = strlen(content);
-
- // We were special-casing FILENAME_BACKTRACE here, but karel says
- // he can retrieve it in inlined form from comments too.
- if (len > CD_TEXT_ATT_SIZE_BZ /*|| (strcmp(name, FILENAME_BACKTRACE) ==
0)*/)
- {
- /* This text item wasn't added in comments, it is too big
- * for that. Attach it as a file.
- */
- rhbz_attach_blob(ax, name, bug_id, content, len, flags);
- }
+ rhbz_attach_blob(ax, name, bug_id, content, len, flags);
}
if ((flags & RHBZ_ATTACH_BINARY_FILES) && (value->flags &
CD_FLAG_BIN))
{
--
1.7.7.6