]> git.proxmox.com Git - proxmox-backup.git/commitdiff
log rotate: do NOT overwrite file with possible writers
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 20 Oct 2020 08:05:51 +0000 (10:05 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 20 Oct 2020 09:09:17 +0000 (11:09 +0200)
this is not the job of logrotate, and the real 20+ years battle
tested log rotate binary does not do so either as it's actually
pretty dangerous.

If we "replace" the file we break any logger which already opened a
new one here, e.g., a dameon starting up, and thus that writer would
log to nirvana.

It's the job of a logger to create a file if not existing, it makes
no sense to do it here.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/tools/logrotate.rs

index ce311fbe01e9e0fc9d930ea6206f25479f524c65..f7d1a693322166ff1d680c91e8444190a6618931 100644 (file)
@@ -6,7 +6,7 @@ use std::io::Read;
 use anyhow::{bail, Error};
 use nix::unistd;
 
-use proxmox::tools::fs::{CreateOptions, make_tmp_file, replace_file};
+use proxmox::tools::fs::{CreateOptions, make_tmp_file};
 
 /// Used for rotating log files and iterating over them
 pub struct LogRotate {
@@ -108,8 +108,6 @@ impl LogRotate {
             rename(&filenames[0], &filenames[1])?;
         }
 
-        // create empty original file
-        replace_file(&filenames[0], b"", options)?;
 
         if let Some(max_files) = max_files {
             // delete all files > max_files