X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=ossec-hids.git;a=blobdiff_plain;f=src%2Fos_dbd%2Fdbd.c;h=3cf3b7aadae4fe95e28b9b62612360d25adb6e02;hp=dff139c6ca914e30b9604fb2a6aa2a21a1aae4cd;hb=3f728675941dc69d4e544d3a880a56240a6e394a;hpb=927951d1c1ad45ba9e7325f07d996154a91c911b diff --git a/src/os_dbd/dbd.c b/src/os_dbd/dbd.c old mode 100755 new mode 100644 index dff139c..3cf3b7a --- a/src/os_dbd/dbd.c +++ b/src/os_dbd/dbd.c @@ -1,6 +1,3 @@ -/* @(#) $Id: ./src/os_dbd/dbd.c, 2011/09/08 dcid Exp $ - */ - /* Copyright (C) 2009 Trend Micro Inc. * All rights reserved. * @@ -8,82 +5,60 @@ * and/or modify it under the terms of the GNU General Public * License (version 2) as published by the FSF - Free Software * Foundation. - * - * License details at the LICENSE file included with OSSEC or - * online at: http://www.ossec.net/en/licensing.html */ - -#ifndef DBD - #define DBD -#endif - -#ifndef ARGV0 - #define ARGV0 "ossec-dbd" -#endif - #include "shared.h" #include "dbd.h" +#ifndef ARGV0 +#define ARGV0 "ossec-dbd" +#endif -/* OS_DBD: Monitor the alerts and insert them into the database. - * Only return in case of error. +/* Monitor the alerts and insert them into the database + * Only returns in case of error */ void OS_DBD(DBConfig *db_config) { time_t tm; struct tm *p; - file_queue *fileq; alert_data *al_data; - - /* Getting currently time before starting */ + /* Get current time before starting */ tm = time(NULL); - p = localtime(&tm); + p = localtime(&tm); - - /* Initating file queue - to read the alerts */ + /* Initialize file queue to read the alerts */ os_calloc(1, sizeof(file_queue), fileq); Init_FileQueue(fileq, p, 0); - - /* Creating location hash */ + /* Create location hash */ db_config->location_hash = OSHash_Create(); - if(!db_config->location_hash) - { - ErrorExit(MEM_ERROR, ARGV0); + if (!db_config->location_hash) { + ErrorExit(MEM_ERROR, ARGV0, errno, strerror(errno)); } - - /* Getting maximum ID */ + /* Get maximum ID */ db_config->alert_id = OS_SelectMaxID(db_config); db_config->alert_id++; - - /* Infinite loop reading the alerts and inserting them. */ - while(1) - { + /* Infinite loop reading the alerts and inserting them */ + while (1) { tm = time(NULL); p = localtime(&tm); - /* Get message if available (timeout of 5 seconds) */ al_data = Read_FileMon(fileq, p, 5); - if(!al_data) - { + if (!al_data) { continue; } - - /* Inserting into the db */ + /* Insert into the db */ OS_Alert_InsertDB(al_data, db_config); - - /* Clearing the memory */ + /* Clear the memory */ FreeAlertData(al_data); } } -/* EOF */