Modified files:
config.c
Log message:
Description: Fixes for v2.0.
Reviewed by: dcid
Bug:
Index: config.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/config/config.c,v
diff -u -r1.19 -r1.20
--- config.c 14 Nov 2008 18:55:16 -0000 1.19
+++ config.c 26 Mar 2009 15:01:32 -0000 1.20
@@ -160,6 +160,10 @@
/* Global */
char *xml_start_ossec = "ossec_config";
char *xml_start_agent = "agent_config";
+
+ char *xml_agent_name = "name";
+ char *xml_agent_os = "os";
+ char *xml_agent_overwrite = "overwrite";
if(OS_ReadXML(cfgfile,&xml) < 0)
@@ -202,10 +206,32 @@
else if((modules & CAGENT_CONFIG) &&
(strcmp(node[i]->element, xml_start_agent) == 0))
{
+ int attrs = 0;
XML_NODE chld_node = NULL;
chld_node = OS_GetElementsbyNode(&xml,node[i]);
+ /* Checking if this is specific to any agent. */
+ while(node[i]->attributes[attrs] && node[i]->values[attrs])
+ {
+ if(strcmp(xml_agent_name, node[i]->attributes[attrs]) == 0)
+ {
+ }
+ else if(strcmp(xml_agent_os, node[i]->attributes[attrs]) == 0)
+ {
+ }
+ else if(strcmp(xml_agent_overwrite, node[i]->attributes[attrs]) == 0)
+ {
+ }
+ else
+ {
+ merror(XML_INVATTR, ARGV0, node[i]->attributes[attrs],
+ cfgfile);
+ }
+ attrs++;
+ }
+
+
/* Main element does not need to have any child */
if(chld_node)
{
Modified files:
config.c
Log message:
Description: Adding MergeFile and UnmergeFile (similar to tar). Switching agent code to be only one thread on agentd.
Reviewed by: dcid
Bug:
Index: config.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/config/config.c,v
diff -u -r1.20 -r1.21
--- config.c 26 Mar 2009 15:01:32 -0000 1.20
+++ config.c 16 Apr 2009 20:02:18 -0000 1.21
@@ -206,6 +206,7 @@
else if((modules & CAGENT_CONFIG) &&
(strcmp(node[i]->element, xml_start_agent) == 0))
{
+ int passed_agent_test = 1;
int attrs = 0;
XML_NODE chld_node = NULL;
chld_node = OS_GetElementsbyNode(&xml,node[i]);
@@ -219,6 +220,20 @@
}
else if(strcmp(xml_agent_os, node[i]->attributes[attrs]) == 0)
{
+ char *agentos = getuname();
+
+ if(agentos)
+ {
+ if(!OS_Match2(xml_agent_os, agentos))
+ {
+ passed_agent_test = 0;
+ }
+ free(agentos);
+ }
+ else
+ {
+ merror("%s: ERROR: Unable to retrieve uname.", ARGV0);
{
Modified files:
config.c
Log message:
Description: Adding option to filter the agent config by agent name.
Reviewed by: dcid
Bug:
Index: config.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/config/config.c,v
diff -u -r1.21 -r1.22
--- config.c 16 Apr 2009 20:02:18 -0000 1.21
+++ config.c 10 Jun 2009 19:53:26 -0000 1.22
@@ -168,7 +168,13 @@
if(OS_ReadXML(cfgfile,&xml) < 0)
{
- merror(XML_ERROR, ARGV0, cfgfile, xml.err, xml.err_line);
+ if(modules & CAGENT_CONFIG)
+ {
+ }
+ else
+ {
+ merror(XML_ERROR, ARGV0, cfgfile, xml.err, xml.err_line);
+ }
return(OS_INVALID);
}
@@ -217,6 +223,20 @@
{
if(strcmp(xml_agent_name, node[i]->attributes[attrs]) == 0)
{
+ char *agentname = os_read_agent_name();
+
+ if(!agentname)
+ {
+ passed_agent_test = 0;
+ }
+ else
+ {
+ if(!OS_Match2(node[i]->values[attrs], agentname))
+ {
+ passed_agent_test = 0;
+ }
+ free(agentname);
+ }
}
else if(strcmp(xml_agent_os, node[i]->attributes[attrs]) == 0)
{
@@ -224,7 +244,7 @@
if(agentos)
{
- if(!OS_Match2(xml_agent_os, agentos))
+ if(!OS_Match2(node[i]->values[attrs], agentos))
{
passed_agent_test = 0;
}
@@ -232,6 +252,7 @@
}
else
{
+ passed_agent_test = 0;
merror("%s: ERROR: Unable to retrieve uname.", ARGV0);
}
}
@@ -250,7 +271,7 @@
/* Main element does not need to have any child */
if(chld_node)
{
- if(read_main_elements(xml, modules, chld_node, d1, d2) < 0)
+ if(passed_agent_test && read_main_elements(xml, modules, chld_node, d1, d2) < 0)
{
merror(CONFIG_ERROR, ARGV0, cfgfile);
return(OS_INVALID);
Modified files:
config.c
Log message:
Description: Fixing shared agent config to only be called from agents.. not from the manager.
Reviewed by: dcid
Bug:
Index: config.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/logcollector/config.c,v
diff -u -r1.19 -r1.20
--- config.c 24 Jun 2009 17:06:27 -0000 1.19
+++ config.c 24 Jun 2009 18:52:13 -0000 1.20
@@ -36,8 +36,10 @@
if(ReadConfig(modules, cfgfile, &log_config, NULL) < 0)
return(OS_INVALID);
+ #ifdef CLIENT
modules|= CAGENT_CONFIG;
ReadConfig(modules, AGENTCONFIG, &log_config, NULL);
+ #endif
logff = log_config.config;