ossec-hids: file-queue.c (HEAD) store_op.c (HEAD) [dcid]

0 views
Skip to first unread message

OSSEC CVS

unread,
Nov 22, 2008, 5:19:50 PM11/22/08
to osse...@ossec.net
Module name: ossec-hids
Changes by: dcid 08/11/22 18:19:47

Modified files:
file-queue.c store_op.c

Log message:
Description: Adding report tool.
Reviewed by: dcid
Bug:

Index: file-queue.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/file-queue.c,v
diff -u -r1.9 -r1.10
--- file-queue.c 17 Jun 2008 17:04:09 -0000 1.9
+++ file-queue.c 22 Nov 2008 22:19:47 -0000 1.10
@@ -58,12 +58,20 @@
fileq->file_name[0] = '\0';
fileq->file_name[MAX_FQUEUE] = '\0';

- snprintf(fileq->file_name, MAX_FQUEUE,
- "%s/%d/%s/ossec-alerts-%02d.log",
- ALERTS,
- fileq->year,
- fileq->mon,
- fileq->day);
+ if(fileq->flags & CRALERT_FP_SET)
+ {
+ snprintf(fileq->file_name, MAX_FQUEUE,
+ "<stdin>");
+ }
+ else
+ {
+ snprintf(fileq->file_name, MAX_FQUEUE,
+ "%s/%d/%s/ossec-alerts-%02d.log",
+ ALERTS,
+ fileq->year,
+ fileq->mon,
+ fileq->day);
+ }
}


