[LIBREPORT PATCH] added report-cli event for anaconda should help with rhbz#950544
by Jiri Moskovcak
- it's just a workaround so I'm not going to close the bz ticket by this commit
---
src/plugins/bugzilla_anaconda_event.conf | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/plugins/bugzilla_anaconda_event.conf b/src/plugins/bugzilla_anaconda_event.conf
index 6d888e4..a9df9df 100644
--- a/src/plugins/bugzilla_anaconda_event.conf
+++ b/src/plugins/bugzilla_anaconda_event.conf
@@ -1,3 +1,6 @@
EVENT=report_Bugzilla component=anaconda
reporter-bugzilla -b \
-F /etc/libreport/plugins/bugzilla_format_libreport.conf
+
+EVENT=report-cli component=anaconda
+ report-cli -e report_Bugzilla -- "$DUMP_DIR"
--
1.8.1.4
11 years
[FAF PATCH] spec: update dependencies
by Michal Toman
Signed-off-by: Michal Toman <mtoman(a)redhat.com>
---
faf.spec.in | 60 +++++++++++++++++++++++++++++++-----------------------------
1 file changed, 31 insertions(+), 29 deletions(-)
diff --git a/faf.spec.in b/faf.spec.in
index 2dfa02c..5b732ba 100644
--- a/faf.spec.in
+++ b/faf.spec.in
@@ -7,14 +7,26 @@ License: GPLv3+
URL: http://fedorahosted.org/faf
Source0: https://fedorahosted.org/released/faf/faf-%{version}.tar.xz
+%if 0%{?rhel:%{rhel} < 7}
+%define sqlalchemy python-sqlalchemy0.7
+%define python_argparse python-argparse
+%else
+%define sqlalchemy python-sqlalchemy
+%define python_argparse python
+%endif
+
Requires(pre): shadow-utils
Requires: binutils
-Requires: btparser-python >= 0:0.22
+Requires: btparser-python >= 0.25
+# eu-addr2line 0.155 gives much better results
Requires: elfutils >= 0.155
+Requires: koji
Requires: libreport-plugin-kerneloops
Requires: libxml2-python
Requires: pycurl
+Requires: %{python_argparse}
+Requires: python-fedora
Requires: python-magic
Requires: python-psycopg2
Requires: python-setuptools
@@ -22,49 +34,33 @@ Requires: python-solv >= 0.0.0-17
Requires: python-bugzilla >= 0.8.0
Requires: rpm-build
Requires: rpm-python
+Requires: %{sqlalchemy}
Requires: yum
BuildRequires: asciidoc
BuildRequires: autoconf
-BuildRequires: btparser-python >= 0:0.22
-BuildRequires: elfutils-devel >= 0.155
+BuildRequires: elfutils-devel
BuildRequires: intltool
BuildRequires: libtool
-BuildRequires: postgresql-server
-BuildRequires: python-psycopg2
-BuildRequires: python-setuptools
-BuildRequires: python-solv >= 0.0.0-17
-BuildRequires: python-bugzilla
-BuildRequires: python-unittest2
-BuildRequires: libxml2-python
-BuildRequires: rpm-python
BuildRequires: xmlto
-BuildRequires: yum
# requirements for tests
-%if 0%{?fedora} >= 18
-BuildRequires: python-django
-%else
-BuildRequires: Django
-%endif
+BuildRequires: btparser-python >= 0.25
BuildRequires: kobo-client
BuildRequires: kobo-django
BuildRequires: kobo-hub
+BuildRequires: libxml2-python
+BuildRequires: %{python_argparse}
+BuildRequires: python-bugzilla >= 0.8.0
BuildRequires: python-django-dajax
BuildRequires: python-django-dajaxice
BuildRequires: python-django-openid-auth
-
-%if 0%{?rhel}
-Requires: python-sqlalchemy0.7
-BuildRequires: python-sqlalchemy0.7
-%else
-Requires: python-sqlalchemy
-BuildRequires: python-sqlalchemy
-%endif
-
-# python-argparse only exists in el6
-%{?el6:Requires: python-argparse}
-%{?el6:BuildRequires: python-argparse}
+BuildRequires: python-setuptools
+BuildRequires: python-solv
+BuildRequires: python-unittest2
+BuildRequires: rpm-python
+BuildRequires: %{sqlalchemy}
+BuildRequires: yum
%description
Faf is a programmable platform for analysis of packages, packaging
@@ -75,6 +71,9 @@ operating system development.
Summary: Kobo hub for %{name} tasks
Group: System Environment/Libraries
Requires: %{name} = %{version}
+# this is just how we named the unofficial package
+# it should get to fedora as python-django-bootstrap or so
+Requires: bootstrap
Requires: httpd
Requires: kobo-client
Requires: kobo-django
@@ -83,6 +82,9 @@ Requires: mod_wsgi
Requires: python-django-dajax
Requires: python-django-dajaxice
Requires: python-django-openid-auth
+Requires: python-django-select2
+Requires: python-tw2-jquery
+Requires: python-tw2-jqplugins-flot
BuildArch: noarch
Requires(post): file
%if 0%{?fedora} >= 15
--
1.8.1.4
11 years
[LIBREPORT PATCH] includes: add macro for last occurrence dump dir file
by Jakub Filak
Related to rhbz#947870
Signed-off-by: Jakub Filak <jfilak(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 55e25e0..71aa6cf 100644
--- a/src/include/internal_libreport.h
+++ b/src/include/internal_libreport.h
@@ -694,6 +694,7 @@ struct dump_dir *open_directory_for_writing(
// 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
11 years
[LIBREPORT PATCH] reporter-rhtsupport: generate archive name from problem dir name
by Denys Vlasenko
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
src/plugins/reporter-rhtsupport.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/src/plugins/reporter-rhtsupport.c b/src/plugins/reporter-rhtsupport.c
index 2eb41b4..406488f 100644
--- a/src/plugins/reporter-rhtsupport.c
+++ b/src/plugins/reporter-rhtsupport.c
@@ -36,6 +36,31 @@ static report_result_t *get_reported_to(const char *dump_dir_name)
}
static
+char *make_temp_file_name(const char *tmpdir_name, const char *dump_dir_name)
+{
+ char *abspath = realpath(dump_dir_name, NULL);
+ char *base = strrchr((abspath ? abspath : dump_dir_name), '/');
+
+ /* If realpath failed and dump_dir_name 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] && 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 = xasprintf("%s/%s.tar.gz", tmpdir_name, base);
+ free(abspath);
+ return name;
+}
+
+static
int create_tarball(const char *tempfile, problem_data_t *problem_data)
{
reportfile_t *file = NULL;
@@ -375,7 +400,7 @@ 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 = make_temp_file_name(tmpdir_name, dump_dir_name);
if (create_tarball(tempfile, problem_data) != 0)
{
errmsg = _("Can't create temporary file in /tmp");
--
1.8.1.4
11 years
[ABRT PATCH 1/2] spec: inc required version of libreport
by Jakub Filak
Closes rhbz#947651
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
abrt.spec.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/abrt.spec.in b/abrt.spec.in
index 48533b7..2010dc6 100644
--- a/abrt.spec.in
+++ b/abrt.spec.in
@@ -45,11 +45,11 @@ BuildRequires: nss-devel
BuildRequires: asciidoc
BuildRequires: doxygen
BuildRequires: xmlto
-BuildRequires: libreport-devel >= 2.1.0
+BuildRequires: libreport-devel >= 2.1.3
BuildRequires: btparser-devel
##satyr migration:
#BuildRequires: satyr-devel
-Requires: libreport >= 2.1.0
+Requires: libreport >= 2.1.3
%if %{with systemd}
Requires: systemd-units
--
1.8.1.4
11 years, 1 month
[FAF PATCH 1/7] Fix internal errors produced by menu genetor
by Jakub Filak
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
pyfaf/hub/menu.py | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/pyfaf/hub/menu.py b/pyfaf/hub/menu.py
index 76263a2..e008705 100644
--- a/pyfaf/hub/menu.py
+++ b/pyfaf/hub/menu.py
@@ -1,7 +1,11 @@
# -*- coding: utf-8 -*-
+import logging
from itertools import ifilter
from django.utils.encoding import smart_unicode
-from django.core.urlresolvers import reverse, NoReverseMatch, resolve
+from django.core.urlresolvers import (reverse,
+ NoReverseMatch,
+ resolve,
+ Resolver404)
class MenuItem(object):
"""
@@ -167,8 +171,11 @@ class MainMenu(MenuItem):
return self
def find_active_menu(self):
- # raises django.http.Http404 exception if URL can't be resolved
- url_name = resolve(self.path_info).url_name
+ try:
+ url_name = resolve(self.path_info).url_name
+ except Resolver404 as ex:
+ logging.exception(str(ex))
+ return None
found = next(ifilter(lambda i: i.visible and i.url_name == url_name,
self.cached_menuitems),
--
1.8.1.4
11 years, 1 month
[ABRT PATCH 1/2] be able to configure without bodhi
by Michal Toman
Signed-off-by: Michal Toman <mtoman(a)redhat.com>
---
configure.ac | 29 +++++++++++++++++++++++++++++
doc/Makefile.am | 4 +++-
src/plugins/Makefile.am | 9 +++++++--
3 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index 1c93170..29b6884 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,3 +1,20 @@
+# copy-pasted from libreport
+# ABRT_PARSE_WITH(PACKAGE)
+# -----------------------
+# For use in AC_ARG_WITH action-if-found, for packages default ON.
+# * Set NO_PACKAGE=YesPlease for --without-PACKAGE
+# * Unset NO_PACKAGE for --with-PACKAGE without ARG
+AC_DEFUN([ABRT_PARSE_WITH],
+ [m4_pushdef([ABRT_UC_PACKAGE], m4_toupper([$1]))dnl
+ if test "$withval" = "no"; then
+ NO_[]ABRT_UC_PACKAGE=YesPlease
+ elif test "$withval" = "yes"; then
+ NO_[]ABRT_UC_PACKAGE=
+ else
+ NO_[]ABRT_UC_PACKAGE=
+ fi
+ m4_popdef([ABRT_UC_PACKAGE])])
+
AC_INIT([abrt],
m4_esyscmd([cat ./abrt-version]),
[crash-catcher(a)fedorahosted.org])
@@ -173,6 +190,18 @@ AC_SUBST(EVENTS_DIR)
AC_SUBST(DEFAULT_DUMP_LOCATION)
AC_SUBST(DEFAULT_DUMP_DIR_MODE)
+AC_ARG_WITH(bodhi,
+AS_HELP_STRING([--with-bodhi],[use Bodhi plugin (default is YES)]),
+ABRT_PARSE_WITH([bodhi]))
+
+if test -z "$NO_BODHI"
+then
+PKG_CHECK_MODULES([JSON_C], [json])
+AM_CONDITIONAL(BUILD_BODHI, true)
+else
+AM_CONDITIONAL(BUILD_BODHI, false)
+fi dnl end NO_BODHI
+
# Initialize the test suite.
AC_CONFIG_TESTDIR(tests)
AC_CONFIG_FILES([tests/Makefile tests/atlocal])
diff --git a/doc/Makefile.am b/doc/Makefile.am
index ea3b47e..94d8f8f 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -18,8 +18,10 @@ MAN1_TXT += abrt-cli.txt
MAN1_TXT += abrt-action-save-package-data.txt
MAN1_TXT += abrt-install-ccpp-hook.txt
MAN1_TXT += abrt-action-analyze-vmcore.txt
-MAN1_TXT += abrt-bodhi.txt
MAN1_TXT += abrt-action-analyze-ccpp-local.txt
+if BUILD_BODHI
+MAN1_TXT += abrt-bodhi.txt
+endif
MAN5_TXT =
MAN5_TXT += abrt.conf.txt
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index b249bf1..707378a 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -22,8 +22,12 @@ bin_PROGRAMS = \
abrt-action-generate-core-backtrace \
abrt-action-analyze-backtrace \
abrt-retrace-client \
- abrt-dedup-client \
+ abrt-dedup-client
+
+if BUILD_BODHI
+bin_PROGRAMS += \
abrt-bodhi
+endif
libexec_PROGRAMS = abrt-action-install-debuginfo-to-abrt-cache
@@ -276,6 +280,7 @@ abrt_dedup_client_SOURCES = \
$(SATYR_LIBS) \
$(NSS_LIBS)
+if BUILD_BODHI
abrt_bodhi_SOURCES = \
bodhi.c
abrt_bodhi_CPPFLAGS = \
@@ -292,7 +297,7 @@ abrt_bodhi_SOURCES = \
$(RPM_LIBS) \
$(LIBREPORT_LIBS) \
$(LIBREPORT_WEB_LIBS)
-
+endif
DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
--
1.8.1.4
11 years, 1 month
[LIBREPORT PATCH] distinguish the event configuration by problem type in the UI closes #149
by Jiri Moskovcak
---
src/workflows/workflow_RHELCCpp.xml.in | 2 +-
src/workflows/workflow_RHELKerneloops.xml.in | 2 +-
src/workflows/workflow_RHELPython.xml.in | 2 +-
src/workflows/workflow_RHELvmcore.xml.in | 2 +-
src/workflows/workflow_RHELxorg.xml.in | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/workflows/workflow_RHELCCpp.xml.in b/src/workflows/workflow_RHELCCpp.xml.in
index 37521cb..6376c5c 100644
--- a/src/workflows/workflow_RHELCCpp.xml.in
+++ b/src/workflows/workflow_RHELCCpp.xml.in
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<workflow>
<_name>Report to Red Hat</_name>
- <_description>Process the report using the Red Hat infrastructure</_description>
+ <_description>Process the C/C++ crash using the Red Hat infrastructure</_description>
<events>
<event>collect_*</event>
diff --git a/src/workflows/workflow_RHELKerneloops.xml.in b/src/workflows/workflow_RHELKerneloops.xml.in
index 2355db2..0baf010 100644
--- a/src/workflows/workflow_RHELKerneloops.xml.in
+++ b/src/workflows/workflow_RHELKerneloops.xml.in
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<workflow>
<_name>Report to Red Hat</_name>
- <_description>Process the report using the Red Hat infrastructure</_description>
+ <_description>Process the kerneloops using the Red Hat infrastructure</_description>
<events>
<event>collect_*</event>
diff --git a/src/workflows/workflow_RHELPython.xml.in b/src/workflows/workflow_RHELPython.xml.in
index 2355db2..a5752ee 100644
--- a/src/workflows/workflow_RHELPython.xml.in
+++ b/src/workflows/workflow_RHELPython.xml.in
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<workflow>
<_name>Report to Red Hat</_name>
- <_description>Process the report using the Red Hat infrastructure</_description>
+ <_description>Process python exception using the Red Hat infrastructure</_description>
<events>
<event>collect_*</event>
diff --git a/src/workflows/workflow_RHELvmcore.xml.in b/src/workflows/workflow_RHELvmcore.xml.in
index 3f56a00..38fdc88 100644
--- a/src/workflows/workflow_RHELvmcore.xml.in
+++ b/src/workflows/workflow_RHELvmcore.xml.in
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<workflow>
<_name>Report to Red Hat</_name>
- <_description>Process the report using the Red Hat infrastructure</_description>
+ <_description>Process the kernel crash using the Red Hat infrastructure</_description>
<events>
<event>analyze_VMcore</event>
diff --git a/src/workflows/workflow_RHELxorg.xml.in b/src/workflows/workflow_RHELxorg.xml.in
index db6b5eb..b088b19 100644
--- a/src/workflows/workflow_RHELxorg.xml.in
+++ b/src/workflows/workflow_RHELxorg.xml.in
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<workflow>
<_name>Report to Red Hat</_name>
- <_description>Process the report using the Red Hat infrastructure</_description>
+ <_description>Process the X Server problem using the Red Hat infrastructure</_description>
<events>
<event>report_Bugzilla</event>
--
1.8.1.4
11 years, 1 month
[LIBREPORT PATCH 1/2] fixed reporting from bugzilla rhbz#926916
by Jiri Moskovcak
---
src/plugins/Makefile.am | 3 ++-
src/plugins/bugzilla_anaconda_event.conf | 3 +++
src/workflows/anaconda_event.conf | 4 ++--
src/workflows/workflow_AnacondaFedora.xml.in | 2 --
4 files changed, 7 insertions(+), 5 deletions(-)
create mode 100644 src/plugins/bugzilla_anaconda_event.conf
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 7ffb894..79fe9d2 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -65,7 +65,8 @@ dist_eventsconf_DATA = \
bugzilla_event.conf \
rhtsupport_event.conf \
uploader_event.conf \
- emergencyanalysis_event.conf
+ emergencyanalysis_event.conf \
+ bugzilla_anaconda_event.conf
reporters_extra_dist =
if BUILD_BUGZILLA
diff --git a/src/plugins/bugzilla_anaconda_event.conf b/src/plugins/bugzilla_anaconda_event.conf
new file mode 100644
index 0000000..6d888e4
--- /dev/null
+++ b/src/plugins/bugzilla_anaconda_event.conf
@@ -0,0 +1,3 @@
+EVENT=report_Bugzilla component=anaconda
+ reporter-bugzilla -b \
+ -F /etc/libreport/plugins/bugzilla_format_libreport.conf
diff --git a/src/workflows/anaconda_event.conf b/src/workflows/anaconda_event.conf
index f71aebd..f369acd 100644
--- a/src/workflows/anaconda_event.conf
+++ b/src/workflows/anaconda_event.conf
@@ -1,2 +1,2 @@
-EVENT=workflow_AnacondaFedora type=anaconda
-EVENT=workflow_AnacondaUpload type=anaconda
+EVENT=workflow_AnacondaFedora component=anaconda
+EVENT=workflow_AnacondaUpload component=anaconda
diff --git a/src/workflows/workflow_AnacondaFedora.xml.in b/src/workflows/workflow_AnacondaFedora.xml.in
index 5c8c2a7..6322d9a 100644
--- a/src/workflows/workflow_AnacondaFedora.xml.in
+++ b/src/workflows/workflow_AnacondaFedora.xml.in
@@ -4,8 +4,6 @@
<_description>Process the report using the Fedora infrastructure</_description>
<events>
- <event>report_uReport</event>
<event>report_Bugzilla</event>
- <event>post_report</event>
</events>
</workflow>
--
1.8.1.4
11 years, 1 month
[FAF PATCH] provide emergency wsgi application
by Richard Marko
Signed-off-by: Richard Marko <rmarko(a)redhat.com>
---
configure.ac | 1 +
faf.spec.in | 23 ++++++++-
pyfaf/Makefile.am | 2 +-
pyfaf/emergency/Makefile.am | 10 ++++
pyfaf/emergency/__init__.py | 0
pyfaf/emergency/emergency.wsgi | 88 +++++++++++++++++++++++++++++++++++
pyfaf/emergency/faf-emergency.conf.in | 16 +++++++
7 files changed, 137 insertions(+), 3 deletions(-)
create mode 100644 pyfaf/emergency/Makefile.am
create mode 100644 pyfaf/emergency/__init__.py
create mode 100644 pyfaf/emergency/emergency.wsgi
create mode 100644 pyfaf/emergency/faf-emergency.conf.in
diff --git a/configure.ac b/configure.ac
index b0117a9..4e39ba1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,6 +52,7 @@ AC_CONFIG_FILES([
tests/utils/Makefile
pyfaf/client/Makefile
pyfaf/client/commands/Makefile
+ pyfaf/emergency/Makefile
pyfaf/hub/Makefile
pyfaf/hub/common/Makefile
pyfaf/hub/problems/Makefile
diff --git a/faf.spec.in b/faf.spec.in
index 6effe3e..5ffa84c 100644
--- a/faf.spec.in
+++ b/faf.spec.in
@@ -93,6 +93,20 @@ Requires(postun): systemd-units httpd
%description hub
Kobo hub for %{name} tasks
+%package emergency
+Summary: Emergency WSGI application
+Group: System Environment/Libraries
+Requires: %{name} = %{version}
+Requires: httpd
+Requires: mod_wsgi
+BuildArch: noarch
+
+%description emergency
+Provides emergency WSGI application
+capable of saving reports to disk
+to work as a backup in case of server
+issues.
+
%package worker
Summary: Kobo worker for %{name} tasks
Group: System Environment/Libraries
@@ -145,9 +159,10 @@ mkdir -p %{buildroot}%{_localstatedir}/log/faf/build
mkdir -p %{buildroot}%{_datadir}/faf/hub/static
# On Fedora, the Python WSGI module is loaded by wsgi.conf in the
# conf.d HTTPD configuration directory. faf-hub.conf requires WSGI to
-# be already active. Here we rename the faf-hub.conf to be loaded
-# after wsgi.conf and not before.
+# be already active. Here we rename the faf-hub.conf and
+# faf-emergency.conf to be loaded after wsgi.conf and not before.
mv %{buildroot}%{_sysconfdir}/httpd/conf.d/{,wsgi-}faf-hub.conf
+mv %{buildroot}%{_sysconfdir}/httpd/conf.d/{,wsgi-}faf-emergency.conf
%check
@@ -297,6 +312,10 @@ fi
%dir %attr(0770, faf, faf) %{_localstatedir}/spool/faf/hub/upload
%{_datadir}/faf/hub
+%files emergency
+%config(noreplace) %{_sysconfdir}/httpd/conf.d/wsgi-faf-emergency.conf
+%{python_sitelib}/pyfaf/emergency
+
%files worker
%config(noreplace) %{_sysconfdir}/faf/worker.conf
%{python_sitelib}/pyfaf/worker
diff --git a/pyfaf/Makefile.am b/pyfaf/Makefile.am
index 533ccd4..c97b1a8 100644
--- a/pyfaf/Makefile.am
+++ b/pyfaf/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = client hub worker storage
+SUBDIRS = client emergency hub worker storage
pyfaf_PYTHON = \
__init__.py \
diff --git a/pyfaf/emergency/Makefile.am b/pyfaf/emergency/Makefile.am
new file mode 100644
index 0000000..26bfc90
--- /dev/null
+++ b/pyfaf/emergency/Makefile.am
@@ -0,0 +1,10 @@
+emergency_PYTHON = emergency.wsgi __init__.py
+emergencydir = $(pythondir)/pyfaf/emergency
+
+httpdconf_DATA = faf-emergency.conf
+httpdconfdir = ${sysconfdir}/httpd/conf.d
+
+EXTRA_DIST = faf-emergency.conf.in
+
+faf-emergency.conf: faf-emergency.conf.in
+ sed -e "s|@PYTHONDIR@|$(pythondir)|g" $< > $@
diff --git a/pyfaf/emergency/__init__.py b/pyfaf/emergency/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/pyfaf/emergency/emergency.wsgi b/pyfaf/emergency/emergency.wsgi
new file mode 100644
index 0000000..205d796
--- /dev/null
+++ b/pyfaf/emergency/emergency.wsgi
@@ -0,0 +1,88 @@
+#! /usr/bin/env python
+
+import os
+import cgi
+import json
+import uuid
+import logging
+
+from wsgiref.simple_server import make_server
+
+import pyfaf
+
+
+def application(environ, start_response):
+ """
+ WSGI application capable of saving incoming uReports to
+ directory, to be used as a backup handler.
+ """
+
+ def is_post_request(environ):
+ """
+ Return True if this request is valid POST request
+ with correct content type
+ """
+
+ if environ["REQUEST_METHOD"].upper() != "POST":
+ return False
+
+ content_type = environ.get("CONTENT_TYPE", "application/x-www-form-urlencoded")
+ return content_type.startswith("multipart/form-data")
+
+ def bad_request():
+ """
+ Respond with HTTP 400 Bad Reqeust.
+ """
+
+ start_response("400 BAD REQUEST",
+ [("Content-Type", "application/json")])
+ return [""]
+
+ def method_not_allowed():
+ """
+ Respond with HTTP 405 Method Not Allowed.
+ """
+
+ start_response("405 METHOD NOT ALLOWED",
+ [("Content-Type", "application/json"),
+ ("Allow", "POST")])
+ return [""]
+
+ spool_dir = pyfaf.config.get("Report.SpoolDirectory")
+
+ if not is_post_request(environ):
+ logging.debug('Not a POST request or content type'
+ ' is not mulitpart/form-data.')
+
+ return method_not_allowed()
+
+ inp = environ["wsgi.input"]
+ fs = cgi.FieldStorage(fp=inp, environ=environ)
+
+ try:
+ fs = fs.list.pop()
+ ureport = fs.file.read()
+ except (IndexError, AttributeError):
+ logging.debug('Unable to parse input.')
+ return bad_request()
+
+ fname = str(uuid.uuid4())
+ with open(os.path.join(spool_dir, "incoming", fname), "w") as fil:
+ fil.write(ureport)
+ logging.info('Report saved as {0}'.format(fname))
+
+ status = "202 ACCEPTED"
+ response_body = json.dumps({"result": False})
+ response_headers = [("Content-Type", "application/json"),
+ ("Content-Length", str(len(response_body)))]
+ start_response(status, response_headers)
+
+ return [response_body]
+
+if __name__ == "__main__":
+ # possible to run as standalone server,
+ # mainly for debugging purposes
+
+ logging.basicConfig(level=logging.DEBUG)
+ server = make_server("0.0.0.0", 8000, application)
+ server.serve_forever()
diff --git a/pyfaf/emergency/faf-emergency.conf.in b/pyfaf/emergency/faf-emergency.conf.in
new file mode 100644
index 0000000..1a14c15
--- /dev/null
+++ b/pyfaf/emergency/faf-emergency.conf.in
@@ -0,0 +1,16 @@
+#WSGISocketPrefix /var/spool/faf/wsgi
+#WSGIDaemonProcess faf user=faf group=faf processes=1 threads=5
+#WSGIProcessGroup faf
+#WSGIScriptAlias /faf @PYTHONDIR(a)/pyfaf/emergency/emergency.wsgi
+
+#<Directory "@PYTHONDIR@/pyfaf/emergency/">
+# <IfModule mod_authz_core.c>
+# # Apache 2.4
+# Require all granted
+# </IfModule>
+# <IfModule !mod_authz_core.c>
+# # Apache 2.2
+# Order allow,deny
+# Allow from all
+# </IfModule>
+#</Directory>
--
1.8.1.4
11 years, 1 month