if(!json_is_string(jarg)) {
SCLogInfo("error: command is not a string");
json_object_set_new(answer, "message", json_string("command is not a string"));
- return TM_ECODE_FAILED;
+ return TM_ECODE_FAILED;
}
filename = json_string_value(jarg);
#ifdef OS_WIN32
if (ConfSet("default-log-dir", cfile->output_dir, 1) != 1) {
SCLogInfo("Can not set output dir to '%s'", cfile->output_dir);
PcapFilesFree(cfile);
- return TM_ECODE_FAILED;
+ return TM_ECODE_FAILED;
}
}
PcapFilesFree(cfile);
/* client connected */
SCLogInfo("Unix socket: client connected");
-
+
uclient = SCMalloc(sizeof(UnixClient));
if (uclient == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate new cient");
Task *ltask;
TAILQ_FOREACH(ltask, &this->tasks, next) {
- int fret = ltask->Func(ltask->data);
+ int fret = ltask->Func(ltask->data);
if (fret != TM_ECODE_OK) {
ret = 0;
}
int found = 0;
Command *lcmd;
- jsoncmd = json_loads(command, 0, &error);
- if (jsoncmd == NULL) {
- SCLogInfo("Invalid command, error on line %d: %s\n", error.line, error.text);
+ if (server_msg == NULL) {
return 0;
}
- if (server_msg == NULL) {
+ jsoncmd = json_loads(command, 0, &error);
+ if (jsoncmd == NULL) {
+ SCLogInfo("Invalid command, error on line %d: %s\n", error.line, error.text);
goto error;
}
if (!strcmp(value, lcmd->name)) {
int fret = TM_ECODE_OK;
found = 1;
- if (lcmd->flags & UNIX_CMD_TAKE_ARGS) {
+ if (lcmd->flags & UNIX_CMD_TAKE_ARGS) {
cmd = json_object_get(jsoncmd, "arguments");
if(!json_is_object(cmd)) {
SCLogInfo("error: argument is not an object");
goto error_cmd;
- }
+ }
}
- fret = lcmd->Func(cmd, server_msg, lcmd->data);
+ fret = lcmd->Func(cmd, server_msg, lcmd->data);
if (fret != TM_ECODE_OK) {
ret = 0;
}
}
json_decref(jsoncmd);
+ json_decref(server_msg);
return ret;
error_cmd:
return 1;
}
-
TAILQ_FOREACH(uclient, &this->clients, next) {
if (FD_ISSET(uclient->fd, &select_set)) {
UnixCommandRun(this, uclient);
* \param flags a flag now used to tune the command type
* \retval TM_ECODE_OK in case of success, TM_ECODE_FAILED in case of failure
*/
-TmEcode UnixManagerRegisterCommand(const char * keyword,
+TmEcode UnixManagerRegisterCommand(const char * keyword,
TmEcode (*Func)(json_t *, json_t *, void *),
void *data, int flags)
{
* \param data a pointer to data that are pass to Func when runned
* \retval TM_ECODE_OK in case of success, TM_ECODE_FAILED in case of failure
*/
-TmEcode UnixManagerRegisterBackgroundTask(
+TmEcode UnixManagerRegisterBackgroundTask(
TmEcode (*Func)(void *),
void *data)
{
}
-/** \brief spawn the unix socket manager thread */
+/** \brief spawn the unix socket manager thread
+ *
+ * \param de_ctx context for detection engine
+ * \param mode if set to 1, init failure cause suricata exit
+ * */
void UnixManagerThreadSpawn(DetectEngineCtx *de_ctx, int mode)
{
ThreadVars *tv_unixmgr = NULL;