projects
/
ossec-hids.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git]
/
src
/
monitord
/
compress_log.c
diff --git
a/src/monitord/compress_log.c
b/src/monitord/compress_log.c
old mode 100755
(executable)
new mode 100644
(file)
index
5ebfc68
..
6631ce0
--- a/
src/monitord/compress_log.c
+++ b/
src/monitord/compress_log.c
@@
-1,6
+1,3
@@
-/* @(#) $Id: ./src/monitord/compress_log.c, 2011/09/08 dcid Exp $
- */
-
/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
*
/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
*
@@
-12,74
+9,70
@@
#include "shared.h"
#include "monitord.h"
#include "shared.h"
#include "monitord.h"
-#include "os_zlib/os_zlib.h"
+#ifdef ZLIB_SYSTEM
+#include <zlib.h>
+#else
+#include "../external/zlib-1.2.11/zlib.h"
+#endif
-/* gzips a log file */
-void OS_CompressLog(char *logfile)
+/* gzip a log file */
+void OS_CompressLog(const char *logfile)
{
FILE *log;
{
FILE *log;
- gzFile *zlog;
+ gzFile zlog;
char logfileGZ[OS_FLSIZE + 1];
int len, err;
char buf[OS_MAXSTR + 1];
char logfileGZ[OS_FLSIZE + 1];
int len, err;
char buf[OS_MAXSTR + 1];
-
/* Do not compress */
/* Do not compress */
- if(mond.compress == 0)
+ if (mond.compress == 0) {
return;
return;
+ }
-
- /* Clearing the memory */
- memset(logfileGZ,'\0',OS_FLSIZE +1);
+ /* Clear memory */
+ memset(logfileGZ, '\0', OS_FLSIZE + 1);
memset(buf, '\0', OS_MAXSTR + 1);
memset(buf, '\0', OS_MAXSTR + 1);
-
- /* Setting the umask */
+ /* Set umask */
umask(0027);
umask(0027);
-
- /* Creating the gzip file name */
+ /* Create the gzip file name */
snprintf(logfileGZ, OS_FLSIZE, "%s.gz", logfile);
snprintf(logfileGZ, OS_FLSIZE, "%s.gz", logfile);
-
- /* Reading log file */
+ /* Read log file */
log = fopen(logfile, "r");
log = fopen(logfile, "r");
- if(!log)
- {
- /* Do not warn in here, since the alert file may not exist. */
+ if (!log) {
+ /* Do not warn in here, since the alert file may not exist */
return;
}
return;
}
- /* Opening compressed file */
+ /* Open compressed file */
zlog = gzopen(logfileGZ, "w");
zlog = gzopen(logfileGZ, "w");
- if(!zlog)
- {
+ if (!zlog) {
fclose(log);
fclose(log);
- merror(FOPEN_ERROR, ARGV0, logfileGZ);
+ merror(FOPEN_ERROR, ARGV0, logfileGZ, errno, strerror(errno));
return;
}
return;
}
- for(;;)
- {
- len = fread(buf, 1, OS_MAXSTR, log);
- if(len <= 0)
+ for (;;) {
+ len = (int) fread(buf, 1, OS_MAXSTR, log);
+ if (len <= 0) {
break;
break;
- if(gzwrite(zlog, buf, (unsigned)len) != len)
+ }
+ if (gzwrite(zlog, buf, (unsigned)len) != len) {
merror("%s: Compression error: %s", ARGV0, gzerror(zlog, &err));
merror("%s: Compression error: %s", ARGV0, gzerror(zlog, &err));
+ }
}
}
- /* Closing */
fclose(log);
gzclose(zlog);
fclose(log);
gzclose(zlog);
- /* Removing uncompressed file */
+ /* Remove uncompressed file */
unlink(logfile);
return;
}
unlink(logfile);
return;
}
-
-/* EOF */