Merge commit 'v2.5.1'
[ossec-hids.git] / src / agentlessd / agentlessd.c
index 6e6bd2e..2db347f 100755 (executable)
@@ -1,11 +1,11 @@
-/* @(#) $Id: agentlessd.c,v 1.13 2009/06/24 17:06:20 dcid Exp $ */
+/* @(#) $Id$ */
 
 /* Copyright (C) 2009 Trend Micro Inc.
  * All rights reserved.
  *
  * This program is a free software; you can redistribute it
  * and/or modify it under the terms of the GNU General Public
- * License (version 3) as published by the FSF - Free Software
+ * License (version 2) as published by the FSF - Free Software
  * Foundation
  */
 
@@ -69,6 +69,30 @@ int send_intcheck_msg(char *script, char *host, char *msg)
 
 
 
+/* Send generic log message. */
+int send_log_msg(char *script, char *host, char *msg)
+{
+    char sys_location[1024 +1];
+
+    sys_location[1024] = '\0';
+    snprintf(sys_location, 1024, "(%s) %s->%s", script, host, SYSCHECK);
+    
+    if(SendMSG(lessdc.queue, msg, sys_location, LOCALFILE_MQ) < 0)
+    {
+        merror(QUEUE_SEND, ARGV0);
+        if((lessdc.queue = StartMQ(DEFAULTQPATH, WRITE)) < 0)
+        {
+            ErrorExit(QUEUE_FATAL, ARGV0, DEFAULTQPATH);
+        }
+
+        /* If we reach here, we can try to send it again */
+        SendMSG(lessdc.queue, msg, sys_location, LOCALFILE_MQ);
+    }
+    return(0);
+}
+
+
+
 /* Generate diffs alerts. */
 int gen_diff_alert(char *host, char *script, int alert_diff_time)
 {
@@ -392,6 +416,12 @@ int run_periodic_cmd(agentlessd_entries *entry, int test_it)
                     send_intcheck_msg(entry->type, entry->server[i]+1, 
                                       tmp_str);
                 }
+                else if(strncmp(buf, "LOG: ", 4) == 0)
+                {
+                    tmp_str = buf + 5;
+                    send_log_msg(entry->type, entry->server[i]+1,
+                                 tmp_str);
+                }
                 else if((entry->state & LESSD_STATE_DIFF) &&
                         (strncmp(buf, "STORE: ", 7) == 0))
                 {