From 00ce0e833e3d85d674037a077a30d5d8bf71585c Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 13 Oct 2010 16:22:13 +0200 Subject: don't catch crashes of any program which starts with "abrt", not only abrtd Signed-off-by: Denys Vlasenko --- src/hooks/abrt-hook-ccpp.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/hooks/abrt-hook-ccpp.cpp') diff --git a/src/hooks/abrt-hook-ccpp.cpp b/src/hooks/abrt-hook-ccpp.cpp index a35bba11..656d5e29 100644 --- a/src/hooks/abrt-hook-ccpp.cpp +++ b/src/hooks/abrt-hook-ccpp.cpp @@ -388,14 +388,14 @@ int main(int argc, char** argv) close(fd); } - if (strstr(executable, "/abrtd")) + if (strstr(executable, "/abrt")) { - /* If abrtd crashes, we don't want to create a _directory_, + /* If abrtd/abrt-foo crashes, we don't want to create a _directory_, * since that can make new copy of abrtd to process it, * and maybe crash again... * Unlike dirs, mere files are ignored by abrtd. */ - snprintf(path, sizeof(path), "%s/abrtd-coredump", dddir); + snprintf(path, sizeof(path), "%s/abrt-coredump", dddir); 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) -- cgit From e0af345334d225356d9f2fdb9a9b250339ffcea2 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 13 Oct 2010 18:12:39 +0200 Subject: better name for abrt-FOO coredumps Signed-off-by: Denys Vlasenko --- src/hooks/abrt-hook-ccpp.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/hooks/abrt-hook-ccpp.cpp') diff --git a/src/hooks/abrt-hook-ccpp.cpp b/src/hooks/abrt-hook-ccpp.cpp index 656d5e29..c4b71afb 100644 --- a/src/hooks/abrt-hook-ccpp.cpp +++ b/src/hooks/abrt-hook-ccpp.cpp @@ -388,14 +388,15 @@ int main(int argc, char** argv) close(fd); } - if (strstr(executable, "/abrt")) + const char *last_slash = strrchr(executable, '/'); + if (last_slash && strncmp(++last_slash, "abrt", 4)) { /* If abrtd/abrt-foo crashes, we don't want to create a _directory_, * since that can make new copy of abrtd to process it, * and maybe crash again... * Unlike dirs, mere files are ignored by abrtd. */ - snprintf(path, sizeof(path), "%s/abrt-coredump", dddir); + snprintf(path, sizeof(path), "%s/%s-coredump", dddir, 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) -- cgit From 3d74694fba4cb9c1a1ab45c377add2710274450e Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 14 Oct 2010 01:11:29 +0200 Subject: whitespace fix Signed-off-by: Denys Vlasenko --- src/hooks/abrt-hook-ccpp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/hooks/abrt-hook-ccpp.cpp') diff --git a/src/hooks/abrt-hook-ccpp.cpp b/src/hooks/abrt-hook-ccpp.cpp index c4b71afb..15116640 100644 --- a/src/hooks/abrt-hook-ccpp.cpp +++ b/src/hooks/abrt-hook-ccpp.cpp @@ -388,7 +388,7 @@ int main(int argc, char** argv) close(fd); } - const char *last_slash = strrchr(executable, '/'); + const char *last_slash = strrchr(executable, '/'); if (last_slash && strncmp(++last_slash, "abrt", 4)) { /* If abrtd/abrt-foo crashes, we don't want to create a _directory_, -- cgit From 98c21e88d96f3e45c5f47ac8a1b9ef7a4b523566 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 14 Oct 2010 15:56:21 +0200 Subject: fix my embarrassing error (check for equality is strncmp == 0!) Signed-off-by: Denys Vlasenko --- src/hooks/abrt-hook-ccpp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/hooks/abrt-hook-ccpp.cpp') diff --git a/src/hooks/abrt-hook-ccpp.cpp b/src/hooks/abrt-hook-ccpp.cpp index 15116640..279ac5db 100644 --- a/src/hooks/abrt-hook-ccpp.cpp +++ b/src/hooks/abrt-hook-ccpp.cpp @@ -389,7 +389,7 @@ int main(int argc, char** argv) } const char *last_slash = strrchr(executable, '/'); - if (last_slash && strncmp(++last_slash, "abrt", 4)) + if (last_slash && strncmp(++last_slash, "abrt", 4) == 0) { /* If abrtd/abrt-foo crashes, we don't want to create a _directory_, * since that can make new copy of abrtd to process it, -- cgit From 9d9a9dd41313ed5d2e544bb3bcdf08dab6f38a48 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 15 Oct 2010 18:32:46 +0200 Subject: change dd_create API to return dd pointer (no need to dd_init it separately) Signed-off-by: Denys Vlasenko --- src/hooks/abrt-hook-ccpp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/hooks/abrt-hook-ccpp.cpp') diff --git a/src/hooks/abrt-hook-ccpp.cpp b/src/hooks/abrt-hook-ccpp.cpp index 279ac5db..146de6e0 100644 --- a/src/hooks/abrt-hook-ccpp.cpp +++ b/src/hooks/abrt-hook-ccpp.cpp @@ -415,8 +415,8 @@ int main(int argc, char** argv) if (path_len >= (sizeof(path) - sizeof("/"FILENAME_COREDUMP))) return 1; - struct dump_dir *dd = dd_init(); - if (dd_create(dd, path, uid)) + struct dump_dir *dd = dd_create(path, uid); + if (dd) { char *cmdline = get_cmdline(pid); /* never NULL */ char *reason = xasprintf("Process %s was killed by signal %s (SIG%s)", executable, signal_str, signame ? signame : signal_str); -- cgit