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)" \