[PATCH-libreport] report-python: don't include executable
by Martin Milata
Doesn't really make sense, as it is always path to the python
executable. bz#741255
---
src/include/problem_data.h | 3 +++
src/lib/problem_data.c | 5 +++++
src/report-python/problem_data.c | 8 ++++++++
3 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/src/include/problem_data.h b/src/include/problem_data.h
index 14d1240..87037a2 100644
--- a/src/include/problem_data.h
+++ b/src/include/problem_data.h
@@ -74,6 +74,9 @@ void add_to_problem_data(problem_data_t *problem_data,
const char *name,
const char *content);
+/* Removes item from problem data */
+void remove_from_problem_data(problem_data_t *problem_data, const char *key);
+
static inline struct problem_item *get_problem_data_item_or_NULL(problem_data_t *problem_data, const char *key)
{
return (struct problem_item *)g_hash_table_lookup(problem_data, key);
diff --git a/src/lib/problem_data.c b/src/lib/problem_data.c
index 2ddff86..7d85709 100644
--- a/src/lib/problem_data.c
+++ b/src/lib/problem_data.c
@@ -155,6 +155,11 @@ void add_to_problem_data(problem_data_t *problem_data,
add_to_problem_data_ext(problem_data, name, content, CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE);
}
+void remove_from_problem_data(problem_data_t *problem_data, const char *key)
+{
+ g_hash_table_remove(problem_data, key);
+}
+
const char *get_problem_item_content_or_die(problem_data_t *problem_data, const char *key)
{
struct problem_item *item = get_problem_data_item_or_NULL(problem_data, key);
diff --git a/src/report-python/problem_data.c b/src/report-python/problem_data.c
index 9067dea..8b4088d 100644
--- a/src/report-python/problem_data.c
+++ b/src/report-python/problem_data.c
@@ -115,8 +115,16 @@ static PyObject *p_create_dump_dir_from_problem_data(PyObject *pself, PyObject *
static PyObject *p_add_basics_to_problem_data(PyObject *pself, PyObject *always_null)
{
p_problem_data *self = (p_problem_data*)pself;
+ int have_executable = (get_problem_data_item_or_NULL(self->cd, "executable") != NULL);
+
add_basics_to_problem_data(self->cd);
+ /* Workaround - the executable item will always be /usr/bin/python, which is useless. */
+ if (!have_executable)
+ {
+ remove_from_problem_data(self->cd, "executable");
+ }
+
Py_RETURN_NONE;
}
--
1.7.6.4
12 years, 3 months
set of patches for abrt-server
by Vratislav Podzimek
These are patches that make abrt-server usable for passing more information to it. So we can patch e.g. pyhook to provide additional information.
At least two of them deserve additional comments:
10/12 -- this is the biggest patch and I really recommend to look at whole patched file attached to a reply to this mail
11/12 -- this one is closely related to the previous one and it contains two shell scripts and .txt files (input for the scripts)
libreport -- I know that the FILENAME_BASENAME is not an ideal name for this value, but it fits in the rest of
them and is related to filenames, so I see it as the least confusing name
Rationale for the whole patch set:
1.) We need to have abrt-server more versatile to be able to provide more information in bugreports. Some of them are Python/Ruby/whatever specific or at least can be obtained from the running interpret environment in an easier way then from abrtd's perspective.
2.) Using GLib adds no additional dependencies.
3.) Using regular expressions makes parsing (and thus whole abrt-server) more versatile, better readable and maintable.
4.) Values checking should be done in one function and easily maintable so that we would be able to add more restrictions easily. If you see the ".txt files -> scripts -> .c files" flow as unnecessary, try to think again about maintainability a security. I mean, this way we have these restrictions hardcoded from the user's point of view (so that he cannot accidentaly modify it), but still easily editable from the maintainer's point of view. But there is one thing missing -- add "parse_checks.sh check_rules.txt > rules.c" to the Makefile. This is something I don't know how to do with Autotools. Can somebody help?
5.) I've tried to preserve the behaviour of the abrt-server including restrictions, but I see length checks as unnecessary. What is the reason for checking length of e.g. ANALYZER? We check the length of the whole communication, so there shouldn't be any security issues after removing it. And if the length causes a system call failure (e.g. creating new file) there still will be an error reported. And we believe that clients won't provide nonsense information (there's no way to check this) so I see no difference in believing that the info is "reasonably short".
So I've tried to explain the reasons of my steps, but of course feel free to ask me to explain anything that's not clear.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno -- Czech Republic
12 years, 6 months
[PATCH] if better backtrace is avail, then upload one
by Nikola Pajkovsky
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
src/plugins/reporter-bugzilla.c | 17 ++++++++++-
src/plugins/rhbz.c | 62 +++++++++++++++++++++++++++++++++++----
src/plugins/rhbz.h | 1 +
3 files changed, 73 insertions(+), 7 deletions(-)
diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
index 4046b24..4739c2e 100644
--- a/src/plugins/reporter-bugzilla.c
+++ b/src/plugins/reporter-bugzilla.c
@@ -377,14 +377,16 @@ int main(int argc, char **argv)
{
const char *package = get_problem_item_content_or_NULL(problem_data, FILENAME_PACKAGE);
const char *arch = get_problem_item_content_or_NULL(problem_data, FILENAME_ARCHITECTURE);
+ const char *rating_str = get_problem_item_content_or_NULL(problem_data, FILENAME_RATING);
char *full_dsc = xasprintf("Package: %s\n"
"Architecture: %s\n"
"OS Release: %s\n"
+ "rating: %s\n"
"\n"
"Comment\n"
"-----\n"
"%s\n",
- package, arch, release, comment
+ package, arch, release, rating_str, comment
);
log(_("Adding new comment to bug %d"), bz->bi_id);
/* unused code, enable it when gui/cli will be ready
@@ -394,6 +396,19 @@ int main(int argc, char **argv)
*/
rhbz_add_comment(client, bz->bi_id, full_dsc, 0);
free(full_dsc);
+
+ unsigned rating = xatou(rating_str);
+ if (bz->bi_best_bt_rating < rating)
+ {
+ char bug_id_str[sizeof(int)*3 + 2];
+ sprintf(bug_id_str, "%i", bz->bi_id);
+
+ const char *bt = get_problem_item_content_or_NULL(problem_data,
+ FILENAME_BACKTRACE);
+ log(_("Attaching better backtrace"));
+ rhbz_attach_blob(client, FILENAME_BACKTRACE, bug_id_str, bt, strlen(bt),
+ RHBZ_NOMAIL_NOTIFY);
+ }
}
}
diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
index 13957b8..f767215 100644
--- a/src/plugins/rhbz.c
+++ b/src/plugins/rhbz.c
@@ -42,14 +42,62 @@ void free_bug_info(struct bug_info *bi)
list_free_with_free(bi->bi_cc_list);
- bi->bi_status = NULL;
- bi->bi_resolution = NULL;
- bi->bi_reporter = NULL;
- bi->bi_product = NULL;
+ free(bi);
+}
- bi->bi_cc_list = NULL;
+unsigned find_best_bt_rating_in_comments(xmlrpc_value *result_xml)
+{
+ xmlrpc_value *comments_memb = rhbz_get_member("longdescs", result_xml);
+ if (!comments_memb)
+ return 0;
- free(bi);
+ int comments_memb_size = rhbz_array_size(comments_memb);
+
+ xmlrpc_env env;
+ xmlrpc_env_init(&env);
+ int best_bt_rating = 0;
+ for (int i = 0; i < comments_memb_size; ++i)
+ {
+ xmlrpc_value* item = NULL;
+ xmlrpc_array_read_item(&env, comments_memb, i, &item);
+ if (env.fault_occurred)
+ abrt_xmlrpc_die(&env);
+
+ char *comment_body = rhbz_bug_read_item("body", item, RHBZ_READ_STR);
+ /* attachments are sometimes without comments -- skip them */
+ if (!comment_body)
+ continue;
+
+ char *start_rating_line = strstr(comment_body, "rating: ");
+ if (!start_rating_line)
+ {
+ error_msg("no rating");
+ continue;
+ }
+
+ start_rating_line += strlen("rating: ");
+ char *end_rating_line = strchr(start_rating_line, '\n');
+ if (!end_rating_line)
+ error_msg_and_die("broken comment body");
+
+ char *rating_line = xstrndup(start_rating_line, end_rating_line - start_rating_line);
+ int old_errno = errno;
+ errno = 0;
+ char *e;
+ long rating = strtoul(rating_line, &e, 10);
+ if (errno || rating_line == e || *e != '\0' || rating > UINT_MAX)
+ {
+ /* error / no digits / illegal trailing chars */
+ errno = old_errno;
+ continue;
+ }
+ errno = old_errno; /* Ok. So restore errno. */
+
+ if (rating > best_bt_rating)
+ best_bt_rating = rating;
+ }
+
+ return best_bt_rating;
}
void rhbz_login(struct abrt_xmlrpc *ax, const char* login, const char* passwd)
@@ -273,6 +321,8 @@ struct bug_info *rhbz_bug_info(struct abrt_xmlrpc *ax, int bug_id)
bz->bi_cc_list = rhbz_bug_cc(xml_bug_response);
+ bz->bi_best_bt_rating = find_best_bt_rating_in_comments(xml_bug_response);
+
xmlrpc_DECREF(xml_bug_response);
return bz;
diff --git a/src/plugins/rhbz.h b/src/plugins/rhbz.h
index 864f603..9878dd7 100644
--- a/src/plugins/rhbz.h
+++ b/src/plugins/rhbz.h
@@ -48,6 +48,7 @@ enum {
struct bug_info {
int bi_id;
int bi_dup_id;
+ unsigned bi_best_bt_rating;
char *bi_status;
char *bi_resolution;
--
1.7.8.rc3.11.g024c8
12 years, 6 months
[PATCH] search only by duphash for selinux
by Nikola Pajkovsky
selinux guy's almost always move filled bug from component selinux-policy
to right component.
bugzilla client is looking for duplicate bug by sending xmlrpc query
"ALL whiteboard:<hash> component:<name> [product:<product>]"
so if bug is moved from component selinux-policy to other, then query
returns NULL and creates a new bug.
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
src/plugins/reporter-bugzilla.c | 14 +++++++-------
src/plugins/rhbz.c | 21 ++++++++++++---------
2 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
index 4739c2e..7f816b7 100644
--- a/src/plugins/reporter-bugzilla.c
+++ b/src/plugins/reporter-bugzilla.c
@@ -280,11 +280,11 @@ int main(int argc, char **argv)
free(version);
log(_("Checking for duplicates"));
- xmlrpc_value *result;
- if (strcmp(product, "Fedora") == 0)
- result = rhbz_search_duphash(client, component, product, duphash);
- else
- result = rhbz_search_duphash(client, component, NULL, duphash);
+
+ const char *product_substitute = (!strcmp(product, "Fedora")) ? product : NULL;
+ const char *component_substitute = (!strcmp(component, "selinux-policy")) ? NULL : component;
+ xmlrpc_value *result = rhbz_search_duphash(client, component_substitute,
+ product_substitute, duphash);
xmlrpc_value *all_bugs = rhbz_get_member("bugs", result);
xmlrpc_DECREF(result);
@@ -310,8 +310,8 @@ int main(int argc, char **argv)
/* found something, but its a different product */
free_bug_info(bz);
- xmlrpc_value *result = rhbz_search_duphash(client, component,
- product, duphash);
+ xmlrpc_value *result = rhbz_search_duphash(client, component_substitute,
+ product_substitute, duphash);
xmlrpc_value *all_bugs = rhbz_get_member("bugs", result);
xmlrpc_DECREF(result);
diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
index 5971042..3fa5168 100644
--- a/src/plugins/rhbz.c
+++ b/src/plugins/rhbz.c
@@ -116,17 +116,20 @@ void rhbz_login(struct abrt_xmlrpc *ax, const char* login, const char* passwd)
xmlrpc_value *rhbz_search_duphash(struct abrt_xmlrpc *ax, const char *component,
const char *product, const char *duphash)
{
- char *query = NULL;
- if (!product)
- query = xasprintf("ALL component:\"%s\" whiteboard:\"%s\"", component, duphash);
- else
- query = xasprintf("ALL component:\"%s\" whiteboard:\"%s\" product:\"%s\"",
- component, duphash, product);
+ struct strbuf *query = strbuf_new();
+ strbuf_append_strf(query, "ALL whiteboard:\"%s\"", duphash);
+
+ if (product)
+ strbuf_append_strf(query, " product:\"%s\"", product);
- VERB3 log("search for '%s'", query);
+ if (component)
+ strbuf_append_strf(query, " component:\"%s\"", component);
+
+ VERB3 log("search for '%s'", query->buf);
xmlrpc_value *ret = abrt_xmlrpc_call(ax, "Bug.search", "({s:s})",
- "quicksearch", query);
- free(query);
+ "quicksearch", query->buf);
+ strbuf_free(query);
+
return ret;
}
--
1.7.8.rc3.11.g024c8
12 years, 6 months
[PATCH] abrt-hook-ccpp: fix 'cd(NULL)' bug; fix badly placed setuid; sanitize stdio; make verbosity settable
by Denys Vlasenko
diff -x '*.po' -d -urpN abrt.1/src/hooks/abrt-hook-ccpp.c abrt.2/src/hooks/abrt-hook-ccpp.c
--- abrt.1/src/hooks/abrt-hook-ccpp.c 2011-10-27 19:31:07.000000000 +0200
+++ abrt.2/src/hooks/abrt-hook-ccpp.c 2011-11-30 16:32:52.615152475 +0100
@@ -195,11 +195,6 @@ static char* get_cwd(pid_t pid)
static int open_user_core(uid_t uid, pid_t pid, char **percent_values)
{
- struct passwd* pw = getpwuid(uid);
- gid_t gid = pw ? pw->pw_gid : uid;
- xsetegid(gid);
- xseteuid(uid);
-
errno = 0;
if (user_pwd == NULL
|| chdir(user_pwd) != 0
@@ -208,6 +203,11 @@ static int open_user_core(uid_t uid, pid
return -1;
}
+ struct passwd* pw = getpwuid(uid);
+ gid_t gid = pw ? pw->pw_gid : uid;
+ xsetegid(gid);
+ xseteuid(uid);
+
if (strcmp(core_basename, "core") == 0)
{
/* Mimic "core.PID" if requested */
@@ -344,6 +344,16 @@ int main(int argc, char** argv)
{
struct stat sb;
+ /* Kernel starts us with all fd's closed.
+ * But it's dangerous:
+ * fprintf(stderr) can dump messages into random fds, etc.
+ */
+ int fd = xopen("/dev/null", O_RDWR);
+ while (fd < 2)
+ fd = xdup(fd);
+ if (fd > 2)
+ close(fd);
+
if (argc < 8)
{
/* percent specifier: %s %c %p %u %g %t %e %h */
@@ -369,10 +379,26 @@ int main(int argc, char** argv)
openlog("abrt", LOG_PID, LOG_DAEMON);
logmode = LOGMODE_SYSLOG;
- errno = 0;
/* Parse abrt.conf */
load_abrt_conf();
+ /* ... and plugins/CCpp.conf */
+ bool setting_MakeCompatCore;
+ bool setting_SaveBinaryImage;
+ {
+ map_string_h *settings = new_map_string();
+ load_conf_file(PLUGINS_CONF_DIR"/CCpp.conf", settings, /*skip key w/o values:*/ false);
+ char *value;
+ value = g_hash_table_lookup(settings, "MakeCompatCore");
+ setting_MakeCompatCore = value && string_to_bool(value);
+ value = g_hash_table_lookup(settings, "SaveBinaryImage");
+ setting_SaveBinaryImage = value && string_to_bool(value);
+ value = g_hash_table_lookup(settings, "VerboseLog");
+ if (value)
+ g_verbose = xatoi_positive(value);
+ free_map_string(settings);
+ }
+ errno = 0;
const char* signal_str = argv[1];
int signal_no = xatoi_positive(signal_str);
off_t ulimit_c = strtoull(argv[2], NULL, 10);
@@ -397,6 +423,8 @@ int main(int argc, char** argv)
/* If we have a saved pattern and it's not a "|PROG ARGS" thing... */
if (s && s[0] != '|')
core_basename = s;
+ else
+ free(s);
}
struct utsname uts;
@@ -414,21 +442,8 @@ int main(int argc, char** argv)
(long)pid, executable);
}
- char *user_pwd = get_cwd(pid); /* may be NULL on error */
-
- /* ... and plugins/CCpp.conf */
- bool setting_MakeCompatCore;
- bool setting_SaveBinaryImage;
- {
- map_string_h *settings = new_map_string();
- load_conf_file(PLUGINS_CONF_DIR"/CCpp.conf", settings, /*skip key w/o values:*/ false);
- char *value;
- value = g_hash_table_lookup(settings, "MakeCompatCore");
- setting_MakeCompatCore = value && string_to_bool(value);
- value = g_hash_table_lookup(settings, "SaveBinaryImage");
- setting_SaveBinaryImage = value && string_to_bool(value);
- free_map_string(settings);
- }
+ user_pwd = get_cwd(pid); /* may be NULL on error */
+ VERB1 log("user_pwd:'%s'", user_pwd);
if (!setting_SaveBinaryImage && src_fd_binary >= 0)
{
@@ -493,7 +508,7 @@ int main(int argc, char** argv)
* if they happen too often. Else, write new marker value.
*/
snprintf(path, sizeof(path), "%s/last-ccpp", g_settings_dump_location);
- int fd = open(path, O_RDWR | O_CREAT, 0600);
+ fd = open(path, O_RDWR | O_CREAT, 0600);
if (fd >= 0)
{
int sz;
diff -x '*.po' -d -urpN abrt.1/src/hooks/CCpp.conf abrt.2/src/hooks/CCpp.conf
--- abrt.1/src/hooks/CCpp.conf 2011-10-27 19:11:55.000000000 +0200
+++ abrt.2/src/hooks/CCpp.conf 2011-11-30 16:26:21.949347149 +0100
@@ -8,6 +8,9 @@ MakeCompatCore = yes
# (useful, for example, when _deleted binary_ segfaults)
SaveBinaryImage = no
+# Used for debugging the hook
+#VerboseLog = 2
+
# Specify where you want to store debuginfos (default: /var/cache/abrt-di)
#
#DebuginfoLocation = /var/cache/abrt-di
12 years, 6 months
[PATCHv2-libreport] enable bodhi for fedora
by Nikola Pajkovsky
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
configure.ac | 19 +++----------------
libreport.spec.in | 11 -----------
po/POTFILES.in | 1 -
src/plugins/Makefile.am | 20 +++++---------------
src/plugins/analyze_LocalGDB_Bodhi.xml.in | 7 -------
src/plugins/bodhi_event.conf | 9 ---------
6 files changed, 8 insertions(+), 59 deletions(-)
delete mode 100644 src/plugins/analyze_LocalGDB_Bodhi.xml.in
delete mode 100644 src/plugins/bodhi_event.conf
diff --git a/configure.ac b/configure.ac
index fbbadad..851cc89 100644
--- a/configure.ac
+++ b/configure.ac
@@ -74,6 +74,9 @@ PKG_CHECK_MODULES([XMLRPC], [xmlrpc])
PKG_CHECK_MODULES([XMLRPC_CLIENT], [xmlrpc_client])
PKG_CHECK_MODULES([CURL], [libcurl])
PKG_CHECK_MODULES([GNOME_KEYRING], [gnome-keyring-1])
+PKG_CHECK_MODULES([JSON_C], [json])
+PKG_CHECK_MODULES([RPM], [rpm])
+
# Just PKG_CHECK_MODULES([PYTHON], [python]) works only with python2.7+
# Below, if python is not found, we set up for python2.6 w/o checking:
PKG_CHECK_MODULES([PYTHON], [python],,[
@@ -85,22 +88,6 @@ PKG_CHECK_MODULES([PROXY], [libproxy-1.0], [
AC_DEFINE([HAVE_PROXY], [1], [Use libproxy])
], [:])
-AS_IF([test "x$enable_bodhi" != "xno"], [
- dnl Do the stuff needed for enabling the feature
- AC_CHECK_LIB([json], [json_tokener_parse],
- [AM_CONDITIONAL(HAVE_BODHI, true)
- AC_DEFINE([HAVE_BODHI], [1], [have bodhi])
- PKG_CHECK_MODULES([JSON_C], [json])
- PKG_CHECK_MODULES([RPM], [rpm])],
- [AM_CONDITIONAL(HAVE_BODHI, false)
- AC_DEFINE([HAVE_BODHI], [0], [have bodhi])])
- ],
- [test "x$enable_bodhi" = "xno"], [
- AM_CONDITIONAL(HAVE_BODHI, false)
- AC_DEFINE([HAVE_BODHI], [0], [have bodhi])
- ]
-)
-
PKG_PROG_PKG_CONFIG
AC_CHECK_HEADER([libtar.h], [],
diff --git a/libreport.spec.in b/libreport.spec.in
index 28e2c3f..687f3c8 100644
--- a/libreport.spec.in
+++ b/libreport.spec.in
@@ -151,7 +151,6 @@ Obsoletes: report-plugin-bugzilla < 0.23-1
Provides: report-config-bugzilla-redhat-com = 0.23-1
Obsoletes: report-config-bugzilla-redhat-com < 0.23-1
-%if 0%{?fedora}
%package plugin-bodhi
Summary: %{name}'s bodhi plugin
BuildRequires: json-c-devel
@@ -162,7 +161,6 @@ BuildRequires: rpm-devel
%description plugin-bodhi
Search for a new updates in bodhi server
-%endif
%description plugin-bugzilla
Plugin to report bugs into the bugzilla.
@@ -327,20 +325,11 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%{_mandir}/man*/reporter-mailx.*
%{_bindir}/reporter-mailx
-%if 0%{?fedora}
%files plugin-bodhi
%defattr(-,root,root,-)
%{_bindir}/abrt-bodhi
%config(noreplace) %{_sysconfdir}/libreport/events.d/bodhi_event.conf
-%{_sysconfdir}/libreport/events/analyze_LocalGDB_Bodhi.xml
%{_mandir}/man1/abrt-bodhi.1.gz
-%else
-# exclude bodhi files for rhel build, otherwise rpm build fails
-%exclude %{_bindir}/abrt-bodhi
-%config(noreplace) %exclude %{_sysconfdir}/libreport/events.d/bodhi_event.conf
-%exclude %{_sysconfdir}/libreport/events/analyze_LocalGDB_Bodhi.xml
-%exclude %{_mandir}/man1/abrt-bodhi.1.gz
-%endif
%files plugin-bugzilla
%defattr(-,root,root,-)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 3fc5d30..86acc61 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -21,7 +21,6 @@ src/plugins/report_Logger.xml.in
src/plugins/report_Mailx.xml.in
src/plugins/report_RHTSupport.xml.in
src/plugins/report_Uploader.xml.in
-src/plugins/analyze_LocalGDB_Bodhi.xml.in
src/plugins/reporter-bugzilla.c
src/plugins/reporter-kerneloops.c
src/plugins/reporter-mailx.c
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 2d489b5..ba51761 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -7,10 +7,8 @@ bin_PROGRAMS = \
reporter-upload \
reporter-mailx \
reporter-print \
- report
-if HAVE_BODHI
-bin_PROGRAMS += abrt-bodhi
-endif
+ report \
+ abrt-bodhi
pluginsconfdir = $(PLUGINS_CONF_DIR)
@@ -31,9 +29,6 @@ dist_events_DATA = \
report_RHTSupport.xml \
report_Kerneloops.xml \
report_Uploader.xml
-if HAVE_BODHI
-dist_events_DATA += analyze_LocalGDB_Bodhi.xml
-endif
@INTLTOOL_XML_RULE@
@@ -44,10 +39,8 @@ dist_eventsconf_DATA = \
print_event.conf \
bugzilla_event.conf \
rhtsupport_event.conf \
- uploader_event.conf
-if HAVE_BODHI
-dist_eventsconf_DATA += bodhi_event.conf
-endif
+ uploader_event.conf \
+ bodhi_event.conf
EXTRA_DIST = \
report_Bugzilla.xml.in \
@@ -57,8 +50,7 @@ EXTRA_DIST = \
report_Mailx.xml.in \
report_RHTSupport.xml.in \
report_Kerneloops.xml.in \
- report_Uploader.xml.in \
- analyze_LocalGDB_Bodhi.xml.in
+ report_Uploader.xml.in
$(DESTDIR)/$(DEBUG_INFO_DIR):
$(mkdir_p) '$@'
@@ -208,7 +200,6 @@ report_CPPFLAGS = \
report_LDADD = \
../lib/libreport.la
-if HAVE_BODHI
abrt_bodhi_SOURCES = \
abrt-bodhi.c
abrt_bodhi_CPPFLAGS = \
@@ -225,6 +216,5 @@ abrt_bodhi_LDADD = \
$(RPM_LIBS) \
../lib/libreport.la \
../lib/libabrt_web.la
-endif
DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
diff --git a/src/plugins/analyze_LocalGDB_Bodhi.xml.in b/src/plugins/analyze_LocalGDB_Bodhi.xml.in
deleted file mode 100644
index a94d8a0..0000000
--- a/src/plugins/analyze_LocalGDB_Bodhi.xml.in
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<event>
- <_name>Local GNU Debugger and search for a new update</_name>
- <_description>Download debuginfo packages, generate backtrace locally using
- GDB and search for a new updates if available</_description>
- <creates-items>backtrace</creates-items>
-</event>
diff --git a/src/plugins/bodhi_event.conf b/src/plugins/bodhi_event.conf
deleted file mode 100644
index 3578e12..0000000
--- a/src/plugins/bodhi_event.conf
+++ /dev/null
@@ -1,9 +0,0 @@
-EVENT=analyze_LocalGDB_Bodhi analyzer=CCpp
- abrt-action-analyze-core --core=coredump -o build_ids &&
- /usr/libexec/abrt-action-install-debuginfo-to-abrt-cache --size_mb=4096 &&
- abrt-action-generate-backtrace &&
- abrt-action-analyze-backtrace &&
- (
- bug_id=$(reporter-bugzilla -h `cat duphash`) &&
- abrt-bodhi -r -b $bug_id
- )
--
1.7.8.rc3.11.g024c8
12 years, 6 months
[PATCH] libreport-filesystem package
by Denys Vlasenko
Mostly harmless :)
diff -d -urpN libreport.5/libreport.spec.in libreport.6/libreport.spec.in
--- libreport.5/libreport.spec.in 2011-11-24 17:52:46.000000000 +0100
+++ libreport.6/libreport.spec.in 2011-11-25 14:45:33.511734287 +0100
@@ -27,6 +27,7 @@ BuildRequires: asciidoc
BuildRequires: xmlto
BuildRequires: newt-devel
BuildRequires: libproxy-devel
+Requires: libreport-filesystem
# required for update from old report library, otherwise we obsolete report-gtk
# and all it's plugins, but don't provide the python bindings and the sealert
# end-up with: can't import report.GtkIO
@@ -46,6 +47,13 @@ BuildRoot: %{_tmppath}/%{name}-%{version
Libraries providing API for reporting different problems in applications
to different bug targets like Bugzilla, ftp, trac, etc...
+%package filesystem
+Summary: Filesystem layout for libreport
+Group: Applications/File
+
+%description filesystem
+Filesystem layout for libreport
+
%package devel
Summary: Development libraries and headers for libreport
Group: Development/Libraries
@@ -254,7 +262,6 @@ gtk-update-icon-cache %{_datadir}/icons/
%defattr(-,root,root,-)
%doc README COPYING
%dir %{_sysconfdir}/%{name}/
-%dir %{_sysconfdir}/%{name}/events.d/
%dir %{_sysconfdir}/%{name}/events/
%dir %{_sysconfdir}/%{name}/plugins/
%config(noreplace) %{_sysconfdir}/%{name}/report_event.conf
@@ -264,6 +271,10 @@ gtk-update-icon-cache %{_datadir}/icons/
%exclude %{_libdir}/libabrt_web.so
%{_mandir}/man5/report_event.conf.5*
+%files filesystem
+%defattr(-,root,root,-)
+%dir %{_sysconfdir}/%{name}/events.d/
+
%files devel
%defattr(-,root,root,-)
# Public api headers:
12 years, 7 months
[PATCH] enable bodhi for fedora
by Nikola Pajkovsky
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
configure.ac | 19 +++----------------
libreport.spec.in | 11 -----------
po/POTFILES.in | 1 -
src/plugins/Makefile.am | 20 +++++---------------
src/plugins/analyze_LocalGDB_Bodhi.xml.in | 7 -------
5 files changed, 8 insertions(+), 50 deletions(-)
delete mode 100644 src/plugins/analyze_LocalGDB_Bodhi.xml.in
diff --git a/configure.ac b/configure.ac
index fbbadad..851cc89 100644
--- a/configure.ac
+++ b/configure.ac
@@ -74,6 +74,9 @@ PKG_CHECK_MODULES([XMLRPC], [xmlrpc])
PKG_CHECK_MODULES([XMLRPC_CLIENT], [xmlrpc_client])
PKG_CHECK_MODULES([CURL], [libcurl])
PKG_CHECK_MODULES([GNOME_KEYRING], [gnome-keyring-1])
+PKG_CHECK_MODULES([JSON_C], [json])
+PKG_CHECK_MODULES([RPM], [rpm])
+
# Just PKG_CHECK_MODULES([PYTHON], [python]) works only with python2.7+
# Below, if python is not found, we set up for python2.6 w/o checking:
PKG_CHECK_MODULES([PYTHON], [python],,[
@@ -85,22 +88,6 @@ PKG_CHECK_MODULES([PROXY], [libproxy-1.0], [
AC_DEFINE([HAVE_PROXY], [1], [Use libproxy])
], [:])
-AS_IF([test "x$enable_bodhi" != "xno"], [
- dnl Do the stuff needed for enabling the feature
- AC_CHECK_LIB([json], [json_tokener_parse],
- [AM_CONDITIONAL(HAVE_BODHI, true)
- AC_DEFINE([HAVE_BODHI], [1], [have bodhi])
- PKG_CHECK_MODULES([JSON_C], [json])
- PKG_CHECK_MODULES([RPM], [rpm])],
- [AM_CONDITIONAL(HAVE_BODHI, false)
- AC_DEFINE([HAVE_BODHI], [0], [have bodhi])])
- ],
- [test "x$enable_bodhi" = "xno"], [
- AM_CONDITIONAL(HAVE_BODHI, false)
- AC_DEFINE([HAVE_BODHI], [0], [have bodhi])
- ]
-)
-
PKG_PROG_PKG_CONFIG
AC_CHECK_HEADER([libtar.h], [],
diff --git a/libreport.spec.in b/libreport.spec.in
index 28e2c3f..687f3c8 100644
--- a/libreport.spec.in
+++ b/libreport.spec.in
@@ -151,7 +151,6 @@ Obsoletes: report-plugin-bugzilla < 0.23-1
Provides: report-config-bugzilla-redhat-com = 0.23-1
Obsoletes: report-config-bugzilla-redhat-com < 0.23-1
-%if 0%{?fedora}
%package plugin-bodhi
Summary: %{name}'s bodhi plugin
BuildRequires: json-c-devel
@@ -162,7 +161,6 @@ BuildRequires: rpm-devel
%description plugin-bodhi
Search for a new updates in bodhi server
-%endif
%description plugin-bugzilla
Plugin to report bugs into the bugzilla.
@@ -327,20 +325,11 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%{_mandir}/man*/reporter-mailx.*
%{_bindir}/reporter-mailx
-%if 0%{?fedora}
%files plugin-bodhi
%defattr(-,root,root,-)
%{_bindir}/abrt-bodhi
%config(noreplace) %{_sysconfdir}/libreport/events.d/bodhi_event.conf
-%{_sysconfdir}/libreport/events/analyze_LocalGDB_Bodhi.xml
%{_mandir}/man1/abrt-bodhi.1.gz
-%else
-# exclude bodhi files for rhel build, otherwise rpm build fails
-%exclude %{_bindir}/abrt-bodhi
-%config(noreplace) %exclude %{_sysconfdir}/libreport/events.d/bodhi_event.conf
-%exclude %{_sysconfdir}/libreport/events/analyze_LocalGDB_Bodhi.xml
-%exclude %{_mandir}/man1/abrt-bodhi.1.gz
-%endif
%files plugin-bugzilla
%defattr(-,root,root,-)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 3fc5d30..86acc61 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -21,7 +21,6 @@ src/plugins/report_Logger.xml.in
src/plugins/report_Mailx.xml.in
src/plugins/report_RHTSupport.xml.in
src/plugins/report_Uploader.xml.in
-src/plugins/analyze_LocalGDB_Bodhi.xml.in
src/plugins/reporter-bugzilla.c
src/plugins/reporter-kerneloops.c
src/plugins/reporter-mailx.c
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 2d489b5..ba51761 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -7,10 +7,8 @@ bin_PROGRAMS = \
reporter-upload \
reporter-mailx \
reporter-print \
- report
-if HAVE_BODHI
-bin_PROGRAMS += abrt-bodhi
-endif
+ report \
+ abrt-bodhi
pluginsconfdir = $(PLUGINS_CONF_DIR)
@@ -31,9 +29,6 @@ dist_events_DATA = \
report_RHTSupport.xml \
report_Kerneloops.xml \
report_Uploader.xml
-if HAVE_BODHI
-dist_events_DATA += analyze_LocalGDB_Bodhi.xml
-endif
@INTLTOOL_XML_RULE@
@@ -44,10 +39,8 @@ dist_eventsconf_DATA = \
print_event.conf \
bugzilla_event.conf \
rhtsupport_event.conf \
- uploader_event.conf
-if HAVE_BODHI
-dist_eventsconf_DATA += bodhi_event.conf
-endif
+ uploader_event.conf \
+ bodhi_event.conf
EXTRA_DIST = \
report_Bugzilla.xml.in \
@@ -57,8 +50,7 @@ EXTRA_DIST = \
report_Mailx.xml.in \
report_RHTSupport.xml.in \
report_Kerneloops.xml.in \
- report_Uploader.xml.in \
- analyze_LocalGDB_Bodhi.xml.in
+ report_Uploader.xml.in
$(DESTDIR)/$(DEBUG_INFO_DIR):
$(mkdir_p) '$@'
@@ -208,7 +200,6 @@ report_CPPFLAGS = \
report_LDADD = \
../lib/libreport.la
-if HAVE_BODHI
abrt_bodhi_SOURCES = \
abrt-bodhi.c
abrt_bodhi_CPPFLAGS = \
@@ -225,6 +216,5 @@ abrt_bodhi_LDADD = \
$(RPM_LIBS) \
../lib/libreport.la \
../lib/libabrt_web.la
-endif
DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
diff --git a/src/plugins/analyze_LocalGDB_Bodhi.xml.in b/src/plugins/analyze_LocalGDB_Bodhi.xml.in
deleted file mode 100644
index a94d8a0..0000000
--- a/src/plugins/analyze_LocalGDB_Bodhi.xml.in
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<event>
- <_name>Local GNU Debugger and search for a new update</_name>
- <_description>Download debuginfo packages, generate backtrace locally using
- GDB and search for a new updates if available</_description>
- <creates-items>backtrace</creates-items>
-</event>
--
1.7.8.rc3.11.g024c8
12 years, 7 months
Re: [PATCH] abrt-dbus: new program. Started by dbus autostart. Can be used to query list of problems
by Denys Vlasenko
On Wed, 2011-11-23 at 19:31 +0100, Denys Vlasenko wrote:
> Example of querying it (note that this also tested autostart -
> abrt-dbus wasn't running prior to this command:
>
> $ dbus-send --system --type=method_call --print-reply --dest=com.redhat.abrt /com/redhat/abrt com.redhat.abrt.GetListOfProblems
> method return sender=:1.49 -> dest=:1.50 reply_serial=2
> array [
> string "/var/spool/abrt/ccpp-2011-11-11-19:18:11-25603"
> ]
>
>
> Other commands are to be added later (after we discuss _which_
> commands we might want to implement).
Updated patch
--
vda
diff -x '*.po' -d -urpN abrt.5/abrt.spec.in abrt.6/abrt.spec.in
--- abrt.5/abrt.spec.in 2011-11-22 15:15:12.980916492 +0100
+++ abrt.6/abrt.spec.in 2011-11-23 17:57:47.856554681 +0100
@@ -365,6 +365,7 @@ gtk-update-icon-cache %{_datadir}/icons/
%{_initrddir}/abrtd
%endif
%{_sbindir}/abrtd
+%{_sbindir}/abrt-dbus
%{_sbindir}/abrt-server
%{_libexecdir}/abrt-handle-event
%{_bindir}/abrt-handle-upload
@@ -373,6 +374,7 @@ gtk-update-icon-cache %{_datadir}/icons/
%config(noreplace) %{_sysconfdir}/%{name}/abrt-action-save-package-data.conf
%config(noreplace) %{_sysconfdir}/%{name}/gpg_keys
%config(noreplace) %{_sysconfdir}/libreport/events.d/abrt_event.conf
+%config(noreplace) %{_sysconfdir}/dbus-1/system.d/dbus-abrt.conf
%config(noreplace) %{_sysconfdir}/libreport/events.d/smart_event.conf
%config(noreplace) %{_sysconfdir}/libreport/events.d/smolt_event.conf
%dir %attr(0755, abrt, abrt) %{_localstatedir}/spool/%{name}
@@ -392,6 +394,7 @@ gtk-update-icon-cache %{_datadir}/icons/
%{_mandir}/man5/abrt.conf.5.gz
%{_mandir}/man5/abrt-action-save-package-data.conf.5.gz
# {_mandir}/man5/pyhook.conf.5.gz
+%{_datadir}/dbus-1/system-services/com.redhat.abrt.service
%files libs
%defattr(-,root,root,-)
diff -x '*.po' -d -urpN abrt.5/po/POTFILES.in abrt.6/po/POTFILES.in
--- abrt.5/po/POTFILES.in 2011-10-27 19:11:55.000000000 +0200
+++ abrt.6/po/POTFILES.in 2011-11-23 18:18:18.073501303 +0100
@@ -5,6 +5,7 @@ src/applet/abrt-applet.desktop.in
src/applet/applet.c
src/daemon/abrt-action-save-package-data.c
src/daemon/abrt-server.c
+src/daemon/abrt-dbus.c
src/daemon/abrtd.c
src/daemon/abrt-handle-event.c
src/gui-gtk/abrt.desktop.in
diff -x '*.po' -d -urpN abrt.5/src/daemon/abrt-dbus.c abrt.6/src/daemon/abrt-dbus.c
--- abrt.5/src/daemon/abrt-dbus.c 1970-01-01 01:00:00.000000000 +0100
+++ abrt.6/src/daemon/abrt-dbus.c 2011-11-23 19:35:58.788340432 +0100
@@ -0,0 +1,533 @@
+/*
+ Copyright (C) 2011 ABRT team
+ Copyright (C) 2011 RedHat 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 <dbus/dbus.h>
+#include <internal_abrt_dbus.h>
+#include "libabrt.h"
+
+/* I want to use -Werror, but gcc-4.4 throws a curveball:
+ * "warning: ignoring return value of 'ftruncate', declared with attribute warn_unused_result"
+ * and (void) cast is not enough to shut it up! Oh God...
+ */
+#define IGNORE_RESULT(func_call) do { if (func_call) /* nothing */; } while (0)
+
+
+#define ABRTD_DBUS_NAME "com.redhat.abrt"
+#define ABRTD_DBUS_PATH "/com/redhat/abrt"
+#define ABRTD_DBUS_IFACE "com.redhat.abrt"
+
+
+static volatile sig_atomic_t s_sig_caught;
+static int s_signal_pipe[2];
+static int s_signal_pipe_write = -1;
+static unsigned s_timeout;
+static bool s_exiting;
+
+
+static void send_flush_and_unref(DBusMessage* msg)
+{
+ if (!g_dbus_conn)
+ {
+ /* Not logging this, it may recurse */
+ return;
+ }
+ if (!dbus_connection_send(g_dbus_conn, msg, NULL /* &serial */))
+ error_msg_and_die("Error sending DBus message");
+ dbus_connection_flush(g_dbus_conn);
+ VERB3 log("DBus message sent");
+ dbus_message_unref(msg);
+}
+
+/*
+ * DBus call handlers
+ */
+
+static GList* scan_directory(const char *path)
+{
+ GList *list = NULL;
+
+ DIR *dp = opendir(path);
+ if (!dp)
+ {
+ /* We don't want to yell if, say, $HOME/.abrt/spool doesn't exist */
+ //perror_msg("Can't open directory '%s'", path);
+ return list;
+ }
+
+ struct dirent *dent;
+ while ((dent = readdir(dp)) != NULL)
+ {
+ if (dot_or_dotdot(dent->d_name))
+ continue; /* skip "." and ".." */
+
+ char *full_name = concat_path_file(path, dent->d_name);
+ struct stat statbuf;
+ if (stat(full_name, &statbuf) == 0 && S_ISDIR(statbuf.st_mode))
+ {
+ /* Silently ignore *any* errors, not only EACCES.
+ * We saw "lock file is locked by process PID" error
+ * when we raced with wizard.
+ */
+ int sv_logmode = logmode;
+ logmode = 0;
+ struct dump_dir *dd = dd_opendir(full_name, DD_OPEN_READONLY | DD_FAIL_QUIETLY_EACCES);
+ logmode = sv_logmode;
+ if (dd)
+ {
+ list = g_list_prepend(list, full_name);
+ full_name = NULL;
+ dd_close(dd);
+ }
+ }
+ free(full_name);
+ }
+ closedir(dp);
+
+ return g_list_reverse(list);
+}
+
+/* To test from command line:
+ * dbus-send --system --type=method_call --print-reply --dest=com.redhat.abrt \
+ * /com/redhat/abrt com.redhat.abrt.GetListOfProblems
+ */
+static int handle_GetListOfProblems(DBusMessage* call, DBusMessage* reply)
+{
+ DBusMessageIter out_iter;
+ dbus_message_iter_init_append(reply, &out_iter);
+
+ GList *list = scan_directory(g_settings_dump_location);
+
+ /* Store the array */
+ DBusMessageIter sub_iter;
+ if (!dbus_message_iter_open_container(&out_iter, DBUS_TYPE_ARRAY, "s", &sub_iter))
+ die_out_of_memory();
+ while (list)
+ {
+ store_string(&sub_iter, (char*)list->data);
+ free(list->data);
+ list = g_list_delete_link(list, list);
+ }
+ if (!dbus_message_iter_close_container(&out_iter, &sub_iter))
+ die_out_of_memory();
+
+ /* Send reply */
+ send_flush_and_unref(reply);
+ return 0;
+}
+
+/*
+ * Glib integration machinery
+ */
+
+/* Callback: "a message is received to a registered object path" */
+static DBusHandlerResult message_received(DBusConnection* conn, DBusMessage* msg, void* data)
+{
+ const char* member = dbus_message_get_member(msg);
+ VERB1 log("%s(method:'%s')", __func__, member);
+
+ //set_client_name(dbus_message_get_sender(msg));
+
+ DBusMessage* reply = dbus_message_new_method_return(msg);
+ int r = -1;
+ if (strcmp(member, "GetListOfProblems") == 0)
+ r = handle_GetListOfProblems(msg, reply);
+// NB: C++ binding also handles "Introspect" method, which returns a string.
+// It was sending "dummy" introspection answer whick looks like this:
+// "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
+// "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
+// "<node>\n"
+// "</node>\n"
+// Apart from a warning from abrt-gui, just sending error back works as well.
+// NB2: we may want to handle "Disconnected" here too.
+
+ if (r < 0)
+ {
+ /* handle_XXX experienced an error (and did not send any reply) */
+ dbus_message_unref(reply);
+ if (dbus_message_get_type(msg) == DBUS_MESSAGE_TYPE_METHOD_CALL)
+ {
+ /* Create and send error reply */
+ reply = dbus_message_new_error(msg, DBUS_ERROR_FAILED, "not supported");
+ if (!reply)
+ die_out_of_memory();
+ send_flush_and_unref(reply);
+ }
+ }
+
+ //set_client_name(NULL);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+static void handle_dbus_err(bool error_flag, DBusError *err)
+{
+ if (dbus_error_is_set(err))
+ {
+ error_msg("dbus error: %s", err->message);
+ /* dbus_error_free(&err); */
+ error_flag = true;
+ }
+ if (!error_flag)
+ return;
+ error_msg_and_die(
+ "Error requesting DBus name %s, possible reasons: "
+ "abrt run by non-root; dbus config is incorrect; "
+ "or dbus daemon needs to be restarted to reload dbus config",
+ ABRTD_DBUS_NAME);
+}
+
+static int init_dbus(void)
+{
+ DBusConnection* conn;
+ DBusError err;
+
+ dbus_error_init(&err);
+ VERB3 log("dbus_bus_get");
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+ handle_dbus_err(conn == NULL, &err);
+ // dbus api says:
+ // "If dbus_bus_get obtains a new connection object never before returned
+ // from dbus_bus_get(), it will call dbus_connection_set_exit_on_disconnect(),
+ // so the application will exit if the connection closes. You can undo this
+ // by calling dbus_connection_set_exit_on_disconnect() yourself after you get
+ // the connection."
+ // ...
+ // "When a connection is disconnected, you are guaranteed to get a signal
+ // "Disconnected" from the interface DBUS_INTERFACE_LOCAL, path DBUS_PATH_LOCAL"
+ //
+ // dbus-daemon drops connections if it recvs a malformed message
+ // (we actually observed this when we sent bad UTF-8 string).
+ // Currently, in this case abrtd just exits with exit code 1.
+ // (symptom: last two log messages are "abrtd: remove_watch()")
+ // If we want to have better logging or other nontrivial handling,
+ // here we need to do:
+ //
+ //dbus_connection_set_exit_on_disconnect(conn, FALSE);
+ //dbus_connection_add_filter(conn, handle_message, NULL, NULL);
+ //
+ // and need to code up handle_message to check for "Disconnected" dbus signal
+
+ /* Also sets g_dbus_conn to conn. */
+ attach_dbus_conn_to_glib_main_loop(conn, "/com/redhat/abrt", message_received);
+
+ VERB3 log("dbus_bus_request_name");
+ int rc = dbus_bus_request_name(conn, ABRTD_DBUS_NAME, DBUS_NAME_FLAG_REPLACE_EXISTING, &err);
+//maybe check that r == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER instead?
+ handle_dbus_err(rc < 0, &err);
+ VERB3 log("dbus init done");
+
+ /* dbus_bus_request_name can already read some data. For example,
+ * if we were autostarted, the call which caused autostart arrives
+ * at this moment. Thus while dbus fd hasn't any data anymore,
+ * dbus library can buffer a message or two.
+ * If we don't do this, the data won't be processed
+ * until next dbus data arrives.
+ */
+ int cnt = 10;
+ while (dbus_connection_dispatch(conn) != DBUS_DISPATCH_COMPLETE && --cnt)
+ VERB3 log("processed initial buffered dbus message");
+
+ return 0;
+}
+
+static void deinit_dbus(void)
+{
+ if (g_dbus_conn != NULL)
+ {
+ dbus_connection_unref(g_dbus_conn);
+ g_dbus_conn = NULL;
+ }
+}
+
+/*
+ * Signal pipe handling
+ */
+
+static void handle_signal(int signo)
+{
+ int save_errno = errno;
+
+ // Enable for debugging only, malloc/printf are unsafe in signal handlers
+ //VERB3 log("Got signal %d", signo);
+
+ uint8_t sig_caught;
+ s_sig_caught = sig_caught = signo;
+ /* Using local copy of s_sig_caught so that concurrent signal
+ * won't change it under us */
+ if (s_signal_pipe_write >= 0)
+ IGNORE_RESULT(write(s_signal_pipe_write, &sig_caught, 1));
+
+ errno = save_errno;
+}
+
+/* Signal pipe handler */
+static gboolean handle_signal_cb(GIOChannel *gio, GIOCondition condition, gpointer ptr_unused)
+{
+ uint8_t signo;
+ gsize len = 0;
+ g_io_channel_read(gio, (void*) &signo, 1, &len);
+ if (len == 1)
+ {
+ /* we did receive a signal */
+ VERB3 log("Got signal %d through signal pipe", signo);
+ s_exiting = 1;
+ }
+ return TRUE; /* "please don't remove this event" */
+}
+
+
+static void start_syslog_logging(void)
+{
+ /* Open stdin to /dev/null */
+ xmove_fd(xopen("/dev/null", O_RDWR), STDIN_FILENO);
+ /* We must not leave fds 0,1,2 closed.
+ * Otherwise fprintf(stderr) dumps messages into random fds, etc. */
+ xdup2(STDIN_FILENO, STDOUT_FILENO);
+ xdup2(STDIN_FILENO, STDERR_FILENO);
+ openlog(g_progname, 0, LOG_DAEMON);
+ logmode = LOGMODE_SYSLOG;
+ putenv((char*)"ABRT_SYSLOG=1");
+}
+
+/* Run main loop with idle timeout.
+ * Basically, almost like glib's g_main_run(loop)
+ */
+static void run_main_loop(GMainLoop *loop)
+{
+ time_t cur_time = time(NULL);
+ GMainContext *context = g_main_loop_get_context(loop);
+ int fds_size = 0;
+ GPollFD *fds = NULL;
+
+ while (!s_exiting)
+ {
+ gboolean some_ready;
+ gint max_priority;
+ gint timeout;
+ gint nfds;
+
+ some_ready = g_main_context_prepare(context, &max_priority);
+ if (some_ready)
+ g_main_context_dispatch(context);
+
+ while (1)
+ {
+ nfds = g_main_context_query(context, max_priority, &timeout, fds, fds_size);
+ if (nfds <= fds_size)
+ break;
+ fds_size = nfds + 16; /* +16: optimizing realloc frequency */
+ fds = (GPollFD *)xrealloc(fds, fds_size * sizeof(fds[0]));
+ }
+
+ if (s_timeout != 0)
+ alarm(s_timeout);
+ g_poll(fds, nfds, timeout);
+ if (s_timeout != 0)
+ alarm(0);
+
+ time_t new_time = time(NULL);
+ if (cur_time != new_time)
+ {
+ cur_time = new_time;
+ load_abrt_conf();
+//TODO: react to changes in g_settings_sWatchCrashdumpArchiveDir
+ }
+
+ some_ready = g_main_context_check(context, max_priority, fds, nfds);
+ if (some_ready)
+ g_main_context_dispatch(context);
+ }
+
+ free(fds);
+ g_main_context_unref(context);
+}
+
+int main(int argc, char** argv)
+{
+ abrt_init(argv);
+
+ int parent_pid = getpid();
+
+ setlocale(LC_ALL, "");
+
+#if ENABLE_NLS
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+#endif
+
+ const char *program_usage_string = _(
+ "& [options]"
+ );
+ enum {
+ OPT_v = 1 << 0,
+ OPT_d = 1 << 1,
+ OPT_s = 1 << 2,
+ OPT_t = 1 << 3,
+ };
+ /* Keep enum above and order of options below in sync! */
+ struct options program_options[] = {
+ OPT__VERBOSE(&g_verbose),
+ OPT_BOOL( 'd', NULL, NULL , _("Do not daemonize")),
+ OPT_BOOL( 's', NULL, NULL , _("Log to syslog even with -d")),
+ OPT_INTEGER('t', NULL, &s_timeout, _("Exit after SEC seconds of inactivity")),
+ OPT_END()
+ };
+ unsigned opts = parse_opts(argc, argv, program_options, program_usage_string);
+
+ export_abrt_envvars(0);
+
+ /* When dbus daemon starts us, it doesn't set PATH
+ * (I saw it set only DBUS_STARTER_ADDRESS and DBUS_STARTER_BUS_TYPE).
+ * In this case, set something sane:
+ */
+ const char *env_path = getenv("PATH");
+ if (!env_path || !env_path[0])
+ putenv((char*)"PATH=/usr/sbin:/usr/bin:/sbin:/bin");
+
+ unsetenv("ABRT_SYSLOG");
+ msg_prefix = g_progname; /* for log(), error_msg() and such */
+
+ if (getuid() != 0)
+ error_msg_and_die("Must be run as root");
+
+ if (opts & OPT_s)
+ start_syslog_logging();
+
+ xpipe(s_signal_pipe);
+ close_on_exec_on(s_signal_pipe[0]);
+ close_on_exec_on(s_signal_pipe[1]);
+ ndelay_on(s_signal_pipe[0]); /* I/O should not block - */
+ ndelay_on(s_signal_pipe[1]); /* especially writes! they happen in signal handler! */
+ signal(SIGTERM, handle_signal);
+ signal(SIGINT, handle_signal);
+ if (s_timeout != 0)
+ signal(SIGALRM, handle_signal);
+
+ /* Daemonize unless -d */
+ if (!(opts & OPT_d))
+ {
+ /* forking to background */
+ pid_t pid = fork();
+ if (pid < 0)
+ {
+ perror_msg_and_die("fork");
+ }
+ if (pid > 0)
+ {
+ /* Parent */
+ /* Wait for child to notify us via SIGTERM that it feels ok */
+ int i = 20; /* 2 sec */
+ while (s_sig_caught == 0 && --i)
+ {
+ usleep(100 * 1000);
+ }
+ if (s_sig_caught == SIGTERM)
+ {
+ exit(0);
+ }
+ if (s_sig_caught)
+ {
+ error_msg_and_die("Failed to start: got sig %d", s_sig_caught);
+ }
+ error_msg_and_die("Failed to start: timeout waiting for child");
+ }
+ /* Child (daemon) continues */
+ setsid(); /* never fails */
+ if (g_verbose == 0 && logmode != LOGMODE_SYSLOG)
+ start_syslog_logging();
+ }
+
+ GMainLoop *pMainloop = NULL;
+ GIOChannel *channel_signal = NULL;
+ guint channel_signal_event_id = 0;
+
+ /* Initialization */
+
+ VERB1 log("Loading settings");
+ if (load_abrt_conf() != 0)
+ goto init_error;
+
+ VERB1 log("Creating glib main loop");
+ pMainloop = g_main_loop_new(NULL, FALSE);
+
+ /* Add an event source which waits for INT/TERM signal */
+ VERB1 log("Adding signal pipe watch to glib main loop");
+ channel_signal = g_io_channel_unix_new(s_signal_pipe[0]);
+ channel_signal_event_id = g_io_add_watch(channel_signal,
+ G_IO_IN,
+ handle_signal_cb,
+ NULL);
+
+ /* Note: this already may process a few dbus messages,
+ * therefore it should be the last thing to initialize.
+ */
+ VERB1 log("Initializing dbus");
+ if (init_dbus() != 0)
+ goto init_error;
+
+ /* Inform parent that we initialized ok */
+ if (!(opts & OPT_d))
+ {
+ VERB1 log("Signalling parent");
+ kill(parent_pid, SIGTERM);
+ if (logmode != LOGMODE_SYSLOG)
+ start_syslog_logging();
+ }
+
+ /* Only now we want signal pipe to work */
+ s_signal_pipe_write = s_signal_pipe[1];
+
+ /* Enter the event loop */
+ log("Init complete, entering main loop");
+ run_main_loop(pMainloop);
+
+ cleanup:
+ /* Error or INT/TERM. Clean up, in reverse order.
+ * Take care to not undo things we did not do.
+ */
+
+ if (channel_signal_event_id > 0)
+ g_source_remove(channel_signal_event_id);
+ if (channel_signal)
+ g_io_channel_unref(channel_signal);
+
+ deinit_dbus();
+
+ if (pMainloop)
+ g_main_loop_unref(pMainloop);
+
+ free_abrt_conf_data();
+
+ /* Exiting */
+ if (s_sig_caught && s_sig_caught != SIGALRM)
+ {
+ error_msg("Got signal %d, exiting", s_sig_caught);
+ signal(s_sig_caught, SIG_DFL);
+ raise(s_sig_caught);
+ }
+ error_msg_and_die("Exiting");
+
+ init_error:
+ /* Initialization error */
+ error_msg("Error while initializing daemon");
+ /* Inform parent that initialization failed */
+ if (!(opts & OPT_d))
+ kill(parent_pid, SIGINT);
+ goto cleanup;
+}
diff -x '*.po' -d -urpN abrt.5/src/daemon/abrtd.c abrt.6/src/daemon/abrtd.c
--- abrt.5/src/daemon/abrtd.c 2011-11-22 15:19:16.114879567 +0100
+++ abrt.6/src/daemon/abrtd.c 2011-11-23 18:00:51.000000000 +0100
@@ -625,9 +625,6 @@ int main(int argc, char** argv)
textdomain(PACKAGE);
#endif
- if (getuid() != 0)
- error_msg_and_die("ABRT daemon must be run as root");
-
const char *program_usage_string = _(
"& [options]"
);
@@ -663,6 +660,10 @@ int main(int argc, char** argv)
unsetenv("ABRT_SYSLOG");
msg_prefix = g_progname; /* for log(), error_msg() and such */
+
+ if (getuid() != 0)
+ error_msg_and_die("Must be run as root");
+
if (opts & OPT_s)
start_syslog_logging();
diff -x '*.po' -d -urpN abrt.5/src/daemon/com.redhat.abrt.service abrt.6/src/daemon/com.redhat.abrt.service
--- abrt.5/src/daemon/com.redhat.abrt.service 1970-01-01 01:00:00.000000000 +0100
+++ abrt.6/src/daemon/com.redhat.abrt.service 2011-11-23 18:21:07.419365798 +0100
@@ -0,0 +1,7 @@
+[D-BUS Service]
+Name=com.redhat.abrt
+# For testing, you may use -t5 to use small timeout of 5 seconds.
+# This will make "abrtd exited while clients existed but were idle"
+# situations easier to trigger
+Exec=/usr/sbin/abrt-dbus -ds -t133
+User=root
diff -x '*.po' -d -urpN abrt.5/src/daemon/dbus-abrt.conf abrt.6/src/daemon/dbus-abrt.conf
--- abrt.5/src/daemon/dbus-abrt.conf 1970-01-01 01:00:00.000000000 +0100
+++ abrt.6/src/daemon/dbus-abrt.conf 2011-11-23 14:00:35.490125072 +0100
@@ -0,0 +1,25 @@
+<!-- This configuration file specifies the required security policies
+ for abrt core daemon to work. -->
+
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+
+ <!-- ../system.conf have denied everything, so we just punch some holes -->
+
+ <policy user="root">
+ <allow own="com.redhat.abrt"/>
+ <allow send_destination="com.redhat.abrt"/>
+ <allow send_interface="com.redhat.abrt"/>
+ </policy>
+
+ <policy at_console="true">
+ <allow send_destination="com.redhat.abrt"/>
+ </policy>
+
+ <!-- Allow anyone to invoke methods on abrt server -->
+ <policy context="default">
+ <allow send_destination="com.redhat.abrt"/>
+ </policy>
+
+</busconfig>
diff -x '*.po' -d -urpN abrt.5/src/daemon/Makefile.am abrt.6/src/daemon/Makefile.am
--- abrt.5/src/daemon/Makefile.am 2011-11-11 18:51:03.078185060 +0100
+++ abrt.6/src/daemon/Makefile.am 2011-11-23 18:11:16.293630447 +0100
@@ -11,7 +11,8 @@ bin_PROGRAMS = \
sbin_PROGRAMS = \
abrtd \
- abrt-server
+ abrt-server \
+ abrt-dbus
libexec_PROGRAMS = abrt-handle-event
@@ -43,6 +44,24 @@ abrt_server_LDADD = \
../lib/libabrt.la \
$(LIBREPORT_LIBS)
+abrt_dbus_SOURCES = \
+ abrt-dbus.c
+abrt_dbus_CPPFLAGS = \
+ -I$(srcdir)/../include \
+ -I$(srcdir)/../lib \
+ -DVAR_RUN=\"$(VAR_RUN)\" \
+ $(GLIB_CFLAGS) \
+ $(DBUS_CFLAGS) \
+ $(LIBREPORT_CFLAGS) \
+ -D_GNU_SOURCE \
+ -Wall -Wwrite-strings \
+ -Werror
+abrt_dbus_LDADD = \
+ $(DBUS_LIBS) \
+ ../lib/libabrt.la \
+ $(LIBREPORT_LIBS) \
+ -labrt_dbus
+
abrt_handle_event_SOURCES = \
abrt-handle-event.c
abrt_handle_event_CPPFLAGS = \
@@ -72,12 +91,17 @@ abrt_action_save_package_data_LDADD = \
$(LIBREPORT_LIBS) \
../lib/libabrt.la
+dbusabrtconfdir = ${sysconfdir}/dbus-1/system.d/
+dist_dbusabrtconf_DATA = dbus-abrt.conf
+
daemonconfdir = $(CONF_DIR)
dist_daemonconf_DATA = \
abrt.conf \
abrt-action-save-package-data.conf \
gpg_keys
+comredhatabrtservicedir = ${datadir}/dbus-1/system-services
+dist_comredhatabrtservice_DATA = com.redhat.abrt.service
EXTRA_DIST = abrt-handle-upload
DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
12 years, 7 months