summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Klic <kklic@redhat.com>2009-12-18 17:09:33 +0100
committerKarel Klic <kklic@redhat.com>2009-12-18 17:09:33 +0100
commit46b2fb8df8d4e025f5bbdd9f53be1f658a9e82c6 (patch)
treea500ef39d5e136932943ab54dff17ebf61781db4
parentf0fe841b0f257ee288b6b88a32597a6282952d34 (diff)
downloadabrt-46b2fb8df8d4e025f5bbdd9f53be1f658a9e82c6.tar.gz
abrt-46b2fb8df8d4e025f5bbdd9f53be1f658a9e82c6.tar.xz
abrt-46b2fb8df8d4e025f5bbdd9f53be1f658a9e82c6.zip
cmdline and daemon checking is done by abrt-python-hook
-rw-r--r--src/Hooks/abrt-hook-python.cpp20
-rw-r--r--src/Hooks/abrt_exception_handler.py.in1
-rw-r--r--src/Hooks/sitecustomize.py42
3 files changed, 16 insertions, 47 deletions
diff --git a/src/Hooks/abrt-hook-python.cpp b/src/Hooks/abrt-hook-python.cpp
index cd17e402..3f79d28a 100644
--- a/src/Hooks/abrt-hook-python.cpp
+++ b/src/Hooks/abrt-hook-python.cpp
@@ -34,21 +34,23 @@
static char *pid;
static char *executable;
static char *uuid;
-static char *cmdline;
int main(int argc, char** argv)
{
+ // Error if daemon is not running.
+ if (!daemon_is_ok())
+ error_msg_and_die("Daemon is not running.");
+
// Parse options
static const struct option longopts[] = {
// name , has_arg , flag, val
{ "pid" , required_argument, NULL, 'p' },
{ "executable", required_argument, NULL, 'e' },
{ "uuid" , required_argument, NULL, 'u' },
- { "cmdline" , required_argument, NULL, 'c' },
{ 0 },
};
int opt;
- while ((opt = getopt_long(argc, argv, "p:e:u:c:l:", longopts, NULL)) != -1)
+ while ((opt = getopt_long(argc, argv, "p:e:u:l:", longopts, NULL)) != -1)
{
switch (opt)
{
@@ -61,9 +63,6 @@ int main(int argc, char** argv)
case 'u':
uuid = optarg;
break;
- case 'c':
- cmdline = optarg;
- break;
default:
usage:
error_msg_and_die(
@@ -72,7 +71,6 @@ int main(int argc, char** argv)
" -p,--pid PID PID of process that caused the crash\n"
" -p,--executable PATH absolute path to the program that crashed\n"
" -u,--uuid UUID hash generated from the backtrace\n"
- " -c,--cmdline TEXT command line of the crashed program\n"
);
}
}
@@ -103,8 +101,12 @@ int main(int argc, char** argv)
dd.SaveText(FILENAME_ANALYZER, "Python");
if (executable)
dd.SaveText(FILENAME_EXECUTABLE, executable);
- if (cmdline)
- dd.SaveText("cmdline", cmdline);
+
+ pid_t pidt = xatoi(pid);
+ char *cmdline = get_cmdline(pidt);
+ dd.SaveText("cmdline", cmdline);
+ free(cmdline);
+
if (uuid)
dd.SaveText("uuid", uuid);
diff --git a/src/Hooks/abrt_exception_handler.py.in b/src/Hooks/abrt_exception_handler.py.in
index b5ec35f3..a0b0519d 100644
--- a/src/Hooks/abrt_exception_handler.py.in
+++ b/src/Hooks/abrt_exception_handler.py.in
@@ -111,7 +111,6 @@ def write_dump(pid, tb_uuid, tb):
command.append("--pid=%s" % pid)
command.append("--executable=%s" % executable)
command.append("--uuid=%s" % tb_uuid)
- command.append("--cmdline=%s" % open("/proc/%s/cmdline" % pid).read().replace('\x00',' '))
helper = subprocess.Popen(command, stdin=subprocess.PIPE)
helper.communicate(tb)
diff --git a/src/Hooks/sitecustomize.py b/src/Hooks/sitecustomize.py
index 8027726b..1a015745 100644
--- a/src/Hooks/sitecustomize.py
+++ b/src/Hooks/sitecustomize.py
@@ -5,41 +5,9 @@
# and python interpreter runs it automatically everytime
# some python script is executed.
-def abrt_daemon_ok():
- try:
- #FIXME: make it relocable! this will work only when installed in default path
- #pidfile = open(VAR_RUN_PID_FILE, "r");
- pidfile = open("/var/run/abrt.pid", "r")
- except Exception, ex:
- # log the exception?
- return False
-
- pid = pidfile.readline()
- pidfile.close()
- if not pid:
- return False
-
- try:
- # pid[:-1] strips the trailing '\n'
- cmdline = open("/proc/%s/cmdline" % pid[:-1], "r").readline()
- except Exception, ex:
- # can't read cmdline
- return False
- if not ("abrtd" in cmdline):
- return False
-
- return True
-
-if abrt_daemon_ok():
- # Prevent abrt exception handler from running when the abrtd daemon is
- # not active.
- try:
- from abrt_exception_handler import installExceptionHandler
-
- installExceptionHandler(debug = 1)
- except Exception, e:
- # FIXME: log errors?
- pass
-else:
- #FIXME: log something?
+try:
+ from abrt_exception_handler import installExceptionHandler
+ installExceptionHandler(debug = 1)
+except Exception, e:
+ # FIXME: log errors?
pass