[GNOME-ABRT PATCH 1/2] Add AppData file
by Jakub Filak
Closes rhbz#1004830
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
po/POTFILES.in | 1 +
src/Makefile.am | 9 ++++++++-
src/gnome-abrt.appdata.xml.in | 19 +++++++++++++++++++
3 files changed, 28 insertions(+), 1 deletion(-)
create mode 100644 src/gnome-abrt.appdata.xml.in
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0f30622..0820dd1 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,4 +1,5 @@
src/gnome-abrt.desktop.in
+src/gnome-abrt.appdata.xml.in
src/gnome_abrt/dbus_problems.py
src/gnome_abrt/dialogs.py
diff --git a/src/Makefile.am b/src/Makefile.am
index f8ab66b..89aa65b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,12 +2,19 @@ SUBDIRS = gnome_abrt
bin_SCRIPTS=gnome-abrt
+@INTLTOOL_XML_RULE@
+
+appdatadir = $(datadir)/appdata
+app_data_in_files = gnome-abrt.appdata.xml.in
+appdata_DATA = $(app_data_in_files:.xml.in=.xml)
+
@INTLTOOL_DESKTOP_RULE@
+
desktopdir = $(datadir)/applications
desktop_in_files = gnome-abrt.desktop.in
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
-EXTRA_DIST = $(bin_SCRIPTS) $(desktop_in_files)
+EXTRA_DIST = $(bin_SCRIPTS) $(desktop_in_files) $(app_data_in_files)
check-local: $(bin_SCRIPTS)
if USE_PYLINT
diff --git a/src/gnome-abrt.appdata.xml.in b/src/gnome-abrt.appdata.xml.in
new file mode 100644
index 0000000..1a756eb
--- /dev/null
+++ b/src/gnome-abrt.appdata.xml.in
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<application>
+<id type="desktop">gnome-abrt.desktop</id>
+<licence>CC0</licence>
+<description>
+ <_p>
+ Collection of software tools designed for collecting, analyzing and reporting of
+ software issues.
+ </_p>
+ <_p>
+ It's main purpose is to ease the process of reporting an issue and finding a solution.
+ </_p>
+</description>
+<url type="homepage">https://github.com/abrt/gnome-abrt</url>
+<screenshots>
+<screenshot type="default">http://jfilak.fedorapeople.org/media/gnome-abrt.png</screenshot>
+</screenshots>
+<updatecontact>crash-catcher(a)lists.fedorahosted.org</updatecontact>
+</application>
--
1.8.3.1
10 years, 8 months
[ABRT PATCH] a-a-ureport: don't crash if cwd was deleted rhbz#998428
by Richard Marko
Signed-off-by: Richard Marko <rmarko(a)redhat.com>
---
src/plugins/abrt-action-ureport | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/plugins/abrt-action-ureport b/src/plugins/abrt-action-ureport
index 44575d8..ecc03ee 100755
--- a/src/plugins/abrt-action-ureport
+++ b/src/plugins/abrt-action-ureport
@@ -54,7 +54,11 @@ if __name__ == "__main__":
set_verbosity(verbose)
- dirname = os.getcwd()
+ # getcwd might fail if cwd was deleted
+ try:
+ dirname = os.getcwd()
+ except OSError:
+ sys.exit(1)
dd = dd_opendir(dirname, 0)
if not dd:
--
1.8.3.1
10 years, 8 months
[ABRT PATCH] doc: update OpenGPGCheck in a-a-save-package-data rhbz#997922
by Richard Marko
OpenGPGCheck is enabled by default and if it's enabled
crashes in unsigned packages are not handled at all.
Signed-off-by: Richard Marko <rmarko(a)redhat.com>
---
doc/abrt-action-save-package-data.conf.txt | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/doc/abrt-action-save-package-data.conf.txt b/doc/abrt-action-save-package-data.conf.txt
index b377ec7..fdf496c 100644
--- a/doc/abrt-action-save-package-data.conf.txt
+++ b/doc/abrt-action-save-package-data.conf.txt
@@ -15,11 +15,11 @@ The configuration file consists of items in the format "Option = Value".
A description of each item follows:
OpenGPGCheck = 'yes' | 'no'::
- When set to 'yes', 'abrt' will report crashes only in executables which belong
+ When set to 'yes', 'abrt' will handle only crashes in executables which belong
to an installed package with valid GPG signature.
- The default is 'no'.
+ The default is 'yes'.
The files containing trusted GPG keys which are used to verify
- the signatures are listed in the gpg_keys configuration file.
+ the signatures are listed in the gpg_keys.conf configuration file.
BlackList = 'packageName', 'packageName' ...::
'abrt' will ignore packages in this list and will not handle their crashes.
BlackListedPaths = '`/path/to/ignore/*`', '`*/another/ignored/path*`' ...::
--
1.8.3.1
10 years, 8 months
[RHEL6 ABRT PATCH] doc: update OpenGPGCheck in a-a-save-package-data rhbz#997922
by Richard Marko
OpenGPGCheck is enabled by default and if it's enabled
crashes in unsigned packages are not handled at all.
Signed-off-by: Richard Marko <rmarko(a)redhat.com>
---
doc/abrt-action-save-package-data.conf.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/doc/abrt-action-save-package-data.conf.txt b/doc/abrt-action-save-package-data.conf.txt
index b377ec7..eb593ee 100644
--- a/doc/abrt-action-save-package-data.conf.txt
+++ b/doc/abrt-action-save-package-data.conf.txt
@@ -15,9 +15,9 @@ The configuration file consists of items in the format "Option = Value".
A description of each item follows:
OpenGPGCheck = 'yes' | 'no'::
- When set to 'yes', 'abrt' will report crashes only in executables which belong
+ When set to 'yes', 'abrt' will handle only crashes in executables which belong
to an installed package with valid GPG signature.
- The default is 'no'.
+ The default is 'yes'.
The files containing trusted GPG keys which are used to verify
the signatures are listed in the gpg_keys configuration file.
BlackList = 'packageName', 'packageName' ...::
--
1.8.3.1
10 years, 8 months
[LIBREPORT PATCH] Create helper functions for sha1-hashing strings. #694
by Denys Vlasenko
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
src/include/internal_libreport.h | 6 ++++++
src/lib/hash_sha1.c | 19 +++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
index ae46ad4..0f335a3 100644
--- a/src/include/internal_libreport.h
+++ b/src/include/internal_libreport.h
@@ -208,6 +208,12 @@ void sha1_hash(sha1_ctx_t *ctx, const void *buffer, size_t len);
#define sha1_end libreport_sha1_end
void sha1_end(sha1_ctx_t *ctx, void *resbuf);
+/* Helpers to hash a string: */
+#define str_to_sha1 libreport_str_to_sha1
+const uint8_t *str_to_sha1(uint8_t result[SHA1_RESULT_LEN], const char *str);
+#define str_to_sha1str libreport_str_to_sha1str
+const char *str_to_sha1str(char result[SHA1_RESULT_LEN*2 + 1], const char *str);
+
#define xatou libreport_xatou
unsigned xatou(const char *numstr);
diff --git a/src/lib/hash_sha1.c b/src/lib/hash_sha1.c
index f8f85d1..4a604c0 100644
--- a/src/lib/hash_sha1.c
+++ b/src/lib/hash_sha1.c
@@ -224,3 +224,22 @@ static void common64_end(sha1_ctx_t *ctx, int swap_needed)
bufpos = 0;
}
}
+
+/* Utility helpers */
+
+const uint8_t *str_to_sha1(uint8_t hash_bytes[SHA1_RESULT_LEN], const char *str)
+{
+ sha1_ctx_t sha1ctx;
+ sha1_begin(&sha1ctx);
+ sha1_hash(&sha1ctx, str, strlen(str));
+ sha1_end(&sha1ctx, hash_bytes);
+ return hash_bytes;
+}
+
+const char *str_to_sha1str(char result[SHA1_RESULT_LEN*2 + 1], const char *str)
+{
+ uint8_t hash_bytes[SHA1_RESULT_LEN];
+ str_to_sha1(hash_bytes, str);
+ bin2hex(result, (void*)hash_bytes, SHA1_RESULT_LEN)[0] = '\0';
+ return result;
+}
--
1.8.1.4
10 years, 8 months
[ABRT PATCH] Use common string-to-sha1_hash functions. #694
by Denys Vlasenko
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
src/cli/abrt-cli-core.c | 18 +++---------------
src/cli/abrt-cli-core.h | 1 -
src/cli/list.c | 3 ++-
src/lib/kernel.c | 8 +-------
src/plugins/abrt-action-analyze-backtrace.c | 14 +-------------
src/plugins/abrt-action-analyze-c.c | 14 +-------------
src/plugins/abrt-action-analyze-python.c | 13 ++++---------
7 files changed, 12 insertions(+), 59 deletions(-)
diff --git a/src/cli/abrt-cli-core.c b/src/cli/abrt-cli-core.c
index 89bd04a..23a74a8 100644
--- a/src/cli/abrt-cli-core.c
+++ b/src/cli/abrt-cli-core.c
@@ -74,19 +74,6 @@ static bool isxdigit_str(const char *str)
return true;
}
-const char *str2hash(const char *str)
-{
- static char result[SHA1_RESULT_LEN*2 + 1];
-
- char hash_bytes[SHA1_RESULT_LEN];
- sha1_ctx_t sha1ctx;
- sha1_begin(&sha1ctx);
- sha1_hash(&sha1ctx, str, strlen(str));
- sha1_end(&sha1ctx, hash_bytes);
- bin2hex(result, hash_bytes, SHA1_RESULT_LEN)[0] = '\0';
- return result;
-}
-
struct name_resolution_param {
const char *shortcut;
unsigned strlen_shortcut;
@@ -96,8 +83,9 @@ struct name_resolution_param {
static int find_dir_by_hash(struct dump_dir *dd, void *arg)
{
struct name_resolution_param *param = arg;
- const char *h = str2hash(dd->dd_dirname);
- if (strncasecmp(param->shortcut, h, param->strlen_shortcut) == 0)
+ char hash_str[SHA1_RESULT_LEN*2 + 1];
+ str_to_sha1str(hash_str, dd->dd_dirname);
+ if (strncasecmp(param->shortcut, hash_str, param->strlen_shortcut) == 0)
{
if (param->found_name)
error_msg_and_die(_("'%s' identifies more than one problem directory"), param->shortcut);
diff --git a/src/cli/abrt-cli-core.h b/src/cli/abrt-cli-core.h
index 2e5dfe5..83d0b5d 100644
--- a/src/cli/abrt-cli-core.h
+++ b/src/cli/abrt-cli-core.h
@@ -30,7 +30,6 @@ void free_vector_of_problem_data(vector_of_problem_data_t *vector);
vector_of_problem_data_t *new_vector_of_problem_data(void);
vector_of_problem_data_t *fetch_crash_infos(GList *dir_list);
-const char *str2hash(const char *str);
/* Returns malloced string, or NULL if not found: */
char *hash2dirname(const char *hash);
diff --git a/src/cli/list.c b/src/cli/list.c
index c6bc895..a7209ed 100644
--- a/src/cli/list.c
+++ b/src/cli/list.c
@@ -110,9 +110,10 @@ static void print_crash_list(vector_of_problem_data_t *crash_list, int detailed,
continue;
}
+ char hash_str[SHA1_RESULT_LEN*2 + 1];
struct problem_item *item = g_hash_table_lookup(crash, CD_DUMPDIR);
if (item)
- printf("@%s\n", str2hash(item->content));
+ printf("@%s\n", str_to_sha1str(hash_str, item->content));
print_crash(crash, detailed, text_size);
if (i != crash_list->len - 1)
printf("\n");
diff --git a/src/lib/kernel.c b/src/lib/kernel.c
index dd2383b..54bf048 100644
--- a/src/lib/kernel.c
+++ b/src/lib/kernel.c
@@ -517,14 +517,8 @@ int koops_hash_str(char hash_str[SHA1_RESULT_LEN*2 + 1], const char *oops_buf)
*/
int bad = (kernel_bt->len == 0);
- char hash_bytes[SHA1_RESULT_LEN];
- sha1_ctx_t sha1ctx;
- sha1_begin(&sha1ctx);
- sha1_hash(&sha1ctx, kernel_bt->buf, kernel_bt->len);
- sha1_end(&sha1ctx, hash_bytes);
+ str_to_sha1str(hash_str, kernel_bt->buf);
strbuf_free(kernel_bt);
-
- bin2hex(hash_str, hash_bytes, SHA1_RESULT_LEN)[0] = '\0';
VERB3 log("hash: %s", hash_str);
return bad;
diff --git a/src/plugins/abrt-action-analyze-backtrace.c b/src/plugins/abrt-action-analyze-backtrace.c
index 9348195..99055cf 100644
--- a/src/plugins/abrt-action-analyze-backtrace.c
+++ b/src/plugins/abrt-action-analyze-backtrace.c
@@ -25,18 +25,6 @@
static const char *dump_dir_name = ".";
-static void create_hash(char hash_str[SHA1_RESULT_LEN*2 + 1], const char *pInput)
-{
- char hash_bytes[SHA1_RESULT_LEN];
- sha1_ctx_t sha1ctx;
- sha1_begin(&sha1ctx);
- sha1_hash(&sha1ctx, pInput, strlen(pInput));
- sha1_end(&sha1ctx, hash_bytes);
-
- bin2hex(hash_str, hash_bytes, SHA1_RESULT_LEN)[0] = '\0';
- //log("hash:%s str:'%s'", hash_str, pInput);
-}
-
int main(int argc, char **argv)
{
/* I18n */
@@ -111,7 +99,7 @@ int main(int argc, char **argv)
VERB3 log("Generating duphash: %s", emptybt->buf);
char hash_str[SHA1_RESULT_LEN*2 + 1];
- create_hash(hash_str, emptybt->buf);
+ str_to_sha1str(hash_str, emptybt->buf);
dd_save_text(dd, FILENAME_DUPHASH, hash_str);
/*
diff --git a/src/plugins/abrt-action-analyze-c.c b/src/plugins/abrt-action-analyze-c.c
index cb2bd78..a53f4fb 100644
--- a/src/plugins/abrt-action-analyze-c.c
+++ b/src/plugins/abrt-action-analyze-c.c
@@ -18,18 +18,6 @@
*/
#include "libabrt.h"
-static void create_hash(char hash_str[SHA1_RESULT_LEN*2 + 1], const char *pInput)
-{
- char hash_bytes[SHA1_RESULT_LEN];
- sha1_ctx_t sha1ctx;
- sha1_begin(&sha1ctx);
- sha1_hash(&sha1ctx, pInput, strlen(pInput));
- sha1_end(&sha1ctx, hash_bytes);
-
- bin2hex(hash_str, hash_bytes, SHA1_RESULT_LEN)[0] = '\0';
- //log("hash:%s str:'%s'", hash_str, pInput);
-}
-
static void trim_unstrip_output(char *result, const char *unstrip_n_output)
{
// lines look like this:
@@ -144,7 +132,7 @@ int main(int argc, char **argv)
/*free(unstrip_n_output);*/
char hash_str[SHA1_RESULT_LEN*2 + 1];
- create_hash(hash_str, string_to_hash);
+ str_to_sha1str(hash_str, string_to_hash);
dd_save_text(dd, FILENAME_UUID, hash_str);
dd_close(dd);
diff --git a/src/plugins/abrt-action-analyze-python.c b/src/plugins/abrt-action-analyze-python.c
index f9b2105..b7ad1a6 100644
--- a/src/plugins/abrt-action-analyze-python.c
+++ b/src/plugins/abrt-action-analyze-python.c
@@ -59,16 +59,11 @@ int main(int argc, char **argv)
/* Hash 1st line of backtrace and save it as UUID and DUPHASH */
/* "example.py:1:<module>:ZeroDivisionError: integer division or modulo by zero" */
- char hash_bytes[SHA1_RESULT_LEN];
- sha1_ctx_t sha1ctx;
- sha1_begin(&sha1ctx);
- const char *bt_end = strchrnul(bt, '\n');
- sha1_hash(&sha1ctx, bt, bt_end - bt);
- sha1_end(&sha1ctx, hash_bytes);
- free(bt);
-
+ char *bt_end = strchrnul(bt, '\n');
+ *bt_end = '\0';
char hash_str[SHA1_RESULT_LEN*2 + 1];
- bin2hex(hash_str, hash_bytes, SHA1_RESULT_LEN)[0] = '\0';
+ str_to_sha1str(hash_str, bt);
+ free(bt);
dd_save_text(dd, FILENAME_UUID, hash_str);
dd_save_text(dd, FILENAME_DUPHASH, hash_str);
--
1.8.1.4
10 years, 8 months
[LIBREPORT PATCH] bugzilla_formatdup*.conf: clearly flag comment as a dup. rhbz#875312, 875233, 864891
by Denys Vlasenko
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
src/plugins/bugzilla_format.conf | 2 ++
src/plugins/bugzilla_format_anaconda.conf | 2 ++
src/plugins/bugzilla_formatdup.conf | 10 +++++++++-
src/plugins/bugzilla_formatdup_anaconda.conf | 10 +++++++++-
4 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/plugins/bugzilla_format.conf b/src/plugins/bugzilla_format.conf
index cad5876..4f321d9 100644
--- a/src/plugins/bugzilla_format.conf
+++ b/src/plugins/bugzilla_format.conf
@@ -15,6 +15,8 @@
# - %summary: bug summary format string.
# - %attach: a list of elements to attach.
# - text, double colon (::) and the list of comma-separated elements.
+# Text can be empty (":: elem1, elem2. elem3" works),
+# in this case "Text:" header line will be omitted.
#
# Elements can be:
# - problem directory element names, which get formatted as
diff --git a/src/plugins/bugzilla_format_anaconda.conf b/src/plugins/bugzilla_format_anaconda.conf
index 8ac8b5c..4af7092 100644
--- a/src/plugins/bugzilla_format_anaconda.conf
+++ b/src/plugins/bugzilla_format_anaconda.conf
@@ -15,6 +15,8 @@
# - %summary: bug summary format string.
# - %attach: a list of elements to attach.
# - text, double colon (::) and the list of comma-separated elements.
+# Text can be empty (":: elem1, elem2. elem3" works),
+# in this case "Text:" header line will be omitted.
#
# Elements can be:
# - problem directory element names, which get formatted as
diff --git a/src/plugins/bugzilla_formatdup.conf b/src/plugins/bugzilla_formatdup.conf
index f5e89f7..6eb1230 100644
--- a/src/plugins/bugzilla_formatdup.conf
+++ b/src/plugins/bugzilla_formatdup.conf
@@ -15,6 +15,8 @@
# - %summary: bug summary format string.
# - %attach: a list of elements to attach.
# - text, double colon (::) and the list of comma-separated elements.
+# Text can be empty (":: elem1, elem2. elem3" works),
+# in this case "Text:" header line will be omitted.
#
# Elements can be:
# - problem directory element names, which get formatted as
@@ -36,8 +38,14 @@
# Nonexistent elements are silently ignored.
# If none of elements exists, the section will not be created.
-%summary:: [abrt] %package%[[: %crash_function%]][[: %reason%]][[: TAINTED %tainted_short%]]
+# When dup is detected, BZ reported adds a comment to it.
+# This comment may interrupt an ongoing conversation in the BZ.
+# (Three people independently filed a bug against abrt about this).
+# Need to clearly explain what this comment is, to prevent confusion.
+# Hopefully, this line would suffice:
+Another user experienced a similar problem:
+# If user filled out comment field, show it:
:: %bare_comment
# var_log_messages has too much variance (time/date),
diff --git a/src/plugins/bugzilla_formatdup_anaconda.conf b/src/plugins/bugzilla_formatdup_anaconda.conf
index efe8fa1..03c7f87 100644
--- a/src/plugins/bugzilla_formatdup_anaconda.conf
+++ b/src/plugins/bugzilla_formatdup_anaconda.conf
@@ -15,6 +15,8 @@
# - %summary: bug summary format string.
# - %attach: a list of elements to attach.
# - text, double colon (::) and the list of comma-separated elements.
+# Text can be empty (":: elem1, elem2. elem3" works),
+# in this case "Text:" header line will be omitted.
#
# Elements can be:
# - problem directory element names, which get formatted as
@@ -36,8 +38,14 @@
# Nonexistent elements are silently ignored.
# If none of elements exists, the section will not be created.
-%summary:: [abrt] %package%[[: %crash_function%]][[: %reason%]][[: TAINTED %tainted_short%]]
+# When dup is detected, BZ reported adds a comment to it.
+# This comment may interrupt an ongoing conversation in the BZ.
+# (Three people independently filed a bug against abrt about this).
+# Need to clearly explain what this comment is, to prevent confusion.
+# Hopefully, this line would suffice:
+Another user experienced a similar problem:
+# If user filled out comment field, show it:
:: %bare_comment
# var_log_messages has too much variance (time/date),
--
1.8.1.4
10 years, 8 months
[ABRT PATCH] abrt-cli report: accept sha1 hashes of directory names. #693
by Denys Vlasenko
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
po/POTFILES.in | 1 +
src/cli/abrt-cli-core.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++
src/cli/abrt-cli-core.h | 4 ++++
src/cli/list.c | 57 ++++--------------------------------------------
src/cli/report.c | 22 ++++++-------------
5 files changed, 74 insertions(+), 68 deletions(-)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index cd0a887..817b3fd 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -42,6 +42,7 @@ src/plugins/bodhi.c
src/hooks/abrt-merge-pstoreoops.c
+src/cli/abrt-cli-core.c
src/cli/abrt-cli.c
src/cli/list.c
src/cli/status.c
diff --git a/src/cli/abrt-cli-core.c b/src/cli/abrt-cli-core.c
index 26d08cc..6826a69 100644
--- a/src/cli/abrt-cli-core.c
+++ b/src/cli/abrt-cli-core.c
@@ -60,3 +60,61 @@ vector_of_problem_data_t *fetch_crash_infos(GList *dir_list)
return vpd;
}
+
+
+static bool isxdigit_str(const char *str)
+{
+ do
+ {
+ if (*str < '0' || *str > '9')
+ if ((*str|0x20) < 'a' || (*str|0x20) > 'f')
+ return false;
+ str++;
+ } while (*str);
+ return true;
+}
+
+char *str2hash(const char *str)
+{
+ static char result[SHA1_RESULT_LEN*2 + 1];
+
+ char hash_bytes[SHA1_RESULT_LEN];
+ sha1_ctx_t sha1ctx;
+ sha1_begin(&sha1ctx);
+ sha1_hash(&sha1ctx, str, strlen(str));
+ sha1_end(&sha1ctx, hash_bytes);
+ bin2hex(result, hash_bytes, SHA1_RESULT_LEN)[0] = '\0';
+ return result;
+}
+
+struct name_resolution_param {
+ const char *shortcut;
+ unsigned strlen_shortcut;
+ char *found_name;
+};
+static int find_dir_by_hash(struct dump_dir *dd, void *arg)
+{
+ struct name_resolution_param *param = arg;
+ char *h = str2hash(dd->dd_dirname);
+ if (strncasecmp(param->shortcut, h, param->strlen_shortcut) == 0)
+ {
+ if (param->found_name)
+ error_msg_and_die(_("'%s' identifies more than one problem directory"), param->shortcut);
+ param->found_name = xstrdup(dd->dd_dirname);
+ }
+ return 0;
+}
+
+char *hash2dirname(const char *hash)
+{
+ unsigned hash_len = strlen(hash);
+ if (!isxdigit_str(hash) || hash_len < 5)
+ return NULL;
+
+ /* Try loading by dirname hash */
+ struct name_resolution_param param = { hash, hash_len, NULL };
+ GList *dir_list = get_problem_storages();
+ for (GList *li = dir_list; li; li = li->next)
+ for_each_problem_in_dir(li->data, getuid(), find_dir_by_hash, ¶m);
+ return param.found_name;
+}
diff --git a/src/cli/abrt-cli-core.h b/src/cli/abrt-cli-core.h
index 8eedc13..d28ef95 100644
--- a/src/cli/abrt-cli-core.h
+++ b/src/cli/abrt-cli-core.h
@@ -30,4 +30,8 @@ void free_vector_of_problem_data(vector_of_problem_data_t *vector);
vector_of_problem_data_t *new_vector_of_problem_data(void);
vector_of_problem_data_t *fetch_crash_infos(GList *dir_list);
+char *str2hash(const char *str);
+char *hash2dirname(const char *hash);
+
+
#endif /* ABRT_CLI_CORE_H_ */
diff --git a/src/cli/list.c b/src/cli/list.c
index a257623..c6bc895 100644
--- a/src/cli/list.c
+++ b/src/cli/list.c
@@ -30,49 +30,6 @@
* ~/.abrt/spool and /var/tmp/abrt? needs more _meditation_.
*/
-static bool isxdigit_str(const char *str)
-{
- do
- {
- if (*str < '0' || *str > '9')
- if ((*str|0x20) < 'a' || (*str|0x20) > 'f')
- return false;
- str++;
- } while (*str);
- return true;
-}
-
-static char *str2hash(const char *str)
-{
- static char result[SHA1_RESULT_LEN*2 + 1];
-
- char hash_bytes[SHA1_RESULT_LEN];
- sha1_ctx_t sha1ctx;
- sha1_begin(&sha1ctx);
- sha1_hash(&sha1ctx, str, strlen(str));
- sha1_end(&sha1ctx, hash_bytes);
- bin2hex(result, hash_bytes, SHA1_RESULT_LEN)[0] = '\0';
- return result;
-}
-
-struct name_resolution_param {
- const char *shortcut;
- unsigned strlen_shortcut;
- char *found_name;
-};
-static int find_dir_by_hash(struct dump_dir *dd, void *arg)
-{
- struct name_resolution_param *param = arg;
- char *h = str2hash(dd->dd_dirname);
- if (strncasecmp(param->shortcut, h, param->strlen_shortcut) == 0)
- {
- if (param->found_name)
- error_msg_and_die(_("'%s' identifies more than one problem directory"), param->shortcut);
- param->found_name = xstrdup(dd->dd_dirname);
- }
- return 0;
-}
-
static problem_data_t *load_problem_data(const char *dump_dir_name)
{
/* First, try loading by dirname */
@@ -81,19 +38,13 @@ static problem_data_t *load_problem_data(const char *dump_dir_name)
struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ DD_OPEN_READONLY);
logmode = sv_logmode;
- unsigned name_len = strlen(dump_dir_name);
/* (git requires at least 5 char hash prefix, we do the same) */
- if (!dd && errno == ENOENT && isxdigit_str(dump_dir_name) && name_len >= 5)
+ if (!dd && errno == ENOENT)
{
/* Try loading by dirname hash */
- struct name_resolution_param param = { dump_dir_name, name_len, NULL };
- GList *dir_list = get_problem_storages();
- for (GList *li = dir_list; li; li = li->next)
- for_each_problem_in_dir(li->data, getuid(), find_dir_by_hash, ¶m);
- if (!param.found_name)
- return NULL;
- dd = dd_opendir(param.found_name, /*flags:*/ DD_OPEN_READONLY);
- free(param.found_name);
+ char *name2 = hash2dirname(dump_dir_name);
+ dd = dd_opendir(name2, /*flags:*/ DD_OPEN_READONLY);
+ free(name2);
}
if (!dd)
diff --git a/src/cli/report.c b/src/cli/report.c
index 781c691..c5787e0 100644
--- a/src/cli/report.c
+++ b/src/cli/report.c
@@ -51,26 +51,18 @@ int cmd_report(int argc, const char **argv)
{
const char *dir_name = *argv++;
- vector_of_problem_data_t *ci = NULL;
- if (*dir_name == '@')
+ char *free_me = NULL;
+ if (access(dir_name, F_OK) != 0 && errno == ENOENT)
{
- dir_name++;
- unsigned at = xatoi_positive(dir_name);
-
- ci = fetch_crash_infos(D_list);
- if (at >= ci->len)
- error_msg_and_die("error: number is out of range '%s'", dir_name);
-
- g_ptr_array_sort_with_data(ci, &cmp_problem_data, (char *) FILENAME_LAST_OCCURRENCE);
- problem_data_t *pd = get_problem_data(ci, at);
-
- dir_name = problem_data_get_content_or_NULL(pd, CD_DUMPDIR);
+ free_me = hash2dirname(dir_name);
+ if (free_me)
+ dir_name = free_me;
}
-
int status = report_problem_in_dir(dir_name,
LIBREPORT_WAIT
| LIBREPORT_RUN_CLI);
- free_vector_of_problem_data(ci);
+ free(free_me);
+
if (status)
exit(status);
}
--
1.8.1.4
10 years, 8 months
[[ABRT PATCH v2] abrt-cli report: accept sha1 hashes of directory names. #693
by Denys Vlasenko
v2: made str2hash() return const char*.
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
po/POTFILES.in | 1 +
src/cli/abrt-cli-core.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++
src/cli/abrt-cli-core.h | 5 +++++
src/cli/list.c | 57 ++++-------------------------------------------
src/cli/report.c | 22 ++++++------------
5 files changed, 76 insertions(+), 68 deletions(-)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index cd0a887..817b3fd 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -42,6 +42,7 @@ src/plugins/bodhi.c
src/hooks/abrt-merge-pstoreoops.c
+src/cli/abrt-cli-core.c
src/cli/abrt-cli.c
src/cli/list.c
src/cli/status.c
diff --git a/src/cli/abrt-cli-core.c b/src/cli/abrt-cli-core.c
index 26d08cc..89bd04a 100644
--- a/src/cli/abrt-cli-core.c
+++ b/src/cli/abrt-cli-core.c
@@ -60,3 +60,62 @@ vector_of_problem_data_t *fetch_crash_infos(GList *dir_list)
return vpd;
}
+
+
+static bool isxdigit_str(const char *str)
+{
+ do
+ {
+ if (*str < '0' || *str > '9')
+ if ((*str|0x20) < 'a' || (*str|0x20) > 'f')
+ return false;
+ str++;
+ } while (*str);
+ return true;
+}
+
+const char *str2hash(const char *str)
+{
+ static char result[SHA1_RESULT_LEN*2 + 1];
+
+ char hash_bytes[SHA1_RESULT_LEN];
+ sha1_ctx_t sha1ctx;
+ sha1_begin(&sha1ctx);
+ sha1_hash(&sha1ctx, str, strlen(str));
+ sha1_end(&sha1ctx, hash_bytes);
+ bin2hex(result, hash_bytes, SHA1_RESULT_LEN)[0] = '\0';
+ return result;
+}
+
+struct name_resolution_param {
+ const char *shortcut;
+ unsigned strlen_shortcut;
+ char *found_name;
+};
+
+static int find_dir_by_hash(struct dump_dir *dd, void *arg)
+{
+ struct name_resolution_param *param = arg;
+ const char *h = str2hash(dd->dd_dirname);
+ if (strncasecmp(param->shortcut, h, param->strlen_shortcut) == 0)
+ {
+ if (param->found_name)
+ error_msg_and_die(_("'%s' identifies more than one problem directory"), param->shortcut);
+ param->found_name = xstrdup(dd->dd_dirname);
+ }
+ return 0;
+}
+
+char *hash2dirname(const char *hash)
+{
+ unsigned hash_len = strlen(hash);
+ if (!isxdigit_str(hash) || hash_len < 5)
+ return NULL;
+
+ /* Try loading by dirname hash */
+ struct name_resolution_param param = { hash, hash_len, NULL };
+ GList *dir_list = get_problem_storages();
+ for (GList *li = dir_list; li; li = li->next)
+ for_each_problem_in_dir(li->data, getuid(), find_dir_by_hash, ¶m);
+ return param.found_name;
+}
diff --git a/src/cli/abrt-cli-core.h b/src/cli/abrt-cli-core.h
index 8eedc13..2e5dfe5 100644
--- a/src/cli/abrt-cli-core.h
+++ b/src/cli/abrt-cli-core.h
@@ -30,4 +30,9 @@ void free_vector_of_problem_data(vector_of_problem_data_t *vector);
vector_of_problem_data_t *new_vector_of_problem_data(void);
vector_of_problem_data_t *fetch_crash_infos(GList *dir_list);
+const char *str2hash(const char *str);
+/* Returns malloced string, or NULL if not found: */
+char *hash2dirname(const char *hash);
+
+
#endif /* ABRT_CLI_CORE_H_ */
diff --git a/src/cli/list.c b/src/cli/list.c
index a257623..c6bc895 100644
--- a/src/cli/list.c
+++ b/src/cli/list.c
@@ -30,49 +30,6 @@
* ~/.abrt/spool and /var/tmp/abrt? needs more _meditation_.
*/
-static bool isxdigit_str(const char *str)
-{
- do
- {
- if (*str < '0' || *str > '9')
- if ((*str|0x20) < 'a' || (*str|0x20) > 'f')
- return false;
- str++;
- } while (*str);
- return true;
-}
-
-static char *str2hash(const char *str)
-{
- static char result[SHA1_RESULT_LEN*2 + 1];
-
- char hash_bytes[SHA1_RESULT_LEN];
- sha1_ctx_t sha1ctx;
- sha1_begin(&sha1ctx);
- sha1_hash(&sha1ctx, str, strlen(str));
- sha1_end(&sha1ctx, hash_bytes);
- bin2hex(result, hash_bytes, SHA1_RESULT_LEN)[0] = '\0';
- return result;
-}
-
-struct name_resolution_param {
- const char *shortcut;
- unsigned strlen_shortcut;
- char *found_name;
-};
-static int find_dir_by_hash(struct dump_dir *dd, void *arg)
-{
- struct name_resolution_param *param = arg;
- char *h = str2hash(dd->dd_dirname);
- if (strncasecmp(param->shortcut, h, param->strlen_shortcut) == 0)
- {
- if (param->found_name)
- error_msg_and_die(_("'%s' identifies more than one problem directory"), param->shortcut);
- param->found_name = xstrdup(dd->dd_dirname);
- }
- return 0;
-}
-
static problem_data_t *load_problem_data(const char *dump_dir_name)
{
/* First, try loading by dirname */
@@ -81,19 +38,13 @@ static problem_data_t *load_problem_data(const char *dump_dir_name)
struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ DD_OPEN_READONLY);
logmode = sv_logmode;
- unsigned name_len = strlen(dump_dir_name);
/* (git requires at least 5 char hash prefix, we do the same) */
- if (!dd && errno == ENOENT && isxdigit_str(dump_dir_name) && name_len >= 5)
+ if (!dd && errno == ENOENT)
{
/* Try loading by dirname hash */
- struct name_resolution_param param = { dump_dir_name, name_len, NULL };
- GList *dir_list = get_problem_storages();
- for (GList *li = dir_list; li; li = li->next)
- for_each_problem_in_dir(li->data, getuid(), find_dir_by_hash, ¶m);
- if (!param.found_name)
- return NULL;
- dd = dd_opendir(param.found_name, /*flags:*/ DD_OPEN_READONLY);
- free(param.found_name);
+ char *name2 = hash2dirname(dump_dir_name);
+ dd = dd_opendir(name2, /*flags:*/ DD_OPEN_READONLY);
+ free(name2);
}
if (!dd)
diff --git a/src/cli/report.c b/src/cli/report.c
index 781c691..c5787e0 100644
--- a/src/cli/report.c
+++ b/src/cli/report.c
@@ -51,26 +51,18 @@ int cmd_report(int argc, const char **argv)
{
const char *dir_name = *argv++;
- vector_of_problem_data_t *ci = NULL;
- if (*dir_name == '@')
+ char *free_me = NULL;
+ if (access(dir_name, F_OK) != 0 && errno == ENOENT)
{
- dir_name++;
- unsigned at = xatoi_positive(dir_name);
-
- ci = fetch_crash_infos(D_list);
- if (at >= ci->len)
- error_msg_and_die("error: number is out of range '%s'", dir_name);
-
- g_ptr_array_sort_with_data(ci, &cmp_problem_data, (char *) FILENAME_LAST_OCCURRENCE);
- problem_data_t *pd = get_problem_data(ci, at);
-
- dir_name = problem_data_get_content_or_NULL(pd, CD_DUMPDIR);
+ free_me = hash2dirname(dir_name);
+ if (free_me)
+ dir_name = free_me;
}
-
int status = report_problem_in_dir(dir_name,
LIBREPORT_WAIT
| LIBREPORT_RUN_CLI);
- free_vector_of_problem_data(ci);
+ free(free_me);
+
if (status)
exit(status);
}
--
1.8.1.4
10 years, 8 months
[ABRT PATCH] abrt-handle-event: don't crash on duplicate detection, rhbz#1001894
by Richard Marko
This prevents abrt-handle-event from crashing when
satyr is unable to get crash thread of one of the
backtraces (e.g. when processing failure results in
core_backtrace file with no threads at all).
Signed-off-by: Richard Marko <rmarko(a)redhat.com>
---
src/daemon/abrt-handle-event.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/daemon/abrt-handle-event.c b/src/daemon/abrt-handle-event.c
index e104cb7..fc0e0ea 100644
--- a/src/daemon/abrt-handle-event.c
+++ b/src/daemon/abrt-handle-event.c
@@ -62,6 +62,15 @@ static int core_backtrace_is_duplicate(struct sr_stacktrace *bt1,
struct sr_thread *thread1 = sr_stacktrace_find_crash_thread(bt1);
struct sr_thread *thread2 = sr_stacktrace_find_crash_thread(bt2);
+ /* sr_stacktrace_find_crash_thread may return NULL if core backtrace is not generated properly
+ * which probably means there's a bug somewhere in satyr
+ */
+ if (thread1 == NULL || thread2 == NULL)
+ {
+ VERB1 log("Unable to find crash thread of one of the backtraces, considering it not duplicate");
+ return 0;
+ }
+
int length2 = sr_thread_frame_count(thread2);
if (length2 <= 0)
--
1.8.3.1
10 years, 8 months