[PATCH] abrt-cli: make "report -v[vv]" export correct $ABRT_VERBOSE value
by Denys Vlasenko
Before this change, it wasn't exporting it.
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
src/cli/report.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/cli/report.c b/src/cli/report.c
index bc51daf..e155e2b 100644
--- a/src/cli/report.c
+++ b/src/cli/report.c
@@ -39,6 +39,8 @@ int cmd_report(int argc, const char **argv)
if (!argv[0])
show_usage_and_die(program_usage_string, program_options);
+ export_abrt_envvars(/*prog_prefix:*/ 0);
+
load_abrt_conf();
GList *D_list = NULL;
D_list = g_list_append(D_list, concat_path_file(g_get_user_cache_dir(), "abrt/spool"));
--
1.8.1.4
11 years, 1 month
[GNOME-ABRT PATCH] Use last occurrence item for problems sorting
by Jakub Filak
Related to rhbz#947870
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/gnome_abrt/oops.glade | 46 ++++++++++++++++++++++++++++++++++++++++------
src/gnome_abrt/problems.py | 6 ++++++
src/gnome_abrt/views.py | 11 ++++++++---
3 files changed, 54 insertions(+), 9 deletions(-)
diff --git a/src/gnome_abrt/oops.glade b/src/gnome_abrt/oops.glade
index f6de0e7..345022e 100644
--- a/src/gnome_abrt/oops.glade
+++ b/src/gnome_abrt/oops.glade
@@ -244,13 +244,13 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="lbl_reported">
+ <object class="GtkLabel" id="lbl_detected">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="xpad">10</property>
<property name="ypad">5</property>
- <property name="label" translatable="yes">Reported</property>
+ <property name="label" translatable="yes">Detected</property>
<attributes>
<attribute name="foreground" value="#87877e7e8080"/>
</attributes>
@@ -295,12 +295,12 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="lbl_reported_value">
+ <object class="GtkLabel" id="lbl_detected_value">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="xpad">5</property>
- <property name="label">no</property>
+ <property name="label">2013-04-09 18:55</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -323,7 +323,7 @@
<property name="left_attach">2</property>
<property name="top_attach">0</property>
<property name="width">1</property>
- <property name="height">4</property>
+ <property name="height">5</property>
</packing>
</child>
<child>
@@ -398,7 +398,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@@ -406,6 +406,40 @@
<child>
<placeholder/>
</child>
+ <child>
+ <object class="GtkLabel" id="lbl_reported">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="xpad">10</property>
+ <property name="ypad">5</property>
+ <property name="label" translatable="yes">Reported</property>
+ <attributes>
+ <attribute name="foreground" value="#87877e7e8080"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="lbl_reported_value">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="xpad">5</property>
+ <property name="label">no</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="left_attach">1</property>
diff --git a/src/gnome_abrt/problems.py b/src/gnome_abrt/problems.py
index adb1f20..4bf7695 100644
--- a/src/gnome_abrt/problems.py
+++ b/src/gnome_abrt/problems.py
@@ -113,6 +113,12 @@ class Problem:
def __getitem__(self, item, cached=True):
if item == 'date':
return datetime.datetime.fromtimestamp(float(self['time']))
+ if item == 'date_last':
+ last_ocr = self['last_occurrence']
+ if last_ocr:
+ return datetime.datetime.fromtimestamp(float(last_ocr))
+ else:
+ return datetime.datetime.fromtimestamp(float(self['time']))
elif item == 'application':
return self.get_application()
elif item == 'is_reported':
diff --git a/src/gnome_abrt/views.py b/src/gnome_abrt/views.py
index ecd37c9..1746052 100644
--- a/src/gnome_abrt/views.py
+++ b/src/gnome_abrt/views.py
@@ -21,6 +21,7 @@ import os
import time
import logging
import subprocess
+import locale
#pygobject
#pylint: disable=E0611
@@ -81,14 +82,14 @@ def problem_to_storage_values(problem):
app = problem.get_application()
return ["{0!s}\n{1!s}".format(app.name or _("N/A"),
problem['type'] or ""),
- "{0!s}\n{1!s}".format(fancydate(problem['date']),
+ "{0!s}\n{1!s}".format(fancydate(problem['date_last']),
problem['count']),
problem]
#pylint: disable=W0613
def time_sort_func(model, first, second, unused):
- lhs = model[first][2]['date'].timetuple()
- rhs = model[second][2]['date'].timetuple()
+ lhs = model[first][2]['date_last'].timetuple()
+ rhs = model[second][2]['date_last'].timetuple()
return time.mktime(lhs) - time.mktime(rhs)
@@ -115,6 +116,7 @@ class OopsWindow(Gtk.ApplicationWindow):
self.lbl_app_name_value = builder.get_object('lbl_app_name_value')
self.lbl_app_version_value = builder.get_object(
'lbl_app_version_value')
+ self.lbl_detected_value = builder.get_object('lbl_detected_value')
self.lbl_reported_value = builder.get_object('lbl_reported_value')
self.tv_problems = builder.get_object('tv_problems')
self.tvs_problems = builder.get_object('tvs_problems')
@@ -365,6 +367,9 @@ class OopsWindow(Gtk.ApplicationWindow):
app.name or _("N/A"), _(' crashed').strip()))
self._builder.lbl_app_version_value.set_text(
problem['package'] or "")
+ self._builder.lbl_detected_value.set_text(
+ problem['date'].strftime(
+ locale.nl_langinfo(locale.D_FMT)))
if app.icon:
self._builder.img_app_icon.set_from_pixbuf(app.icon)
--
1.8.1.4
11 years, 1 month
[GNOME-ABRT PATCH] Compare all DesktopEntry.*() return values to None
by Jakub Filak
Closes rhbz#949979
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/gnome_abrt/application.py | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/src/gnome_abrt/application.py b/src/gnome_abrt/application.py
index ae32113..8f1ff85 100644
--- a/src/gnome_abrt/application.py
+++ b/src/gnome_abrt/application.py
@@ -49,6 +49,8 @@ def compare_executable(executable, desktop_entry):
return False
dexec = desktop_entry.get_executable()
+ if not dexec:
+ return False
realpath = None
if executable[0] == '/' and os.path.islink(executable):
@@ -66,9 +68,14 @@ def compare_executable(executable, desktop_entry):
or (realpath and compare_executable(realpath, desktop_entry)))
def compare_cmdline(cmdline, desktop_entry):
+ if not cmdline:
+ return False
+
+ ret = False
dcmdline = desktop_entry.get_commandline()
- ret = (os.path.basename(cmdline) == os.path.basename(dcmdline)
- or cmdline == dcmdline)
+ if dcmdline:
+ ret = (os.path.basename(cmdline) == os.path.basename(dcmdline)
+ or cmdline == dcmdline)
# try to handle interpreters like python
if not ret:
@@ -84,10 +91,18 @@ def compare_component(component, desktop_entry):
return False
if isinstance(dicon, Gio.ThemedIcon):
- return component in dicon.get_names()
+ names = dicon.get_names()
+ if not names:
+ return False
+ return component in names
elif isinstance(dicon, Gio.FileIcon):
- logging.debug("File icon: {0}".format(dicon.to_string()))
- base_name = os.path.basename(dicon.to_string())
+ str_dicon = dicon.to_string()
+ if not str_dicon:
+ logging.debug("File icon which cannot be convert to string")
+ return False
+
+ logging.debug("File icon: {0}".format())
+ base_name = os.path.basename(str_dicon)
if component == base_name:
return True
elif '.' in base_name:
--
1.8.1.4
11 years, 1 month
[SATYR PATCH] Use sr_realloc instead of realloc
by Martin Milata
Related to rhbz#951432.
Signed-off-by: Martin Milata <mmilata(a)redhat.com>
---
lib/cluster.c | 2 +-
lib/strbuf.c | 7 +------
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/lib/cluster.c b/lib/cluster.c
index e5825ee..75c9f61 100644
--- a/lib/cluster.c
+++ b/lib/cluster.c
@@ -76,7 +76,7 @@ cluster_add_index(struct cluster *cluster, int index)
if (cluster->size >= cluster->alloced)
{
cluster->alloced = cluster->alloced >= 1 ? cluster->alloced * 2 : 1;
- cluster->objects = realloc(cluster->objects, sizeof (*cluster->objects)
+ cluster->objects = sr_realloc(cluster->objects, sizeof (*cluster->objects)
* cluster->alloced);
}
cluster->objects[cluster->size++] = index;
diff --git a/lib/strbuf.c b/lib/strbuf.c
index 27099c7..e051155 100644
--- a/lib/strbuf.c
+++ b/lib/strbuf.c
@@ -80,12 +80,7 @@ sr_strbuf_grow(struct sr_strbuf *strbuf, int num)
while (strbuf->len + num + 1 > strbuf->alloc)
strbuf->alloc *= 2; /* huge grow = infinite loop */
- strbuf->buf = realloc(strbuf->buf, strbuf->alloc);
- if (!strbuf->buf)
- {
- puts("Error while allocating memory for string buffer.");
- exit(5);
- }
+ strbuf->buf = sr_realloc(strbuf->buf, strbuf->alloc);
}
}
--
1.7.11.7
11 years, 1 month
[BTPARSER PATCH] Introduce and use btp_realloc
by Martin Milata
Fixes rhbz#951432.
Signed-off-by: Martin Milata <mmilata(a)redhat.com>
---
lib/cluster.c | 2 +-
lib/strbuf.c | 13 ++++---------
lib/utils.c | 13 +++++++++++++
3 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/lib/cluster.c b/lib/cluster.c
index 4a93649..c7f174a 100644
--- a/lib/cluster.c
+++ b/lib/cluster.c
@@ -76,7 +76,7 @@ cluster_add_index(struct cluster *cluster, int index)
if (cluster->size >= cluster->alloced)
{
cluster->alloced = cluster->alloced >= 1 ? cluster->alloced * 2 : 1;
- cluster->objects = realloc(cluster->objects, sizeof (*cluster->objects)
+ cluster->objects = btp_realloc(cluster->objects, sizeof (*cluster->objects)
* cluster->alloced);
}
cluster->objects[cluster->size++] = index;
diff --git a/lib/strbuf.c b/lib/strbuf.c
index 061192d..532337d 100644
--- a/lib/strbuf.c
+++ b/lib/strbuf.c
@@ -77,15 +77,10 @@ btp_strbuf_grow(struct btp_strbuf *strbuf, int num)
{
if (strbuf->len + num + 1 > strbuf->alloc)
{
- while (strbuf->len + num + 1 > strbuf->alloc)
- strbuf->alloc *= 2; /* huge grow = infinite loop */
-
- strbuf->buf = realloc(strbuf->buf, strbuf->alloc);
- if (!strbuf->buf)
- {
- puts("Error while allocating memory for string buffer.");
- exit(5);
- }
+ while (strbuf->len + num + 1 > strbuf->alloc)
+ strbuf->alloc *= 2; /* huge grow = infinite loop */
+
+ strbuf->buf = btp_realloc(strbuf->buf, strbuf->alloc);
}
}
diff --git a/lib/utils.c b/lib/utils.c
index 1b9495e..779e70a 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -52,6 +52,19 @@ btp_mallocz(size_t size)
return ptr;
}
+void *
+btp_realloc(void *ptr, size_t size)
+{
+ void *result = realloc(ptr, size);
+ /* When size is 0, realloc may return NULL on success. */
+ if (!result && size > 0)
+ {
+ fprintf(stderr, "btp: out of memory");
+ exit(1);
+ }
+ return result;
+}
+
char *
btp_vasprintf(const char *format, va_list p)
{
--
1.7.11.7
11 years, 1 month
[GNOME-ABRT PATCH] Display 'component' name instead of 'executable' if desktop file is missing
by Jakub Filak
Closes #20
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/gnome_abrt/application.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/gnome_abrt/application.py b/src/gnome_abrt/application.py
index ae32113..fd1cdd2 100644
--- a/src/gnome_abrt/application.py
+++ b/src/gnome_abrt/application.py
@@ -31,12 +31,14 @@ from gi.repository import GdkPixbuf
class Application(object):
def __init__(self, executable, name=None, icon=None):
- self.executable = executable
+ self.executable = executable or "??"
if name:
self.name = name
- else:
+ elif executable:
self.name = os.path.basename(executable)
+ else:
+ self.name = "??"
self.icon = icon
@@ -137,4 +139,4 @@ def find_application(component, executable, cmdline):
icon=icon)
return __globa_app_cache__[pred[0]]
- return Application(executable if executable else "??")
+ return Application(executable, name=component)
--
1.8.1.4
11 years, 1 month
[LIBREPORT PATCH] reporter-upload: create tarball with the name based on directory's name
by Denys Vlasenko
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
src/plugins/reporter-upload.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/plugins/reporter-upload.c b/src/plugins/reporter-upload.c
index bff8105..a527431 100644
--- a/src/plugins/reporter-upload.c
+++ b/src/plugins/reporter-upload.c
@@ -49,7 +49,9 @@ static int create_and_upload_archive(
/* Create a child gzip which will compress the data */
/* SELinux guys are not happy with /tmp, using /var/run/abrt */
/* Reverted back to /tmp for ABRT2 */
- tempfile = xasprintf("/tmp/abrt-upload-%s-%lu.tar.gz", iso_date_string(NULL), (long)getpid());
+ tempfile = concat_path_basename("/tmp", dump_dir_name);
+ tempfile = append_to_malloced_string(tempfile, ".tar.gz");
+
int pipe_from_parent_to_child[2];
xpipe(pipe_from_parent_to_child);
child = vfork();
--
1.8.1.4
11 years, 1 month
[LIBREPORT PATCH] emit a message when searching bugzilla for duplicates closes #151
by Jiri Moskovcak
Signed-off-by: Jiri Moskovcak <jmoskovc(a)redhat.com>
---
src/plugins/reporter-bugzilla.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
index 0d6c9a9..8557618 100644
--- a/src/plugins/reporter-bugzilla.c
+++ b/src/plugins/reporter-bugzilla.c
@@ -941,6 +941,7 @@ int main(int argc, char **argv)
if (abrt_hash)
{
+ log(_("Looking for similar problems in bugzilla"));
char *hash;
if (prefixcmp(abrt_hash, "abrt_hash:"))
hash = xasprintf("abrt_hash:%s", abrt_hash);
--
1.8.1.4
11 years, 1 month
[FAF PATCH] save uReports that fail parsing for later debugging
by Michal Toman
Signed-off-by: Michal Toman <mtoman(a)redhat.com>
---
pyfaf/hub/menu.py | 3 +++
pyfaf/hub/reports/forms.py | 30 ++++++++++++++++++++++++++-
pyfaf/hub/reports/urls.py | 2 ++
pyfaf/hub/reports/views.py | 30 +++++++++++++++++++++++++++
pyfaf/hub/templates/reports/Makefile.am | 2 ++
pyfaf/hub/templates/reports/invalid.html | 26 +++++++++++++++++++++++
pyfaf/hub/templates/reports/invalid_item.html | 24 +++++++++++++++++++++
pyfaf/storage/Makefile.am | 1 +
pyfaf/storage/__init__.py | 1 +
pyfaf/storage/debug.py | 14 +++++++++++++
10 files changed, 132 insertions(+), 1 deletion(-)
create mode 100644 pyfaf/hub/templates/reports/invalid.html
create mode 100644 pyfaf/hub/templates/reports/invalid_item.html
create mode 100644 pyfaf/storage/debug.py
diff --git a/pyfaf/hub/menu.py b/pyfaf/hub/menu.py
index 76263a2..05a5f0c 100644
--- a/pyfaf/hub/menu.py
+++ b/pyfaf/hub/menu.py
@@ -230,6 +230,9 @@ menu = (
placeholder=True, url_args_pattern=[42]),
MenuItem("Diff", "pyfaf.hub.reports.views.diff",
placeholder=True, url_args_pattern=[42, 42]),
+ StaffMenuItem("Invalid uReports", "pyfaf.hub.reports.views.invalid"),
+ StaffMenuItem("Invalid uReport",
+ "pyfaf.hub.reports.views.invalid_item", placeholder=True),
StaffMenuItem("New", "pyfaf.hub.reports.views.new", on_right=True),
)),
MenuItem("Statistics", "today_stats", menu=(
diff --git a/pyfaf/hub/reports/forms.py b/pyfaf/hub/reports/forms.py
index f77ba49..79984a0 100644
--- a/pyfaf/hub/reports/forms.py
+++ b/pyfaf/hub/reports/forms.py
@@ -1,10 +1,13 @@
+import datetime
import json
+import logging
from django import forms
from pyfaf import ureport
from pyfaf.hub.common.forms import (OsComponentFilterForm,
FafMultipleChoiceField)
+from pyfaf.storage import getDatabase, InvalidUReport
class ReportFilterForm(OsComponentFilterForm):
status_values = ['new', 'processed']
@@ -29,18 +32,43 @@ class ReportFilterForm(OsComponentFilterForm):
class NewReportForm(forms.Form):
file = forms.FileField(label='uReport file')
+ def _save_invalid_ureport(self, ureport, errormsg, reporter=None):
+ try:
+ db = getDatabase()
+
+ new = InvalidUReport()
+ new.errormsg = errormsg
+ new.date = datetime.datetime.utcnow()
+ new.reporter = reporter
+ db.session.add(new)
+ db.session.flush()
+
+ new.save_lob("ureport", ureport)
+ except Exception as ex:
+ logging.error(str(ex))
+
def clean_file(self):
raw_data = self.cleaned_data['file'].read()
try:
data = json.loads(raw_data)
- except:
+ except Exception as ex:
+ self._save_invalid_ureport(raw_data, str(ex))
raise forms.ValidationError('Invalid JSON file')
converted = ureport.convert_to_str(data)
try:
ureport.validate(converted)
except Exception as exp:
+ reporter = None
+ if ("reporter" in converted and
+ "name" in converted["reporter"] and
+ "version" in converted["reporter"]):
+ reporter = "{0} {1}".format(converted["reporter"]["name"],
+ converted["reporter"]["version"])
+
+ self._save_invalid_ureport(json.dumps(data, indent=2),
+ str(exp), reporter=reporter)
raise forms.ValidationError('Validation failed: %s' % exp)
return dict(converted=converted, json=raw_data)
diff --git a/pyfaf/hub/reports/urls.py b/pyfaf/hub/reports/urls.py
index 34f9d3a..af6f052 100644
--- a/pyfaf/hub/reports/urls.py
+++ b/pyfaf/hub/reports/urls.py
@@ -9,6 +9,8 @@ urlpatterns = patterns('pyfaf.hub.reports.views',
url(r'^new/$', 'new'),
url(r'^attach/$', 'attach'),
url(r'^bthash/(?P<bthash>[a-fA-F0-9]+)/$', 'bthash_forward'),
+ url(r'^invalid/$', 'invalid'),
+ url(r'^invalid/(?P<report_id>[0-9]+)/$', 'invalid_item'),
url(r'^diff/(?P<lhs_id>\d+)/(?P<rhs_id>\d+)/$', 'diff'),
diff --git a/pyfaf/hub/reports/views.py b/pyfaf/hub/reports/views.py
index d933c48..1afd2a6 100644
--- a/pyfaf/hub/reports/views.py
+++ b/pyfaf/hub/reports/views.py
@@ -30,6 +30,7 @@ from pyfaf.storage.report import (Report,
ReportPackage,
ReportRhbz,
ReportUnknownPackage)
+from pyfaf.storage.debug import InvalidUReport
from pyfaf.hub.common.utils import paginate
from pyfaf.hub.common.forms import OsComponentFilterForm
@@ -407,3 +408,32 @@ def bthash_forward(request, bthash):
args=[reportbt.backtrace.report.id])
return response
+
+def invalid(request):
+ if not request.user.is_staff:
+ raise Http404
+
+ db = pyfaf.storage.getDatabase()
+ reports = (db.session.query(InvalidUReport)
+ .order_by(desc(InvalidUReport.date))
+ .all())
+
+ return render_to_response("reports/invalid.html",
+ {"reports": paginate(reports, request)},
+ context_instance=RequestContext(request))
+
+def invalid_item(request, report_id):
+ if not request.user.is_staff:
+ raise Http404
+
+ db = pyfaf.storage.getDatabase()
+ report = (db.session.query(InvalidUReport)
+ .filter(InvalidUReport.id == report_id)
+ .first())
+
+ if report is None:
+ raise Http404
+
+ return render_to_response("reports/invalid_item.html",
+ {"report": report, "report_data": report.get_lob("ureport")},
+ context_instance=RequestContext(request))
diff --git a/pyfaf/hub/templates/reports/Makefile.am b/pyfaf/hub/templates/reports/Makefile.am
index 8d578c5..e23d33a 100644
--- a/pyfaf/hub/templates/reports/Makefile.am
+++ b/pyfaf/hub/templates/reports/Makefile.am
@@ -1,6 +1,8 @@
reports_DATA = \
index.html \
item.html \
+ invalid.html \
+ invalid_item.html \
list.html \
new.html \
success.html \
diff --git a/pyfaf/hub/templates/reports/invalid.html b/pyfaf/hub/templates/reports/invalid.html
new file mode 100644
index 0000000..4eae369
--- /dev/null
+++ b/pyfaf/hub/templates/reports/invalid.html
@@ -0,0 +1,26 @@
+{% extends "base.html" %}
+
+{% block title %}Invalid uReports list{% endblock %}
+
+{% block content %}
+ <table class="table table-bordered">
+ <tr>
+ <th>Date</th>
+ <th>Error</th>
+ <th>Reporter</th>
+ <th>uReport</th>
+ </tr>
+ {% for report in reports.object_list %}
+ <tr>
+ <td>{{ report.date|date:"Y-m-d" }}</td>
+ <td>{{ report.errormsg }}</td>
+ <td>{% if report.reporter %}{{ report.reporter }}{% endif %}</td>
+ <td><a href="{% url pyfaf.hub.reports.views.invalid_item report.id %}">Show</a></td>
+ </tr>
+ {% endfor %}
+ </table>
+
+ {% with reports as paginated %}
+ {% include "paginator.html" %}
+ {% endwith %}
+{% endblock %}
diff --git a/pyfaf/hub/templates/reports/invalid_item.html b/pyfaf/hub/templates/reports/invalid_item.html
new file mode 100644
index 0000000..9114b53
--- /dev/null
+++ b/pyfaf/hub/templates/reports/invalid_item.html
@@ -0,0 +1,24 @@
+{% extends "base.html" %}
+
+{% block title %}Invalid uReport #{{ report.id }}{% endblock %}
+
+{% block submenu_append %}
+ <li class="active">
+ <a href="">Invalid uReport #{{ report.id }}</a>
+ </li>
+{% endblock %}
+
+{% block content %}
+ <dl class="dl-horizontal">
+ <dt>Occurred:</td>
+ <dd>{{ report.date|date:"Y-m-d H:i:s" }}</dd>
+
+ <dt>Reporter:</td>
+ <dd>{% if report.reporter %}{{ report.reporter }}{% else %}unknown{% endif %}</dd>
+
+ <dt>Error message:</dt>
+ <dd>{{ report.errormsg }}</dd>
+ </dl>
+
+ <pre>{{ report_data }}</pre>
+{% endblock %}
diff --git a/pyfaf/storage/Makefile.am b/pyfaf/storage/Makefile.am
index 43a3357..2fab86d 100644
--- a/pyfaf/storage/Makefile.am
+++ b/pyfaf/storage/Makefile.am
@@ -3,6 +3,7 @@ SUBDIRS = fixtures
pyfaf_storage_PYTHON = \
__init__.py \
common.py \
+ debug.py \
hub.py \
kb.py \
llvm.py \
diff --git a/pyfaf/storage/__init__.py b/pyfaf/storage/__init__.py
index 5492798..5a5cf40 100644
--- a/pyfaf/storage/__init__.py
+++ b/pyfaf/storage/__init__.py
@@ -163,6 +163,7 @@ from report import *
from llvm import *
from hub import *
from kb import *
+from debug import *
def getDatabase():
db = Database.__instance__
diff --git a/pyfaf/storage/debug.py b/pyfaf/storage/debug.py
new file mode 100644
index 0000000..4b76f27
--- /dev/null
+++ b/pyfaf/storage/debug.py
@@ -0,0 +1,14 @@
+from . import Column
+from . import DateTime
+from . import GenericTable
+from . import Integer
+from . import String
+
+class InvalidUReport(GenericTable):
+ __tablename__ = "invalidureports"
+ __lobs__ = { "ureport": 1 << 22 }
+
+ id = Column(Integer, primary_key=True)
+ errormsg = Column(String(512), nullable=False)
+ reporter = Column(String(64), nullable=True)
+ date = Column(DateTime, nullable=False, index=True)
--
1.8.1.4
11 years, 1 month
[LIBREPORT PATCH v2] reporter-rhtsupport: generate archive name from problem dir name
by Denys Vlasenko
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
src/include/internal_libreport.h | 12 +++++++++---
src/lib/concat_path_file.c | 24 ++++++++++++++++++++++++
src/plugins/reporter-rhtsupport.c | 3 ++-
3 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
index 55e25e0..456db38 100644
--- a/src/include/internal_libreport.h
+++ b/src/include/internal_libreport.h
@@ -108,8 +108,6 @@ int suffixcmp(const char *str, const char *suffix);
char *strtrim(char *str);
#define strtrimch libreport_strtrimch
char *strtrimch(char *str, int ch);
-#define concat_path_file libreport_concat_path_file
-char *concat_path_file(const char *path, const char *filename);
#define append_to_malloced_string libreport_append_to_malloced_string
char *append_to_malloced_string(char *mstr, const char *append);
#define skip_whitespace libreport_skip_whitespace
@@ -120,6 +118,15 @@ char* skip_non_whitespace(const char *s);
#define overlapping_strcpy libreport_overlapping_strcpy
void overlapping_strcpy(char *dst, const char *src);
+#define concat_path_file libreport_concat_path_file
+char *concat_path_file(const char *path, const char *filename);
+/*
+ * Used to construct a name in a different directory with the basename
+ * similar to the old name, if possible.
+ */
+#define concat_path_basename libreport_concat_path_basename
+char *concat_path_basename(const char *path, const char *filename);
+
/* A-la fgets, but malloced and of unlimited size */
#define xmalloc_fgets libreport_xmalloc_fgets
char *xmalloc_fgets(FILE *file);
@@ -289,7 +296,6 @@ double get_dirsize_find_largest_dir(
const char *excluded /* can be NULL */
);
-
#define ndelay_on libreport_ndelay_on
int ndelay_on(int fd);
#define ndelay_off libreport_ndelay_off
diff --git a/src/lib/concat_path_file.c b/src/lib/concat_path_file.c
index 44965d0..39ae07a 100644
--- a/src/lib/concat_path_file.c
+++ b/src/lib/concat_path_file.c
@@ -33,3 +33,27 @@ char *concat_path_file(const char *path, const char *filename)
filename++;
return xasprintf("%s%s%s", path, (end != path && end[-1] != '/' ? "/" : ""), filename);
}
+
+char *concat_path_basename(const char *path, const char *filename)
+{
+ char *abspath = realpath(filename, NULL);
+ char *base = strrchr((abspath ? abspath : filename), '/');
+
+ /* If realpath failed and filename is malicious (say, "/foo/.."),
+ * we may end up tricked into doing some bad things. Don't allow that.
+ */
+ char buf[sizeof("tmp-"LIBREPORT_ISO_DATE_STRING_SAMPLE"-%lu")];
+ if (base && base[1] != '\0' && base[1] != '.')
+ {
+ /* We have a slash and it's not "foo/" or "foo/.<something>" */
+ base++;
+ }
+ else
+ {
+ sprintf(buf, "tmp-%s-%lu", iso_date_string(NULL), (long)getpid());
+ base = buf;
+ }
+ char *name = concat_path_file(path, base);
+ free(abspath);
+ return name;
+}
diff --git a/src/plugins/reporter-rhtsupport.c b/src/plugins/reporter-rhtsupport.c
index 2eb41b4..90e88ed 100644
--- a/src/plugins/reporter-rhtsupport.c
+++ b/src/plugins/reporter-rhtsupport.c
@@ -375,7 +375,8 @@ 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());
+ tempfile = concat_path_basename(tmpdir_name, dump_dir_name);
+ tempfile = append_to_malloced_string(tempfile, ".tar.gz");
if (create_tarball(tempfile, problem_data) != 0)
{
errmsg = _("Can't create temporary file in /tmp");
--
1.8.1.4
11 years, 1 month