[SATYR PATCH] Parse koops module list from multiple lines
by Martin Milata
The module list may be split into multiple lines, at arbitrary
position. The parsing function now tries to handle that, though not in
a very robust way, by means of heuristic that decides whether the next
line is a continuation of the previous.
Closes #24.
Signed-off-by: Martin Milata <mmilata(a)redhat.com>
---
lib/koops_stacktrace.c | 85 +++++++++++++++++++++++++++++++++++++++--------
tests/koops_stacktrace.at | 63 +++++++++++++++++++++++++++++++++--
tests/python/koops.py | 2 +-
3 files changed, 134 insertions(+), 16 deletions(-)
diff --git a/lib/koops_stacktrace.c b/lib/koops_stacktrace.c
index a10d816..8964d04 100644
--- a/lib/koops_stacktrace.c
+++ b/lib/koops_stacktrace.c
@@ -144,6 +144,34 @@ sr_koops_stacktrace_parse(const char **input,
return stacktrace;
}
+static bool
+module_list_continues(const char *input)
+{
+ char *end = strchr(input, '\n');
+
+ /* Module list shouldn't be on the last line */
+ if (!end || input == end)
+ return false;
+
+ size_t line_len = end - input;
+ char *line = sr_malloc(line_len + 1);
+ memcpy(line, input, line_len);
+ line[line_len] = '\0';
+
+ bool res = true;
+
+ /* Usually follows the module list */
+ if (strstr(line, "Pid: "))
+ res = false;
+ /* There should be no timestamp in the continuation */
+ else if (sr_koops_skip_timestamp(&input))
+ res = false;
+ /* Other conditions may need to be added */
+
+ free(line);
+ return res;
+}
+
char **
sr_koops_stacktrace_parse_modules(const char **input)
{
@@ -157,27 +185,58 @@ sr_koops_stacktrace_parse_modules(const char **input)
if (!sr_skip_string(&local_input, "Modules linked in:"))
return NULL;
- sr_skip_char_span(&local_input, " \t");
+ int ws = sr_skip_char_span(&local_input, " \t");
int result_size = 20, result_offset = 0;
char **result = sr_malloc(result_size * sizeof(char*));
char *module;
- bool success;
- while ((success = sr_parse_char_cspan(&local_input, " \t\n[", &module)))
+ while (true)
{
- // result_size is lowered by 1 because we need to terminate
- // the list by a NULL pointer.
- if (result_offset == result_size - 1)
+ if (sr_parse_char_cspan(&local_input, " \t\n[", &module))
{
- result_size *= 2;
- result = sr_realloc(result,
- result_size * sizeof(char*));
+ // result_size is lowered by 1 because we need to terminate
+ // the list by a NULL pointer.
+ if (result_offset == result_size - 1)
+ {
+ result_size *= 2;
+ result = sr_realloc(result,
+ result_size * sizeof(char*));
+ }
+
+ result[result_offset] = module;
+ ++result_offset;
+ ws = sr_skip_char_span(&local_input, " \t");
}
-
- result[result_offset] = module;
- ++result_offset;
- sr_skip_char_span(&local_input, " \t");
+ else if(*local_input == '\n')
+ {
+ /* We're at the end of the line. Check whether the next line might
+ * be a continuation of the module list. */
+ if (!module_list_continues(local_input + 1))
+ break;
+
+ local_input++;
+
+ /* If the next line does not start with space and there wasn't
+ * any space before the newline either, then the last module was
+ * split into two parts and we need to read the rest */
+ if (*local_input != ' ' && ws == 0 && result_offset > 0)
+ {
+ char *therest;
+ if (!sr_parse_char_cspan(&local_input, " \t\n[", &therest))
+ {
+ break; /* wtf? */
+ }
+
+ char *tmp = sr_asprintf("%s%s", result[result_offset-1], therest);
+ free(result[result_offset-1]);
+ result[result_offset-1] = tmp;
+ }
+
+ ws = sr_skip_char_span(&local_input, " \t");
+ }
+ else
+ break;
}
result[result_offset] = NULL;
diff --git a/tests/koops_stacktrace.at b/tests/koops_stacktrace.at
index d30e8b9..672b0fc 100644
--- a/tests/koops_stacktrace.at
+++ b/tests/koops_stacktrace.at
@@ -22,7 +22,6 @@ check(bool success,
if (modules)
{
- assert(*input == '\0');
int offset = 0;
while (modules[offset])
{
@@ -55,6 +54,38 @@ main(void)
check(true,
"[110417.280431] Modules linked in: vfat fat usb_storage",
modules);
+
+ check(true,
+ "[110417.280431] Modules linked in: vfat fat usb_storage [last unloaded: scsi_wait_scan]\n",
+ modules);
+
+ check(true,
+ "[110417.280431] Modules linked in: vfat fat usb_storage \n[last unloaded: scsi_wait_scan]\n",
+ modules);
+
+ check(true,
+ "[110417.280431] Modules linked in: vfat fat usb_storage\n [last unloaded: scsi_wait_scan]\n",
+ modules);
+
+ check(true,
+ "[110417.280431] Modules linked in: vfat fat usb_st\norage [last unloaded: scsi_wait_scan]\n",
+ modules);
+
+ check(true,
+ "[110417.280431] Modules linked in: vfat fat \nusb_storage [last unloaded: scsi_wait_scan]\n",
+ modules);
+
+ check(true,
+ "[110417.280431] Modules linked in: vfat fat\n usb_storage [last unloaded: scsi_wait_scan]\n",
+ modules);
+
+ check(true,
+ "[110417.280431] Modules linked in: vfat fat usb_storage\n"
+ "Pid: 31337, comm: ksoftirqd/2\n",
+ modules);
+
+ check(false, "[110417.280434] I hate autotest", modules);
+
return 0;
}
]])
@@ -299,7 +330,35 @@ main(void)
" , \"bluetooth\"\n"
" , \"iwlwifi\"\n"
" , \"snd_pcm\"\n"
- " , \"parport_pc\" ]\n"
+ " , \"parport_pc\"\n"
+ " , \"joydev\"\n"
+ " , \"parport\"\n"
+ " , \"snd_timer\"\n"
+ " , \"microcode\"\n"
+ " , \"mac80211\"\n"
+ " , \"snd\"\n"
+ " , \"soundcore\"\n"
+ " , \"snd_page_alloc\"\n"
+ " , \"i2c_i801\"\n"
+ " , \"cfg80211\"\n"
+ " , \"iTCO_wdt\"\n"
+ " , \"iTCO_vendor_support\"\n"
+ " , \"rfkill\"\n"
+ " , \"e1000e\"\n"
+ " , \"sunrpc\"\n"
+ " , \"xts\"\n"
+ " , \"gf128mul\"\n"
+ " , \"dm_crypt\"\n"
+ " , \"sdhci_pci\"\n"
+ " , \"sdhci\"\n"
+ " , \"mmc_core\"\n"
+ " , \"wmi\"\n"
+ " , \"i915\"\n"
+ " , \"drm_kms_helper\"\n"
+ " , \"drm\"\n"
+ " , \"i2c_algo_bit\"\n"
+ " , \"i2c_core\"\n"
+ " , \"video\" ]\n"
", \"frames\":\n"
" [ { \"address\": 18446744071579204319\n"
" , \"reliable\": true\n"
diff --git a/tests/python/koops.py b/tests/python/koops.py
index b702548..b343979 100755
--- a/tests/python/koops.py
+++ b/tests/python/koops.py
@@ -11,7 +11,7 @@ except ImportError:
path = '../kerneloopses/rhbz-827868'
frames_expected = 32
-mods_expected = 91
+mods_expected = 119
if not os.path.isfile(path):
path = '../' + path
--
1.7.11.7
10 years, 11 months
[SATYR PATCH] Fix fingerprint incompatibility with btparser
by Martin Milata
The libcalls and calltree_leaves fingerprint components were not sorted
before hashing, due to me not being able to use qsort properly ...
Signed-off-by: Martin Milata <mmilata(a)redhat.com>
---
lib/core_fingerprint.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib/core_fingerprint.c b/lib/core_fingerprint.c
index ddf2a4d..d153f8b 100644
--- a/lib/core_fingerprint.c
+++ b/lib/core_fingerprint.c
@@ -30,6 +30,7 @@
#include <ctype.h>
#include <string.h>
#include <stdio.h>
+#include <stdlib.h>
static void
fingerprint_add_bool(struct sr_strbuf *buffer,
@@ -279,9 +280,9 @@ get_libcalls(char ***symbol_list,
}
static int
-strcmp_reverse(const char *s1, const char *s2)
+strcmp_wrapper(const char **s1, const char **s2)
{
- return -strcmp(s1, s2);
+ return strcmp(*s1, *s2);
}
static bool
@@ -308,7 +309,7 @@ fp_libcalls(struct sr_strbuf *fingerprint,
return false;
qsort(symbol_list, symbol_list_size,
- sizeof(char*), (comparison_fn_t)strcmp_reverse);
+ sizeof(char*), (comparison_fn_t)strcmp_wrapper);
/* Make it unique. */
sr_struniq(symbol_list, &symbol_list_size);
@@ -347,7 +348,7 @@ fp_calltree_leaves(struct sr_strbuf *fingerprint,
return false;
qsort(symbol_list, symbol_list_size,
- sizeof(char*), (comparison_fn_t)strcmp_reverse);
+ sizeof(char*), (comparison_fn_t)strcmp_wrapper);
/* Make it unique. */
sr_struniq(symbol_list, &symbol_list_size);
--
1.7.11.7
10 years, 11 months
[SATYR PATCH] abrt: parse kernel package version
by Martin Milata
Signed-off-by: Martin Milata <mmilata(a)redhat.com>
---
lib/abrt.c | 48 ++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 42 insertions(+), 6 deletions(-)
diff --git a/lib/abrt.c b/lib/abrt.c
index edcbc6b..803455e 100644
--- a/lib/abrt.c
+++ b/lib/abrt.c
@@ -312,13 +312,16 @@ sr_abrt_report_from_dir(const char *directory,
free(component_filename);
/* RPM packages. */
- report->rpm_packages = sr_abrt_rpm_packages_from_dir(
- directory, error_message);
-
- if (!report->rpm_packages)
+ if (report->report_type != SR_REPORT_KERNELOOPS)
{
- sr_report_free(report);
- return NULL;
+ report->rpm_packages = sr_abrt_rpm_packages_from_dir(
+ directory, error_message);
+
+ if (!report->rpm_packages)
+ {
+ sr_report_free(report);
+ return NULL;
+ }
}
/* Core stacktrace. */
@@ -399,6 +402,39 @@ sr_abrt_report_from_dir(const char *directory,
/* Kerneloops stacktrace. */
if (report->report_type == SR_REPORT_KERNELOOPS)
{
+ /* Determine kernel version */
+ char *kernel_filename = sr_build_path(directory,
+ "kernel",
+ NULL);
+ char *kernel_contents = sr_file_to_string(kernel_filename,
+ error_message);
+ free(kernel_filename);
+ if (!kernel_contents)
+ {
+ sr_report_free(report);
+ return NULL;
+ }
+
+ char *kernel_nevra = sr_asprintf("kernel-%s", kernel_contents);
+ struct sr_rpm_package *package = sr_rpm_package_new();
+ bool success = sr_rpm_package_parse_nevra(kernel_nevra,
+ &package->name,
+ &package->epoch,
+ &package->version,
+ &package->release,
+ &package->architecture);
+ if (!success)
+ {
+ sr_rpm_package_free(package, true);
+ *error_message = sr_asprintf("Failed to parse \"%s\".",
+ kernel_nevra);
+
+ sr_report_free(report);
+ return NULL;
+ }
+ report->rpm_packages = package;
+
+ /* Load the Kerneloops stacktrace */
char *backtrace_filename = sr_build_path(directory,
"backtrace",
NULL);
--
1.7.11.7
10 years, 11 months
[SATYR PATCH] Fix segfault in sr_rpm_package_uniq
by Martin Milata
Signed-off-by: Martin Milata <mmilata(a)redhat.com>
---
lib/rpm.c | 13 +++++++---
tests/rpm.at | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 87 insertions(+), 3 deletions(-)
diff --git a/lib/rpm.c b/lib/rpm.c
index 9a553b0..200ae9d 100644
--- a/lib/rpm.c
+++ b/lib/rpm.c
@@ -224,13 +224,20 @@ sr_rpm_package_uniq(struct sr_rpm_package *packages)
}
else
{
+ /* deleted record is not the first in list */
if (prev)
+ {
prev->next = loop->next;
+ sr_rpm_package_free(loop, false);
+ loop = prev->next;
+ }
+ /* deleting first record */
else
+ {
packages = loop->next;
-
- sr_rpm_package_free(loop, false);
- loop = prev->next;
+ sr_rpm_package_free(loop, false);
+ loop = packages;
+ }
}
continue;
diff --git a/tests/rpm.at b/tests/rpm.at
index 638c9c0..bc683e6 100644
--- a/tests/rpm.at
+++ b/tests/rpm.at
@@ -79,3 +79,80 @@ main(void)
return 0;
}
]])
+
+## ------------------- ##
+## sr_rpm_package_uniq ##
+## ------------------- ##
+AT_TESTFUN([sr_rpm_package_uniq],
+[[
+#include <lib/rpm.h>
+#include <lib/utils.h>
+#include <assert.h>
+#include <stdint.h>
+
+int
+main(void)
+{
+ struct sr_rpm_package *p1 = sr_rpm_package_new();
+ struct sr_rpm_package *p2 = sr_rpm_package_new();
+ struct sr_rpm_package *p3 = sr_rpm_package_new();
+
+ p1->name = sr_strdup("coreutils");
+ p1->version = sr_strdup("8.15");
+ p1->release = sr_strdup("10.fc17");
+ p1->next = p2;
+
+ p2->name = sr_strdup("coreutils");
+ p2->version = sr_strdup("8.15");
+ p2->release = sr_strdup("10.fc17");
+ p2->architecture = sr_strdup("x86_64");
+ p2->install_time = 1363628422;
+ p2->next = p3;
+
+ p3->name = sr_strdup("glibc");
+ p3->version = sr_strdup("2.15");
+ p3->release = sr_strdup("58.fc17");
+ p3->architecture = sr_strdup("x86_64");
+ p3->install_time = 1363628422;
+
+ struct sr_rpm_package *packages = p1;
+ packages = sr_rpm_package_uniq(packages);
+
+ assert(packages == p2);
+ assert(packages->next == p3);
+ assert(packages->next->next == NULL);
+
+ sr_rpm_package_free(packages, true);
+
+ p1 = sr_rpm_package_new();
+ p2 = sr_rpm_package_new();
+ p3 = sr_rpm_package_new();
+
+ p1->name = sr_strdup("glibc");
+ p1->version = sr_strdup("2.15");
+ p1->release = sr_strdup("58.fc17");
+ p1->architecture = sr_strdup("x86_64");
+ p1->install_time = 1363628422;
+ p1->next = p2;
+
+ p2->name = sr_strdup("coreutils");
+ p2->version = sr_strdup("8.15");
+ p2->release = sr_strdup("10.fc17");
+ p2->next = p3;
+
+ p3->name = sr_strdup("coreutils");
+ p3->version = sr_strdup("8.15");
+ p3->release = sr_strdup("10.fc17");
+ p3->architecture = sr_strdup("x86_64");
+ p3->install_time = 1363628422;
+
+ packages = p1;
+ packages = sr_rpm_package_uniq(packages);
+
+ assert(packages == p1);
+ assert(packages->next == p3);
+ assert(packages->next->next == NULL);
+
+ return 0;
+}
+]])
--
1.7.11.7
10 years, 11 months
[LIBREPORT PATCH] workflow_config_dialog: get rid of deprecated warning
by Jakub Filak
gtk_scrolled_window_add_with_viewport has been deprecated since gtk-3.7.8
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/gtk-helpers/workflow_config_dialog.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/gtk-helpers/workflow_config_dialog.c b/src/gtk-helpers/workflow_config_dialog.c
index 32be2fa..decdb37 100644
--- a/src/gtk-helpers/workflow_config_dialog.c
+++ b/src/gtk-helpers/workflow_config_dialog.c
@@ -90,7 +90,15 @@ config_dialog_t *create_workflow_config_dialog(const char *workflow_name, GtkWin
GtkWidget *scrolled = gtk_scrolled_window_new(NULL, NULL);
GtkWidget *content = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+
+#if ((GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 7) || (GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION == 7 && GTK_MICRO_VERSION < 8))
+ /* http://developer.gnome.org/gtk3/unstable/GtkScrolledWindow.html#gtk-scrol... */
+ /* gtk_scrolled_window_add_with_viewport has been deprecated since version 3.8 and should not be used in newly-written code. */
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), content);
+#else
+ /* gtk_container_add() will now automatically add a GtkViewport if the child doesn't implement GtkScrollable. */
+ gtk_container_add(GTK_CONTAINER(scrolled), content);
+#endif
GtkWidget *dialog_box = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
gtk_box_pack_start(GTK_BOX(dialog_box), scrolled, false, true, 0);
--
1.8.1.4
10 years, 11 months
[RHEL6 LIBREPORT PATCH 1/2] includes: add macro for last occurrence dump dir file - rhbz#961231
by Jiri Moskovcak
From: Jakub Filak <jfilak(a)redhat.com>
Related to rhbz#947870
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
Signed-off-by: Martin Milata <mmilata(a)redhat.com>
Signed-off-by: Jiri Moskovcak <jmoskovc(a)redhat.com>
---
src/include/internal_libreport.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
index 31c65b4..72688c4 100644
--- a/src/include/internal_libreport.h
+++ b/src/include/internal_libreport.h
@@ -670,6 +670,7 @@ bool make_dir_recursive(char *dir, mode_t dir_mode);
// Filenames in problem directory:
// filled by a hook:
#define FILENAME_TIME "time" /* mandatory */
+#define FILENAME_LAST_OCCURRENCE "last_occurrence" /* optional */
#define FILENAME_REASON "reason" /* mandatory? */
#define FILENAME_UID "uid" /* mandatory? */
/*
--
1.8.1.4
10 years, 12 months
[ABRT EL6 PATCH] abrtd: update last occurrence dump dir file
by Jiri Moskovcak
From: Jakub Filak <jfilak(a)redhat.com>
Related to rhbz#947870
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
Signed-off-by: Martin Milata <mmilata(a)redhat.com>
---
src/daemon/abrtd.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/src/daemon/abrtd.c b/src/daemon/abrtd.c
index 54006b3..6e73cb3 100644
--- a/src/daemon/abrtd.c
+++ b/src/daemon/abrtd.c
@@ -434,6 +434,41 @@ static gboolean handle_event_output_cb(GIOChannel *gio, GIOCondition condition,
char new_count_str[sizeof(long)*3 + 2];
sprintf(new_count_str, "%lu", count);
dd_save_text(dd, FILENAME_COUNT, new_count_str);
+
+ /* This condition can be simplified to either
+ * (status * != 0 && * state->dup_of_dir) or (count == 1). But the
+ * chosen form is much more reliable and safe. We must not call
+ * dd_opendir() to locked dd otherwise we go into a deadlock.
+ */
+ if (strcmp(dd->dd_dirname, state->dirname) != 0)
+ {
+ /* Update the last occurrence file by the time file of the new problem */
+ struct dump_dir *new_dd = dd_opendir(state->dirname, DD_OPEN_READONLY);
+ char *last_ocr = NULL;
+ if (new_dd)
+ {
+ /* TIME must exists in a valid dump directory but we don't want to die
+ * due to broken duplicated dump directory */
+ last_ocr = dd_load_text_ext(new_dd, FILENAME_TIME,
+ DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE | DD_FAIL_QUIETLY_ENOENT);
+ dd_close(new_dd);
+ }
+ else
+ { /* dd_opendir() already produced a message with good information about failure */
+ error_msg("Can't read the last occurrence file from the new dump directory.");
+ }
+
+ if (!last_ocr)
+ { /* the new dump directory may lie in the dump location for some time */
+ log("Using current time for the last occurrence file which may be incorrect.");
+ time_t t = time(NULL);
+ last_ocr = xasprintf("%lu", (long)t);
+ }
+
+ dd_save_text(dd, FILENAME_LAST_OCCURRENCE, last_ocr);
+
+ free(last_ocr);
+ }
}
dd_close(dd);
--
1.8.1.4
10 years, 12 months
[ABRT EL6 PATCH 1/3] fix problem occurrence counter updating algorithm
by Jiri Moskovcak
From: Jakub Filak <jfilak(a)redhat.com>
- closes trac#878
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/daemon/abrtd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/daemon/abrtd.c b/src/daemon/abrtd.c
index 6e73cb3..85f39fb 100644
--- a/src/daemon/abrtd.c
+++ b/src/daemon/abrtd.c
@@ -400,14 +400,15 @@ static gboolean handle_event_output_cb(GIOChannel *gio, GIOCondition condition,
{
log("'post-create' on '%s' killed by signal %d",
state->dirname, WTERMSIG(status));
+ goto delete_bad_dir;
}
/* else: it is WIFEXITED(status) */
else if (!state->dup_of_dir)
{
log("'post-create' on '%s' exited with %d",
state->dirname, WEXITSTATUS(status));
+ goto delete_bad_dir;
}
- goto delete_bad_dir;
}
char *work_dir = state->dup_of_dir ? state->dup_of_dir : state->dirname;
--
1.8.1.4
10 years, 12 months
[SATYR PATCH] python: fix attribute deletion segfault
by Martin Milata
Previous commit 93d2ef8b730bc2659e348bce9f7ecfc902600b9d introduced a
bug where an attempt to delete a computed attribute results in a
segmentation fault.
The setters in C bindings have been modified to check whether the new
parameter is NULL and throw an exception if it is.
Signed-off-by: Martin Milata <mmilata(a)redhat.com>
---
python/py_common.c | 24 ++++++++++++++++++++++++
python/py_gdb_sharedlib.c | 6 ++++++
tests/python/koops.py | 1 +
tests/python/test_helpers.py | 1 +
4 files changed, 32 insertions(+)
diff --git a/python/py_common.c b/python/py_common.c
index 15aa108..2b4dd9b 100644
--- a/python/py_common.c
+++ b/python/py_common.c
@@ -42,6 +42,12 @@ sr_py_getter_string(PyObject *self, void *data)
int
sr_py_setter_string(PyObject *self, PyObject *rhs, void *data)
{
+ if (rhs == NULL)
+ {
+ PyErr_SetString(PyExc_TypeError, "Cannot delete this attribute.");
+ return -1;
+ }
+
struct getset_offsets *gsoff = data;
char *newvalue = PyString_AsString(rhs);
@@ -66,6 +72,12 @@ sr_py_getter_uint32(PyObject *self, void *data)
int
sr_py_setter_uint32(PyObject *self, PyObject *rhs, void *data)
{
+ if (rhs == NULL)
+ {
+ PyErr_SetString(PyExc_TypeError, "Cannot delete this attribute.");
+ return -1;
+ }
+
struct getset_offsets *gsoff = data;
long newvalue = PyInt_AsLong(rhs);
@@ -95,6 +107,12 @@ sr_py_getter_bool(PyObject *self, void *data)
int
sr_py_setter_bool(PyObject *self, PyObject *rhs, void *data)
{
+ if (rhs == NULL)
+ {
+ PyErr_SetString(PyExc_TypeError, "Cannot delete this attribute.");
+ return -1;
+ }
+
struct getset_offsets *gsoff = data;
bool newvalue = PyObject_IsTrue(rhs);
@@ -116,6 +134,12 @@ sr_py_getter_uint64(PyObject *self, void *data)
int
sr_py_setter_uint64(PyObject *self, PyObject *rhs, void *data)
{
+ if (rhs == NULL)
+ {
+ PyErr_SetString(PyExc_TypeError, "Cannot delete this attribute.");
+ return -1;
+ }
+
struct getset_offsets *gsoff = data;
unsigned long long newvalue = PyInt_AsUnsignedLongLongMask(rhs);
diff --git a/python/py_gdb_sharedlib.c b/python/py_gdb_sharedlib.c
index 4d34278..da66c79 100644
--- a/python/py_gdb_sharedlib.c
+++ b/python/py_gdb_sharedlib.c
@@ -124,6 +124,12 @@ sr_py_gdb_sharedlib_get_symbols(PyObject *self, void *data)
int
sr_py_gdb_sharedlib_set_symbols(PyObject *self, PyObject *rhs, void *data)
{
+ if (rhs == NULL)
+ {
+ PyErr_SetString(PyExc_TypeError, "Cannot delete this attribute.");
+ return -1;
+ }
+
long newvalue = PyInt_AsLong(rhs);
if (PyErr_Occurred())
return -1;
diff --git a/tests/python/koops.py b/tests/python/koops.py
index fbeb8dd..f0c6ac0 100755
--- a/tests/python/koops.py
+++ b/tests/python/koops.py
@@ -31,6 +31,7 @@ class TestKerneloops(BindingsTestCase):
## not implemented, expected to fail
#self.koops.modules = ['foo', 'bar']
#self.assertEqual(len(self.koops.modules), 2)
+ self.assertRaises(NotImplementedError, self.koops.__delattr__, 'modules')
def test_dup(self):
dup = self.koops.dup()
diff --git a/tests/python/test_helpers.py b/tests/python/test_helpers.py
index 4bd03a0..e8de55d 100644
--- a/tests/python/test_helpers.py
+++ b/tests/python/test_helpers.py
@@ -8,6 +8,7 @@ class BindingsTestCase(unittest.TestCase):
self.assertEqual(obj.__getattribute__(attr), orig_val)
obj.__setattr__(attr, new_val)
self.assertEqual(obj.__getattribute__(attr), new_val)
+ self.assertRaises(TypeError, obj.__delattr__, attr)
if __name__ == '__main__':
import sys
--
1.7.11.7
10 years, 12 months
[ABRT PATCH] console notification shouldn't ask confirmation - closes #652
by Jiri Moskovcak
Signed-off-by: Jiri Moskovcak <jmoskovc(a)redhat.com>
---
src/cli/abrt-console-notification.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/cli/abrt-console-notification.sh b/src/cli/abrt-console-notification.sh
index 6d24848..937abb0 100755
--- a/src/cli/abrt-console-notification.sh
+++ b/src/cli/abrt-console-notification.sh
@@ -15,7 +15,7 @@ fi
# always update the lastnotification
if [ -f "$TMPPATH" ]; then
date +%s > "$TMPPATH"
- mv "$TMPPATH" "$SINCEFILE"
+ mv -f "$TMPPATH" "$SINCEFILE"
fi
abrt-cli status --since="$SINCE" 2> /dev/null
--
1.8.1.4
10 years, 12 months