getting infos about crash, deleting dump dirs and invoking reporting belongs to abrt.git (abrt-gui does it too)
abrt-cli uses commands now instead of switches for main purpose like deleting, reporting and getting information about crash.
second steps will be to add aliases for commands. If aliases won't be set for commands, then abbreviation for commands comes to play.
Usage string for abrt-cli: abrt-cli [--version] [--base-dir=DUMP_DIR] <command> [<args>]
--base-dir - change base dir for dump directories --version - print out version and die
commands are: list rm report
Each command can take it's own arguments.
list command ------------ Usage: abrt-cli list [options] [<dump-dir>]...
-v, --verbose Be verbose
-f, --full List even reported problems -d, --detailed Show detailed report
Maybe option --detail is better then --detailed
rm command ---------- Usage: abrt-cli rm [options] [<dump-dir>]...
-v, --verbose Be verbose
note that you can do abrt-cli rm /path/to/base/dir/cpp-* so wildcard is working out of box
report command -------------- Usage: abrt-cli report [options] [<dump-dir>]...
-v, --verbose Be verbose
simply invoke report_problem_in_dir
Signed-off-by: Nikola Pajkovsky npajkovs@redhat.com --- .gitignore | 1 + abrt.spec.in | 4 +- configure.ac | 1 + src/Makefile.am | 2 +- src/cli/Makefile.am | 25 +++++ src/cli/abrt-cli.c | 144 +++++++++++++++++++++++++++++ src/cli/builtin-cmd.h | 28 ++++++ src/cli/list.c | 242 +++++++++++++++++++++++++++++++++++++++++++++++++ src/cli/report.c | 43 +++++++++ src/cli/rm.c | 53 +++++++++++ 10 files changed, 540 insertions(+), 3 deletions(-) create mode 100644 src/cli/Makefile.am create mode 100644 src/cli/abrt-cli.c create mode 100644 src/cli/builtin-cmd.h create mode 100644 src/cli/list.c create mode 100644 src/cli/report.c create mode 100644 src/cli/rm.c
diff --git a/.gitignore b/.gitignore index 745cb02..a60e543 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ src/hooks/abrt_exception_handler.py src/hooks/abrt-hook-ccpp src/applet/abrt-applet.desktop src/gui-gtk/abrt.desktop +src/cli/abrt-cli
# cscope files cscope.* diff --git a/abrt.spec.in b/abrt.spec.in index 00e37d4..3334b70 100644 --- a/abrt.spec.in +++ b/abrt.spec.in @@ -185,8 +185,6 @@ mkdir -p $RPM_BUILD_ROOT/var/cache/abrt-di mkdir -p $RPM_BUILD_ROOT/var/run/abrt mkdir -p $RPM_BUILD_ROOT/var/spool/abrt mkdir -p $RPM_BUILD_ROOT/var/spool/abrt-upload -# compat before we split abrt-cli and report-cli -ln -s %{_bindir}/report-cli $RPM_BUILD_ROOT/%{_bindir}/abrt-cli
desktop-file-install \ --dir ${RPM_BUILD_ROOT}%{_datadir}/applications \ @@ -429,6 +427,8 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : %files cli %defattr(-,root,root,-) %{_bindir}/abrt-cli +# provide asap +#% {_mandir}/man1/report-cli.1.gz
%files desktop %defattr(-,root,root,-) diff --git a/configure.ac b/configure.ac index 1726093..8de55d2 100644 --- a/configure.ac +++ b/configure.ac @@ -138,6 +138,7 @@ AC_CONFIG_FILES([ src/hooks/Makefile src/applet/Makefile src/gui-gtk/Makefile + src/cli/Makefile po/Makefile.in icons/Makefile ]) diff --git a/src/Makefile.am b/src/Makefile.am index b41b939..ab95ef7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1 +1 @@ -SUBDIRS = include lib hooks daemon applet gui-gtk plugins +SUBDIRS = include lib hooks daemon applet gui-gtk plugins cli diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am new file mode 100644 index 0000000..c5ebc14 --- /dev/null +++ b/src/cli/Makefile.am @@ -0,0 +1,25 @@ +-include ../../config.mak + +bin_PROGRAMS = abrt-cli + +CLI_C = +CLI_C += abrt-cli.c + +BUILTIN_C = +BUILTIN_C += list.c +BUILTIN_C += rm.c +BUILTIN_C += report.c + +abrt_cli_SOURCES = $(CLI_C) $(BUILTIN_C) builtin-cmd.h + +abrt_cli_CFLAGS = \ + -I$(srcdir)/../include \ + -I$(srcdir)/../lib \ + -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ + $(LIBREPORT_CFLAGS) \ + -Wwrite-strings -Werror + +abrt_cli_LDADD = \ + $(LIBREPORT_LIBS) + +DEFS = -DLOCALEDIR="$(localedir)" @DEFS@ diff --git a/src/cli/abrt-cli.c b/src/cli/abrt-cli.c new file mode 100644 index 0000000..ebc1620 --- /dev/null +++ b/src/cli/abrt-cli.c @@ -0,0 +1,144 @@ +/* + 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 "abrtlib.h" +#include "builtin-cmd.h" + +#define USAGE_OPTS_WIDTH 12 +#define USAGE_GAP 2 + +/* TODO: add --pager(default) and --no-pager */ + +const char abrt_cli_usage_string[] = + "abrt-cli [--version] <command> [<args>]"; + +struct cmd_struct { + const char *cmd; + int (*fn)(int, const char **); + const char *help; +}; + +static void list_cmds_help(const struct cmd_struct *commands) +{ + for (const struct cmd_struct *p = commands; p->cmd; ++p) + { + size_t pos; + int pad; + + pos = fprintf(stderr, " "); + pos += fprintf(stderr, "%s", p->cmd); + + if (pos <= USAGE_OPTS_WIDTH) + pad = USAGE_OPTS_WIDTH - pos; + else + { + fputc('\n', stderr); + pad = USAGE_OPTS_WIDTH; + } + + fprintf(stderr, "%*s%s\n", pad + USAGE_GAP, "", p->help); + } +} + +static void handle_internal_options(int *argc, const char ***argv) +{ + while (*argc > 0) + { + const char *cmd = (*argv)[0]; + if (cmd[0] != '-') + break; + + if (strcmp(cmd, "--version") == 0) + { + puts(PACKAGE_VERSION); + exit(0); + } +#if 0 + else if (prefixcmp(cmd, "--base-dir=") == 0) + D_list = g_list_append(D_list, xstrdup(cmd + strlen("--base-dir="))); + else if (prefixcmp(cmd, "--list-events") == 0) + { + const char *pfx = cmd + strlen("--list-events"); + if (pfx && *pfx) + pfx += 1; /* skip '=' */ + + char *events = list_possible_events(NULL, dump_dir_name, pfx); + if (!events) + exit(1); /* error msg is already logged */ + + fputs(events, stdout); + free(events); + + exit(0); + } +#endif + else + error_msg_and_die("usage: %s", abrt_cli_usage_string); + + (*argv)++; + (*argc)--; + } +} + +static void handle_internal_command(int argc, const char **argv, + const struct cmd_struct *commands) +{ + const char *cmd = argv[0]; + + for (const struct cmd_struct *p = commands; p->cmd; ++p) + { + if (strcmp(p->cmd, cmd)) + continue; + + exit(p->fn(argc, argv)); + } +} + +int main(int argc, const char **argv) +{ + abrt_init((char **)argv); + + setlocale(LC_ALL, ""); +#if ENABLE_NLS + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); +#endif + + argv++; + argc--; + + const struct cmd_struct commands[] = { + {"list", cmd_list, _("List not yet reported problems")}, + {"rm", cmd_rm, _("Remove files from problem directory")}, + {"report", cmd_report, _("Analyze and report problem data in problem directory")}, + {"info", cmd_info, _("Print information about DUMP_DIR")}, + {NULL, NULL, NULL} + }; + + handle_internal_options(&argc, &argv); + if (argc > 0) + handle_internal_command(argc, argv, commands); + + /* user didn't specify command; print out help */ + printf("%s\n\n", abrt_cli_usage_string); + list_cmds_help(commands); + printf("\n%s\n", _("See 'abrt-cli <command> -h' for more information")); + + return 0; +} diff --git a/src/cli/builtin-cmd.h b/src/cli/builtin-cmd.h new file mode 100644 index 0000000..cea77d8 --- /dev/null +++ b/src/cli/builtin-cmd.h @@ -0,0 +1,28 @@ +/* + 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. +*/ + +#ifndef _BUILTIN_CMD_H_ +#define _BUILTIN_CMD_H_ + +extern int cmd_list(int argc, const char **argv); +extern int cmd_rm(int argc, const char **argv); +extern int cmd_report(int argc, const char **argv); +extern int cmd_info(int argc, const char **argv); + +#endif /* _BUILTIN-CMD_H_ */ diff --git a/src/cli/list.c b/src/cli/list.c new file mode 100644 index 0000000..833b4c7 --- /dev/null +++ b/src/cli/list.c @@ -0,0 +1,242 @@ +/* + 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 "abrtlib.h" +#include "builtin-cmd.h" + +/* TODO: npajkovs + * add --since + * add --until + * add --pretty=oneline|raw|normal|format="%a %b %c" + * add wildcard e.g. *-2011-04-01-10-* (list all problems in specific day) + * + * TODO?: remove base dir from list of crashes? is there a way that same crash can be in + * ~/.abrt/spool and /var/spool/abrt? needs more _meditation_. + */ + +/* Vector of problems: */ +/* problem_data_vector[i] = { "name" = { "content", CD_FLAG_foo_bits } } */ +typedef GPtrArray vector_of_problem_data_t; + +static inline problem_data_t *get_problem_data(vector_of_problem_data_t *vector, unsigned i) +{ + return (problem_data_t *)g_ptr_array_index(vector, i); +} + +static void free_vector_of_problem_data(vector_of_problem_data_t *vector) +{ + if (vector) + g_ptr_array_free(vector, TRUE); +} + +static vector_of_problem_data_t *new_vector_of_problem_data(void) +{ + return g_ptr_array_new_with_free_func((void (*)(void*)) &free_problem_data); +} + +static problem_data_t *fill_crash_info(const char *dump_dir_name) +{ + int sv_logmode = logmode; + logmode = 0; /* suppress EPERM/EACCES errors in opendir */ + struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ DD_OPEN_READONLY); + logmode = sv_logmode; + + if (!dd) + return NULL; + + problem_data_t *problem_data = create_problem_data_from_dump_dir(dd); + dd_close(dd); + add_to_problem_data_ext(problem_data, CD_DUMPDIR, dump_dir_name, + CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE + CD_FLAG_LIST); + + return problem_data; +} + +static void get_all_crash_infos(vector_of_problem_data_t *retval, const char *dir_name) +{ + VERB1 log("Loading dumps from '%s'", dir_name); + + DIR *dir = opendir(dir_name); + if (dir != NULL) + { + struct dirent *dent; + while ((dent = readdir(dir)) != NULL) + { + if (dot_or_dotdot(dent->d_name)) + continue; /* skip "." and ".." */ + + char *dump_dir_name = concat_path_file(dir_name, dent->d_name); + + struct stat statbuf; + if (stat(dump_dir_name, &statbuf) == 0 + && S_ISDIR(statbuf.st_mode)) + { + problem_data_t *problem_data = fill_crash_info(dump_dir_name); + if (problem_data) + g_ptr_array_add(retval, problem_data); + } + free(dump_dir_name); + } + closedir(dir); + } +} + +/** Prints basic information about a crash to stdout. */ +static void print_crash(problem_data_t *problem_data, int detailed) +{ + if (!problem_data) + return; + + char *desc; + if (detailed) + { + int show_multiline = (detailed ? MAKEDESC_SHOW_MULTILINE : 0); + desc = make_description(problem_data, + /*names_to_skip:*/ NULL, + /*max_text_size:*/ CD_TEXT_ATT_SIZE, + MAKEDESC_SHOW_FILES | show_multiline); + } + else + { + desc = make_description(problem_data, + /*names_to_skip:*/ NULL, + /*max_text_size:*/ CD_TEXT_ATT_SIZE, + MAKEDESC_SHOW_ONLY_LIST); + } + fprintf(stdout, "%s", desc); + free(desc); +} + +/** + * Prints a list containing "crashes" to stdout. + * @param include_reported + * Do not skip entries marked as already reported. + */ +static void print_crash_list(vector_of_problem_data_t *crash_list, int include_reported, + int detailed) +{ + unsigned i; + for (i = 0; i < crash_list->len; ++i) + { + problem_data_t *crash = get_problem_data(crash_list, i); + if (!include_reported) + { + const char *msg = get_problem_item_content_or_NULL(crash, FILENAME_REPORTED_TO); + if (msg) + continue; + } + print_crash(crash, detailed); + if (i != crash_list->len - 1) + printf("\n"); + } +} + +int cmd_list(int argc, const char **argv) +{ + const char *program_usage_string = _( + "\b list [options] [<dump-dir>]..." + ); + + static int opt_full, opt_detailed; + struct options program_options[] = { + OPT__VERBOSE(&g_verbose), + OPT_GROUP(""), + OPT_BOOL('f', "full" , &opt_full, _("List even reported problems")), + /* deprecate -d option with --pretty=full*/ + OPT_BOOL('d', "detailed" , &opt_detailed, _("Show detailed report")), + OPT_END() + }; + + parse_opts(argc, (char **)argv, program_options, program_usage_string); + + GList *D_list = NULL; + if (optind < argc) + while (optind < argc) + D_list = g_list_append(D_list, xstrdup(argv[optind++])); + + if (!D_list) + { + char *home = getenv("HOME"); + if (home) + D_list = g_list_append(D_list, concat_path_file(home, ".abrt/spool")); + D_list = g_list_append(D_list, xstrdup((void*)DEBUG_DUMPS_DIR)); + } + + VERB2 + { + log("Base directory"); + for (GList *li = D_list; li; li = li->next) + log("\t %s", (char *) li->data); + } + + vector_of_problem_data_t *ci = new_vector_of_problem_data(); + while (D_list) + { + char *dir = (char *)D_list->data; + get_all_crash_infos(ci, dir); + D_list = g_list_remove(D_list, dir); + free(dir); + } + print_crash_list(ci, opt_full, opt_detailed); + free_vector_of_problem_data(ci); + g_list_free(D_list); + + return 0; +} + +int cmd_info(int argc, const char **argv) +{ + const char *program_usage_string = _( + "\b info [options] [<dump-dir>]..." + ); + + static int opt_detailed; + struct options program_options[] = { + OPT__VERBOSE(&g_verbose), + OPT_GROUP(""), + /* deprecate -d option with --pretty=full*/ + OPT_BOOL('d', "detailed" , &opt_detailed, _("Show detailed report")), + OPT_END() + }; + + parse_opts(argc, (char **)argv, program_options, program_usage_string); + + if (optind < argc) + { + while (optind < argc) + { + const char *dump_dir = argv[optind++]; + problem_data_t *problem = fill_crash_info(dump_dir); + if (!problem) + { + error_msg("no such problem directory '%s'", dump_dir); + continue; + } + print_crash(problem, opt_detailed); + free_problem_data(problem); + if (optind - argc) + printf("\n"); + } + exit(0); + } + + show_usage_and_die(program_usage_string, program_options); + + return 0; +} diff --git a/src/cli/report.c b/src/cli/report.c new file mode 100644 index 0000000..1d2ffbc --- /dev/null +++ b/src/cli/report.c @@ -0,0 +1,43 @@ +/* + 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 "abrtlib.h" +#include "builtin-cmd.h" + +int cmd_report(int argc, const char **argv) +{ + const char *program_usage_string = _( + "\b report [options] [<dump-dir>]..." + ); + + struct options program_options[] = { + OPT__VERBOSE(&g_verbose), + OPT_END() + }; + + parse_opts(argc, (char **)argv, program_options, program_usage_string); + if (optind < argc) + while (optind < argc) + report_problem_in_dir(argv[optind++], + LIBREPORT_ANALYZE | LIBREPORT_NOWAIT); + + show_usage_and_die(program_usage_string, program_options); + + return 0; +} diff --git a/src/cli/rm.c b/src/cli/rm.c new file mode 100644 index 0000000..eac01af --- /dev/null +++ b/src/cli/rm.c @@ -0,0 +1,53 @@ +/* + 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 "abrtlib.h" +#include "builtin-cmd.h" + +/* TODO npajkovs: + * add -n, --dry-run + * add -q, --quite + */ + +int cmd_rm(int argc, const char **argv) +{ + const char *program_usage_string = _( + "\b rm [options] [<dump-dir>]..." + ); + + struct options program_options[] = { + OPT__VERBOSE(&g_verbose), + OPT_END() + }; + + parse_opts(argc, (char **)argv, program_options, program_usage_string); + if (optind < argc) + { + int status; + while (optind < argc) + { + const char *rm_dir = argv[optind++]; + status = delete_dump_dir_possibly_using_abrtd(rm_dir); + if (!status) + log("rm '%s'", rm_dir); + } + } + + return 0; +}
Signed-off-by: Nikola Pajkovsky npajkovs@redhat.com --- configure.ac | 7 --- src/applet/Makefile.am | 1 - src/cli/Makefile.am | 4 +- src/cli/list.c | 4 +- src/daemon/Makefile.am | 3 - src/daemon/abrt-server.c | 21 +++++++--- src/daemon/abrt.conf | 5 ++ src/daemon/abrtd.c | 24 ++++++----- src/gui-gtk/Makefile.am | 4 +- src/gui-gtk/main.c | 5 +- src/hooks/Makefile.am | 1 - src/hooks/abrt-hook-ccpp.c | 85 +++++++++++++++++--------------------- src/hooks/abrt-install-ccpp-hook | 4 +- src/lib/Makefile.am | 7 --- src/lib/abrt_conf.c | 14 ++++++- src/lib/abrt_conf.h | 2 + src/lib/hooklib.c | 9 ++-- src/lib/hooklib.h | 2 +- src/plugins/Makefile.am | 7 --- 19 files changed, 104 insertions(+), 105 deletions(-)
diff --git a/configure.ac b/configure.ac index 8de55d2..cb15a1d 100644 --- a/configure.ac +++ b/configure.ac @@ -94,14 +94,8 @@ PLUGINS_LIB_DIR='${libdir}/${PACKAGE_NAME}' ENABLE_SOCKET_OR_DBUS='-DENABLE_DBUS=1' LIBEXEC_DIR='${libexecdir}'
-DEBUG_DUMPS_DIR='${localstatedir}/spool/${PACKAGE_NAME}' DEBUG_INFO_DIR='${localstatedir}/cache/${PACKAGE_NAME}-di'
-AC_ARG_WITH(debugdumpsdir, - [AS_HELP_STRING([--with-debugdumpdir=DIR], - [Directory where debugdumps are created])], - [DEBUG_DUMPS_DIR="$withval"]) - AC_ARG_WITH(debuginfosdir, [AS_HELP_STRING([--with-debuginfodir=DIR], [Directory where debuginfo is stored])], @@ -114,7 +108,6 @@ AC_SUBST(REPORT_PLUGINS_CONF_DIR) AC_SUBST(EVENTS_CONF_DIR) AC_SUBST(EVENTS_DIR) AC_SUBST(PLUGINS_LIB_DIR) -AC_SUBST(DEBUG_DUMPS_DIR) AC_SUBST(DEBUG_INFO_DIR) AC_SUBST(LIBEXEC_DIR)
diff --git a/src/applet/Makefile.am b/src/applet/Makefile.am index db5266d..247bee2 100644 --- a/src/applet/Makefile.am +++ b/src/applet/Makefile.am @@ -9,7 +9,6 @@ abrt_applet_CPPFLAGS = \ -DBIN_DIR="$(bindir)" \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ - -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \ -DICON_DIR="${datadir}/abrt/icons/hicolor/48x48/status" \ diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am index c5ebc14..bbd1402 100644 --- a/src/cli/Makefile.am +++ b/src/cli/Makefile.am @@ -15,11 +15,11 @@ abrt_cli_SOURCES = $(CLI_C) $(BUILTIN_C) builtin-cmd.h abrt_cli_CFLAGS = \ -I$(srcdir)/../include \ -I$(srcdir)/../lib \ - -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ $(LIBREPORT_CFLAGS) \ -Wwrite-strings -Werror
abrt_cli_LDADD = \ - $(LIBREPORT_LIBS) + $(LIBREPORT_LIBS) \ + ../lib/libabrt.la
DEFS = -DLOCALEDIR="$(localedir)" @DEFS@ diff --git a/src/cli/list.c b/src/cli/list.c index 833b4c7..e4f30fe 100644 --- a/src/cli/list.c +++ b/src/cli/list.c @@ -170,13 +170,15 @@ int cmd_list(int argc, const char **argv) while (optind < argc) D_list = g_list_append(D_list, xstrdup(argv[optind++]));
+ load_abrt_conf(); if (!D_list) { char *home = getenv("HOME"); if (home) D_list = g_list_append(D_list, concat_path_file(home, ".abrt/spool")); - D_list = g_list_append(D_list, xstrdup((void*)DEBUG_DUMPS_DIR)); + D_list = g_list_append(D_list, xstrdup(g_settings_dump_location)); } + free_abrt_conf_data();
VERB2 { diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am index 18d41b6..9770e56 100644 --- a/src/daemon/Makefile.am +++ b/src/daemon/Makefile.am @@ -23,7 +23,6 @@ abrtd_CPPFLAGS = \ -DBIN_DIR="$(bindir)" \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ - -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \ @@ -47,7 +46,6 @@ abrt_server_CPPFLAGS = \ -DBIN_DIR="$(bindir)" \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ - -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \ @@ -69,7 +67,6 @@ abrt_action_save_package_data_CPPFLAGS = \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ -DLOCALSTATEDIR='"$(localstatedir)"' \ - -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \ diff --git a/src/daemon/abrt-server.c b/src/daemon/abrt-server.c index 8153ad6..78e4ebd 100644 --- a/src/daemon/abrt-server.c +++ b/src/daemon/abrt-server.c @@ -100,7 +100,8 @@ static int create_debug_dump() This directory is renamed to final directory name after all files have been stored into it. */ - char *path = xasprintf(DEBUG_DUMPS_DIR"/%s-%s-%u.new", + char *path = xasprintf("%s/%s-%s-%u.new", + g_settings_dump_location, dir_basename, iso_date_string(NULL), pid); @@ -150,8 +151,8 @@ static int create_debug_dump() */ unsigned maxsize = g_settings_nMaxCrashReportsSize + g_settings_nMaxCrashReportsSize / 4; maxsize |= 63; - check_free_space(maxsize); - trim_debug_dumps(DEBUG_DUMPS_DIR, maxsize * (double)(1024*1024), path); + check_free_space(maxsize, g_settings_dump_location); + trim_debug_dumps(g_settings_dump_location, maxsize * (double)(1024*1024), path); }
free(path); @@ -162,15 +163,19 @@ static int create_debug_dump() /* Remove dump dir */ static int delete_path(const char *dump_dir_name) { - /* If doesn't start with "DEBUG_DUMPS_DIR/"... */ - if (strncmp(dump_dir_name, DEBUG_DUMPS_DIR"/", strlen(DEBUG_DUMPS_DIR"/")) != 0 + /* If doesn't start with "g_settings_dump_location/"... */ + char *dump_location = xasprintf("%s/", g_settings_dump_location); + log("%s", dump_location); + if (strncmp(dump_dir_name, dump_location, strlen(dump_location)) != 0 /* or contains "/." anywhere (-> might contain ".." component) */ - || strstr(dump_dir_name + strlen(DEBUG_DUMPS_DIR), "/.") + || strstr(dump_dir_name + strlen(g_settings_dump_location), "/.") ) { /* Then refuse to operate on it (someone is attacking us??) */ error_msg("Bad dump directory name '%s', not deleting", dump_dir_name); + free(dump_location); return 400; /* Bad Request */ } + free(dump_location);
struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0); if (!dd) @@ -491,10 +496,14 @@ int main(int argc, char **argv) client_uid = cr.uid; }
+ load_abrt_conf(); + int r = perform_http_xact(); if (r == 0) r = 200;
+ free_abrt_conf_data(); + printf("HTTP/1.1 %u \r\n\r\n", r);
return (r >= 400); /* Error if 400+ */ diff --git a/src/daemon/abrt.conf b/src/daemon/abrt.conf index c9a4333..e3820f2 100644 --- a/src/daemon/abrt.conf +++ b/src/daemon/abrt.conf @@ -8,3 +8,8 @@ # Max size for crash storage [MiB] or 0 for unlimited # MaxCrashReportsSize = 1000 + +# Specify where you want to store coredumps and all files which are needed for +# reporting. (default:/var/spool/abrt) +# +#DumpLocation = /var/spool/abrt diff --git a/src/daemon/abrtd.c b/src/daemon/abrtd.c index 853d78f..d7b3f0e 100644 --- a/src/daemon/abrtd.c +++ b/src/daemon/abrtd.c @@ -290,7 +290,7 @@ static int is_crash_a_dup(const char *dump_dir_name, void *param)
/* Scan crash dumps looking for a dup */ //TODO: explain why this is safe wrt concurrent runs - DIR *dir = opendir(DEBUG_DUMPS_DIR); + DIR *dir = opendir(g_settings_dump_location); if (dir != NULL) { struct dirent *dent; @@ -301,7 +301,7 @@ static int is_crash_a_dup(const char *dump_dir_name, void *param)
int different; char *uid, *uuid; - char *dump_dir_name2 = concat_path_file(DEBUG_DUMPS_DIR, dent->d_name); + char *dump_dir_name2 = concat_path_file(g_settings_dump_location, dent->d_name);
if (strcmp(dump_dir_name, dump_dir_name2) == 0) goto next; /* we are never a dup of ourself */ @@ -521,7 +521,8 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin if (fork() == 0) { xchdir(dir); - execlp("abrt-handle-upload", "abrt-handle-upload", DEBUG_DUMPS_DIR, dir, name, (char*)NULL); + execlp("abrt-handle-upload", "abrt-handle-upload", + g_settings_dump_location, dir, name, (char*)NULL); error_msg_and_die("Can't execute '%s'", "abrt-handle-upload"); } } @@ -546,13 +547,14 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin { char *worst_dir = NULL; while (g_settings_nMaxCrashReportsSize > 0 - && get_dirsize_find_largest_dir(DEBUG_DUMPS_DIR, &worst_dir, name) / (1024*1024) >= g_settings_nMaxCrashReportsSize + && get_dirsize_find_largest_dir(g_settings_dump_location, &worst_dir, name) / (1024*1024) >= g_settings_nMaxCrashReportsSize && worst_dir ) { - log("Size of '%s' >= %u MB, deleting '%s'", DEBUG_DUMPS_DIR, g_settings_nMaxCrashReportsSize, worst_dir); + log("Size of '%s' >= %u MB, deleting '%s'", + g_settings_dump_location, g_settings_nMaxCrashReportsSize, worst_dir); send_dbus_sig_QuotaExceeded(_("The size of the report exceeded the quota. Please check system's MaxCrashReportsSize value in abrt.conf.")); /* deletes both directory and DB record */ - char *d = concat_path_file(DEBUG_DUMPS_DIR, worst_dir); + char *d = concat_path_file(g_settings_dump_location, worst_dir); free(worst_dir); worst_dir = NULL; delete_dump_dir(d); @@ -562,7 +564,7 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin
char *fullname = NULL; problem_data_t *problem_data = NULL; - fullname = concat_path_file(DEBUG_DUMPS_DIR, name); + fullname = concat_path_file(g_settings_dump_location, name); mw_result_t res = LoadDebugDump(fullname, &problem_data); const char *first = problem_data ? get_problem_item_content_or_NULL(problem_data, CD_DUMPDIR) : NULL; switch (res) @@ -696,7 +698,7 @@ static void sanitize_dump_dir_rights() * us with thousands of bogus or malicious dumps */ /* 07000 bits are setuid, setgit, and sticky, and they must be unset */ /* 00777 bits are usual "rwxrwxrwx" access rights */ - ensure_writable_dir(DEBUG_DUMPS_DIR, 0755, "abrt"); + ensure_writable_dir(g_settings_dump_location, 0755, "abrt"); /* debuginfo cache */ ensure_writable_dir(DEBUG_INFO_DIR, 0775, "abrt"); /* temp dir */ @@ -826,10 +828,10 @@ int main(int argc, char** argv) perror_msg_and_die("inotify_init failed"); close_on_exec_on(inotify_fd);
- /* Watching DEBUG_DUMPS_DIR for new files... */ - if (inotify_add_watch(inotify_fd, DEBUG_DUMPS_DIR, IN_CREATE | IN_MOVED_TO) < 0) + /* Watching 'g_settings_dump_location' for new files... */ + if (inotify_add_watch(inotify_fd, g_settings_dump_location, IN_CREATE | IN_MOVED_TO) < 0) { - perror_msg("inotify_add_watch failed on '%s'", DEBUG_DUMPS_DIR); + perror_msg("inotify_add_watch failed on '%s'", g_settings_dump_location); goto init_error; } if (g_settings_sWatchCrashdumpArchiveDir) diff --git a/src/gui-gtk/Makefile.am b/src/gui-gtk/Makefile.am index 5025082..a2bb755 100644 --- a/src/gui-gtk/Makefile.am +++ b/src/gui-gtk/Makefile.am @@ -9,7 +9,6 @@ abrt_gui_CFLAGS = \ -DBIN_DIR="$(bindir)" \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ - -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \ -DICON_DIR="${datadir}/abrt/icons/hicolor/48x48/status" \ @@ -25,7 +24,8 @@ abrt_gui_LDADD = \ -lglib-2.0 \ -lgthread-2.0 \ $(GTK_LIBS) \ - $(LIBREPORT_GTK_LIBS) + $(LIBREPORT_GTK_LIBS) \ + ../lib/libabrt.la # $(LIBNOTIFY_LIBS)
#test_report_SOURCES = \ diff --git a/src/gui-gtk/main.c b/src/gui-gtk/main.c index 1409191..78290dc 100644 --- a/src/gui-gtk/main.c +++ b/src/gui-gtk/main.c @@ -728,7 +728,6 @@ int main(int argc, char **argv) "\b [-vp] [DIR]...\n" "\n" "Shows list of ABRT dump directories in specified DIR(s)\n" - "(default DIRs: "DEBUG_DUMPS_DIR" $HOME/.abrt/spool)" ); enum { OPT_v = 1 << 0, @@ -746,8 +745,9 @@ int main(int argc, char **argv)
GtkWidget *main_window = create_main_window();
+ load_abrt_conf(); const char *default_dirs[] = { - "/var/spool/abrt", + g_settings_dump_location, NULL, NULL, }; @@ -784,5 +784,6 @@ int main(int argc, char **argv) /* Enter main loop */ gtk_main();
+ free_abrt_conf_data(); return 0; } diff --git a/src/hooks/Makefile.am b/src/hooks/Makefile.am index 95cd363..f202776 100644 --- a/src/hooks/Makefile.am +++ b/src/hooks/Makefile.am @@ -14,7 +14,6 @@ abrt_hook_ccpp_SOURCES = \ abrt_hook_ccpp_CPPFLAGS = \ -I$(srcdir)/../include \ -I$(srcdir)/../lib \ - -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DCONF_DIR="$(CONF_DIR)" \ -DVAR_RUN="$(VAR_RUN)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \ diff --git a/src/hooks/abrt-hook-ccpp.c b/src/hooks/abrt-hook-ccpp.c index 93b368b..52d006f 100644 --- a/src/hooks/abrt-hook-ccpp.c +++ b/src/hooks/abrt-hook-ccpp.c @@ -309,13 +309,11 @@ int main(int argc, char** argv) { struct stat sb;
- if (argc < 9) /* no argv[8]? */ + if (argc < 8) { - /* percent specifier: %s %c %p %u %g %t %e %h */ - /* argv: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] */ - // [OLD_PATTERN] is deprecated, so removing it from help: - //error_msg_and_die("Usage: %s DUMPDIR SIGNO CORE_SIZE_LIMIT PID UID GID TIME BINARY_NAME [HOSTNAME [OLD_PATTERN]]", argv[0]); - error_msg_and_die("Usage: %s DUMPDIR SIGNO CORE_SIZE_LIMIT PID UID GID TIME BINARY_NAME [HOSTNAME]", argv[0]); + /* percent specifier: %s %c %p %u %g %t %e %h */ + /* argv: [0] [1] [2] [3] [4] [5] [6] [7] [8]*/ + error_msg_and_die("Usage: %s SIGNO CORE_SIZE_LIMIT PID UID GID TIME BINARY_NAME [HOSTNAME]", argv[0]); }
/* Not needed on 2.6.30. @@ -337,20 +335,23 @@ int main(int argc, char** argv) logmode = LOGMODE_SYSLOG;
errno = 0; - const char* dddir = argv[1]; - const char* signal_str = argv[2]; + /* Parse abrt.conf */ + load_abrt_conf(); + + const char* signal_str = argv[1]; int signal_no = xatoi_positive(signal_str); - off_t ulimit_c = strtoull(argv[3], NULL, 10); + off_t ulimit_c = strtoull(argv[2], NULL, 10); if (ulimit_c < 0) /* unlimited? */ { /* set to max possible >0 value */ ulimit_c = ~((off_t)1 << (sizeof(off_t)*8-1)); } - pid_t pid = xatoi_positive(argv[4]); - uid_t uid = xatoi_positive(argv[5]); + pid_t pid = xatoi_positive(argv[3]); + uid_t uid = xatoi_positive(argv[4]); if (errno || pid <= 0) { - perror_msg_and_die("pid '%s' or limit '%s' is bogus", argv[4], argv[3]); + free_abrt_conf_data(); + perror_msg_and_die("pid '%s' or limit '%s' is bogus", argv[3], argv[2]); }
FILE *saved_core_pattern = fopen(VAR_RUN"/abrt/saved_core_pattern", "r"); @@ -360,52 +361,27 @@ int main(int argc, char** argv) fclose(saved_core_pattern); /* If we have a saved pattern and it's not a "|PROG ARGS" thing... */ if (s && s[0] != '|') - { core_basename = s; - argv[10] = NULL; /* don't use old way to pass OLD_PATTERN */ - } }
struct utsname uts; - if (!argv[9]) /* no HOSTNAME? */ + if (!argv[8]) /* no HOSTNAME? */ { uname(&uts); - argv[9] = uts.nodename; - } - else /* argv[9]=HOSTNAME exists.*/ - if (argv[10]) /* OLD_PATTERN? (deprecated) */ - { - char *buf = (char*) xzalloc(strlen(argv[10]) / 2 + 2); - char *end = hex2bin(buf, argv[10], strlen(argv[10])); - if (end && end > buf && end[-1] == '\0') - { - core_basename = buf; - //log("core_basename:'%s'", core_basename); - } - else - { - /* Until recently, kernels were truncating expanded core pattern. - * In this case, we end up here... - */ - error_msg("bad old pattern '%s', ignoring and using 'core'", argv[10]); - /* core_basename = "core"; - already is */ - free(buf); - } + argv[8] = uts.nodename; }
int src_fd_binary; char *executable = get_executable(pid, &src_fd_binary); if (executable && strstr(executable, "/abrt-hook-ccpp")) { + free_abrt_conf_data(); error_msg_and_die("pid %lu is '%s', not dumping it to avoid recursion", (long)pid, executable); }
char *user_pwd = get_cwd(pid); /* may be NULL on error */
- /* Parse abrt.conf */ - load_abrt_conf(); - free_abrt_conf_data(); /* can do this because we need only g_settings_nMaxCrashReportsSize */ /* ... and plugins/CCpp.conf */ bool setting_MakeCompatCore; bool setting_SaveBinaryImage; @@ -430,7 +406,7 @@ int main(int argc, char** argv) int user_core_fd = -1; if (setting_MakeCompatCore && ulimit_c != 0) /* note: checks "user_pwd == NULL" inside; updates core_basename */ - user_core_fd = open_user_core(user_pwd, uid, pid, &argv[2]); + user_core_fd = open_user_core(user_pwd, uid, pid, &argv[1]);
if (executable == NULL) { @@ -475,7 +451,7 @@ int main(int argc, char** argv) */ unsigned maxsize = g_settings_nMaxCrashReportsSize + g_settings_nMaxCrashReportsSize / 4; maxsize |= 63; - check_free_space(maxsize); + check_free_space(maxsize, g_settings_dump_location); }
char path[PATH_MAX]; @@ -483,7 +459,7 @@ int main(int argc, char** argv) /* Check /var/spool/abrt/last-ccpp marker, do not dump repeated crashes * if they happen too often. Else, write new marker value. */ - snprintf(path, sizeof(path), "%s/last-ccpp", dddir); + snprintf(path, sizeof(path), "%s/last-ccpp", g_settings_dump_location); int fd = open(path, O_RDWR | O_CREAT, 0600); if (fd >= 0) { @@ -502,6 +478,7 @@ int main(int argc, char** argv) error_msg("not dumping repeating crash in '%s'", executable); if (setting_MakeCompatCore) goto create_user_core; + free_abrt_conf_data(); return 1; } } @@ -521,7 +498,7 @@ int main(int argc, char** argv) * and maybe crash again... * Unlike dirs, mere files are ignored by abrtd. */ - snprintf(path, sizeof(path), "%s/%s-coredump", dddir, last_slash); + snprintf(path, sizeof(path), "%s/%s-coredump", g_settings_dump_location, last_slash); int abrt_core_fd = xopen3(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); off_t core_size = copyfd_eof(STDIN_FILENO, abrt_core_fd, COPYFD_SPARSE); if (core_size < 0 || fsync(abrt_core_fd) != 0) @@ -529,16 +506,21 @@ int main(int argc, char** argv) unlink(path); /* copyfd_eof logs the error including errno string, * but it does not log file name */ + free_abrt_conf_data(); error_msg_and_die("error saving coredump to %s", path); } log("saved core dump of pid %lu (%s) to %s (%llu bytes)", (long)pid, executable, path, (long long)core_size); + free_abrt_conf_data(); return 0; }
unsigned path_len = snprintf(path, sizeof(path), "%s/ccpp-%s-%lu.new", - dddir, iso_date_string(NULL), (long)pid); + g_settings_dump_location, iso_date_string(NULL), (long)pid); if (path_len >= (sizeof(path) - sizeof("/"FILENAME_COREDUMP))) + { + free_abrt_conf_data(); return 1; + }
struct dump_dir *dd = dd_create(path, uid, 0640); if (dd) @@ -588,6 +570,7 @@ int main(int argc, char** argv) if (sz < 0 || fsync(dst_fd_binary) != 0) { unlink(path); + free_abrt_conf_data(); error_msg_and_die("error saving binary image to %s", path); } close(dst_fd_binary); @@ -606,6 +589,7 @@ int main(int argc, char** argv) unlink(core_basename); } errno = sv_errno; + free_abrt_conf_data(); perror_msg_and_die("Can't open '%s'", path); } fchown(abrt_core_fd, dd->dd_uid, dd->dd_gid); @@ -636,6 +620,7 @@ int main(int argc, char** argv) } /* copyfd_sparse logs the error including errno string, * but it does not log file name */ + free_abrt_conf_data(); error_msg_and_die("error writing %s", path); } log("saved core dump of pid %lu (%s) to %s (%llu bytes)", (long)pid, executable, path, (long long)core_size); @@ -667,16 +652,20 @@ int main(int argc, char** argv) */ unsigned maxsize = g_settings_nMaxCrashReportsSize + g_settings_nMaxCrashReportsSize / 4; maxsize |= 63; - trim_debug_dumps(DEBUG_DUMPS_DIR, maxsize * (double)(1024*1024), path); + trim_debug_dumps(g_settings_dump_location, maxsize * (double)(1024*1024), path); }
+ free_abrt_conf_data(); return 0; }
/* We didn't create abrt dump, but may need to create compat coredump */ create_user_core: if (user_core_fd < 0) + { + free_abrt_conf_data(); return 0; + }
off_t core_size = copyfd_size(STDIN_FILENO, user_core_fd, ulimit_c, COPYFD_SPARSE); if (core_size < 0 || fsync(user_core_fd) != 0) { @@ -684,15 +673,17 @@ int main(int argc, char** argv) perror_msg("error writing %s/%s", user_pwd, core_basename); xchdir(user_pwd); unlink(core_basename); + free_abrt_conf_data(); return 1; } if (ulimit_c == 0 || core_size > ulimit_c) { xchdir(user_pwd); unlink(core_basename); + free_abrt_conf_data(); return 1; } log("saved core dump of pid %lu to %s/%s (%llu bytes)", (long)pid, user_pwd, core_basename, (long long)core_size); - + free_abrt_conf_data(); return 0; } diff --git a/src/hooks/abrt-install-ccpp-hook b/src/hooks/abrt-install-ccpp-hook index 86f4714..cb0e016 100755 --- a/src/hooks/abrt-install-ccpp-hook +++ b/src/hooks/abrt-install-ccpp-hook @@ -11,9 +11,9 @@ SAVED_PATTERN_DIR="/var/run/abrt" SAVED_PATTERN_FILE="/var/run/abrt/saved_core_pattern" HOOK_BIN="/usr/libexec/abrt-hook-ccpp" # Must match percent_specifiers[] order in abrt-hook-ccpp.c: -PATTERN="|$HOOK_BIN /var/spool/abrt %s %c %p %u %g %t %e" +PATTERN="|$HOOK_BIN %s %c %p %u %g %t %e" # Same, but with bogus "executable name" parameter -PATTERN1="|$HOOK_BIN /var/spool/abrt %s %c %p %u %g %t e" +PATTERN1="|$HOOK_BIN %s %c %p %u %g %t e"
# core_pipe_limit specifies how many dump_helpers can run at the same time # 0 - means unlimited, but it's not guaranteed that /proc/<pid> of crashing diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index d9465b3..08c8749 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -19,7 +19,6 @@ libabrt_la_CPPFLAGS = \ -I$(srcdir)/../lib \ -DLOCALSTATEDIR='"$(localstatedir)"' \ -DVAR_RUN="$(VAR_RUN)" \ - -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \ -DCONF_DIR="$(CONF_DIR)" \ @@ -32,9 +31,3 @@ libabrt_la_LDFLAGS = \ -version-info 0:1:0 libabrt_la_LIBADD = \ $(GLIB_LIBS) - -$(DESTDIR)/$(DEBUG_DUMPS_DIR): - $(mkdir_p) '$@' -# no need to chmod it here -#chmod 1777 '$@' -install-data-local: $(DESTDIR)/$(DEBUG_DUMPS_DIR) diff --git a/src/lib/abrt_conf.c b/src/lib/abrt_conf.c index 5545b7d..1115ee1 100644 --- a/src/lib/abrt_conf.c +++ b/src/lib/abrt_conf.c @@ -20,12 +20,15 @@
char * g_settings_sWatchCrashdumpArchiveDir = NULL; unsigned int g_settings_nMaxCrashReportsSize = 1000; - +char * g_settings_dump_location = NULL;
void free_abrt_conf_data() { free(g_settings_sWatchCrashdumpArchiveDir); g_settings_sWatchCrashdumpArchiveDir = NULL; + + free(g_settings_dump_location); + g_settings_dump_location = NULL; }
static void ParseCommon(map_string_h *settings, const char *conf_filename) @@ -52,6 +55,15 @@ static void ParseCommon(map_string_h *settings, const char *conf_filename) g_hash_table_remove(settings, "MaxCrashReportsSize"); }
+ value = g_hash_table_lookup(settings, "DumpLocation"); + if (value) + { + g_settings_dump_location = xstrdup(value); + g_hash_table_remove(settings, "DumpLocation"); + } + else + g_settings_dump_location = xstrdup("/var/spool/abrt"); + GHashTableIter iter; char *name; /*char *value; - already declared */ diff --git a/src/lib/abrt_conf.h b/src/lib/abrt_conf.h index 14fc742..ccd3ca9 100644 --- a/src/lib/abrt_conf.h +++ b/src/lib/abrt_conf.h @@ -27,6 +27,8 @@ extern "C" { extern unsigned int g_settings_nMaxCrashReportsSize; #define g_settings_sWatchCrashdumpArchiveDir abrt_g_settings_sWatchCrashdumpArchiveDir extern char * g_settings_sWatchCrashdumpArchiveDir; +#define g_settings_dump_location abrt_g_settings_dump_location +extern char * g_settings_dump_location;
#define load_abrt_conf abrt_load_abrt_conf int load_abrt_conf(); diff --git a/src/lib/hooklib.c b/src/lib/hooklib.c index b5fcec2..5ebec97 100644 --- a/src/lib/hooklib.c +++ b/src/lib/hooklib.c @@ -19,12 +19,12 @@ #include "internal_libreport.h" #include "hooklib.h"
-void check_free_space(unsigned setting_MaxCrashReportsSize) +void check_free_space(unsigned setting_MaxCrashReportsSize, const char *dump_location) { struct statvfs vfs; - if (statvfs(DEBUG_DUMPS_DIR, &vfs) != 0) + if (statvfs(dump_location, &vfs) != 0) { - perror_msg_and_die("statvfs('%s')", DEBUG_DUMPS_DIR); + perror_msg_and_die("statvfs('%s')", dump_location); }
/* Check that at least MaxCrashReportsSize/4 MBs are free */ @@ -34,7 +34,8 @@ void check_free_space(unsigned setting_MaxCrashReportsSize) unsigned long fs_free_mb_x4 = ((unsigned long long)vfs.f_bfree / (1024/4)) * vfs.f_bsize / 1024; if (fs_free_mb_x4 < setting_MaxCrashReportsSize) { - error_msg_and_die("aborting dump: only %luMiB is available on %s", fs_free_mb_x4 / 4, DEBUG_DUMPS_DIR); + error_msg_and_die("aborting dump: only %luMiB is available on %s", + fs_free_mb_x4 / 4, dump_location); } }
diff --git a/src/lib/hooklib.h b/src/lib/hooklib.h index 1add7d0..0cb3f60 100644 --- a/src/lib/hooklib.h +++ b/src/lib/hooklib.h @@ -23,7 +23,7 @@ extern "C" { #endif
#define check_free_space abrt_check_free_space -void check_free_space(unsigned setting_MaxCrashReportsSize); +void check_free_space(unsigned setting_MaxCrashReportsSize, const char *dump_location);
#define trim_debug_dumps abrt_trim_debug_dumps void trim_debug_dumps(const char *dirname, double cap_size, const char *exclude_path); diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index 30b20e2..cb4b6ff 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -91,7 +91,6 @@ abrt_dump_oops_CPPFLAGS = \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ -DLOCALSTATEDIR='"$(localstatedir)"' \ - -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \ @@ -112,7 +111,6 @@ abrt_action_analyze_c_CPPFLAGS = \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ -DLOCALSTATEDIR='"$(localstatedir)"' \ - -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \ @@ -132,7 +130,6 @@ abrt_action_analyze_python_CPPFLAGS = \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ -DLOCALSTATEDIR='"$(localstatedir)"' \ - -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \ @@ -153,7 +150,6 @@ abrt_action_analyze_oops_CPPFLAGS = \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ -DLOCALSTATEDIR='"$(localstatedir)"' \ - -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \ @@ -173,7 +169,6 @@ abrt_action_trim_files_CPPFLAGS = \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ -DLOCALSTATEDIR='"$(localstatedir)"' \ - -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \ @@ -194,7 +189,6 @@ abrt_action_generate_backtrace_CPPFLAGS = \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ -DLOCALSTATEDIR='"$(localstatedir)"' \ - -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \ @@ -214,7 +208,6 @@ abrt_action_analyze_backtrace_CPPFLAGS = \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ -DLOCALSTATEDIR='"$(localstatedir)"' \ - -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \
seems ok, except removing the compatibility hack with old kernels, but since no one probably uses abrt2 + pre .28 kernels go ahead and push it.
J.
On 07/22/2011 05:33 PM, Nikola Pajkovsky wrote:
Signed-off-by: Nikola Pajkovskynpajkovs@redhat.com
configure.ac | 7 --- src/applet/Makefile.am | 1 - src/cli/Makefile.am | 4 +- src/cli/list.c | 4 +- src/daemon/Makefile.am | 3 - src/daemon/abrt-server.c | 21 +++++++--- src/daemon/abrt.conf | 5 ++ src/daemon/abrtd.c | 24 ++++++----- src/gui-gtk/Makefile.am | 4 +- src/gui-gtk/main.c | 5 +- src/hooks/Makefile.am | 1 - src/hooks/abrt-hook-ccpp.c | 85 +++++++++++++++++--------------------- src/hooks/abrt-install-ccpp-hook | 4 +- src/lib/Makefile.am | 7 --- src/lib/abrt_conf.c | 14 ++++++- src/lib/abrt_conf.h | 2 + src/lib/hooklib.c | 9 ++-- src/lib/hooklib.h | 2 +- src/plugins/Makefile.am | 7 --- 19 files changed, 104 insertions(+), 105 deletions(-)
diff --git a/configure.ac b/configure.ac index 8de55d2..cb15a1d 100644 --- a/configure.ac +++ b/configure.ac @@ -94,14 +94,8 @@ PLUGINS_LIB_DIR='${libdir}/${PACKAGE_NAME}' ENABLE_SOCKET_OR_DBUS='-DENABLE_DBUS=1' LIBEXEC_DIR='${libexecdir}'
-DEBUG_DUMPS_DIR='${localstatedir}/spool/${PACKAGE_NAME}' DEBUG_INFO_DIR='${localstatedir}/cache/${PACKAGE_NAME}-di'
-AC_ARG_WITH(debugdumpsdir,
[AS_HELP_STRING([--with-debugdumpdir=DIR],
[Directory where debugdumps are created])],
[DEBUG_DUMPS_DIR="$withval"])
- AC_ARG_WITH(debuginfosdir, [AS_HELP_STRING([--with-debuginfodir=DIR], [Directory where debuginfo is stored])],
@@ -114,7 +108,6 @@ AC_SUBST(REPORT_PLUGINS_CONF_DIR) AC_SUBST(EVENTS_CONF_DIR) AC_SUBST(EVENTS_DIR) AC_SUBST(PLUGINS_LIB_DIR) -AC_SUBST(DEBUG_DUMPS_DIR) AC_SUBST(DEBUG_INFO_DIR) AC_SUBST(LIBEXEC_DIR)
diff --git a/src/applet/Makefile.am b/src/applet/Makefile.am index db5266d..247bee2 100644 --- a/src/applet/Makefile.am +++ b/src/applet/Makefile.am @@ -9,7 +9,6 @@ abrt_applet_CPPFLAGS = \ -DBIN_DIR="$(bindir)" \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \
- -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \ -DICON_DIR="${datadir}/abrt/icons/hicolor/48x48/status" \
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am index c5ebc14..bbd1402 100644 --- a/src/cli/Makefile.am +++ b/src/cli/Makefile.am @@ -15,11 +15,11 @@ abrt_cli_SOURCES = $(CLI_C) $(BUILTIN_C) builtin-cmd.h abrt_cli_CFLAGS = \ -I$(srcdir)/../include \ -I$(srcdir)/../lib \
-DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ $(LIBREPORT_CFLAGS) \ -Wwrite-strings -Werror
abrt_cli_LDADD = \
$(LIBREPORT_LIBS)
$(LIBREPORT_LIBS) \
../lib/libabrt.la
DEFS = -DLOCALEDIR="$(localedir)" @DEFS@
diff --git a/src/cli/list.c b/src/cli/list.c index 833b4c7..e4f30fe 100644 --- a/src/cli/list.c +++ b/src/cli/list.c @@ -170,13 +170,15 @@ int cmd_list(int argc, const char **argv) while (optind< argc) D_list = g_list_append(D_list, xstrdup(argv[optind++]));
- load_abrt_conf(); if (!D_list) { char *home = getenv("HOME"); if (home) D_list = g_list_append(D_list, concat_path_file(home, ".abrt/spool"));
D_list = g_list_append(D_list, xstrdup((void*)DEBUG_DUMPS_DIR));
D_list = g_list_append(D_list, xstrdup(g_settings_dump_location)); }
free_abrt_conf_data();
VERB2 {
diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am index 18d41b6..9770e56 100644 --- a/src/daemon/Makefile.am +++ b/src/daemon/Makefile.am @@ -23,7 +23,6 @@ abrtd_CPPFLAGS = \ -DBIN_DIR="$(bindir)" \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \
- -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \
@@ -47,7 +46,6 @@ abrt_server_CPPFLAGS = \ -DBIN_DIR="$(bindir)" \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \
- -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \
@@ -69,7 +67,6 @@ abrt_action_save_package_data_CPPFLAGS = \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ -DLOCALSTATEDIR='"$(localstatedir)"' \
- -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \
diff --git a/src/daemon/abrt-server.c b/src/daemon/abrt-server.c index 8153ad6..78e4ebd 100644 --- a/src/daemon/abrt-server.c +++ b/src/daemon/abrt-server.c @@ -100,7 +100,8 @@ static int create_debug_dump() This directory is renamed to final directory name after all files have been stored into it. */
- char *path = xasprintf(DEBUG_DUMPS_DIR"/%s-%s-%u.new",
- char *path = xasprintf("%s/%s-%s-%u.new",
g_settings_dump_location, dir_basename, iso_date_string(NULL), pid);
@@ -150,8 +151,8 @@ static int create_debug_dump() */ unsigned maxsize = g_settings_nMaxCrashReportsSize + g_settings_nMaxCrashReportsSize / 4; maxsize |= 63;
check_free_space(maxsize);
trim_debug_dumps(DEBUG_DUMPS_DIR, maxsize * (double)(1024*1024), path);
check_free_space(maxsize, g_settings_dump_location);
trim_debug_dumps(g_settings_dump_location, maxsize * (double)(1024*1024), path); } free(path);
@@ -162,15 +163,19 @@ static int create_debug_dump() /* Remove dump dir */ static int delete_path(const char *dump_dir_name) {
- /* If doesn't start with "DEBUG_DUMPS_DIR/"... */
- if (strncmp(dump_dir_name, DEBUG_DUMPS_DIR"/", strlen(DEBUG_DUMPS_DIR"/")) != 0
- /* If doesn't start with "g_settings_dump_location/"... */
- char *dump_location = xasprintf("%s/", g_settings_dump_location);
- log("%s", dump_location);
- if (strncmp(dump_dir_name, dump_location, strlen(dump_location)) != 0 /* or contains "/." anywhere (-> might contain ".." component) */
|| strstr(dump_dir_name + strlen(DEBUG_DUMPS_DIR), "/.")
|| strstr(dump_dir_name + strlen(g_settings_dump_location), "/.") ) { /* Then refuse to operate on it (someone is attacking us??) */ error_msg("Bad dump directory name '%s', not deleting", dump_dir_name);
free(dump_location); return 400; /* Bad Request */ }
free(dump_location);
struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0); if (!dd)
@@ -491,10 +496,14 @@ int main(int argc, char **argv) client_uid = cr.uid; }
load_abrt_conf();
int r = perform_http_xact(); if (r == 0) r = 200;
free_abrt_conf_data();
printf("HTTP/1.1 %u \r\n\r\n", r); return (r>= 400); /* Error if 400+ */
diff --git a/src/daemon/abrt.conf b/src/daemon/abrt.conf index c9a4333..e3820f2 100644 --- a/src/daemon/abrt.conf +++ b/src/daemon/abrt.conf @@ -8,3 +8,8 @@ # Max size for crash storage [MiB] or 0 for unlimited # MaxCrashReportsSize = 1000
+# Specify where you want to store coredumps and all files which are needed for +# reporting. (default:/var/spool/abrt) +# +#DumpLocation = /var/spool/abrt diff --git a/src/daemon/abrtd.c b/src/daemon/abrtd.c index 853d78f..d7b3f0e 100644 --- a/src/daemon/abrtd.c +++ b/src/daemon/abrtd.c @@ -290,7 +290,7 @@ static int is_crash_a_dup(const char *dump_dir_name, void *param)
/* Scan crash dumps looking for a dup */
//TODO: explain why this is safe wrt concurrent runs
- DIR *dir = opendir(DEBUG_DUMPS_DIR);
- DIR *dir = opendir(g_settings_dump_location); if (dir != NULL) { struct dirent *dent;
@@ -301,7 +301,7 @@ static int is_crash_a_dup(const char *dump_dir_name, void *param)
int different; char *uid, *uuid;
char *dump_dir_name2 = concat_path_file(DEBUG_DUMPS_DIR, dent->d_name);
char *dump_dir_name2 = concat_path_file(g_settings_dump_location, dent->d_name); if (strcmp(dump_dir_name, dump_dir_name2) == 0) goto next; /* we are never a dup of ourself */
@@ -521,7 +521,8 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin if (fork() == 0) { xchdir(dir);
execlp("abrt-handle-upload", "abrt-handle-upload", DEBUG_DUMPS_DIR, dir, name, (char*)NULL);
execlp("abrt-handle-upload", "abrt-handle-upload",
g_settings_dump_location, dir, name, (char*)NULL); error_msg_and_die("Can't execute '%s'", "abrt-handle-upload"); } }
@@ -546,13 +547,14 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin { char *worst_dir = NULL; while (g_settings_nMaxCrashReportsSize> 0 -&& get_dirsize_find_largest_dir(DEBUG_DUMPS_DIR,&worst_dir, name) / (1024*1024)>= g_settings_nMaxCrashReportsSize +&& get_dirsize_find_largest_dir(g_settings_dump_location,&worst_dir, name) / (1024*1024)>= g_settings_nMaxCrashReportsSize && worst_dir ) {
log("Size of '%s'>= %u MB, deleting '%s'", DEBUG_DUMPS_DIR, g_settings_nMaxCrashReportsSize, worst_dir);
log("Size of '%s'>= %u MB, deleting '%s'",
g_settings_dump_location, g_settings_nMaxCrashReportsSize, worst_dir); send_dbus_sig_QuotaExceeded(_("The size of the report exceeded the quota. Please check system's MaxCrashReportsSize value in abrt.conf.")); /* deletes both directory and DB record */
char *d = concat_path_file(DEBUG_DUMPS_DIR, worst_dir);
char *d = concat_path_file(g_settings_dump_location, worst_dir); free(worst_dir); worst_dir = NULL; delete_dump_dir(d);
@@ -562,7 +564,7 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin
char *fullname = NULL; problem_data_t *problem_data = NULL;
fullname = concat_path_file(DEBUG_DUMPS_DIR, name);
fullname = concat_path_file(g_settings_dump_location, name); mw_result_t res = LoadDebugDump(fullname,&problem_data); const char *first = problem_data ? get_problem_item_content_or_NULL(problem_data, CD_DUMPDIR) : NULL; switch (res)
@@ -696,7 +698,7 @@ static void sanitize_dump_dir_rights() * us with thousands of bogus or malicious dumps */ /* 07000 bits are setuid, setgit, and sticky, and they must be unset */ /* 00777 bits are usual "rwxrwxrwx" access rights */
- ensure_writable_dir(DEBUG_DUMPS_DIR, 0755, "abrt");
- ensure_writable_dir(g_settings_dump_location, 0755, "abrt"); /* debuginfo cache */ ensure_writable_dir(DEBUG_INFO_DIR, 0775, "abrt"); /* temp dir */
@@ -826,10 +828,10 @@ int main(int argc, char** argv) perror_msg_and_die("inotify_init failed"); close_on_exec_on(inotify_fd);
- /* Watching DEBUG_DUMPS_DIR for new files... */
- if (inotify_add_watch(inotify_fd, DEBUG_DUMPS_DIR, IN_CREATE | IN_MOVED_TO)< 0)
- /* Watching 'g_settings_dump_location' for new files... */
- if (inotify_add_watch(inotify_fd, g_settings_dump_location, IN_CREATE | IN_MOVED_TO)< 0) {
perror_msg("inotify_add_watch failed on '%s'", DEBUG_DUMPS_DIR);
perror_msg("inotify_add_watch failed on '%s'", g_settings_dump_location); goto init_error; } if (g_settings_sWatchCrashdumpArchiveDir)
diff --git a/src/gui-gtk/Makefile.am b/src/gui-gtk/Makefile.am index 5025082..a2bb755 100644 --- a/src/gui-gtk/Makefile.am +++ b/src/gui-gtk/Makefile.am @@ -9,7 +9,6 @@ abrt_gui_CFLAGS = \ -DBIN_DIR="$(bindir)" \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \
- -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \ -DICON_DIR="${datadir}/abrt/icons/hicolor/48x48/status" \
@@ -25,7 +24,8 @@ abrt_gui_LDADD = \ -lglib-2.0 \ -lgthread-2.0 \ $(GTK_LIBS) \
- $(LIBREPORT_GTK_LIBS)
$(LIBREPORT_GTK_LIBS) \
../lib/libabrt.la # $(LIBNOTIFY_LIBS)
#test_report_SOURCES = \
diff --git a/src/gui-gtk/main.c b/src/gui-gtk/main.c index 1409191..78290dc 100644 --- a/src/gui-gtk/main.c +++ b/src/gui-gtk/main.c @@ -728,7 +728,6 @@ int main(int argc, char **argv) "\b [-vp] [DIR]...\n" "\n" "Shows list of ABRT dump directories in specified DIR(s)\n"
"(default DIRs: "DEBUG_DUMPS_DIR" $HOME/.abrt/spool)" ); enum { OPT_v = 1<< 0,
@@ -746,8 +745,9 @@ int main(int argc, char **argv)
GtkWidget *main_window = create_main_window();
- load_abrt_conf(); const char *default_dirs[] = {
"/var/spool/abrt",
g_settings_dump_location, NULL, NULL, };
@@ -784,5 +784,6 @@ int main(int argc, char **argv) /* Enter main loop */ gtk_main();
- free_abrt_conf_data(); return 0; }
diff --git a/src/hooks/Makefile.am b/src/hooks/Makefile.am index 95cd363..f202776 100644 --- a/src/hooks/Makefile.am +++ b/src/hooks/Makefile.am @@ -14,7 +14,6 @@ abrt_hook_ccpp_SOURCES = \ abrt_hook_ccpp_CPPFLAGS = \ -I$(srcdir)/../include \ -I$(srcdir)/../lib \
- -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DCONF_DIR="$(CONF_DIR)" \ -DVAR_RUN="$(VAR_RUN)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \
diff --git a/src/hooks/abrt-hook-ccpp.c b/src/hooks/abrt-hook-ccpp.c index 93b368b..52d006f 100644 --- a/src/hooks/abrt-hook-ccpp.c +++ b/src/hooks/abrt-hook-ccpp.c @@ -309,13 +309,11 @@ int main(int argc, char** argv) { struct stat sb;
- if (argc< 9) /* no argv[8]? */
- if (argc< 8) {
/* percent specifier: %s %c %p %u %g %t %e %h */
/* argv: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] */
// [OLD_PATTERN] is deprecated, so removing it from help:
//error_msg_and_die("Usage: %s DUMPDIR SIGNO CORE_SIZE_LIMIT PID UID GID TIME BINARY_NAME [HOSTNAME [OLD_PATTERN]]", argv[0]);
error_msg_and_die("Usage: %s DUMPDIR SIGNO CORE_SIZE_LIMIT PID UID GID TIME BINARY_NAME [HOSTNAME]", argv[0]);
/* percent specifier: %s %c %p %u %g %t %e %h */
/* argv: [0] [1] [2] [3] [4] [5] [6] [7] [8]*/
error_msg_and_die("Usage: %s SIGNO CORE_SIZE_LIMIT PID UID GID TIME BINARY_NAME [HOSTNAME]", argv[0]); } /* Not needed on 2.6.30.
@@ -337,20 +335,23 @@ int main(int argc, char** argv) logmode = LOGMODE_SYSLOG;
errno = 0;
- const char* dddir = argv[1];
- const char* signal_str = argv[2];
- /* Parse abrt.conf */
- load_abrt_conf();
- const char* signal_str = argv[1]; int signal_no = xatoi_positive(signal_str);
- off_t ulimit_c = strtoull(argv[3], NULL, 10);
- off_t ulimit_c = strtoull(argv[2], NULL, 10); if (ulimit_c< 0) /* unlimited? */ { /* set to max possible>0 value */ ulimit_c = ~((off_t)1<< (sizeof(off_t)*8-1)); }
- pid_t pid = xatoi_positive(argv[4]);
- uid_t uid = xatoi_positive(argv[5]);
- pid_t pid = xatoi_positive(argv[3]);
- uid_t uid = xatoi_positive(argv[4]); if (errno || pid<= 0) {
perror_msg_and_die("pid '%s' or limit '%s' is bogus", argv[4], argv[3]);
free_abrt_conf_data();
perror_msg_and_die("pid '%s' or limit '%s' is bogus", argv[3], argv[2]); } FILE *saved_core_pattern = fopen(VAR_RUN"/abrt/saved_core_pattern", "r");
@@ -360,52 +361,27 @@ int main(int argc, char** argv) fclose(saved_core_pattern); /* If we have a saved pattern and it's not a "|PROG ARGS" thing... */ if (s&& s[0] != '|')
{ core_basename = s;
argv[10] = NULL; /* don't use old way to pass OLD_PATTERN */
} } struct utsname uts;
if (!argv[9]) /* no HOSTNAME? */
- if (!argv[8]) /* no HOSTNAME? */ { uname(&uts);
argv[9] = uts.nodename;
- }
- else /* argv[9]=HOSTNAME exists.*/
- if (argv[10]) /* OLD_PATTERN? (deprecated) */
- {
char *buf = (char*) xzalloc(strlen(argv[10]) / 2 + 2);
char *end = hex2bin(buf, argv[10], strlen(argv[10]));
if (end&& end> buf&& end[-1] == '\0')
{
core_basename = buf;
//log("core_basename:'%s'", core_basename);
}
else
{
/* Until recently, kernels were truncating expanded core pattern.
* In this case, we end up here...
*/
error_msg("bad old pattern '%s', ignoring and using 'core'", argv[10]);
/* core_basename = "core"; - already is */
free(buf);
}
argv[8] = uts.nodename; } int src_fd_binary; char *executable = get_executable(pid,&src_fd_binary); if (executable&& strstr(executable, "/abrt-hook-ccpp")) {
free_abrt_conf_data(); error_msg_and_die("pid %lu is '%s', not dumping it to avoid recursion", (long)pid, executable); } char *user_pwd = get_cwd(pid); /* may be NULL on error */
- /* Parse abrt.conf */
- load_abrt_conf();
- free_abrt_conf_data(); /* can do this because we need only g_settings_nMaxCrashReportsSize */ /* ... and plugins/CCpp.conf */ bool setting_MakeCompatCore; bool setting_SaveBinaryImage;
@@ -430,7 +406,7 @@ int main(int argc, char** argv) int user_core_fd = -1; if (setting_MakeCompatCore&& ulimit_c != 0) /* note: checks "user_pwd == NULL" inside; updates core_basename */
user_core_fd = open_user_core(user_pwd, uid, pid,&argv[2]);
user_core_fd = open_user_core(user_pwd, uid, pid,&argv[1]); if (executable == NULL) {
@@ -475,7 +451,7 @@ int main(int argc, char** argv) */ unsigned maxsize = g_settings_nMaxCrashReportsSize + g_settings_nMaxCrashReportsSize / 4; maxsize |= 63;
check_free_space(maxsize);
check_free_space(maxsize, g_settings_dump_location); } char path[PATH_MAX];
@@ -483,7 +459,7 @@ int main(int argc, char** argv) /* Check /var/spool/abrt/last-ccpp marker, do not dump repeated crashes * if they happen too often. Else, write new marker value. */
- snprintf(path, sizeof(path), "%s/last-ccpp", dddir);
- snprintf(path, sizeof(path), "%s/last-ccpp", g_settings_dump_location); int fd = open(path, O_RDWR | O_CREAT, 0600); if (fd>= 0) {
@@ -502,6 +478,7 @@ int main(int argc, char** argv) error_msg("not dumping repeating crash in '%s'", executable); if (setting_MakeCompatCore) goto create_user_core;
free_abrt_conf_data(); return 1; } }
@@ -521,7 +498,7 @@ int main(int argc, char** argv) * and maybe crash again... * Unlike dirs, mere files are ignored by abrtd. */
snprintf(path, sizeof(path), "%s/%s-coredump", dddir, last_slash);
snprintf(path, sizeof(path), "%s/%s-coredump", g_settings_dump_location, last_slash); int abrt_core_fd = xopen3(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); off_t core_size = copyfd_eof(STDIN_FILENO, abrt_core_fd, COPYFD_SPARSE); if (core_size< 0 || fsync(abrt_core_fd) != 0)
@@ -529,16 +506,21 @@ int main(int argc, char** argv) unlink(path); /* copyfd_eof logs the error including errno string, * but it does not log file name */
free_abrt_conf_data(); error_msg_and_die("error saving coredump to %s", path); } log("saved core dump of pid %lu (%s) to %s (%llu bytes)", (long)pid, executable, path, (long long)core_size);
free_abrt_conf_data(); return 0; } unsigned path_len = snprintf(path, sizeof(path), "%s/ccpp-%s-%lu.new",
dddir, iso_date_string(NULL), (long)pid);
g_settings_dump_location, iso_date_string(NULL), (long)pid); if (path_len>= (sizeof(path) - sizeof("/"FILENAME_COREDUMP)))
{
free_abrt_conf_data(); return 1;
}
struct dump_dir *dd = dd_create(path, uid, 0640); if (dd)
@@ -588,6 +570,7 @@ int main(int argc, char** argv) if (sz< 0 || fsync(dst_fd_binary) != 0) { unlink(path);
free_abrt_conf_data(); error_msg_and_die("error saving binary image to %s", path); } close(dst_fd_binary);
@@ -606,6 +589,7 @@ int main(int argc, char** argv) unlink(core_basename); } errno = sv_errno;
free_abrt_conf_data(); perror_msg_and_die("Can't open '%s'", path); } fchown(abrt_core_fd, dd->dd_uid, dd->dd_gid);
@@ -636,6 +620,7 @@ int main(int argc, char** argv) } /* copyfd_sparse logs the error including errno string, * but it does not log file name */
free_abrt_conf_data(); error_msg_and_die("error writing %s", path); } log("saved core dump of pid %lu (%s) to %s (%llu bytes)", (long)pid, executable, path, (long long)core_size);
@@ -667,16 +652,20 @@ int main(int argc, char** argv) */ unsigned maxsize = g_settings_nMaxCrashReportsSize + g_settings_nMaxCrashReportsSize / 4; maxsize |= 63;
trim_debug_dumps(DEBUG_DUMPS_DIR, maxsize * (double)(1024*1024), path);
trim_debug_dumps(g_settings_dump_location, maxsize * (double)(1024*1024), path); }
free_abrt_conf_data(); return 0; } /* We didn't create abrt dump, but may need to create compat coredump */
create_user_core: if (user_core_fd< 0)
{
free_abrt_conf_data(); return 0;
}
off_t core_size = copyfd_size(STDIN_FILENO, user_core_fd, ulimit_c, COPYFD_SPARSE); if (core_size< 0 || fsync(user_core_fd) != 0) {
@@ -684,15 +673,17 @@ int main(int argc, char** argv) perror_msg("error writing %s/%s", user_pwd, core_basename); xchdir(user_pwd); unlink(core_basename);
free_abrt_conf_data(); return 1; } if (ulimit_c == 0 || core_size> ulimit_c) { xchdir(user_pwd); unlink(core_basename);
free_abrt_conf_data(); return 1; } log("saved core dump of pid %lu to %s/%s (%llu bytes)", (long)pid, user_pwd, core_basename, (long long)core_size);
- free_abrt_conf_data(); return 0; }
diff --git a/src/hooks/abrt-install-ccpp-hook b/src/hooks/abrt-install-ccpp-hook index 86f4714..cb0e016 100755 --- a/src/hooks/abrt-install-ccpp-hook +++ b/src/hooks/abrt-install-ccpp-hook @@ -11,9 +11,9 @@ SAVED_PATTERN_DIR="/var/run/abrt" SAVED_PATTERN_FILE="/var/run/abrt/saved_core_pattern" HOOK_BIN="/usr/libexec/abrt-hook-ccpp" # Must match percent_specifiers[] order in abrt-hook-ccpp.c: -PATTERN="|$HOOK_BIN /var/spool/abrt %s %c %p %u %g %t %e" +PATTERN="|$HOOK_BIN %s %c %p %u %g %t %e" # Same, but with bogus "executable name" parameter -PATTERN1="|$HOOK_BIN /var/spool/abrt %s %c %p %u %g %t e" +PATTERN1="|$HOOK_BIN %s %c %p %u %g %t e"
# core_pipe_limit specifies how many dump_helpers can run at the same time # 0 - means unlimited, but it's not guaranteed that /proc/<pid> of crashing diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index d9465b3..08c8749 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -19,7 +19,6 @@ libabrt_la_CPPFLAGS = \ -I$(srcdir)/../lib \ -DLOCALSTATEDIR='"$(localstatedir)"' \ -DVAR_RUN="$(VAR_RUN)" \
- -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \ -DCONF_DIR="$(CONF_DIR)" \
@@ -32,9 +31,3 @@ libabrt_la_LDFLAGS = \ -version-info 0:1:0 libabrt_la_LIBADD = \ $(GLIB_LIBS)
-$(DESTDIR)/$(DEBUG_DUMPS_DIR):
- $(mkdir_p) '$@'
-# no need to chmod it here -#chmod 1777 '$@' -install-data-local: $(DESTDIR)/$(DEBUG_DUMPS_DIR) diff --git a/src/lib/abrt_conf.c b/src/lib/abrt_conf.c index 5545b7d..1115ee1 100644 --- a/src/lib/abrt_conf.c +++ b/src/lib/abrt_conf.c @@ -20,12 +20,15 @@
char * g_settings_sWatchCrashdumpArchiveDir = NULL; unsigned int g_settings_nMaxCrashReportsSize = 1000;
+char * g_settings_dump_location = NULL;
void free_abrt_conf_data() { free(g_settings_sWatchCrashdumpArchiveDir); g_settings_sWatchCrashdumpArchiveDir = NULL;
free(g_settings_dump_location);
g_settings_dump_location = NULL; }
static void ParseCommon(map_string_h *settings, const char *conf_filename)
@@ -52,6 +55,15 @@ static void ParseCommon(map_string_h *settings, const char *conf_filename) g_hash_table_remove(settings, "MaxCrashReportsSize"); }
- value = g_hash_table_lookup(settings, "DumpLocation");
- if (value)
- {
g_settings_dump_location = xstrdup(value);
g_hash_table_remove(settings, "DumpLocation");
- }
- else
g_settings_dump_location = xstrdup("/var/spool/abrt");
GHashTableIter iter; char *name; /*char *value; - already declared */
diff --git a/src/lib/abrt_conf.h b/src/lib/abrt_conf.h index 14fc742..ccd3ca9 100644 --- a/src/lib/abrt_conf.h +++ b/src/lib/abrt_conf.h @@ -27,6 +27,8 @@ extern "C" { extern unsigned int g_settings_nMaxCrashReportsSize; #define g_settings_sWatchCrashdumpArchiveDir abrt_g_settings_sWatchCrashdumpArchiveDir extern char * g_settings_sWatchCrashdumpArchiveDir; +#define g_settings_dump_location abrt_g_settings_dump_location +extern char * g_settings_dump_location;
#define load_abrt_conf abrt_load_abrt_conf int load_abrt_conf(); diff --git a/src/lib/hooklib.c b/src/lib/hooklib.c index b5fcec2..5ebec97 100644 --- a/src/lib/hooklib.c +++ b/src/lib/hooklib.c @@ -19,12 +19,12 @@ #include "internal_libreport.h" #include "hooklib.h"
-void check_free_space(unsigned setting_MaxCrashReportsSize) +void check_free_space(unsigned setting_MaxCrashReportsSize, const char *dump_location) { struct statvfs vfs;
- if (statvfs(DEBUG_DUMPS_DIR,&vfs) != 0)
- if (statvfs(dump_location,&vfs) != 0) {
perror_msg_and_die("statvfs('%s')", DEBUG_DUMPS_DIR);
perror_msg_and_die("statvfs('%s')", dump_location); } /* Check that at least MaxCrashReportsSize/4 MBs are free */
@@ -34,7 +34,8 @@ void check_free_space(unsigned setting_MaxCrashReportsSize) unsigned long fs_free_mb_x4 = ((unsigned long long)vfs.f_bfree / (1024/4)) * vfs.f_bsize / 1024; if (fs_free_mb_x4< setting_MaxCrashReportsSize) {
error_msg_and_die("aborting dump: only %luMiB is available on %s", fs_free_mb_x4 / 4, DEBUG_DUMPS_DIR);
error_msg_and_die("aborting dump: only %luMiB is available on %s",
}fs_free_mb_x4 / 4, dump_location); }
diff --git a/src/lib/hooklib.h b/src/lib/hooklib.h index 1add7d0..0cb3f60 100644 --- a/src/lib/hooklib.h +++ b/src/lib/hooklib.h @@ -23,7 +23,7 @@ extern "C" { #endif
#define check_free_space abrt_check_free_space -void check_free_space(unsigned setting_MaxCrashReportsSize); +void check_free_space(unsigned setting_MaxCrashReportsSize, const char *dump_location);
#define trim_debug_dumps abrt_trim_debug_dumps void trim_debug_dumps(const char *dirname, double cap_size, const char *exclude_path); diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index 30b20e2..cb4b6ff 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -91,7 +91,6 @@ abrt_dump_oops_CPPFLAGS = \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ -DLOCALSTATEDIR='"$(localstatedir)"' \
- -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \
@@ -112,7 +111,6 @@ abrt_action_analyze_c_CPPFLAGS = \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ -DLOCALSTATEDIR='"$(localstatedir)"' \
- -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \
@@ -132,7 +130,6 @@ abrt_action_analyze_python_CPPFLAGS = \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ -DLOCALSTATEDIR='"$(localstatedir)"' \
- -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \
@@ -153,7 +150,6 @@ abrt_action_analyze_oops_CPPFLAGS = \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ -DLOCALSTATEDIR='"$(localstatedir)"' \
- -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \
@@ -173,7 +169,6 @@ abrt_action_trim_files_CPPFLAGS = \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ -DLOCALSTATEDIR='"$(localstatedir)"' \
- -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \
@@ -194,7 +189,6 @@ abrt_action_generate_backtrace_CPPFLAGS = \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ -DLOCALSTATEDIR='"$(localstatedir)"' \
- -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \
@@ -214,7 +208,6 @@ abrt_action_analyze_backtrace_CPPFLAGS = \ -DVAR_RUN="$(VAR_RUN)" \ -DCONF_DIR="$(CONF_DIR)" \ -DLOCALSTATEDIR='"$(localstatedir)"' \
- -DDEBUG_DUMPS_DIR="$(DEBUG_DUMPS_DIR)" \ -DDEBUG_INFO_DIR="$(DEBUG_INFO_DIR)" \ -DPLUGINS_LIB_DIR="$(PLUGINS_LIB_DIR)" \ -DPLUGINS_CONF_DIR="$(PLUGINS_CONF_DIR)" \
crash-catcher@lists.fedorahosted.org