1 /* @(#) $Id: manage_files.c,v 1.10 2009/06/24 17:06:27 dcid Exp $ */
3 /* Copyright (C) 2009 Trend Micro Inc.
6 * This program is a free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License (version 3) as published by the FSF - Free Software
16 char *(months[])={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug",
17 "Sep","Oct","Nov","Dec"};
20 /* OS_GetLogLocation: v0.1, 2005/04/25 */
21 void manage_files(int cday, int cmon, int cyear)
31 char elogfile[OS_FLSIZE +1];
32 char elogfile_old[OS_FLSIZE +1];
34 char alogfile[OS_FLSIZE +1];
35 char alogfile_old[OS_FLSIZE +1];
37 char flogfile[OS_FLSIZE +1];
38 char flogfile_old[OS_FLSIZE +1];
41 /* Getting time from the day before (for log signing) */
45 pp_old = localtime_r(&tm_old, &p_old);
47 pp_old = localtime(&tm_old);
51 memset(elogfile, '\0', OS_FLSIZE +1);
52 memset(elogfile_old, '\0', OS_FLSIZE +1);
53 memset(alogfile, '\0', OS_FLSIZE +1);
54 memset(alogfile_old, '\0', OS_FLSIZE +1);
55 memset(flogfile, '\0', OS_FLSIZE +1);
56 memset(flogfile_old, '\0', OS_FLSIZE +1);
59 /* When the day changes, we wait up to day_wait
60 * before compressing the file.
66 snprintf(elogfile, OS_FLSIZE, "%s/%d/%s/ossec-%s-%02d.log",
72 /* Event log file old */
73 snprintf(elogfile_old, OS_FLSIZE, "%s/%d/%s/ossec-%s-%02d.log",
76 months[pp_old->tm_mon],
80 OS_SignLog(elogfile, elogfile_old, 0);
81 OS_CompressLog(elogfile);
85 snprintf(alogfile, OS_FLSIZE, "%s/%d/%s/ossec-%s-%02d.log",
91 /* alert logfile old */
92 snprintf(alogfile_old, OS_FLSIZE, "%s/%d/%s/ossec-%s-%02d.log",
95 months[pp_old->tm_mon],
98 OS_SignLog(alogfile, alogfile_old, 1);
99 OS_CompressLog(alogfile);
102 /* firewall events */
103 snprintf(flogfile, OS_FLSIZE, "%s/%d/%s/ossec-%s-%02d.log",
109 /* firewall events old */
110 snprintf(flogfile_old, OS_FLSIZE, "%s/%d/%s/ossec-%s-%02d.log",
112 pp_old->tm_year+1900,
113 months[pp_old->tm_mon],
116 OS_SignLog(flogfile, flogfile_old, 0);
117 OS_CompressLog(flogfile);