rasdaemon and abrt
by 李俊良
Hi, all
Fedora 19 has a tool named rasdaemon. From its maintainer, Mauro, I know
that rasdaemon and ABRT will work together. But I don't know much about
that. Would anyone introduce something about rasdaemon and ABRT?
10 years, 6 months
[ABRT PATCH] add prefix from configure to the path of debuginfo installer - closes #701
by Petr Kubat
Also adds the same prefix to analyze-ccpp-local.
Signed-off-by: Petr Kubat <pkubat(a)redhat.com>
---
src/plugins/Makefile.am | 9 ++++-
src/plugins/abrt-action-analyze-ccpp-local | 47 ----------------------
src/plugins/abrt-action-analyze-ccpp-local.in | 47 ++++++++++++++++++++++
.../abrt-action-install-debuginfo-to-abrt-cache.c | 13 +++---
4 files changed, 62 insertions(+), 54 deletions(-)
delete mode 100755 src/plugins/abrt-action-analyze-ccpp-local
create mode 100644 src/plugins/abrt-action-analyze-ccpp-local.in
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index c0c0745..58fe725 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -92,7 +92,7 @@ EXTRA_DIST = \
abrt-gdb-exploitable \
https-utils.h \
post_report.xml.in \
- abrt-action-analyze-ccpp-local
+ abrt-action-analyze-ccpp-local.in
confdir = $(CONF_DIR)
dist_conf_DATA = \
@@ -250,6 +250,7 @@ abrt_action_install_debuginfo_to_abrt_cache_CPPFLAGS = \
-I$(srcdir)/../include \
-I$(srcdir)/../lib \
-D_GNU_SOURCE \
+ -DCONF_PREFIX=\"$(prefix)\" \
$(LIBREPORT_CFLAGS) \
-Wall -Wwrite-strings \
-fPIE
@@ -313,6 +314,12 @@ endif
DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
+DISTCLEANFILES = abrt-action-analyze-ccpp-local
+
abrt-action-perform-ccpp-analysis: abrt-action-perform-ccpp-analysis.in
sed -e s,\@libexecdir\@,$(libexecdir),g \
$< >$@
+
+abrt-action-analyze-ccpp-local: abrt-action-analyze-ccpp-local.in
+ sed -e s,\@LIBEXEC_DIR\@,$(libexecdir),g \
+ $< >$@
diff --git a/src/plugins/abrt-action-analyze-ccpp-local b/src/plugins/abrt-action-analyze-ccpp-local
deleted file mode 100755
index ef0976e..0000000
--- a/src/plugins/abrt-action-analyze-ccpp-local
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-
-INSTALL_DI=true
-WITH_BODHI=true
-# if bz is set to false it also disables bodhi, because it needs it's result
-WITH_BUGZILLA=true
-for opt in "$@"; do
- if [ x"$opt" = x"--without-di" ]; then
- INSTALL_DI=false
- fi
-
- if [ x"$opt" = x"--without-bz" ]; then
- WITH_BUGZILLA=false
- fi
-
- if [ x"$opt" = x"--without-bodhi" ]; then
- WITH_BODHI=false
- fi
-done
-
-if $INSTALL_DI; then
- # On some systems debuginfo install needs root privileges.
- # Running a suided-to-abrt wrapper would make
- # debuginfo install fail even for root.
- # Therefore, if we are root, we don't use the wrapper.
- if [ x"`id -u`" = x"0" ]; then
- abrt-action-analyze-core --core=coredump -o build_ids && abrt-action-install-debuginfo --size_mb=4096
- else
- abrt-action-analyze-core --core=coredump -o build_ids && /usr/libexec/abrt-action-install-debuginfo-to-abrt-cache --size_mb=4096
- fi
- rm -f build_ids
-fi
-
-if [ $? = 0 ]; then
- abrt-action-generate-backtrace &&
- abrt-action-analyze-backtrace
- if [ "$?" == "0" ]; then
- if $WITH_BUGZILLA; then
- bug_id=$(reporter-bugzilla -h "`cat duphash`")
- if $WITH_BODHI; then
- if test -n "$bug_id"; then
- abrt-bodhi -r -b $bug_id
- fi
- fi
- fi
- fi
-fi
diff --git a/src/plugins/abrt-action-analyze-ccpp-local.in b/src/plugins/abrt-action-analyze-ccpp-local.in
new file mode 100644
index 0000000..de131c8
--- /dev/null
+++ b/src/plugins/abrt-action-analyze-ccpp-local.in
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+INSTALL_DI=true
+WITH_BODHI=true
+# if bz is set to false it also disables bodhi, because it needs it's result
+WITH_BUGZILLA=true
+for opt in "$@"; do
+ if [ x"$opt" = x"--without-di" ]; then
+ INSTALL_DI=false
+ fi
+
+ if [ x"$opt" = x"--without-bz" ]; then
+ WITH_BUGZILLA=false
+ fi
+
+ if [ x"$opt" = x"--without-bodhi" ]; then
+ WITH_BODHI=false
+ fi
+done
+
+if $INSTALL_DI; then
+ # On some systems debuginfo install needs root privileges.
+ # Running a suided-to-abrt wrapper would make
+ # debuginfo install fail even for root.
+ # Therefore, if we are root, we don't use the wrapper.
+ if [ x"`id -u`" = x"0" ]; then
+ abrt-action-analyze-core --core=coredump -o build_ids && abrt-action-install-debuginfo --size_mb=4096
+ else
+ abrt-action-analyze-core --core=coredump -o build_ids && @LIBEXEC_DIR@/abrt-action-install-debuginfo-to-abrt-cache --size_mb=4096
+ fi
+ rm -f build_ids
+fi
+
+if [ $? = 0 ]; then
+ abrt-action-generate-backtrace &&
+ abrt-action-analyze-backtrace
+ if [ "$?" == "0" ]; then
+ if $WITH_BUGZILLA; then
+ bug_id=$(reporter-bugzilla -h "`cat duphash`")
+ if $WITH_BODHI; then
+ if test -n "$bug_id"; then
+ abrt-bodhi -r -b $bug_id
+ fi
+ fi
+ fi
+ fi
+fi
diff --git a/src/plugins/abrt-action-install-debuginfo-to-abrt-cache.c b/src/plugins/abrt-action-install-debuginfo-to-abrt-cache.c
index b642070..c00fb3a 100644
--- a/src/plugins/abrt-action-install-debuginfo-to-abrt-cache.c
+++ b/src/plugins/abrt-action-install-debuginfo-to-abrt-cache.c
@@ -112,12 +112,13 @@ int main(int argc, char **argv)
} while (*p);
#endif
/* Set safe PATH */
-// TODO: honor configure --prefix here by adding it to PATH
-// (otherwise abrt-action-install-debuginfo would fail to spawn abrt-action-trim-files):
- if (u == 0)
- putenv((char*) "PATH=/usr/sbin:/sbin:/usr/bin:/bin");
- else
- putenv((char*) "PATH=/usr/bin:/bin");
+ // Adding configure --prefix to the PATH so that
+ // abrt-action-install-debuginfo doesn't fail when spawning
+ // abrt-action-trim-files
+ char path_env[] = "PATH=/usr/sbin:/sbin:/usr/bin:/bin:" CONF_PREFIX "/bin:" CONF_PREFIX "/sbin";
+ if (u != 0)
+ strcpy(path_env, "PATH=/usr/bin:/bin:" CONF_PREFIX "/bin");
+ putenv(path_env);
}
execvp(EXECUTABLE, argv);
--
1.8.3.1
10 years, 7 months
[LIBREPORT PATCH] reprot-gtk: underline tab titles with sensitive information
by Jakub Filak
Closes rhbz#1008125
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/gui-wizard-gtk/wizard.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index 36ad3fa..dd46160 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -2190,6 +2190,8 @@ static bool highligh_words_in_textview(int page, GtkTextView *tev, GList *words)
PangoAttrList *attrs = pango_attr_list_new();
PangoAttribute *foreground_attr = pango_attr_foreground_new(65535, 0, 0);
pango_attr_list_insert(attrs, foreground_attr);
+ PangoAttribute *underline_attr = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
+ pango_attr_list_insert(attrs, underline_attr);
gtk_label_set_attributes(GTK_LABEL(tab_lbl), attrs);
/* The current order of the found words is defined by order of words in the
--
1.8.3.1
10 years, 7 months
Re: rasdaemon and abrt cooperation
by Denys Vlasenko
On 06/05/2013 03:25 PM, Petr Holasek wrote:
> Hi Denys,
>
> I have some ideas about rasdaemon abrt hook
> and also following questions.
>
> Feel free to stop by or ping me, when you'll
> be in office, I'll be there till ~6PM today
> and afternoon tomorrow.
Currently we use Unix domain socket at
/var/run/abrt/abrt.socket
to support creation of problem data from crashing python
applications.
The socket accepts the following HTTP requests:
DELETE <problem_dir> HTTP/1.1
PUT / HTTP/1.1
DELETE request is straightforward, and anyway, you don't need it.
PUT request has the following form:
PUT / HTTP/1.1<CR><LF>
headers<CR><LF>
<CR><LF>
name1=value1<NUL>name2=value2<NUL>...
It appears that we misunderstood HTTP protocol and we should
have used POST instead of PUT. I am going to add POST alias
which works the same as PUT, and remove PUT sometime in the future.
For now, use PUT. The URI in PUT should be just /.
The headers following PUT line are currently ignored.
The body is NUL-delimited (not newline delimited!) set
of name-value pairs which describe the problem.
You can use any names which make sense for your problem
(for example, if someone is reporting an out-of-paper
problem with a printer, sending "printer_name=FOO" would make sense).
Some names *have* to be in the problem:
type=
reason=
"type" describes what kind of the problem it is. Say, "Python"
is used by python crashes. You need to invent your own identifier(s)
for the problems you want to report. Say, "mem_error" for ECC/cache
errors, "bus_error" for PCI errors?
This field is used to differentiate abrt's response to a problem.
We don't want ECC errors reported to Bugzilla, right? :)
"reason" is a short, one-line, human-readable description of the problem,
suitable, for example, for showing in the list of problems. Examples
we currently see or use:
"<module>:ZeroDivisionError: integer division or modulo by zero"
"Segmentation fault at address 0x7ff6bf09e010"
"Process %s was killed by signal %s"
time=<unixtime in seconds> will be added automatically unless you supply it.
I looked thru the list of names we use and many don't make sense for you
(say, "uid" makes no sense for ECC errors :), but the following ones
may be useful:
architecture=<uname.machine>
comment=<long, multi-line description of the problem (if "reason" isn't enough)>
kernel=<kernel version>
cmdline=<kernel cmdline>
As I said, if you have more data to report, create your own name=value pair
to be saved.
Server will respond with
HTTP/1.1 <http_code> <CR><LF>
<CR><LF>
http_code will be 201 ("Created") on success.
Do you think you can use this interface from rasdaemon?
--
vda
10 years, 7 months
[GNOME-ABRT PATCH 1/3] Do not crash on None in signal handler
by Jakub Filak
Closes rhbz#1005472
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/gnome_abrt/views.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/gnome_abrt/views.py b/src/gnome_abrt/views.py
index 1d7ddb9..dfea616 100644
--- a/src/gnome_abrt/views.py
+++ b/src/gnome_abrt/views.py
@@ -497,6 +497,15 @@ class OopsWindow(Gtk.ApplicationWindow):
if storage_problems:
model = self._builder.tv_problems.get_model()
+
+ # For some strange reason, get_model() sometimes returns None when
+ # this function is called from a signal handler but the signal
+ # handler is synchronously called from GMainLoop so there is no
+ # place for race conditions. If the described situation arises,
+ # base model will be used.
+ if model is None:
+ model = self._builder.ls_problems
+
pit = None
if old_selection:
pit = self._find_problem_iter(old_selection[0], model)
--
1.8.3.1
10 years, 7 months
[ABRT PATCH] add prefix from configure to the path of debuginfo installer - closes #701
by Petr Kubat
Signed-off-by: Petr Kubat <pkubat(a)redhat.com>
---
src/plugins/Makefile.am | 1 +
src/plugins/abrt-action-install-debuginfo-to-abrt-cache.c | 13 +++++++------
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index c0c0745..38ac8e4 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -250,6 +250,7 @@ abrt_action_install_debuginfo_to_abrt_cache_CPPFLAGS = \
-I$(srcdir)/../include \
-I$(srcdir)/../lib \
-D_GNU_SOURCE \
+ -DCONF_PREFIX=\"$(prefix)\" \
$(LIBREPORT_CFLAGS) \
-Wall -Wwrite-strings \
-fPIE
diff --git a/src/plugins/abrt-action-install-debuginfo-to-abrt-cache.c b/src/plugins/abrt-action-install-debuginfo-to-abrt-cache.c
index b642070..dc6fc28 100644
--- a/src/plugins/abrt-action-install-debuginfo-to-abrt-cache.c
+++ b/src/plugins/abrt-action-install-debuginfo-to-abrt-cache.c
@@ -112,12 +112,13 @@ int main(int argc, char **argv)
} while (*p);
#endif
/* Set safe PATH */
-// TODO: honor configure --prefix here by adding it to PATH
-// (otherwise abrt-action-install-debuginfo would fail to spawn abrt-action-trim-files):
- if (u == 0)
- putenv((char*) "PATH=/usr/sbin:/sbin:/usr/bin:/bin");
- else
- putenv((char*) "PATH=/usr/bin:/bin");
+ // Adding configure --prefix to the PATH so that
+ // abrt-action-install-debuginfo doesn't fail when spawning
+ // abrt-action-trim-files
+ char path_env[] = "PATH=/usr/sbin:/sbin:/usr/bin:/bin:" CONF_PREFIX;
+ if (u != 0)
+ strcpy(path_env, "PATH=/usr/bin:/bin:" CONF_PREFIX);
+ putenv(path_env);
}
execvp(EXECUTABLE, argv);
--
1.8.3.1
10 years, 7 months
[ABRT PATCH] retrace-client: query CCpp exploitable information from Retrace server; closes #703
by Michal Toman
Signed-off-by: Michal Toman <mtoman(a)redhat.com>
---
src/plugins/abrt-retrace-client.c | 138 ++++++++++++++++++++++++++++++++++++--
1 file changed, 131 insertions(+), 7 deletions(-)
diff --git a/src/plugins/abrt-retrace-client.c b/src/plugins/abrt-retrace-client.c
index 1712702..8b35dbe 100644
--- a/src/plugins/abrt-retrace-client.c
+++ b/src/plugins/abrt-retrace-client.c
@@ -21,6 +21,7 @@
#define MAX_FORMATS 16
#define MAX_RELEASES 32
#define MAX_DOTS_PER_LINE 80
+#define MIN_EXPLOITABLE_RATING 4
enum
{
@@ -929,6 +930,93 @@ static void run_backtrace(const char *task_id, const char *task_password)
free(backtrace_text);
}
+/* This is not robust at all but will work for now */
+static int get_exploitable_rating(const char *exploitable_text)
+{
+ const char *colon = strrchr(exploitable_text, ':');
+ int result;
+ if (!colon || sscanf(colon, ": %d", &result) != 1)
+ {
+ VERB1 log_msg("Unable to determine exploitable rating");
+ return -1;
+ }
+
+ VERB1 log_msg("Exploitable rating: %d", result);
+ return result;
+}
+
+/* Caller must free exploitable_text */
+static void exploitable(const char *task_id, const char *task_password,
+ char **exploitable_text)
+{
+ PRFileDesc *tcp_sock, *ssl_sock;
+ ssl_connect(&cfg, &tcp_sock, &ssl_sock);
+ struct strbuf *http_request = strbuf_new();
+ strbuf_append_strf(http_request,
+ "GET /%s/exploitable HTTP/1.1\r\n"
+ "Host: %s\r\n"
+ "X-Task-Password: %s\r\n"
+ "Content-Length: 0\r\n"
+ "Connection: close\r\n"
+ "%s"
+ "%s"
+ "\r\n",
+ task_id, cfg.url, task_password,
+ lang.accept_charset,
+ lang.accept_language
+ );
+
+ PRInt32 written = PR_Send(tcp_sock, http_request->buf, http_request->len,
+ /*flags:*/0, PR_INTERVAL_NO_TIMEOUT);
+ if (written == -1)
+ {
+ alert_connection_error(cfg.url);
+ error_msg_and_die(_("Failed to send HTTP header of length %d: NSS error %d."),
+ http_request->len, PR_GetError());
+ }
+ strbuf_free(http_request);
+ char *http_response = tcp_read_response(tcp_sock);
+ char *http_body = http_get_body(http_response);
+ if (!http_body)
+ {
+ alert_server_error(cfg.url);
+ error_msg_and_die(_("Invalid response from server: missing HTTP message body."));
+ }
+ if (http_show_headers)
+ http_print_headers(stderr, http_response);
+ int response_code = http_get_response_code(http_response);
+
+ free(http_response);
+ ssl_disconnect(ssl_sock);
+
+ /* 404 = exploitability results not available
+ 200 = OK
+ anything else = error */
+ if (response_code == 404)
+ *exploitable_text = NULL;
+ else if (response_code == 200)
+ *exploitable_text = http_body;
+ else
+ {
+ alert_server_error(cfg.url);
+ error_msg_and_die(_("Unexpected HTTP response from server: %d\n%s"),
+ response_code, http_body);
+ }
+}
+
+static void run_exploitable(const char *task_id, const char *task_password)
+{
+ char *exploitable_text;
+ exploitable(task_id, task_password, &exploitable_text);
+ if (exploitable_text)
+ {
+ printf("%s\n", exploitable_text);
+ free(exploitable_text);
+ }
+ else
+ puts("No exploitability information available.");
+}
+
static void run_log(const char *task_id, const char *task_password)
{
PRFileDesc *tcp_sock, *ssl_sock;
@@ -1026,19 +1114,47 @@ static int run_batch(bool delete_temp_archive)
{
char *backtrace_text;
backtrace(task_id, task_password, &backtrace_text);
+ char *exploitable_text = NULL;
+ if (task_type == TASK_RETRACE)
+ {
+ exploitable(task_id, task_password, &exploitable_text);
+ if (!exploitable_text)
+ VERB1 log_msg("No exploitable data available");
+ }
+
if (dump_dir_name)
{
+ struct dump_dir *dd = dd_opendir(dump_dir_name, 0/* flags */);
+ if (!dd)
+ {
+ free(backtrace_text);
+ xfunc_die();
+ }
+
/* the result of TASK_VMCORE is not backtrace, but kernel log */
- char *backtrace_path = xasprintf("%s/%s", dump_dir_name,
- task_type == TASK_VMCORE ? FILENAME_KERNEL_LOG : FILENAME_BACKTRACE);
- int backtrace_fd = xopen3(backtrace_path, O_WRONLY | O_CREAT | O_TRUNC, DEFAULT_DUMP_DIR_MODE);
- xwrite(backtrace_fd, backtrace_text, strlen(backtrace_text));
- close(backtrace_fd);
- free(backtrace_path);
+ const char *target = task_type == TASK_VMCORE ? FILENAME_KERNEL_LOG : FILENAME_BACKTRACE;
+ dd_save_text(dd, target, backtrace_text);
+
+ if (exploitable_text)
+ {
+ int exploitable_rating = get_exploitable_rating(exploitable_text);
+ if (exploitable_rating >= MIN_EXPLOITABLE_RATING)
+ dd_save_text(dd, FILENAME_EXPLOITABLE, exploitable_text);
+ else
+ VERB1 log_msg("Not saving exploitable data, rating < %d",
+ MIN_EXPLOITABLE_RATING);
+ }
+
+ dd_close(dd);
}
else
- printf("%s", backtrace_text);
+ {
+ printf("%s\n", backtrace_text);
+ if (exploitable_text)
+ printf("%s\n", exploitable_text);
+ }
free(backtrace_text);
+ free(exploitable_text);
}
else
{
@@ -1198,6 +1314,14 @@ int main(int argc, char **argv)
error_msg_and_die(_("Task password is needed."));
run_log(task_id, task_password);
}
+ else if (0 == strcasecmp(operation, "exploitable"))
+ {
+ if (!task_id)
+ error_msg_and_die(_("Task id is needed."));
+ if (!task_password)
+ error_msg_and_die(_("Task password is needed."));
+ run_exploitable(task_id, task_password);
+ }
else
error_msg_and_die(_("Unknown operation: %s."), operation);
--
1.8.3.1
10 years, 7 months
[PATCH] introduce FILENAME_EXPLOITABLE; related to abrt/abrt#703
by Michal Toman
Signed-off-by: Michal Toman <mtoman(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 0f335a3..c59ecd7 100644
--- a/src/include/internal_libreport.h
+++ b/src/include/internal_libreport.h
@@ -867,6 +867,7 @@ struct dump_dir *open_directory_for_writing(
#define FILENAME_PKG_ARCH "pkg_arch"
#define FILENAME_USERNAME "username"
#define FILENAME_ABRT_VERSION "abrt_version"
+#define FILENAME_EXPLOITABLE "exploitable"
// Not stored as files, added "on the fly":
#define CD_DUMPDIR "Directory"
--
1.8.3.1
10 years, 7 months
[ABRT PATCH 1/2] remove abrt-dedup-client; related to #702
by Michal Toman
Signed-off-by: Michal Toman <mtoman(a)redhat.com>
---
.gitignore | 1 -
doc/Makefile.am | 1 -
doc/abrt-dedup-client.txt | 52 --------
po/POTFILES.in | 1 -
src/plugins/Makefile.am | 18 +--
src/plugins/abrt-dedup-client.c | 264 ----------------------------------------
src/plugins/ccpp_event.conf | 1 -
7 files changed, 1 insertion(+), 337 deletions(-)
delete mode 100644 doc/abrt-dedup-client.txt
delete mode 100644 src/plugins/abrt-dedup-client.c
diff --git a/.gitignore b/.gitignore
index 9fcbe04..4a5e967 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,7 +28,6 @@ src/plugins/abrt-action-trim-files
src/plugins/abrt-watch-log
src/plugins/abrt-dump-oops
src/plugins/abrt-dump-xorg
-src/plugins/abrt-dedup-client
src/plugins/abrt-retrace-client
src/plugins/abrt-action-install-debuginfo
src/plugins/abrt-action-generate-core-backtrace
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 74834b0..1ca52b5 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -25,7 +25,6 @@ MAN1_TXT += abrt-harvest-pstoreoops.txt
MAN1_TXT += abrt-harvest-vmcore.txt
MAN1_TXT += abrt-merge-pstoreoops.txt
MAN1_TXT += abrt-server.txt
-MAN1_TXT += abrt-dedup-client.txt
MAN1_TXT += abrt-cli.txt
MAN1_TXT += abrt-action-save-package-data.txt
MAN1_TXT += abrt-action-save-kernel-data.txt
diff --git a/doc/abrt-dedup-client.txt b/doc/abrt-dedup-client.txt
deleted file mode 100644
index b837fcd..0000000
--- a/doc/abrt-dedup-client.txt
+++ /dev/null
@@ -1,52 +0,0 @@
-abrt-dedup-client(1)
-==================
-
-NAME
-----
-abrt-dedup-client - The ABRT dedup server client.
-
-SYNOPSIS
---------
-'abrt-dedup-client' [-vsk] [--url URL] [--port PORT] [-d DIR] [--headers]
-
-DESCRIPTION
------------
-'abrt-dedup-client' is the command-line tool for searching for duplicates.
-
-OPTIONS
--------
--v, --verbose::
- be verbose
-
--s, --syslog::
- log to syslog
-
--k, --insecure::
- allow insecure connection to dedup server
-
---url URL::
- dedup server URL [Default: retrace.fedoraproject.org]
-
---port NUM::
- dedup server port [Default: 443]
-
--d, --dump-dir DIR::
- problem directory [Default: current directory]
-
---headers::
- (debug) show received HTTP headers
-
-ENVIRONMENT
------------
-DEDUP_SERVER_URL::
- dedup server URL
-
-DEDUP_SERVER_PORT::
- dedup server PORT
-
-DEDUP_SERVER_INSECURE::
- Allow insecure connection to dedup server (use 'insecure')
-
-AUTHORS
--------
-* ABRT team
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 817b3fd..bd6c482 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -28,7 +28,6 @@ src/plugins/abrt-action-generate-core-backtrace.c
src/plugins/abrt-action-install-debuginfo.in
src/plugins/abrt-action-perform-ccpp-analysis.in
src/plugins/abrt-action-trim-files.c
-src/plugins/abrt-dedup-client.c
src/plugins/abrt-gdb-exploitable
src/plugins/abrt-watch-log.c
src/plugins/abrt-dump-oops.c
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index c0c0745..44eb2dd 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -22,8 +22,7 @@ bin_PROGRAMS = \
abrt-action-generate-backtrace \
abrt-action-generate-core-backtrace \
abrt-action-analyze-backtrace \
- abrt-retrace-client \
- abrt-dedup-client
+ abrt-retrace-client
if BUILD_BODHI
bin_PROGRAMS += \
@@ -277,21 +276,6 @@ abrt_retrace_client_SOURCES = \
$(SATYR_LIBS) \
$(NSS_LIBS)
-abrt_dedup_client_SOURCES = \
- abrt-dedup-client.c \
- https-utils.c
- abrt_dedup_client_CFLAGS = \
- -I$(srcdir)/../include \
- -I$(srcdir)/../lib \
- $(NSS_CFLAGS) \
- $(GLIB_CFLAGS) \
- -D_GNU_SOURCE \
- $(LIBREPORT_CFLAGS)
- abrt_dedup_client_LDADD = \
- $(LIBREPORT_LIBS) \
- $(SATYR_LIBS) \
- $(NSS_LIBS)
-
if BUILD_BODHI
abrt_bodhi_SOURCES = \
bodhi.c
diff --git a/src/plugins/abrt-dedup-client.c b/src/plugins/abrt-dedup-client.c
deleted file mode 100644
index 830efda..0000000
--- a/src/plugins/abrt-dedup-client.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- Copyright (C) 2012 ABRT Team
- Copyright (C) 2012 Red Hat, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include <syslog.h>
-#include "https-utils.h"
-
-#define SHOW_PREFIX "SHOW "
-#define SAVE_PREFIX "SAVE "
-
-static const char *dump_dir_name = ".";
-static char *component = NULL;
-static char *backtrace = NULL;
-static bool http_show_headers = false;
-static struct https_cfg cfg =
-{
- .url = "retrace.fedoraproject.org",
- .port = 443,
- .ssl_allow_insecure = false,
-};
-
-/* allowed characters are [a-zA-Z0-9_\.\-\+] */
-/* http://fedoraproject.org/wiki/Packaging:NamingGuidelines */
-static inline int is_valid_component_name(const char *name)
-{
- int i;
- unsigned char c;
- for (i = 0; name[i]; ++i)
- {
- c = (unsigned char)name[i];
- if (!isalnum(c) &&
- c != '-' && c != '.' &&
- c != '+' && c != '_')
- return 0;
- }
-
- return 1;
-}
-
-/* idea from curl */
-/* escape everything except [a-zA-Z0-9\.\-_~] */
-static void escape(const char *src, struct strbuf *dest)
-{
- int i;
- unsigned char c;
- for (i = 0; src[i]; ++i)
- {
- c = (unsigned char)src[i];
- if (isalnum(c) ||
- c == '-' || c == '.' ||
- c == '~' || c == '_')
- strbuf_append_char(dest, c);
- else
- strbuf_append_strf(dest, "%%%02X", c);
- }
-}
-
-int main(int argc, char **argv)
-{
- setlocale(LC_ALL, "");
-#if ENABLE_NLS
- bindtextdomain(PACKAGE, LOCALEDIR);
- textdomain(PACKAGE);
-#endif
-
- struct language lang;
- get_language(&lang);
-
- enum {
- OPT_verbose = 1 << 0,
- OPT_syslog = 1 << 1,
- OPT_insecure = 1 << 2,
- OPT_url = 1 << 3,
- OPT_port = 1 << 4,
- OPT_directory = 1 << 5,
- OPT_headers = 1 << 6,
- };
-
- /* Keep enum above and order of options below in sync! */
- struct options options[] = {
- OPT__VERBOSE(&g_verbose),
- OPT_BOOL('s', "syslog", NULL, _("log to syslog")),
- OPT_BOOL('k', "insecure", NULL,
- _("allow insecure connection to dedup server")),
- OPT_STRING(0, "url", &(cfg.url), "URL",
- _("dedup server URL")),
- OPT_INTEGER(0, "port", &(cfg.port),
- _("dedup server port")),
- OPT_STRING('d', "dump-dir", &dump_dir_name, "DUMP_DIR",
- _("Problem directory")),
- OPT_BOOL(0, "headers", NULL,
- _("(debug) show received HTTP headers")),
- OPT_END()
- };
-
- const char *usage = _("abrt-dedup-client component backtrace_file [options]");
-
- char *env_url = getenv("DEDUP_SERVER_URL");
- if (env_url)
- cfg.url = env_url;
-
- char *env_port = getenv("DEDUP_SERVER_PORT");
- if (env_port)
- cfg.port = xatou(env_port);
-
- char *env_insecure = getenv("DEDUP_SERVER_INSECURE");
- if (env_insecure)
- cfg.ssl_allow_insecure = strncmp(env_insecure, "insecure", strlen("insecure")) == 0;
-
- unsigned opts = parse_opts(argc, argv, options, usage);
- if (opts & OPT_syslog)
- {
- openlog(msg_prefix, 0, LOG_DAEMON);
- logmode = LOGMODE_SYSLOG;
- }
-
- /* expecting no positional arguments */
- argv += optind;
- if (argv[0])
- show_usage_and_die(usage, options);
-
- if (!cfg.ssl_allow_insecure)
- cfg.ssl_allow_insecure = opts & OPT_insecure;
-
- http_show_headers = opts & OPT_headers;
-
- /* load component and backtrace from dump_dir */
- struct dump_dir *dd = dd_opendir(dump_dir_name, DD_OPEN_READONLY);
- /* error message was emitted by dd_opendir */
- if (!dd)
- xfunc_die();
- component = dd_load_text_ext(dd, FILENAME_COMPONENT,
- DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE);
- backtrace = dd_load_text_ext(dd, FILENAME_BACKTRACE,
- DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE);
- dd_close(dd);
-
- if (!component || !backtrace)
- error_msg_and_die(_("'" FILENAME_COMPONENT "' and '" FILENAME_BACKTRACE
- "' files are required to check for duplicates."));
-
- if (!is_valid_component_name(component))
- error_msg_and_die(_("Forbidden component name: '%s'."), component);
-
- struct strbuf *request_body = strbuf_new();
- strbuf_append_str(request_body, "component=");
- /* escape component - may contain '+' */
- escape(component, request_body);
- free(component);
- strbuf_append_str(request_body, "&backtrace=");
- escape(backtrace, request_body);
- free(backtrace);
-
- struct strbuf *request = strbuf_new();
- strbuf_append_strf(request,
- "POST /btserver.cgi HTTP/1.1\r\n"
- "Host: %s\r\n"
- "Content-Type: application/x-www-form-urlencoded\r\n"
- "Content-Length: %d\r\n"
- "Connection: close\r\n"
- "%s"
- "%s"
- "\r\n",
- cfg.url,
- request_body->len,
- lang.accept_charset,
- lang.accept_language
- );
-
- strbuf_append_str(request, request_body->buf);
- strbuf_free(request_body);
-
- /* Initialize NSS */
- SECMODModule *mod;
- PK11GenericObject *cert;
- nss_init(&mod, &cert);
-
- /* start SSL communication */
- PRFileDesc *tcp_sock, *ssl_sock;
- ssl_connect(&cfg, &tcp_sock, &ssl_sock);
- PRInt32 written = PR_Send(tcp_sock, request->buf, request->len,
- 0/*flags*/, PR_INTERVAL_NO_TIMEOUT);
- if (written < 0)
- {
- alert_connection_error(cfg.url);
- error_msg_and_die(_("Failed to send HTTP request of length %d: NSS error %d."),
- request->len, PR_GetError());
- }
-
- char *response = tcp_read_response(tcp_sock);
- strbuf_free(request);
- ssl_disconnect(ssl_sock);
- if (http_show_headers)
- http_print_headers(stdout, response);
-
- char *response_body = http_get_body(response);
- char *encoding = http_get_header_value(response, "Transfer-Encoding");
- if (encoding && strcasecmp("chunked", encoding) == 0)
- {
- char *newbody = http_join_chunked(response_body, strlen(response_body));
- free(response_body);
- response_body = newbody;
- }
- free(encoding);
-
- /* iterate line by line */
- struct strbuf *result = strbuf_new();
- char *line, *newline;
- for (line = response_body; line; line = newline)
- {
- newline = strchr(line, '\n');
- if (newline)
- {
- *newline = '\0';
- /* we are on '\n', the line could be terminated by "\r\n" */
- if (*(newline - 1) == '\r')
- *(newline - 1) = '\0';
- ++newline;
- }
-
- /* forward to client */
- if (strncmp(SHOW_PREFIX, line, strlen(SHOW_PREFIX)) == 0)
- puts(line + strlen(SHOW_PREFIX));
- /* save to FILENAME_REMOTE_RESULT */
- else if (strncmp(SAVE_PREFIX, line, strlen(SAVE_PREFIX)) == 0)
- strbuf_append_strf(result, "%s\n", line + strlen(SAVE_PREFIX));
- else
- /* ignore anything else, just print on -v */
- VERB1 printf("Ignoring: '%s'\n", line);
- }
-
- /* save result */
- if (result->len > 0)
- {
- dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
- if (!dd)
- xfunc_die();
- dd_save_text(dd, FILENAME_REMOTE_RESULT, result->buf);
- dd_close(dd);
- }
- strbuf_free(result);
-
- free(response);
- free(response_body);
-
- /* Shutdown NSS. */
- nss_close(mod, cert);
-
- return 0;
-}
diff --git a/src/plugins/ccpp_event.conf b/src/plugins/ccpp_event.conf
index 1dacbeb..e7aec1d 100644
--- a/src/plugins/ccpp_event.conf
+++ b/src/plugins/ccpp_event.conf
@@ -63,7 +63,6 @@ EVENT=analyze_LocalGDB analyzer=CCpp
# Bugzilla requires nonempty duphash
EVENT=report_Bugzilla analyzer=CCpp duphash!=
- abrt-dedup-client
test -f component || abrt-action-save-package-data
component="`cat component`"
format="bugzilla_format.conf"
--
1.8.3.1
10 years, 7 months
[ABRT PATCH] abrt-*-client: simplify formatting of locale-related headers
by Denys Vlasenko
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
src/plugins/abrt-dedup-client.c | 24 ++++---
src/plugins/abrt-retrace-client.c | 134 ++++++++++++--------------------------
src/plugins/https-utils.c | 17 ++++-
src/plugins/https-utils.h | 4 +-
4 files changed, 72 insertions(+), 107 deletions(-)
diff --git a/src/plugins/abrt-dedup-client.c b/src/plugins/abrt-dedup-client.c
index 835d551..830efda 100644
--- a/src/plugins/abrt-dedup-client.c
+++ b/src/plugins/abrt-dedup-client.c
@@ -171,19 +171,17 @@ int main(int argc, char **argv)
"Host: %s\r\n"
"Content-Type: application/x-www-form-urlencoded\r\n"
"Content-Length: %d\r\n"
- "Connection: close\r\n",
- cfg.url, request_body->len);
-
- if (lang.encoding)
- strbuf_append_strf(request, "Accept-Charset: %s\r\n", lang.encoding);
-
- if (lang.locale)
- {
- strbuf_append_strf(request, "Accept-Language: %s\r\n", lang.locale);
- free(lang.locale);
- }
-
- strbuf_append_strf(request, "\r\n%s", request_body->buf);
+ "Connection: close\r\n"
+ "%s"
+ "%s"
+ "\r\n",
+ cfg.url,
+ request_body->len,
+ lang.accept_charset,
+ lang.accept_language
+ );
+
+ strbuf_append_str(request, request_body->buf);
strbuf_free(request_body);
/* Initialize NSS */
diff --git a/src/plugins/abrt-retrace-client.c b/src/plugins/abrt-retrace-client.c
index 940939b..cc0b802 100644
--- a/src/plugins/abrt-retrace-client.c
+++ b/src/plugins/abrt-retrace-client.c
@@ -29,6 +29,8 @@ enum
TASK_VMCORE,
};
+static struct language lang;
+
struct retrace_settings
{
int running_tasks;
@@ -369,8 +371,6 @@ static int check_package(const char *nvr, const char *arch, map_string_t *osinfo
{
char *releaseid = get_release_id(osinfo, arch);
- struct language lang;
- get_language(&lang);
PRFileDesc *tcp_sock, *ssl_sock;
ssl_connect(&cfg, &tcp_sock, &ssl_sock);
struct strbuf *http_request = strbuf_new();
@@ -382,21 +382,14 @@ static int check_package(const char *nvr, const char *arch, map_string_t *osinfo
"X-Package-NVR: %s\r\n"
"X-Package-Arch: %s\r\n"
"X-OS-Release: %s\r\n",
- cfg.url, nvr, arch, releaseid);
-
- if (lang.encoding)
- strbuf_append_strf(http_request,
- "Accept-Charset: %s\r\n",
- lang.encoding);
- if (lang.locale)
- {
- strbuf_append_strf(http_request,
- "Accept-Language: %s\r\n",
- lang.locale);
- free(lang.locale);
- }
+ "%s"
+ "%s"
+ "\r\n",
+ cfg.url, nvr, arch, releaseid,
+ lang.accept_charset,
+ lang.accept_language
+ );
- strbuf_append_str(http_request, "\r\n");
PRInt32 written = PR_Send(tcp_sock, http_request->buf, http_request->len,
/*flags:*/0, PR_INTERVAL_NO_TIMEOUT);
if (written == -1)
@@ -446,9 +439,6 @@ static int create(bool delete_temp_archive,
char **task_id,
char **task_password)
{
- struct language lang;
- get_language(&lang);
-
if (delay)
{
puts(_("Querying server settings"));
@@ -659,22 +649,14 @@ static int create(bool delete_temp_archive,
"Content-Type: application/x-xz-compressed-tar\r\n"
"Content-Length: %lld\r\n"
"Connection: close\r\n"
- "X-Task-Type: %d\r\n",
- cfg.url, (long long)file_stat.st_size, task_type);
-
- if (lang.encoding)
- strbuf_append_strf(http_request,
- "Accept-Charset: %s\r\n",
- lang.encoding);
- if (lang.locale)
- {
- strbuf_append_strf(http_request,
- "Accept-Language: %s\r\n",
- lang.locale);
- free(lang.locale);
- }
-
- strbuf_append_str(http_request, "\r\n");
+ "X-Task-Type: %d\r\n"
+ "%s"
+ "%s"
+ "\r\n",
+ cfg.url, (long long)file_stat.st_size, task_type,
+ lang.accept_charset,
+ lang.accept_language
+ );
PRInt32 written = PR_Send(tcp_sock, http_request->buf, http_request->len,
/*flags:*/0, PR_INTERVAL_NO_TIMEOUT);
@@ -825,9 +807,6 @@ static void status(const char *task_id,
char **task_status,
char **status_message)
{
- struct language lang;
- get_language(&lang);
-
PRFileDesc *tcp_sock, *ssl_sock;
ssl_connect(&cfg, &tcp_sock, &ssl_sock);
struct strbuf *http_request = strbuf_new();
@@ -836,22 +815,14 @@ static void status(const char *task_id,
"Host: %s\r\n"
"X-Task-Password: %s\r\n"
"Content-Length: 0\r\n"
- "Connection: close\r\n",
- task_id, cfg.url, task_password);
-
- if (lang.encoding)
- strbuf_append_strf(http_request,
- "Accept-Charset: %s\r\n",
- lang.encoding);
- if (lang.locale)
- {
- strbuf_append_strf(http_request,
- "Accept-Language: %s\r\n",
- lang.locale);
- free(lang.locale);
- }
-
- strbuf_append_str(http_request, "\r\n");
+ "Connection: close\r\n"
+ "%s"
+ "%s"
+ "\r\n",
+ task_id, cfg.url, task_password,
+ lang.accept_charset,
+ lang.accept_language
+ );
PRInt32 written = PR_Send(tcp_sock, http_request->buf, http_request->len,
/*flags:*/0, PR_INTERVAL_NO_TIMEOUT);
@@ -903,9 +874,6 @@ static void run_status(const char *task_id, const char *task_password)
static void backtrace(const char *task_id, const char *task_password,
char **backtrace)
{
- struct language lang;
- get_language(&lang);
-
PRFileDesc *tcp_sock, *ssl_sock;
ssl_connect(&cfg, &tcp_sock, &ssl_sock);
struct strbuf *http_request = strbuf_new();
@@ -914,22 +882,14 @@ static void backtrace(const char *task_id, const char *task_password,
"Host: %s\r\n"
"X-Task-Password: %s\r\n"
"Content-Length: 0\r\n"
- "Connection: close\r\n",
- task_id, cfg.url, task_password);
-
- if (lang.encoding)
- strbuf_append_strf(http_request,
- "Accept-Charset: %s\r\n",
- lang.encoding);
- if (lang.locale)
- {
- strbuf_append_strf(http_request,
- "Accept-Language: %s\r\n",
- lang.locale);
- free(lang.locale);
- }
-
- strbuf_append_str(http_request, "\r\n");
+ "Connection: close\r\n"
+ "%s"
+ "%s"
+ "\r\n",
+ task_id, cfg.url, task_password,
+ lang.accept_charset,
+ lang.accept_language
+ );
PRInt32 written = PR_Send(tcp_sock, http_request->buf, http_request->len,
/*flags:*/0, PR_INTERVAL_NO_TIMEOUT);
@@ -971,9 +931,6 @@ static void run_backtrace(const char *task_id, const char *task_password)
static void run_log(const char *task_id, const char *task_password)
{
- struct language lang;
- get_language(&lang);
-
PRFileDesc *tcp_sock, *ssl_sock;
ssl_connect(&cfg, &tcp_sock, &ssl_sock);
struct strbuf *http_request = strbuf_new();
@@ -982,22 +939,14 @@ static void run_log(const char *task_id, const char *task_password)
"Host: %s\r\n"
"X-Task-Password: %s\r\n"
"Content-Length: 0\r\n"
- "Connection: close\r\n",
- task_id, cfg.url, task_password);
-
- if (lang.encoding)
- strbuf_append_strf(http_request,
- "Accept-Charset: %s\r\n",
- lang.encoding);
- if (lang.locale)
- {
- strbuf_append_strf(http_request,
- "Accept-Language: %s\r\n",
- lang.locale);
- free(lang.locale);
- }
-
- strbuf_append_str(http_request, "\r\n");
+ "Connection: close\r\n"
+ "%s"
+ "%s"
+ "\r\n",
+ task_id, cfg.url, task_password,
+ lang.accept_charset,
+ lang.accept_language
+ );
PRInt32 written = PR_Send(tcp_sock, http_request->buf, http_request->len,
/*flags:*/0, PR_INTERVAL_NO_TIMEOUT);
@@ -1114,6 +1063,7 @@ int main(int argc, char **argv)
#endif
abrt_init(argv);
+ get_language(&lang);
const char *task_id = NULL;
const char *task_password = NULL;
diff --git a/src/plugins/https-utils.c b/src/plugins/https-utils.c
index 85d3f80..cb3c606 100644
--- a/src/plugins/https-utils.c
+++ b/src/plugins/https-utils.c
@@ -26,19 +26,34 @@ void get_language(struct language *lang)
{
lang->locale = NULL;
lang->encoding = NULL;
+ /*
+ * Note: ->accept_language and ->accept_charset will always be non-NULL:
+ * if we don't know them, they'll be ""; otherwise,
+ * they will be fully formed HTTP headers, with \r\n at the end.
+ * IOW: they are formatted for adding them to HTTP headers as-is.
+ */
char *locale = setlocale(LC_ALL, NULL);
if (!locale)
+ {
+ lang->accept_language = xzalloc(1);
+ lang->accept_charset = xzalloc(1);
return;
+ }
lang->locale = xstrdup(locale);
- lang->encoding = strchr(lang->locale, '.');
+ lang->accept_language = xasprintf("Accept-Language: %s\r\n", locale);
+ lang->encoding = strchr(lang->locale, '.');
if (!lang->encoding)
+ {
+ lang->accept_charset = xzalloc(1);
return;
+ }
*lang->encoding = '\0';
++lang->encoding;
+ lang->accept_charset = xasprintf("Accept-Charset: %s\r\n", lang->encoding);
}
void alert_server_error(const char *peer_name)
diff --git a/src/plugins/https-utils.h b/src/plugins/https-utils.h
index 7f73ab9..8ff9aed 100644
--- a/src/plugins/https-utils.h
+++ b/src/plugins/https-utils.h
@@ -39,7 +39,10 @@ struct language
{
char *locale;
char *encoding;
+ char *accept_charset;
+ char *accept_language;
};
+void get_language(struct language *lang);
struct https_cfg
{
@@ -48,7 +51,6 @@ struct https_cfg
bool ssl_allow_insecure;
};
-void get_language(struct language *lang);
void alert_server_error(const char *peer_name);
void alert_connection_error(const char *peer_name);
void ssl_connect(struct https_cfg *cfg, PRFileDesc **tcp_sock, PRFileDesc **ssl_sock);
--
1.8.1.4
10 years, 7 months