diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-11-16 17:04:55 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-11-16 17:04:55 +0100 |
commit | 473ed1c34b98b0515031eef9bfd3a140d8bb2c92 (patch) | |
tree | 8eda4f2c25e202f333e809b3c252b08c7a0c6415 /lib/Plugins | |
parent | f8c20e22c8919dc1651af5c51cb5a6cf2a26481c (diff) | |
download | abrt-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/Plugins')
-rw-r--r-- | lib/Plugins/RunApp.cpp | 32 |
1 files changed, 25 insertions, 7 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); |