public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] applied: [PATCH backup 1/4] log rotate: do NOT overwrite file with possible writers
Date: Tue, 20 Oct 2020 11:10:41 +0200	[thread overview]
Message-ID: <20201020091044.6971-1-t.lamprecht@proxmox.com> (raw)

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 | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/tools/logrotate.rs b/src/tools/logrotate.rs
index ce311fbe..f7d1a693 100644
--- a/src/tools/logrotate.rs
+++ b/src/tools/logrotate.rs
@@ -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
-- 
2.27.0





             reply	other threads:[~2020-10-20  9:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-20  9:10 Thomas Lamprecht [this message]
2020-10-20  9:10 ` [pbs-devel] applied: [PATCH backup 2/4] log rotate: factor out compression in private function Thomas Lamprecht
2020-10-20  9:10 ` [pbs-devel] applied: [PATCH backup 3/4] log rotate: do NOT compress first rotation Thomas Lamprecht
2020-10-20  9:10 ` [pbs-devel] applied: [PATCH backup 4/4] log rotate: move basic rotation logic into module for reuse Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201020091044.6971-1-t.lamprecht@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal