On Friday, November 19, 2010 12:12:08 pm Denys Vlasenko wrote:
On Fri, 2010-11-19 at 12:01 +0100, Nikola Pajkovsky wrote:
> backported from 1.1.x branch.
>
> Save tainted flag from /proc/sys/kernel/tainted. When flag is set to 1
> TAINED string is added to bugzilla summary.
>
> Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
> ---
>
> src/include/crash_types.h | 1 +
> src/plugins/KerneloopsScanner.cpp | 15 +++++++++++++++
> src/plugins/abrt-action-bugzilla.cpp | 9 +++++++++
> 3 files changed, 25 insertions(+), 0 deletions(-)
>
> diff --git a/src/include/crash_types.h b/src/include/crash_types.h
> index de9f7bf..37dda28 100644
> --- a/src/include/crash_types.h
> +++ b/src/include/crash_types.h
> @@ -52,6 +52,7 @@
>
> #define FILENAME_HOSTNAME "hostname"
> // Optional. Set to "1" by abrt-handle-upload for every unpacked
> crashdump #define FILENAME_REMOTE "remote"
>
> +#define FILENAME_TAINTED "tainted"
Maybe "kernel_tainted"? Not all crashes are about kernel
fixed to #define FILENAME_TAINTED "kernel_tainted"
> // TODO: TicketUploader also has open-coded "TICKET",
"CUSTOMER" files
>
> // Apart from CD_UID, which is also stored as a file in dump directory,
>
> diff --git a/src/plugins/KerneloopsScanner.cpp
> b/src/plugins/KerneloopsScanner.cpp index d187daa..a0b6944 100644
> --- a/src/plugins/KerneloopsScanner.cpp
> +++ b/src/plugins/KerneloopsScanner.cpp
> @@ -121,6 +121,20 @@ int save_oops_to_debug_dump(GList **oopsList)
>
> VERB1 log("Saving %u oopses as crash dump dirs", idx >= countdown
?
> countdown-1 : idx);
>
> + char tainted[1];
> + /* once tainted flag is set to 1, only restart can reset the flag to
> 0 */ + int tainted_fd = open("/proc/sys/kernel/tainted", O_RDONLY); +
> if (tainted_fd > 0)
Check should be ">= 0".
fixed
> + {
> + /* contain only 0 or 1 */
> + if (read(tainted_fd, &tainted, 1) != 1)
> + error_msg("Unable to read one byte from
> /proc/sys/kernel/tainted"); +
> + close(tainted_fd);
> + }
> + else
> + error_msg("/proc/sys/kernel/tainted does not exist");
On error, tainted is undefined (contains garbage from stack).
> +
>
> int errors = 0;
>
> while (idx != 0 && --countdown != 0)
>
> @@ -143,6 +157,7 @@ int save_oops_to_debug_dump(GList **oopsList)
>
> /* Optional, makes generated bz more informative */
> strchrnul(second_line, '\n')[0] = '\0';
> dd_save_text(dd, FILENAME_REASON, second_line);
>
> + dd_save_text(dd, FILENAME_TAINTED, second_line);
Moreover, tainted seems to be unused. You do not save it,
instead you are saving 1st line of oops into FILENAME_TAINTED.
Copy&paste mistake. Fixed. kernel_tainted file will be created only when
tainted flag is set.
> dd_close(dd);
>
> }
> else
>
> diff --git a/src/plugins/abrt-action-bugzilla.cpp
> b/src/plugins/abrt-action-bugzilla.cpp index 90c7d3b..073d534 100644
> --- a/src/plugins/abrt-action-bugzilla.cpp
> +++ b/src/plugins/abrt-action-bugzilla.cpp
> @@ -391,6 +391,8 @@ xmlrpc_int32 ctx::new_bug(const map_crash_data_t&
> pCrashData, int depend_on_bugn
>
> const char *duphash =
> get_crash_data_item_content_or_NULL(pCrashData, FILENAME_DUPHASH);
> const char *reason =
> get_crash_data_item_content_or_NULL(pCrashData, FILENAME_REASON);
> const char *function =
> get_crash_data_item_content_or_NULL(pCrashData,
> FILENAME_CRASH_FUNCTION);
>
> + const char *analyzer =
> get_crash_data_item_content_or_NULL(pCrashData, FILENAME_ANALYZER); +
> const char *tainted =
> get_crash_data_item_content_or_NULL(pCrashData, FILENAME_TAINTED);
>
> struct strbuf *buf_summary = strbuf_new();
> strbuf_append_strf(buf_summary, "[abrt] %s", package);
>
> @@ -401,6 +403,13 @@ xmlrpc_int32 ctx::new_bug(const map_crash_data_t&
> pCrashData, int depend_on_bugn
>
> if (reason != NULL)
>
> strbuf_append_strf(buf_summary, ": %s", reason);
>
> + if (tainted && analyzer
> + && (tainted[0] == '1')
> + && (strcmp(analyzer, "Kerneloops") == 0)
> + ) {
> + strbuf_append_str(buf_summary, ": TAINTED");
> + }
> +
>
> char *status_whiteboard = xasprintf("abrt_hash:%s", duphash);
>
> char *bz_dsc = make_description_bz(pCrashData);
--
Nikola