Here's another attempt at solving the bug. It adds a flag to add_basics_to_problem_data indicating whether or not we are interested about data from current process. Additionally, it adds optional argument to createAlertSignature, which can be used by sealert to pass the executable directly.
Suggestions are welcome.
Martin
-->8-->8-->8-->8-->8-->8-->8-->8-->8-->8-->8--
- add_basics_to_problem_data takes parameter indicating whether we are adding information about current process - function for adding basic data not from the current process is added to the python api - createAlertSignature takes optional argument that can be used to manually set the executable --- src/include/problem_data.h | 4 +++- src/lib/problem_data.c | 4 ++-- src/report-python/__init__.py | 6 ++++-- src/report-python/problem_data.c | 19 ++++++++++++++----- 4 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/src/include/problem_data.h b/src/include/problem_data.h index 14d1240..f332433 100644 --- a/src/include/problem_data.h +++ b/src/include/problem_data.h @@ -57,7 +57,9 @@ typedef GHashTable problem_data_t;
problem_data_t *new_problem_data(void);
-void add_basics_to_problem_data(problem_data_t *pd); +/* If this_process is true, it means we are adding information about current + * process and can e.g. read path of the executable from /proc. */ +void add_basics_to_problem_data(problem_data_t *pd, int this_process);
static inline void free_problem_data(problem_data_t *problem_data) { diff --git a/src/lib/problem_data.c b/src/lib/problem_data.c index 9d45d3e..7f81ea3 100644 --- a/src/lib/problem_data.c +++ b/src/lib/problem_data.c @@ -57,7 +57,7 @@ problem_data_t *new_problem_data(void) free, free_problem_item); }
-void add_basics_to_problem_data(problem_data_t *pd) +void add_basics_to_problem_data(problem_data_t *pd, int this_process) { const char *analyzer = get_problem_item_content_or_NULL(pd, FILENAME_ANALYZER); if (analyzer == NULL) @@ -106,7 +106,7 @@ void add_basics_to_problem_data(problem_data_t *pd)
pid_t pid = getpid(); const char *executable = get_problem_item_content_or_NULL(pd, FILENAME_EXECUTABLE); - if (executable == NULL && pid > 0) + if (executable == NULL && this_process && pid > 0) { char buf[PATH_MAX+1]; char *exe = xasprintf("/proc/%u/exe", pid); diff --git a/src/report-python/__init__.py b/src/report-python/__init__.py index 6f4f543..a7f7dc3 100644 --- a/src/report-python/__init__.py +++ b/src/report-python/__init__.py @@ -130,14 +130,16 @@ def getVersion():
return _hardcoded_default_version
-def createAlertSignature(component, hashmarkername, hashvalue, summary, alertSignature): +def createAlertSignature(component, hashmarkername, hashvalue, summary, alertSignature, executable=None): pd = problem_data() pd.add("component", component) pd.add("hashmarkername", hashmarkername) pd.add("duphash", hashvalue) pd.add("reason", summary) pd.add("description", alertSignature) - pd.add_basics() + if executable: + pd.add("executable", executable) + pd.add_basics_other_process()
return pd
diff --git a/src/report-python/problem_data.c b/src/report-python/problem_data.c index 9067dea..791c439 100644 --- a/src/report-python/problem_data.c +++ b/src/report-python/problem_data.c @@ -115,7 +115,15 @@ static PyObject *p_create_dump_dir_from_problem_data(PyObject *pself, PyObject * static PyObject *p_add_basics_to_problem_data(PyObject *pself, PyObject *always_null) { p_problem_data *self = (p_problem_data*)pself; - add_basics_to_problem_data(self->cd); + add_basics_to_problem_data(self->cd, 1); + + Py_RETURN_NONE; +} + +static PyObject *p_add_basics_to_problem_data_other_proc(PyObject *pself, PyObject *always_null) +{ + p_problem_data *self = (p_problem_data*)pself; + add_basics_to_problem_data(self->cd, 0);
Py_RETURN_NONE; } @@ -127,10 +135,11 @@ static PyObject *p_add_basics_to_problem_data(PyObject *pself, PyObject *always_
static PyMethodDef p_problem_data_methods[] = { /* method_name, func, flags, doc_string */ - { "add" , p_problem_data_add , METH_VARARGS }, - { "get" , p_get_problem_data_item , METH_VARARGS }, - { "create_dump_dir", p_create_dump_dir_from_problem_data, METH_VARARGS }, - { "add_basics", p_add_basics_to_problem_data, METH_NOARGS }, + { "add" , p_problem_data_add , METH_VARARGS }, + { "get" , p_get_problem_data_item , METH_VARARGS }, + { "create_dump_dir" , p_create_dump_dir_from_problem_data , METH_VARARGS }, + { "add_basics" , p_add_basics_to_problem_data , METH_NOARGS }, + { "add_basics_other_process", p_add_basics_to_problem_data_other_proc, METH_NOARGS }, { NULL } };