summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-11-16 17:04:55 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-11-16 17:04:55 +0100
commit473ed1c34b98b0515031eef9bfd3a140d8bb2c92 (patch)
tree8eda4f2c25e202f333e809b3c252b08c7a0c6415 /lib
parentf8c20e22c8919dc1651af5c51cb5a6cf2a26481c (diff)
downloadabrt-473ed1c34b98b0515031eef9bfd3a140d8bb2c92.tar.gz
abrt-473ed1c34b98b0515031eef9bfd3a140d8bb2c92.tar.xz
abrt-473ed1c34b98b0515031eef9bfd3a140d8bb2c92.zip
add experimental saving of /var/log/Xorg*.log for X crashes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Plugins/RunApp.cpp32
-rw-r--r--lib/Utils/DebugDump.cpp8
2 files changed, 29 insertions, 11 deletions
diff --git a/lib/Plugins/RunApp.cpp b/lib/Plugins/RunApp.cpp
index 3be7bdf4..a2aa6987 100644
--- a/lib/Plugins/RunApp.cpp
+++ b/lib/Plugins/RunApp.cpp
@@ -21,7 +21,6 @@
#include "RunApp.h"
-#include <stdio.h>
#include "DebugDump.h"
#include "ABRTException.h"
#include "CommLayerInner.h"
@@ -30,20 +29,39 @@
#define COMMAND 0
#define FILENAME 1
+using namespace std;
+
void CActionRunApp::Run(const char *pActionDir, const char *pArgs)
{
- update_client(_("Executing RunApp plugin..."));
+ /* Don't update_client() - actions run at crash time */
+ log("RunApp('%s','%s')", pActionDir, pArgs);
- std::string output;
vector_string_t args;
-
parse_args(pArgs, args, '"');
- FILE *fp = popen(args[COMMAND].c_str(), "r");
+ const char *cmd = args[COMMAND].c_str();
+ if (!cmd[0])
+ {
+ return;
+ }
+
+//FIXME: need to be able to escape " in .conf
+ /* Chdir to the dump dir. Command can analyze component and such.
+ * Example:
+ * test x"`cat component`" = x"xorg-x11-apps" && cp /var/log/Xorg.0.log .
+ */
+//Can do it using chdir() in child if we'd open-code popen
+ string cd_and_cmd = ssprintf("cd '%s'; %s", pActionDir, cmd);
+ FILE *fp = popen(cd_and_cmd.c_str(), "r");
if (fp == NULL)
{
- throw CABRTException(EXCEP_PLUGIN, "Can't execute " + args[COMMAND]);
+ /* Happens only on resource starvation (fork fails or out-of-mem) */
+ return;
}
+
+//FIXME: RunApp("gzip -9 </var/log/Xorg.0.log", "Xorg.0.log.gz") fails
+//since we mangle NULs.
+ string output;
char line[1024];
while (fgets(line, 1024, fp) != NULL)
{
@@ -51,7 +69,7 @@ void CActionRunApp::Run(const char *pActionDir, const char *pArgs)
}
pclose(fp);
- if (args.size() > 1)
+ if (args.size() > FILENAME)
{
CDebugDump dd;
dd.Open(pActionDir);
diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp
index ba11d965..2883d01f 100644
--- a/lib/Utils/DebugDump.cpp
+++ b/lib/Utils/DebugDump.cpp
@@ -74,7 +74,7 @@ void CDebugDump::Open(const char *pDir)
bool CDebugDump::Exist(const char* pPath)
{
- std::string fullPath = m_sDebugDumpDir + "/" + pPath;
+ std::string fullPath = concat_path_file(m_sDebugDumpDir.c_str(), pPath);
return ExistFileDir(fullPath.c_str());
}
@@ -433,7 +433,7 @@ void CDebugDump::LoadText(const char* pName, std::string& pData)
{
throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::LoadText(): DebugDump is not opened.");
}
- std::string fullPath = m_sDebugDumpDir + '/' + pName;
+ std::string fullPath = concat_path_file(m_sDebugDumpDir.c_str(), pName);
LoadTextFile(fullPath.c_str(), pData);
}
@@ -443,7 +443,7 @@ void CDebugDump::SaveText(const char* pName, const char* pData)
{
throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::SaveText(): DebugDump is not opened.");
}
- std::string fullPath = m_sDebugDumpDir + "/" + pName;
+ std::string fullPath = concat_path_file(m_sDebugDumpDir.c_str(), pName);
SaveBinaryFile(fullPath.c_str(), pData, strlen(pData));
}
void CDebugDump::SaveBinary(const char* pName, const char* pData, unsigned pSize)
@@ -452,7 +452,7 @@ void CDebugDump::SaveBinary(const char* pName, const char* pData, unsigned pSize
{
throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::SaveBinary(): DebugDump is not opened.");
}
- std::string fullPath = m_sDebugDumpDir + "/" + pName;
+ std::string fullPath = concat_path_file(m_sDebugDumpDir.c_str(), pName);
SaveBinaryFile(fullPath.c_str(), pData, pSize);
}