From 0e0aa3788dc3f2bf91f566fee6b695d0cd9939f4 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 13 Nov 2009 14:27:34 +0100 Subject: make plugin descriptions more consistent in style Signed-off-by: Denys Vlasenko --- lib/Plugins/RunApp.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/Plugins/RunApp.cpp') diff --git a/lib/Plugins/RunApp.cpp b/lib/Plugins/RunApp.cpp index e525d89..3be7bdf 100644 --- a/lib/Plugins/RunApp.cpp +++ b/lib/Plugins/RunApp.cpp @@ -63,8 +63,7 @@ PLUGIN_INFO(ACTION, CActionRunApp, "RunApp", "0.0.1", - "Simple action plugin which runs a command " - "and it can save command's output", + "Runs a command, saves its output", "zprikryl@redhat.com", "https://fedorahosted.org/abrt/wiki", ""); -- cgit From 473ed1c34b98b0515031eef9bfd3a140d8bb2c92 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 16 Nov 2009 17:04:55 +0100 Subject: add experimental saving of /var/log/Xorg*.log for X crashes Signed-off-by: Denys Vlasenko --- lib/Plugins/RunApp.cpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'lib/Plugins/RunApp.cpp') diff --git a/lib/Plugins/RunApp.cpp b/lib/Plugins/RunApp.cpp index 3be7bdf..a2aa698 100644 --- a/lib/Plugins/RunApp.cpp +++ b/lib/Plugins/RunApp.cpp @@ -21,7 +21,6 @@ #include "RunApp.h" -#include #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 1) + if (args.size() > FILENAME) { CDebugDump dd; dd.Open(pActionDir); -- cgit From 2ccbb0e4bce7c22a44e67f2de9e5a155bd0aed86 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 18 Nov 2009 13:21:15 +0100 Subject: add support for \" escaping in config file Signed-off-by: Denys Vlasenko --- lib/Plugins/RunApp.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/Plugins/RunApp.cpp') diff --git a/lib/Plugins/RunApp.cpp b/lib/Plugins/RunApp.cpp index a2aa698..f7cbc01 100644 --- a/lib/Plugins/RunApp.cpp +++ b/lib/Plugins/RunApp.cpp @@ -52,6 +52,7 @@ void CActionRunApp::Run(const char *pActionDir, const char *pArgs) */ //Can do it using chdir() in child if we'd open-code popen string cd_and_cmd = ssprintf("cd '%s'; %s", pActionDir, cmd); + VERB1 log("RunApp: executing '%s'", cd_and_cmd.c_str()); FILE *fp = popen(cd_and_cmd.c_str(), "r"); if (fp == NULL) { @@ -65,7 +66,8 @@ void CActionRunApp::Run(const char *pActionDir, const char *pArgs) char line[1024]; while (fgets(line, 1024, fp) != NULL) { - output += line; + if (args.size() > FILENAME) + output += line; } pclose(fp); -- cgit