diff options
| author | Jiri Moskovcak <jmoskovc@localhost.localdomain> | 2009-11-16 19:31:39 +0100 |
|---|---|---|
| committer | Jiri Moskovcak <jmoskovc@localhost.localdomain> | 2009-11-16 19:31:39 +0100 |
| commit | e02e60e8b1b3083ea13454c61460d72a0188517a (patch) | |
| tree | 1679fa5bf56a00f9b6f3947cc2e1aef1f4c2559f /lib/Plugins/RunApp.cpp | |
| parent | 80a2d45c6ce729fc778d2ecc00569635cf886e7b (diff) | |
| parent | b69dd49d43a7c538c55e5cebab97c5f217cfe8fb (diff) | |
| download | abrt-e02e60e8b1b3083ea13454c61460d72a0188517a.tar.gz abrt-e02e60e8b1b3083ea13454c61460d72a0188517a.tar.xz abrt-e02e60e8b1b3083ea13454c61460d72a0188517a.zip | |
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'lib/Plugins/RunApp.cpp')
| -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); |
