-/* @(#) $Id$ */
+/* @(#) $Id: ./src/analysisd/dodiff.c, 2012/07/23 dcid Exp $
+ */
/* Copyright (C) 2010 Trend Micro Inc.
* All rights reserved.
* License (version 2) as published by the FSF - Free Software
* Foundation.
*
- * License details at the LICENSE file included with OSSEC or
+ * License details at the LICENSE file included with OSSEC or
* online at: http://www.ossec.net/en/licensing.html
*/
dirrule = strrchr(file, '/');
if(!dirrule)
{
- merror("%s: ERROR: Invalid file name to diff: %s",
+ merror("%s: ERROR: Invalid file name to diff: %s",
ARGV0, file);
return(0);
}
int date_of_change;
char *htpt = NULL;
char flastfile[OS_SIZE_2048 +1];
- char fdifffile[OS_SIZE_2048 +1];
char flastcontent[OS_SIZE_8192 +1];
currently_rule->last_events[0] = NULL;
+
if(lf->hostname[0] == '(')
{
htpt = strchr(lf->hostname, ')');
{
*htpt = '\0';
}
- snprintf(flastfile, OS_SIZE_2048, "%s/%s/%d/%s", DIFF_DIR, lf->hostname+1,
- currently_rule->sigid, DIFF_LAST_FILE);
+ snprintf(flastfile, OS_SIZE_2048, "%s/%s/%d/%s", DIFF_DIR, lf->hostname+1,
+ currently_rule->sigid, DIFF_LAST_FILE);
if(htpt)
{
}
else
{
- snprintf(flastfile, OS_SIZE_2048, "%s/%s/%d/%s", DIFF_DIR, lf->hostname,
+ snprintf(flastfile, OS_SIZE_2048, "%s/%s/%d/%s", DIFF_DIR, lf->hostname,
currently_rule->sigid, DIFF_LAST_FILE);
}
date_of_change = File_DateofChange(flastfile);
if(date_of_change <= 0)
{
- merror("last file: %s",flastfile);
if(!_add2last(lf->log, lf->size, flastfile))
{
merror("%s: ERROR: unable to create last file: %s", ARGV0, flastfile);
}
- /* File was modified. */
- if(lf->hostname[0] == '(')
- {
- htpt = strchr(lf->hostname, ')');
- if(htpt)
- {
- *htpt = '\0';
- }
- snprintf(fdifffile, OS_SIZE_2048, "%s/%s/%d/state.%d", DIFF_DIR, lf->hostname+1,
- currently_rule->sigid, date_of_change);
-
- if(htpt)
- {
- *htpt = ')';
- }
- htpt = NULL;
- }
- else
- {
- snprintf(fdifffile, OS_SIZE_2048, "%s/%s/%d/state.%d", DIFF_DIR, lf->hostname,
- currently_rule->sigid, date_of_change);
- }
-
- rename(flastfile, fdifffile);
if(!_add2last(lf->log, lf->size, flastfile))
{
merror("%s: ERROR: unable to create last file: %s", ARGV0, flastfile);