Skip to content
Snippets Groups Projects
Commit 4a8dbfc9 authored by Borja's avatar Borja Committed by Vikman Fdez-Castro
Browse files

Fix log rotation in windows (#776)

* Fix log rotation in windows

* Update changelog
parent 36d572ed
Branches
Tags
No related merge requests found
......@@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file.
- Windows prevents agent from renaming file. ([#773](https://github.com/wazuh/wazuh/pull/773))
- Fix manager-agent version comparison in remote upgrades. ([#765](https://github.com/wazuh/wazuh/pull/765))
- Fix log flooding when restarting agent while the merged file is being receiving. ([#788](https://github.com/wazuh/wazuh/pull/788))
- Fix issue when overwriting rotated logs in Windows agents. ([#776](https://github.com/wazuh/wazuh/pull/776))
## [v3.3.0]
......
......@@ -116,7 +116,7 @@ void w_rotate_log(int compress, int keep_log_days, int new_day, int rotate_json,
snprintf(old_rename_path, PATH_MAX, "%s/ossec-%02d-001.log.gz", month_dir, tm.tm_mday);
counter = 1;
while (counter < daily_rotations) {
if (rename(old_rename_path, rename_path) != 0) {
if (rename_ex(old_rename_path, rename_path) != 0) {
merror("Couldn't rename compressed log '%s' to '%s': '%s'", old_rename_path, rename_path, strerror(errno));
return;
}
......@@ -129,7 +129,7 @@ void w_rotate_log(int compress, int keep_log_days, int new_day, int rotate_json,
}
if (!IsFile(old_path)) {
if (rename(old_path, new_path) == 0) {
if (rename_ex(old_path, new_path) == 0) {
if (compress) {
OS_CompressLog(new_path);
}
......@@ -160,7 +160,7 @@ void w_rotate_log(int compress, int keep_log_days, int new_day, int rotate_json,
snprintf(old_rename_path, PATH_MAX, "%s/ossec-%02d-001.json.gz", month_dir, tm.tm_mday);
counter = 1;
while (counter < daily_rotations) {
if (rename(old_rename_path, rename_path) != 0) {
if (rename_ex(old_rename_path, rename_path) != 0) {
merror("Couldn't rename compressed log '%s' to '%s': '%s'", old_rename_path, rename_path, strerror(errno));
return;
}
......@@ -173,7 +173,7 @@ void w_rotate_log(int compress, int keep_log_days, int new_day, int rotate_json,
}
if (!IsFile(old_path_json)) {
if (rename(old_path_json, new_path_json) == 0) {
if (rename_ex(old_path_json, new_path_json) == 0) {
if (compress) {
OS_CompressLog(new_path_json);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment