From 0977486599769b9af8898764e721f213fdd04b62 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 14 Dec 2009 20:56:53 +0100 Subject: abrt-debuginfo-install: better logging Signed-off-by: Denys Vlasenko --- lib/Plugins/CCpp.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 37a2c8b..ba4efa2 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -397,7 +397,9 @@ static void InstallDebugInfos(const char *pDebugDumpDir, /* log() goes to stderr/syslog, it's ok to use it here */ VERB1 log("Executing: %s %s %s %s", "abrt-debuginfo-install", coredump, tempdir, debuginfo_dirs); execlp("abrt-debuginfo-install", "abrt-debuginfo-install", coredump, tempdir, debuginfo_dirs, NULL); - exit(1); + perror_msg("Can't execute '%s'", "abrt-debuginfo-install"); + /* Serious error (1 means "some debuginfos not found") */ + exit(2); } close(pipeout[1]); @@ -436,9 +438,20 @@ static void InstallDebugInfos(const char *pDebugDumpDir, update_client("%s", buff); } } - fclose(pipeout_fp); - wait(NULL); + + int status = 0; + while (waitpid(child, &status, 0) < 0 && errno == EINTR) + continue; + if (WIFEXITED(status)) + { + if (WEXITSTATUS(status) > 1) + error_msg("abrt-debuginfo-install exited with %u", (int)WEXITSTATUS(status)); + } + else + { + error_msg("abrt-debuginfo-install killed by signal %u", (int)WTERMSIG(status)); + } } static double get_dir_size(const char *dirname, -- cgit From b4bd0face2bafdf314f9ba4a3537106c967b8022 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 15 Dec 2009 12:24:39 +0100 Subject: abrt-debuginfo-install stderr is also redirected to parent Signed-off-by: Denys Vlasenko --- lib/Plugins/CCpp.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index ba4efa2..0fe3d32 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -385,11 +385,9 @@ static void InstallDebugInfos(const char *pDebugDumpDir, { close(pipeout[0]); xmove_fd(pipeout[1], STDOUT_FILENO); + /* We want parent to see errors in the same stream */ + xdup2(STDOUT_FILENO, STDERR_FILENO); xmove_fd(xopen("/dev/null", O_RDONLY), STDIN_FILENO); - /* Not a good idea, we won't see any error messages */ - /*close(STDERR_FILENO);*/ - - setsid(); char *coredump = xasprintf("%s/"FILENAME_COREDUMP, pDebugDumpDir); /* SELinux guys are not happy with /tmp, using /var/run/abrt */ -- cgit From 1e119f37b85b90c5a9a17fdcbc80625727b4ab66 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 15 Dec 2009 19:54:51 +0100 Subject: fix all instances of atoi() usage Signed-off-by: Denys Vlasenko --- lib/Plugins/CCpp.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 0fe3d32..c9a31c7 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -309,7 +309,7 @@ static void GetBacktrace(const char *pDebugDumpDir, args[11] = (char*)"info sharedlib"; args[12] = NULL; - ExecVP(args, atoi(UID.c_str()), pBacktrace); + ExecVP(args, xatoi_u(UID.c_str()), pBacktrace); } static void GetIndependentBuildIdPC(const char *unstrip_n_output, @@ -355,7 +355,7 @@ static string run_unstrip_n(const char *pDebugDumpDir) args[3] = NULL; string output; - ExecVP(args, atoi(UID.c_str()), output); + ExecVP(args, xatoi_u(UID.c_str()), output); free(args[1]); @@ -575,7 +575,7 @@ string CAnalyzerCCpp::GetGlobalUUID(const char *pDebugDumpDir) close(pipeout[0]); /* read side of the pipe */ /* abrt-backtrace is executed under the user's uid and gid. */ - uid_t uid = atoi(uid_str.c_str()); + uid_t uid = xatoi_u(uid_str.c_str()); struct passwd* pw = getpwuid(uid); gid_t gid = pw ? pw->pw_gid : uid; setgroups(1, &gid); @@ -670,7 +670,7 @@ void CAnalyzerCCpp::CreateReport(const char *pDebugDumpDir, int force) dd.Close(); /* do not keep dir locked longer than needed */ string build_ids; - if (m_bInstallDebugInfo && DebuginfoCheckPolkit(atoi(UID.c_str()))) + if (m_bInstallDebugInfo && DebuginfoCheckPolkit(xatoi_u(UID.c_str()))) { if (m_nDebugInfoCacheMB > 0) { @@ -761,7 +761,7 @@ void CAnalyzerCCpp::SetSettings(const map_plugin_settings_t& pSettings) it = pSettings.find("DebugInfoCacheMB"); if (it != end) { - m_nDebugInfoCacheMB = atoi(it->second.c_str()); + m_nDebugInfoCacheMB = xatou(it->second.c_str()); } it = pSettings.find("InstallDebugInfo"); if (it == end) //compat, remove after 0.0.11 -- cgit From 716a4ffceeb0c47d24cb00a186fd7c7e3f40992f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 16 Dec 2009 18:33:04 +0100 Subject: lib/Plugins/CCpp.cpp: save gdb error messages too Signed-off-by: Denys Vlasenko --- lib/Plugins/CCpp.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index c9a31c7..15b4707 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -96,7 +96,7 @@ static string concat_str_vector(char **strings) } /* Returns status. See `man 2 wait` for status information. */ -static int ExecVP(char **pArgs, uid_t uid, string& pOutput) +static int ExecVP(char **pArgs, uid_t uid, int redirect_stderr, string& pOutput) { int pipeout[2]; pid_t child; @@ -114,8 +114,6 @@ static int ExecVP(char **pArgs, uid_t uid, string& pOutput) xmove_fd(pipeout[1], STDOUT_FILENO); /* Make sure stdin is safely open to nothing */ xmove_fd(xopen("/dev/null", O_RDONLY), STDIN_FILENO); - /* Not a good idea, we won't see any error messages */ - /* close(STDERR_FILENO); */ struct passwd* pw = getpwuid(uid); gid_t gid = pw ? pw->pw_gid : uid; @@ -136,6 +134,11 @@ static int ExecVP(char **pArgs, uid_t uid, string& pOutput) unsetenv("LC_NUMERIC"); unsetenv("LC_TIME"); + if (redirect_stderr) + { + /* We want parent to see errors in the same stream */ + xdup2(STDOUT_FILENO, STDERR_FILENO); + } execvp(pArgs[0], pArgs); /* VERB1 since sometimes we expect errors here */ VERB1 perror_msg("Can't execute '%s'", pArgs[0]); @@ -309,7 +312,7 @@ static void GetBacktrace(const char *pDebugDumpDir, args[11] = (char*)"info sharedlib"; args[12] = NULL; - ExecVP(args, xatoi_u(UID.c_str()), pBacktrace); + ExecVP(args, xatoi_u(UID.c_str()), /*redirect_stderr:*/ 1, pBacktrace); } static void GetIndependentBuildIdPC(const char *unstrip_n_output, @@ -355,7 +358,7 @@ static string run_unstrip_n(const char *pDebugDumpDir) args[3] = NULL; string output; - ExecVP(args, xatoi_u(UID.c_str()), output); + ExecVP(args, xatoi_u(UID.c_str()), /*redirect_stderr:*/ 0, output); free(args[1]); @@ -385,8 +388,6 @@ static void InstallDebugInfos(const char *pDebugDumpDir, { close(pipeout[0]); xmove_fd(pipeout[1], STDOUT_FILENO); - /* We want parent to see errors in the same stream */ - xdup2(STDOUT_FILENO, STDERR_FILENO); xmove_fd(xopen("/dev/null", O_RDONLY), STDIN_FILENO); char *coredump = xasprintf("%s/"FILENAME_COREDUMP, pDebugDumpDir); @@ -394,6 +395,8 @@ static void InstallDebugInfos(const char *pDebugDumpDir, char *tempdir = xasprintf(LOCALSTATEDIR"/run/abrt/tmp-%u-%lu", (int)getpid(), (long)time(NULL)); /* log() goes to stderr/syslog, it's ok to use it here */ VERB1 log("Executing: %s %s %s %s", "abrt-debuginfo-install", coredump, tempdir, debuginfo_dirs); + /* We want parent to see errors in the same stream */ + xdup2(STDOUT_FILENO, STDERR_FILENO); execlp("abrt-debuginfo-install", "abrt-debuginfo-install", coredump, tempdir, debuginfo_dirs, NULL); perror_msg("Can't execute '%s'", "abrt-debuginfo-install"); /* Serious error (1 means "some debuginfos not found") */ @@ -444,11 +447,11 @@ static void InstallDebugInfos(const char *pDebugDumpDir, if (WIFEXITED(status)) { if (WEXITSTATUS(status) > 1) - error_msg("abrt-debuginfo-install exited with %u", (int)WEXITSTATUS(status)); + error_msg("%s exited with %u", "abrt-debuginfo-install", (int)WEXITSTATUS(status)); } else { - error_msg("abrt-debuginfo-install killed by signal %u", (int)WTERMSIG(status)); + error_msg("%s killed by signal %u", "abrt-debuginfo-install", (int)WTERMSIG(status)); } } -- cgit From 687be490d8092842f9a016132a4204023d9b8d6e Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 16 Dec 2009 19:22:00 +0100 Subject: src/Hooks/CCpp.cpp: use and honour %c (core limit size). Makes MakeCompatCore = yes much more frielndly - now users with ulimit -c 0 won't get unwanted coredumps. Signed-off-by: Denys Vlasenko --- lib/Plugins/CCpp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 15b4707..99c1c77 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -37,7 +37,7 @@ using namespace std; #define CORE_PATTERN_IFACE "/proc/sys/kernel/core_pattern" -#define CORE_PATTERN "|"CCPP_HOOK_PATH" "DEBUG_DUMPS_DIR" %p %s %u" +#define CORE_PATTERN "|"CCPP_HOOK_PATH" "DEBUG_DUMPS_DIR" %p %s %u %c" #define FILENAME_COREDUMP "coredump" #define FILENAME_BACKTRACE "backtrace" -- cgit