@@ -71,29 +79,32 @@
/** int Handle_Queue(file_queue *fileq)
* Re Handle the file queue.
*/
-int Handle_Queue(file_queue *fileq, u_int8_t seek_end)
+int Handle_Queue(file_queue *fileq, int flags)
{
/* Closing if it is open */
- if(fileq->fp)
+ if(!(flags & CRALERT_FP_SET))
{
- fclose(fileq->fp);
- fileq->fp = NULL;
- }
-
-
- /* We must be able to open the file, fseek and get the
- * time of change from it.
- */
- fileq->fp = fopen(fileq->file_name, "r");
- if(!fileq->fp)
- {
- /* Queue not available */
- return(0);
+ if(fileq->fp)
+ {
+ fclose(fileq->fp);
+ fileq->fp = NULL;
+ }
+
+
+ /* We must be able to open the file, fseek and get the
+ * time of change from it.
+ */
+ fileq->fp = fopen(fileq->file_name, "r");
+ if(!fileq->fp)
+ {
+ /* Queue not available */
+ return(0);
+ }
}


/* Seeking the end of file */
- if(seek_end)
+ if(!(flags & CRALERT_READ_ALL))
{
if(fseek(fileq->fp, 0, SEEK_END) < 0)
{
@@ -127,7 +138,10 @@
int Init_FileQueue(file_queue *fileq, struct tm *p, int flags)
{
/* Initializing file_queue fields. */
- fileq->fp = NULL;
+ if(!(flags & CRALERT_FP_SET))
+ {
+ fileq->fp = NULL;
+ }
fileq->last_change = 0;
fileq->flags = 0;

@@ -147,7 +161,7 @@


/* Always seek end when starting the queue */
- if(Handle_Queue(fileq, 1) < 0)
+ if(Handle_Queue(fileq, fileq->flags) < 0)
{
return(-1);
}

Index: store_op.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/store_op.c,v
diff -u -r1.9 -r1.10
--- store_op.c 17 Jun 2008 17:04:09 -0000 1.9
+++ store_op.c 22 Nov 2008 22:19:47 -0000 1.10
@@ -39,6 +39,7 @@
}


+
/* Deletes the list storage
* Return NULL on error
*/
@@ -76,6 +77,7 @@
}


+
/* Set the maximum number of elements
* in the storage. Returns 0 on error or
* 1 on success.
@@ -99,6 +101,7 @@
}


+
/* Set the pointer to the function to free the memory
* data.
*/
@@ -115,6 +118,94 @@



+/* Sorts the storage by size.
+ *
+ */
+int OSStore_Sort(OSStore *list, void*(sort_data_function)(void *d1, void *d2))
+{
+ OSStoreNode *newnode = NULL;
+ OSStoreNode *movenode = NULL;
+ list->cur_node = list->first_node;
+
+ while(list->cur_node)
+ {
+ movenode = list->cur_node->prev;
+
+ /* Here we check for all the previous entries, using the sort . */
+ while(movenode)
+ {
+
+ if(sort_data_function(list->cur_node->data, movenode->data))
+ {
+ movenode = movenode->prev;
+ }
+
+ /* In here, this node should stay where it is. */
+ else if(movenode == list->cur_node->prev)
+ {
+ break;
+ }
+
+ /* In here we need to replace the nodes. */
+ else
+ {
+ newnode = list->cur_node;
+
+ if(list->cur_node->prev)
+ list->cur_node->prev->next = list->cur_node->next;
+
+ if(list->cur_node->next)
+ list->cur_node->next->prev = list->cur_node->prev;
+ else
+ list->last_node = list->cur_node->prev;
+
+ list->cur_node = list->cur_node->prev;
+
+
+ newnode->next = movenode->next;
+ newnode->prev = movenode;
+
+ if(movenode->next)
+ movenode->next->prev = newnode;
+
+ movenode->next = newnode;
+
+
+ break;
+ }
+ }
+
+
+ /* If movenode is not set, we need to put the current node in first.*/
+ if(!movenode && (list->cur_node != list->first_node))
+ {
+ newnode = list->cur_node;
+
+ if(list->cur_node->prev)
+ list->cur_node->prev->next = list->cur_node->next;
+
+ if(list->cur_node->next)
+ list->cur_node->next->prev = list->cur_node->prev;
+ else
+ list->last_node = list->cur_node->prev;
+
+ list->cur_node = list->cur_node->prev;
+
+ newnode->prev = NULL;
+ newnode->next = list->first_node;
+ list->first_node->prev = newnode;
+
+ list->first_node = newnode;
+ }
+
+ list->cur_node = list->cur_node->next;
+ }
+
+ return(1);
+}
+
+
+
/* Get key position from storage
* Returns 0 if not present or the key
* if available.
@@ -141,6 +232,16 @@
pos++;
}
return(0);
+}
+
+
+
+/* Get first node from storage.
+ * Returns NULL if not present.
+ */
+OSStoreNode *OSStore_GetFirstNode(OSStore *list)
+{
+ return(list->first_node);
}


OSSEC CVS

unread,
Jun 24, 2009, 2:53:13 PM6/24/09
to osse...@ossec.net
Module name: ossec-hids
Changes by: dcid 09/06/24 15:53:09

Modified files:
agent_op.c debug_op.c dirtree_op.c file-queue.c file_op.c hash_op.c
help.c list_op.c math_op.c mem_op.c mq_op.c privsep_op.c
pthreads_op.c read-agents.c read-alert.c regex_op.c report_op.c
rules_op.c sig_op.c store_op.c validate_op.c wait_op.c

Log message:
Description: Changing copyrights to Trend Micro
Reviewed by: dcid
Bug:

Index: agent_op.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/agent_op.c,v
diff -u -r1.6 -r1.7
--- agent_op.c 24 Jun 2009 18:52:13 -0000 1.6
+++ agent_op.c 24 Jun 2009 18:53:08 -0000 1.7
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it

Index: debug_op.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/debug_op.c,v
diff -u -r1.14 -r1.15
--- debug_op.c 17 Jun 2008 17:04:09 -0000 1.14
+++ debug_op.c 24 Jun 2009 18:53:08 -0000 1.15
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2004-2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it

Index: dirtree_op.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/dirtree_op.c,v
diff -u -r1.3 -r1.4
--- dirtree_op.c 17 Jun 2008 17:04:09 -0000 1.3
+++ dirtree_op.c 24 Jun 2009 18:53:08 -0000 1.4
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it

Index: file-queue.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/file-queue.c,v

diff -u -r1.10 -r1.11
--- file-queue.c 22 Nov 2008 22:19:47 -0000 1.10
+++ file-queue.c 24 Jun 2009 18:53:08 -0000 1.11
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
*
* This program is a free software; you can redistribute it

Index: file_op.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/file_op.c,v
diff -u -r1.31 -r1.32
--- file_op.c 16 Apr 2009 23:09:30 -0000 1.31
+++ file_op.c 24 Jun 2009 18:53:08 -0000 1.32
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2004-2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it

Index: hash_op.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/hash_op.c,v
diff -u -r1.4 -r1.5
--- hash_op.c 17 Jun 2008 17:04:09 -0000 1.4
+++ hash_op.c 24 Jun 2009 18:53:08 -0000 1.5
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it

Index: help.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/help.c,v
diff -u -r1.8 -r1.9
--- help.c 17 Jun 2008 17:04:09 -0000 1.8
+++ help.c 24 Jun 2009 18:53:08 -0000 1.9
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it

Index: list_op.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/list_op.c,v
diff -u -r1.16 -r1.17
--- list_op.c 17 Jun 2008 17:04:09 -0000 1.16
+++ list_op.c 24 Jun 2009 18:53:08 -0000 1.17
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
*
* This program is a free software; you can redistribute it

Index: math_op.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/math_op.c,v
diff -u -r1.2 -r1.3
--- math_op.c 17 Jun 2008 17:04:09 -0000 1.2
+++ math_op.c 24 Jun 2009 18:53:08 -0000 1.3
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it

Index: mem_op.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/mem_op.c,v
diff -u -r1.6 -r1.7
--- mem_op.c 17 Jun 2008 17:04:09 -0000 1.6
+++ mem_op.c 24 Jun 2009 18:53:08 -0000 1.7
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2005,2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it

Index: mq_op.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/mq_op.c,v
diff -u -r1.24 -r1.25
--- mq_op.c 17 Jun 2008 17:04:09 -0000 1.24
+++ mq_op.c 24 Jun 2009 18:53:08 -0000 1.25
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2004-2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it

Index: privsep_op.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/privsep_op.c,v
diff -u -r1.7 -r1.8
--- privsep_op.c 17 Jun 2008 17:04:09 -0000 1.7
+++ privsep_op.c 24 Jun 2009 18:53:08 -0000 1.8
@@ -1,6 +1,6 @@
/* $OSSEC, privsep_op.h, v0.2, 2004/08/05, Daniel B. Cid$ */

-/* Copyright (C) 2004,2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
*
* This program is a free software; you can redistribute it

Index: pthreads_op.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/pthreads_op.c,v
diff -u -r1.7 -r1.8
--- pthreads_op.c 17 Jun 2008 17:04:09 -0000 1.7
+++ pthreads_op.c 24 Jun 2009 18:53:08 -0000 1.8
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it

Index: read-agents.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/read-agents.c,v
diff -u -r1.17 -r1.18
--- read-agents.c 3 Jun 2009 18:09:55 -0000 1.17
+++ read-agents.c 24 Jun 2009 18:53:08 -0000 1.18
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2005-2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
*
* This program is a free software; you can redistribute it

Index: read-alert.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/read-alert.c,v
diff -u -r1.9 -r1.10
--- read-alert.c 17 Jun 2008 17:04:09 -0000 1.9
+++ read-alert.c 24 Jun 2009 18:53:08 -0000 1.10
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
*
* This program is a free software; you can redistribute it

Index: regex_op.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/regex_op.c,v
diff -u -r1.11 -r1.12
--- regex_op.c 17 Jun 2008 17:04:09 -0000 1.11
+++ regex_op.c 24 Jun 2009 18:53:08 -0000 1.12
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2005,2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it

Index: report_op.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/report_op.c,v
diff -u -r1.1 -r1.2
--- report_op.c 26 Nov 2008 16:34:25 -0000 1.1
+++ report_op.c 24 Jun 2009 18:53:08 -0000 1.2
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it

Index: rules_op.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/rules_op.c,v
diff -u -r1.5 -r1.6
--- rules_op.c 21 May 2009 14:41:36 -0000 1.5
+++ rules_op.c 24 Jun 2009 18:53:08 -0000 1.6
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it

Index: sig_op.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/sig_op.c,v
diff -u -r1.7 -r1.8
--- sig_op.c 17 Jun 2008 17:04:09 -0000 1.7
+++ sig_op.c 24 Jun 2009 18:53:09 -0000 1.8
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
*
* This program is a free software; you can redistribute it

Index: store_op.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/store_op.c,v

diff -u -r1.10 -r1.11
--- store_op.c 22 Nov 2008 22:19:47 -0000 1.10
+++ store_op.c 24 Jun 2009 18:53:09 -0000 1.11
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
*
* This program is a free software; you can redistribute it

Index: validate_op.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/validate_op.c,v
diff -u -r1.26 -r1.27
--- validate_op.c 8 Aug 2008 17:18:30 -0000 1.26
+++ validate_op.c 24 Jun 2009 18:53:09 -0000 1.27
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2004-2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it

Index: wait_op.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/shared/wait_op.c,v
diff -u -r1.4 -r1.5
--- wait_op.c 17 Jun 2008 17:04:09 -0000 1.4
+++ wait_op.c 24 Jun 2009 18:53:09 -0000 1.5
@@ -1,6 +1,6 @@
/* @(#) $Id$ */

-/* Copyright (C) 2006-2008 Third Brigade, Inc.
+/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it

Reply all
Reply to author
Forward
0 new messages