[PATCH 2/3] reporter-rhtsupport: make -t[CASE_ID] work without FILEs
by Denys Vlasenko
This closes #140
--
vda
diff -x '*.po' -d -urpN libreport.1/src/plugins/reporter-rhtsupport.c libreport.2/src/plugins/reporter-rhtsupport.c
--- libreport.1/src/plugins/reporter-rhtsupport.c 2013-03-21 13:39:54.620205617 +0100
+++ libreport.2/src/plugins/reporter-rhtsupport.c 2013-03-21 13:39:58.393199033 +0100
@@ -250,18 +250,14 @@ int main(int argc, char **argv)
if (opts & OPT_t)
{
- if (!*argv)
- show_usage_and_die(program_usage_string, program_options);
-
if (!case_no)
{
- /* -t */
+ /* -t: extract URL where we previously reported it */
report_result_t *reported_to = get_reported_to(dump_dir_name);
if (!reported_to || !reported_to->url)
error_msg_and_die("Can't attach: problem data in '%s' "
"was not reported to RHTSupport and therefore has no URL",
dump_dir_name);
-
//log("URL:'%s'", reported_to->url);
//log("MSG:'%s'", reported_to->msg);
free(url);
@@ -278,51 +274,54 @@ int main(int argc, char **argv)
free(url1);
}
- while (*argv)
+ if (*argv)
{
- log(_("Attaching '%s' to case '%s'"), *argv, url);
- rhts_result_t *result = attach_file_to_case(url,
- login,
- password,
- ssl_verify,
- *argv
- );
- if (result->error)
- error_msg_and_die("%s", result->msg);
- log("Attachment URL:%s", result->url);
- log("File attached successfully");
- free_rhts_result(result);
- argv++;
+ /* -t[CASE] FILE: just attach files and exit */
+ while (*argv)
+ {
+ log(_("Attaching '%s' to case '%s'"), *argv, url);
+ rhts_result_t *result = attach_file_to_case(url,
+ login,
+ password,
+ ssl_verify,
+ *argv
+ );
+ if (result->error)
+ error_msg_and_die("%s", result->msg);
+ log("Attachment URL:%s", result->url);
+ log("File attached successfully");
+ free_rhts_result(result);
+ argv++;
+ }
+ return 0;
}
-
- return 0;
}
-
- if (*argv)
- show_usage_and_die(program_usage_string, program_options);
-
- /* Creating a new case */
-
- report_result_t *reported_to = get_reported_to(dump_dir_name);
- if (reported_to && reported_to->url && !(opts & OPT_f))
+ else /* no -t: creating a new case */
{
- char *msg = xasprintf("This problem was already reported to RHTS (see '%s')."
- " Do you still want to create a RHTSupport ticket?",
- reported_to->url);
- int yes = ask_yes_no(msg);
- free(msg);
- if (!yes)
- return 0;
+ if (*argv)
+ show_usage_and_die(program_usage_string, program_options);
+
+ report_result_t *reported_to = get_reported_to(dump_dir_name);
+ if (reported_to && reported_to->url && !(opts & OPT_f))
+ {
+ char *msg = xasprintf("This problem was already reported to RHTS (see '%s')."
+ " Do you still want to create a RHTSupport ticket?",
+ reported_to->url);
+ int yes = ask_yes_no(msg);
+ free(msg);
+ if (!yes)
+ return 0;
+ }
+ free_report_result(reported_to);
}
- free_report_result(reported_to);
+
+ /* Gzipping e.g. 0.5gig coredump takes a while. Let user know what we are doing */
+ log(_("Compressing data"));
problem_data_t *problem_data = create_problem_data_for_reporting(dump_dir_name);
if (!problem_data)
xfunc_die(); /* create_problem_data_for_reporting already emitted error msg */
- /* Gzipping e.g. 0.5gig coredump takes a while. Let user know what we are doing */
- log(_("Compressing data"));
-
const char *errmsg = NULL;
char *tempfile = NULL;
rhts_result_t *result = NULL;
@@ -340,7 +339,6 @@ int main(int argc, char **argv)
package = problem_data_get_content_or_NULL(problem_data, FILENAME_PACKAGE);
reason = problem_data_get_content_or_NULL(problem_data, FILENAME_REASON);
function = problem_data_get_content_or_NULL(problem_data, FILENAME_CRASH_FUNCTION);
-
{
struct strbuf *buf_summary = strbuf_new();
strbuf_append_strf(buf_summary, "[abrt] %s", package);
@@ -351,6 +349,7 @@ int main(int argc, char **argv)
summary = strbuf_free_nobuf(buf_summary);
dsc = make_description_bz(problem_data, CD_TEXT_ATT_SIZE_BZ);
}
+
char tmpdir_name[sizeof("/tmp/rhtsupport-"LIBREPORT_ISO_DATE_STRING_SAMPLE"-XXXXXX")];
snprintf(tmpdir_name, sizeof(tmpdir_name), "/tmp/rhtsupport-%s-XXXXXX", iso_date_string(NULL));
/* mkdtemp does mkdir(xxx, 0700), should be safe (is it?) */
@@ -358,7 +357,6 @@ int main(int argc, char **argv)
{
error_msg_and_die(_("Can't create a temporary directory in /tmp"));
}
-
/* Starting from here, we must perform cleanup on errors
* (delete temp dir)
*/
@@ -369,6 +367,8 @@ int main(int argc, char **argv)
goto ret;
}
+//TODO: fetch size, use it to decide whether to fetch hints
+
/* Check for hints and show them if we have something */
result = get_rhts_hints(url,
login,
@@ -410,47 +410,67 @@ int main(int argc, char **argv)
}
}
free_rhts_result(result);
- /*result = NULL; - redundant, result is assigned just below */
-
- /* Send tempfile */
- log(_("Creating a new case"));
- result = create_new_case(url,
- login,
- password,
- ssl_verify,
- release,
- summary,
- dsc,
- package
- );
+ result = NULL;
- if (result->error)
+ if (!(opts & OPT_t))
{
- /*
- * Message can contain "...server says: 'multi-line <html> text'"
- * Replace all '\n' with spaces:
- * we want this message to be, logically, one log entry.
- * IOW: one line, not many lines.
- */
- char *src, *dst;
- errmsg = dst = src = result->msg;
- while (1)
+ log(_("Creating a new case"));
+ result = create_new_case(url,
+ login,
+ password,
+ ssl_verify,
+ release,
+ summary,
+ dsc,
+ package
+ );
+ if (result->error)
{
- unsigned char c = *src++;
- if (c == '\n')
- c = ' ';
- *dst++ = c;
- if (c == '\0')
- break;
+ /*
+ * Message can contain "...server says: 'multi-line <html> text'"
+ * Replace all '\n' with spaces:
+ * we want this message to be, logically, one log entry.
+ * IOW: one line, not many lines.
+ */
+ char *src, *dst;
+ errmsg = dst = src = result->msg;
+ while (1)
+ {
+ unsigned char c = *src++;
+ if (c == '\n')
+ c = ' ';
+ *dst++ = c;
+ if (c == '\0')
+ break;
+ }
+ /* Remove trailing spaces (usually produced by trailing '\n') */
+ while (--dst >= errmsg && *dst == ' ')
+ *dst = '\0';
+ goto ret;
}
- /* Remove trailing spaces (usually produced by trailing '\n') */
- while (--dst >= errmsg && *dst == ' ')
- *dst = '\0';
- goto ret;
+ /* No error in case creation */
+ /* Record "reported_to" element */
+ struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
+ if (dd)
+ {
+ char *msg = xasprintf("RHTSupport: TIME=%s URL=%s%s%s",
+ iso_date_string(NULL),
+ result->url,
+ result->msg ? " MSG=" : "", result->msg ? result->msg : ""
+ );
+ add_reported_to(dd, msg);
+ free(msg);
+ dd_close(dd);
+ if (result->msg)
+ log("%s", result->msg);
+ log("URL=%s", result->url);
+ }
+ /* else: error msg was already emitted by dd_opendir */
+ url = result->url;
}
- /* No error in case creation. Attach the file. */
- result_atch = attach_file_to_case(result->url,
+ /* Attach the tarball of -d DIR */
+ result_atch = attach_file_to_case(url,
login,
password,
ssl_verify,
@@ -458,29 +478,18 @@ int main(int argc, char **argv)
);
if (result_atch->error)
{
- /* Error. Prepend "Case created" text to whatever error message there is,
- * so that user knows that case _was_ created despite error in attaching.
- */
- log("Case created but report attachment failed: %s", result_atch->msg);
- }
-
- /* Record "reported_to" element */
- struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
- if (dd)
- {
- char *msg = xasprintf("RHTSupport: TIME=%s URL=%s%s%s",
- iso_date_string(NULL),
- result->url,
- result->msg ? " MSG=" : "", result->msg ? result->msg : ""
- );
- add_reported_to(dd, msg);
- free(msg);
- dd_close(dd);
- if (result->msg)
- log("%s", result->msg);
- log("URL=%s", result->url);
+ if (!(opts & OPT_t))
+ {
+ /* Prepend "Case created" text to whatever error message there is,
+ * so that user knows that case _was_ created despite error in attaching.
+ */
+ log("Case created but failed to attach problem data: %s", result_atch->msg);
+ }
+ else
+ {
+ log("Failed to attach problem data: %s", result_atch->msg);
+ }
}
- /* else: error msg was already emitted by dd_opendir */
ret:
unlink(tempfile);
11 years, 2 months
[PATCH 1/3] reporter-rhtsupport: factor out tarball creation
by Denys Vlasenko
diff -x '*.po' -d -urpN libreport.0/src/plugins/reporter-rhtsupport.c libreport.1/src/plugins/reporter-rhtsupport.c
--- libreport.0/src/plugins/reporter-rhtsupport.c 2013-02-07 14:31:32.000000000 +0100
+++ libreport.1/src/plugins/reporter-rhtsupport.c 2013-03-21 13:39:54.620205617 +0100
@@ -33,6 +33,134 @@ static report_result_t *get_reported_to(
return reported_to;
}
+static
+int create_tarball(const char *tempfile, problem_data_t *problem_data)
+{
+ reportfile_t *file = NULL;
+
+ int pipe_from_parent_to_child[2];
+ xpipe(pipe_from_parent_to_child);
+ pid_t child = fork();
+ if (child == 0)
+ {
+ /* child */
+ close(pipe_from_parent_to_child[1]);
+ xmove_fd(xopen3(tempfile, O_WRONLY | O_CREAT | O_EXCL, 0600), 1);
+ xmove_fd(pipe_from_parent_to_child[0], 0);
+ execlp("gzip", "gzip", NULL);
+ perror_msg_and_die("Can't execute '%s'", "gzip");
+ }
+ close(pipe_from_parent_to_child[0]);
+
+ TAR *tar = NULL;
+ if (tar_fdopen(&tar, pipe_from_parent_to_child[1], (char*)tempfile,
+ /*fileops:(standard)*/ NULL, O_WRONLY | O_CREAT, 0644, TAR_GNU) != 0)
+ {
+ goto ret;
+ }
+
+ file = new_reportfile();
+ {
+ GHashTableIter iter;
+ char *name;
+ struct problem_item *value;
+ g_hash_table_iter_init(&iter, problem_data);
+ while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
+ {
+ const char *content = value->content;
+ if (value->flags & CD_FLAG_TXT)
+ {
+ reportfile_add_binding_from_string(file, name, content);
+ }
+ else if (value->flags & CD_FLAG_BIN)
+ {
+ const char *basename = strrchr(content, '/');
+ if (basename)
+ basename++;
+ else
+ basename = content;
+ char *xml_name = concat_path_file("content", basename);
+ reportfile_add_binding_from_namedfile(file,
+ /*on_disk_filename */ content,
+ /*binding_name */ name,
+ /*recorded_filename*/ xml_name,
+ /*binary */ 1);
+ if (tar_append_file(tar, (char*)content, xml_name) != 0)
+ {
+ free(xml_name);
+ goto ret;
+ }
+ free(xml_name);
+ }
+ }
+ }
+ const char *signature = reportfile_as_string(file);
+ /*
+ * Note: this pointer points to string which is owned by
+ * "file" object, can't free "file" just yet.
+ */
+
+ /* Write out content.xml in the tarball's root */
+ {
+ unsigned len = strlen(signature);
+ unsigned len512 = (len + 511) & ~511;
+ char *block = (char*)memcpy(xzalloc(len512), signature, len);
+
+ th_set_type(tar, S_IFREG | 0644);
+ th_set_mode(tar, S_IFREG | 0644);
+ //th_set_link(tar, char *linkname);
+ //th_set_device(tar, dev_t device);
+ //th_set_user(tar, uid_t uid);
+ //th_set_group(tar, gid_t gid);
+ th_set_mtime(tar, time(NULL));
+ th_set_path(tar, (char*)"content.xml");
+ th_set_size(tar, len);
+ th_finish(tar); /* caclulate and store th xsum etc */
+
+ if (th_write(tar) != 0 /* writes header block */
+ /* writes content.xml, padded to 512 bytes */
+ || full_write(tar_fd(tar), block, len512) != len512
+ || tar_append_eof(tar) != 0 /* writes EOF blocks */
+ || tar_close(tar) != 0
+ ) {
+ free(block);
+ goto ret;
+ }
+ tar = NULL;
+ free(block);
+ }
+
+ /* We must be sure gzip finished, and finished successfully */
+ int status;
+ safe_waitpid(child, &status, 0);
+ child = -1;
+ if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
+ {
+ /* Hopefully, by this time child emitted more meaningful
+ * error message. But just in case it didn't:
+ */
+ goto ret;
+ }
+ return 0; /* success */
+
+ ret:
+ /* We must close write fd first, or else child will wait forever */
+ if (tar)
+ tar_close(tar);
+ //close(pipe_from_parent_to_child[1]); - tar_close() does it itself
+
+ /* Now wait for child to exit */
+ if (child > 0)
+ {
+ // Damn, selinux does not allow SIGKILLing our own child! wtf??
+ //kill(child, SIGKILL); /* just in case */
+ safe_waitpid(child, NULL, 0);
+ }
+
+ free_reportfile(file);
+ return 1; /* failure */
+}
+
int main(int argc, char **argv)
{
abrt_init(argv);
@@ -196,10 +324,7 @@ int main(int argc, char **argv)
log(_("Compressing data"));
const char *errmsg = NULL;
- TAR *tar = NULL;
- pid_t child;
char *tempfile = NULL;
- reportfile_t *file = NULL;
rhts_result_t *result = NULL;
rhts_result_t *result_atch = NULL;
char *dsc = NULL;
@@ -226,7 +351,6 @@ int main(int argc, char **argv)
summary = strbuf_free_nobuf(buf_summary);
dsc = make_description_bz(problem_data, CD_TEXT_ATT_SIZE_BZ);
}
- file = new_reportfile();
char tmpdir_name[sizeof("/tmp/rhtsupport-"LIBREPORT_ISO_DATE_STRING_SAMPLE"-XXXXXX")];
snprintf(tmpdir_name, sizeof(tmpdir_name), "/tmp/rhtsupport-%s-XXXXXX", iso_date_string(NULL));
/* mkdtemp does mkdir(xxx, 0700), should be safe (is it?) */
@@ -238,107 +362,9 @@ int main(int argc, char **argv)
/* Starting from here, we must perform cleanup on errors
* (delete temp dir)
*/
-
tempfile = xasprintf("%s/tmp-%s-%lu.tar.gz", tmpdir_name, iso_date_string(NULL), (long)getpid());
-
- int pipe_from_parent_to_child[2];
- xpipe(pipe_from_parent_to_child);
- child = fork();
- if (child == 0)
- {
- /* child */
- close(pipe_from_parent_to_child[1]);
- xmove_fd(xopen3(tempfile, O_WRONLY | O_CREAT | O_EXCL, 0600), 1);
- xmove_fd(pipe_from_parent_to_child[0], 0);
- execlp("gzip", "gzip", NULL);
- perror_msg_and_die("Can't execute '%s'", "gzip");
- }
- close(pipe_from_parent_to_child[0]);
-
- if (tar_fdopen(&tar, pipe_from_parent_to_child[1], tempfile,
- /*fileops:(standard)*/ NULL, O_WRONLY | O_CREAT, 0644, TAR_GNU) != 0)
- {
- errmsg = _("Can't create temporary file in /tmp");
- goto ret;
- }
-
- {
- GHashTableIter iter;
- char *name;
- struct problem_item *value;
- g_hash_table_iter_init(&iter, problem_data);
- while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
- {
- const char *content = value->content;
- if (value->flags & CD_FLAG_TXT)
- {
- reportfile_add_binding_from_string(file, name, content);
- }
- else if (value->flags & CD_FLAG_BIN)
- {
- const char *basename = strrchr(content, '/');
- if (basename)
- basename++;
- else
- basename = content;
- char *xml_name = concat_path_file("content", basename);
- reportfile_add_binding_from_namedfile(file,
- /*on_disk_filename */ content,
- /*binding_name */ name,
- /*recorded_filename*/ xml_name,
- /*binary */ 1);
- if (tar_append_file(tar, (char*)content, xml_name) != 0)
- {
- errmsg = _("Can't create temporary file in /tmp");
- free(xml_name);
- goto ret;
- }
- free(xml_name);
- }
- }
- }
-
- /* Write out content.xml in the tarball's root */
- {
- const char *signature = reportfile_as_string(file);
- unsigned len = strlen(signature);
- unsigned len512 = (len + 511) & ~511;
- char *block = (char*)memcpy(xzalloc(len512), signature, len);
-
- th_set_type(tar, S_IFREG | 0644);
- th_set_mode(tar, S_IFREG | 0644);
- //th_set_link(tar, char *linkname);
- //th_set_device(tar, dev_t device);
- //th_set_user(tar, uid_t uid);
- //th_set_group(tar, gid_t gid);
- th_set_mtime(tar, time(NULL));
- th_set_path(tar, (char*)"content.xml");
- th_set_size(tar, len);
- th_finish(tar); /* caclulate and store th xsum etc */
-
- if (th_write(tar) != 0 /* writes header block */
- /* writes content.xml, padded to 512 bytes */
- || full_write(tar_fd(tar), block, len512) != len512
- || tar_append_eof(tar) != 0 /* writes EOF blocks */
- || tar_close(tar) != 0
- ) {
- free(block);
- errmsg = _("Can't create temporary file in /tmp");
- goto ret;
- }
- tar = NULL;
- free(block);
- }
-
- /* We must be sure gzip finished, and finished successfully */
- int status;
- safe_waitpid(child, &status, 0);
- child = -1;
- if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
+ if (create_tarball(tempfile, problem_data) != 0)
{
- /* Hopefully, by this time child emitted more meaningful
- * error message. But just in case it didn't:
- */
errmsg = _("Can't create temporary file in /tmp");
goto ret;
}
@@ -457,22 +483,8 @@ int main(int argc, char **argv)
/* else: error msg was already emitted by dd_opendir */
ret:
- /* We must close write fd first, or else child will wait forever */
- if (tar)
- tar_close(tar);
- //close(pipe_from_parent_to_child[1]); - tar_close() does it itself
-
- /* Now wait for child to exit */
- if (child > 0)
- {
- // Damn, selinux does not allow SIGKILLing our own child! wtf??
- //kill(child, SIGKILL); /* just in case */
- safe_waitpid(child, NULL, 0);
- }
-
unlink(tempfile);
free(tempfile);
- free_reportfile(file);
rmdir(tmpdir_name);
/* Note: errmsg may be = result->msg, don't move this code block
11 years, 2 months
Parameter for adaptive thread normalization
by Miroslav Lichvar
I'm working on a thread normalization method to mark frequent frames
which shouldn't be used in the report clustering. It has one parameter
and I'm trying to find a good default value for it.
At the URL below is a list of functions and results of the method
marked as stars in five columns for values 2.0, 3.0, 5.0, 10.0 and
20.0. With larger values the method is less aggressive.
http://mlichvar.fedorapeople.org/tmp/norm_frames
If you are familiar with some of the objects (binaries, shared
libraries, kernel modules, ...), please check the results and tell me
which value (column of stars) you think gives the best results in
marking of functions which shouldn't be used in the clustering.
Thanks,
--
Miroslav Lichvar
11 years, 2 months
[PATCH 3/3] reporter-rhtsupport: skip hints check if uploaded data is really large
by Denys Vlasenko
diff -x '*.po' -d -urpN libreport.2/src/include/internal_libreport.h libreport.3/src/include/internal_libreport.h
--- libreport.2/src/include/internal_libreport.h 2013-02-12 13:48:29.000000000 +0100
+++ libreport.3/src/include/internal_libreport.h 2013-03-21 11:52:18.044065167 +0100
@@ -362,6 +362,8 @@ ssize_t xsendto(int s, const void *buf,
void xstat(const char *name, struct stat *stat_buf);
#define fstat_st_size_or_die libreport_fstat_st_size_or_die
off_t fstat_st_size_or_die(int fd);
+#define stat_st_size_or_die libreport_stat_st_size_or_die
+off_t stat_st_size_or_die(const char *filename);
#define xopen3 libreport_xopen3
int xopen3(const char *pathname, int flags, int mode);
diff -x '*.po' -d -urpN libreport.2/src/lib/xfuncs.c libreport.3/src/lib/xfuncs.c
--- libreport.2/src/lib/xfuncs.c 2013-02-07 14:31:32.000000000 +0100
+++ libreport.3/src/lib/xfuncs.c 2013-03-21 11:52:47.166013656 +0100
@@ -286,6 +286,14 @@ off_t fstat_st_size_or_die(int fd)
return statbuf.st_size;
}
+off_t stat_st_size_or_die(const char *filename)
+{
+ struct stat statbuf;
+ if (stat(filename, &statbuf))
+ perror_msg_and_die("Can't stat '%s'", filename);
+ return statbuf.st_size;
+}
+
// Die if we can't open a file and return a fd
int xopen3(const char *pathname, int flags, int mode)
{
diff -x '*.po' -d -urpN libreport.2/src/plugins/reporter-rhtsupport.c libreport.3/src/plugins/reporter-rhtsupport.c
--- libreport.2/src/plugins/reporter-rhtsupport.c 2013-03-21 13:39:58.393199033 +0100
+++ libreport.3/src/plugins/reporter-rhtsupport.c 2013-03-21 13:39:22.026262577 +0100
@@ -23,6 +23,8 @@
#include "abrt_rh_support.h"
#include "reporter-rhtsupport.h"
+#define QUERY_HINTS_IF_SMALLER_THAN (8*1024*1024)
+
static report_result_t *get_reported_to(const char *dump_dir_name)
{
struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
@@ -367,50 +369,53 @@ int main(int argc, char **argv)
goto ret;
}
-//TODO: fetch size, use it to decide whether to fetch hints
+ off_t tempfile_size = stat_st_size_or_die(tempfile);
- /* Check for hints and show them if we have something */
- result = get_rhts_hints(url,
- login,
- password,
- ssl_verify,
- tempfile
- );
+ if (tempfile_size <= QUERY_HINTS_IF_SMALLER_THAN)
+ {
+ /* Check for hints and show them if we have something */
+ result = get_rhts_hints(url,
+ login,
+ password,
+ ssl_verify,
+ tempfile
+ );
#if 0 /* testing */
- log("ERR:%d", result->error);
- log("MSG:'%s'", result->msg);
- log("BODY:'%s'", result->body);
- result->error = 0;
- result->body = xstrdup(
- "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
- "<problems xmlns=\"http://www.redhat.com/gss/strata\">"
- "<link uri=\"http://access.redhat.com/\" rel=\"help\">The main Red Hat Support web site</link>"
- "<property name=\"content\">an ABRT report</property>"
- "<problem>"
- "<property name=\"source\">a backtrace in the ABRT report</property>"
- "<link uri=\"https://avalon-ci.gss.redhat.com/kb/docs/DOC-22029\" rel=\"suggestion\">[RHEL 5.3] EVO autocompletion lookup hang</link>"
- "</problem>"
- "</problems>"
- );
+ log("ERR:%d", result->error);
+ log("MSG:'%s'", result->msg);
+ log("BODY:'%s'", result->body);
+ result->error = 0;
+ result->body = xstrdup(
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
+ "<problems xmlns=\"http://www.redhat.com/gss/strata\">"
+ "<link uri=\"http://access.redhat.com/\" rel=\"help\">The main Red Hat Support web site</link>"
+ "<property name=\"content\">an ABRT report</property>"
+ "<problem>"
+ "<property name=\"source\">a backtrace in the ABRT report</property>"
+ "<link uri=\"https://avalon-ci.gss.redhat.com/kb/docs/DOC-22029\" rel=\"suggestion\">[RHEL 5.3] EVO autocompletion lookup hang</link>"
+ "</problem>"
+ "</problems>"
+ );
#endif
- if (result->error == 0 && result->body)
- {
- /* The message might contain URLs to known solutions and such */
- char *hint = parse_response_from_RHTS_hint_xml2txt(result->body);
- if (hint)
+ if (result->error == 0 && result->body)
{
- hint = append_to_malloced_string(hint, " ");
- hint = append_to_malloced_string(hint,
- _("Do you still want to create a RHTSupport ticket?")
- );
- int create_ticket = ask_yes_no(hint);
- free(hint);
- if (!create_ticket)
- goto ret;
+ /* The message might contain URLs to known solutions and such */
+ char *hint = parse_response_from_RHTS_hint_xml2txt(result->body);
+ if (hint)
+ {
+ hint = append_to_malloced_string(hint, " ");
+ hint = append_to_malloced_string(hint,
+ _("Do you still want to create a RHTSupport ticket?")
+ );
+ int create_ticket = ask_yes_no(hint);
+ free(hint);
+ if (!create_ticket)
+ goto ret;
+ }
}
+ free_rhts_result(result);
+ result = NULL;
}
- free_rhts_result(result);
- result = NULL;
if (!(opts & OPT_t))
{
11 years, 2 months
[ABRT PATCH] pyhook: resolve relative path to script RequireAbsolutePath is "no"
by Jakub Filak
- make a copy of CWD at exception handler installation time
- deficiencies:
* the CWD can be already changed by another .pth script
* I saw an AttributeError for missing getcwd() in os module but I
can't reproduce it
- this patch also fixes #611 because write_dump() stops using sys.argv
- closes #610
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/hooks/abrt_exception_handler.py.in | 31 +++++++++++++++----------------
tests/pyhook.at | 2 +-
2 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/src/hooks/abrt_exception_handler.py.in b/src/hooks/abrt_exception_handler.py.in
index 710ebdc..66fab18 100644
--- a/src/hooks/abrt_exception_handler.py.in
+++ b/src/hooks/abrt_exception_handler.py.in
@@ -29,14 +29,7 @@ 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:
- # We don't know the path.
- # (BTW, we *can't* assume the script is in current directory.)
- executable = sys.argv[0]
-
+def write_dump(executable, tb_text, tb):
dso_list = None
try:
import rpm
@@ -173,7 +166,7 @@ def conf_enabled(var_name):
file.close()
return -1
-def handleMyException((etype, value, tb)):
+def handleMyException((orig_pwd, etype, value, tb)):
"""
The exception handling function.
@@ -216,13 +209,19 @@ def handleMyException((etype, value, tb)):
syslog.syslog("detected unhandled Python exception")
raise Exception
- # Ignore scripts with relative path unless "RequireAbsolutePath = no".
- # (In this case we can't reliably determine package)
- syslog.syslog("detected unhandled Python exception in '%s'" % sys.argv[0])
- if sys.argv[0][0] != "/":
- if conf_enabled("RequireAbsolutePath") != 0:
+ if sys.argv[0][0] == "/":
+ executable = os.path.abspath(sys.argv[0])
+ else:
+ # Ignore scripts with relative path unless "RequireAbsolutePath = no".
+ # (In this case we can't reliably determine package)
+ if not conf_enabled("RequireAbsolutePath"):
+ executable = os.path.abspath(os.path.join(orig_pwd, sys.argv[0]))
+ else:
+ syslog.syslog("ignored unhandled Python exception in '%s' because of relative path to script" % sys.argv[0])
raise Exception
+ syslog.syslog("detected unhandled Python exception in '%s'" % executable)
+
import traceback
elist = traceback.format_exception(etype, value, tb)
@@ -263,7 +262,7 @@ def handleMyException((etype, value, tb)):
text += "".join(elist)
# Send data to the daemon
- write_dump(text, tb)
+ write_dump(executable, text, tb)
except:
# Silently ignore any error in this hook,
@@ -277,7 +276,7 @@ def installExceptionHandler():
"""
Install the exception handling function.
"""
- sys.excepthook = lambda etype, value, tb: handleMyException((etype, value, tb))
+ sys.excepthook = lambda etype, value, tb: handleMyException((os.getcwd(), etype, value, tb))
# install the exception handler when the abrt_exception_handler
# module is imported
diff --git a/tests/pyhook.at b/tests/pyhook.at
index 92a23bd..3c314d0 100644
--- a/tests/pyhook.at
+++ b/tests/pyhook.at
@@ -9,7 +9,7 @@ import sys
sys.path.insert(0, "../../../src/hooks")
import abrt_exception_handler
sys.argv[0]="/...testsuite.../$1.py"
-def write_dump(tb_text, tb):
+def write_dump(executable, tb_text, tb):
print tb_text.splitlines()[0]
abrt_exception_handler.write_dump = write_dump
$2
--
1.8.1.4
11 years, 2 months
[PATCH 1/3] be able to read release file on openSUSE
by Michal Toman
---
src/lib/dump_dir.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/lib/dump_dir.c b/src/lib/dump_dir.c
index 6289302..3da394d 100644
--- a/src/lib/dump_dir.c
+++ b/src/lib/dump_dir.c
@@ -640,7 +640,15 @@ void dd_create_basic_files(struct dump_dir *dd, uid_t uid, const char *chroot_di
release = load_text_file("/etc/system-release",
DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE | DD_OPEN_FOLLOW);
if (!release)
- release = load_text_file("/etc/redhat-release", DD_OPEN_FOLLOW);
+ release = load_text_file("/etc/redhat-release",
+ DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE | DD_OPEN_FOLLOW);
+ if (!release)
+ release = load_text_file("/etc/SuSE-release", DD_OPEN_FOLLOW);
+
+ char *newline = strchr(release, '\n');
+ if (newline)
+ *newline = '\0';
+
dd_save_text(dd, FILENAME_OS_RELEASE, release);
if (chroot_dir)
{
--
1.8.1.4
11 years, 2 months
Plans to improve abrt-cli based on feedback from GSS
by Denys Vlasenko
A bit of brainstorming on "abrt-cli report"...
"abrt-cli report" runs $EDITOR. This action looks a bit
surprising, at least to me.
does it make sense to add a prompt
"Do you want to review/edit text fields of the problem
being reported (y/N): "
Currently, "abrt-cli report" shows the following choice
How would you like to report?
1) Logger
2) Red Hat Customer Support
I propose to replace it with
How would you like to report?
1) Create new Red Hat Customer Support case
2) Add to existing Red Hat Customer Support case
3) Save the problem data to a *.tar.gz in /tmp
This will require splitting of existing report_RHTSupport
event into two.
To support he above, the following changes in backend are needed:
reporter-rhtsupport needs to be extended:
* make -tCASE_NO work without FILE argument - that is, it needs
to be taught to upload a tarball of -d DIR to the specified
case, not a FILE.
* -t without CASE_NO needs a way to ask for case no from user.
* needs to learn new trick: if archive is large, upload it
to an URL (e.g. ftp://dropbox.redhat.com/incoming/)
and only add a link to it to the created/updated case.
reporter-upload is usable to create /tmp/abrt-upload-*.tar.gz,
but (1) it loses directory name (it's not in the tarball)
and (2) tool name is not intuitive.
It already can be used for uploading to GSS's ftp (dropbox.redhat.com):
$ reporter-upload -u ftp://dropbox.redhat.com/incoming/
Compressing data
Sending /tmp/abrt-upload-2013-03-19-13:14:19-5838.tar.gz to ftp://dropbox.redhat.com/incoming/
Successfully sent /tmp/abrt-upload-2013-03-19-13:14:19-5838.tar.gz to ftp://dropbox.redhat.com/incoming/
but need to make it so that there is a *default* -c CONFFILE,
or we can specify URL in .xml or event .conf files.
We will likely need a progress indicator for huge uploads.
While we are at it:
rhtsupport_event.conf needs a comment explaining it a bit.
I would say:
# On RHEL, we want "abrt-cli report DIR" to let users run
# RHTS reporter (among other possible choices):
EVENT=report_RHTSupport
reporter-rhtsupport
I propose that these changes need to happen in HEAD first, and then
backported to rhel6.
--
vda
11 years, 2 months
faf design notes
by Jiri Moskovcak
For https://github.com/abrt/faf/wiki/Design:
Should the plugins be python modules or classes?
- +1 for classes (it's the right way for OOP)
- Storage, core, WebUI ? how about Model, View, Controller?
- ok, just nitpicking
- I miss some use-cases explaining why it's needed and how would it look
like when it's done
e.g:
<use-case>
Now when we'd like to add support for java we need to edit foo.py, 4
templates, change the database, edit the storage.py and add config to
httpd.conf
with the new plugin framework we will just install these files:
plugins/java.py
templates/java.html
conf/java.conf
- no need to edit files which doesn't belong to the plugin
</use-case>
- so we can then easily decide if we cover those use-cases or not
+ also some use-cases of what should the plugins be able to do and how
it will be done would be nice - e.g:
<use-case>
The Java plugin wants to add a page /classes containing list of all java
classes somehow connected with crashes sorted by it's occurrence. With
the current implementation it's impossible (or possible after changing
50+ files) with the plugin framework it will work like this ... (nice
and easy way how to do it :))
</use-case>
--Jirka
11 years, 2 months
[ABRT PATCH] spec: require libreport workflow package acc. to OS type
by Jakub Filak
- closes rhbz#921941
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
abrt.spec.in | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/abrt.spec.in b/abrt.spec.in
index f8433c2..65d3cd2 100644
--- a/abrt.spec.in
+++ b/abrt.spec.in
@@ -219,7 +219,12 @@ Requires: gnome-abrt
Requires: abrt-plugin-bodhi
Requires: libreport-plugin-logger, libreport-plugin-bugzilla
Requires: libreport-plugin-ureport
+%if 0%{?fedora}
Requires: libreport-fedora
+%endif
+%if 0%{?rhel}
+Requires: libreport-rhel
+%endif
#Requires: abrt-plugin-firefox
Obsoletes: bug-buddy > 0.0.1
Provides: bug-buddy
--
1.8.1.4
11 years, 2 months
[ABRT PATCH] Show a confirmation notify bubble for reported problems in ShortenedReporting mode
by Jakub Filak
- closes #623
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/applet/applet.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/src/applet/applet.c b/src/applet/applet.c
index 1a7e783..edc5ff7 100644
--- a/src/applet/applet.c
+++ b/src/applet/applet.c
@@ -792,14 +792,14 @@ static gboolean server_has_persistence(void)
static void notify_problem_list(GList *problems, int flags)
{
- bool persistence = false;
+ bool persistence_supported = false;
if (notify_is_initted() || notify_init(_("Problem detected")))
- persistence = server_has_persistence();
+ persistence_supported = server_has_persistence();
else
/* show icon and don't try to show notify if initialization of libnotify failed */
flags |= SHOW_ICON_ONLY;
- if (!persistence || flags & SHOW_ICON_ONLY)
+ if (!persistence_supported || flags & SHOW_ICON_ONLY)
{
/* Use a message of the last one */
GList *last = g_list_last(problems);
@@ -820,20 +820,27 @@ static void notify_problem_list(GList *problems, int flags)
for (GList *iter = problems; iter; iter = g_list_next(iter))
{
problem_info_t *pi = iter->data;
- if (ignored_problems_contains(g_ignore_set, pi->problem_dir)
- || (is_shortened_reporting_enabled() && pi->was_announced))
+ if (ignored_problems_contains(g_ignore_set, pi->problem_dir))
{ /* In case of shortened reporting, show the problem notification only once. */
problem_info_free(pi);
continue;
}
- pi->was_announced = true;
+ /* Don't show persistent notification (let notification bubble expire
+ * and disappear in few seconds) with ShortenedReporting mode enabled
+ * and already announced problem. And of course show persistent bubble
+ * only if the persistence is supported.
+ */
+ const bool persistent_notification = (persistence_supported
+ && !(is_shortened_reporting_enabled() && pi->was_announced));
- NotifyNotification *notification = new_warn_notification(persistence);
+ NotifyNotification *notification = new_warn_notification(persistent_notification);
notify_notification_add_action(notification, "IGNORE", _("Ignore"),
NOTIFY_ACTION_CALLBACK(action_ignore),
pi, NULL);
+ pi->was_announced = true;
+
if (pi->known)
{ /* Problem has been 'autoreported' and is considered as KNOWN
*/
--
1.8.1.4
11 years, 2 months