]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
unix-manager: doc and whitespace fixes
authorEric Leblond <eric@regit.org>
Mon, 19 Nov 2012 10:53:29 +0000 (11:53 +0100)
committerEric Leblond <eric@regit.org>
Tue, 20 Nov 2012 10:01:54 +0000 (11:01 +0100)
src/runmode-unix-socket.c
src/unix-manager.c

index d83ff932a2fa85dd76aabc0091b2e397ace8a724..79888ecc88877f9d8e6612eb011d74f6cca22bcf 100644 (file)
@@ -194,7 +194,7 @@ TmEcode UnixSocketAddPcapFile(json_t *cmd, json_t* answer, void *data)
     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
@@ -292,7 +292,7 @@ TmEcode UnixSocketPcapFilesCheck(void *data)
             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);
index 44f3dc500d59fb9e65b5e84fd09a43b3f6e59f81..3efa79dd1a63d62fbea4821902c83f41897a711a 100644 (file)
@@ -334,7 +334,7 @@ int UnixCommandAccept(UnixCommand *this)
 
     /* client connected */
     SCLogInfo("Unix socket: client connected");
-    
+
     uclient = SCMalloc(sizeof(UnixClient));
     if (uclient == NULL) {
         SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate new cient");
@@ -352,7 +352,7 @@ int UnixCommandBackgroundTasks(UnixCommand* this)
     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;
         }
@@ -380,13 +380,13 @@ int UnixCommandExecute(UnixCommand * this, char *command, UnixClient *client)
     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;
     }
 
@@ -401,14 +401,14 @@ int UnixCommandExecute(UnixCommand * this, char *command, UnixClient *client)
         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;
             }
@@ -436,6 +436,7 @@ int UnixCommandExecute(UnixCommand * this, char *command, UnixClient *client)
     }
 
     json_decref(jsoncmd);
+    json_decref(server_msg);
     return ret;
 
 error_cmd:
@@ -512,7 +513,6 @@ int UnixMain(UnixCommand * this)
         return 1;
     }
 
-    
     TAILQ_FOREACH(uclient, &this->clients, next) {
         if (FD_ISSET(uclient->fd, &select_set)) {
             UnixCommandRun(this, uclient);
@@ -613,7 +613,7 @@ UnixCommand command;
  * \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)
 {
@@ -663,7 +663,7 @@ TmEcode UnixManagerRegisterCommand(const char * keyword,
  * \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)
 {
@@ -751,7 +751,11 @@ void *UnixManagerThread(void *td)
 }
 
 
-/** \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;