From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 3588D611E1 for ; Tue, 20 Oct 2020 11:11:21 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 305DBCF58 for ; Tue, 20 Oct 2020 11:10:51 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 84673CF18 for ; Tue, 20 Oct 2020 11:10:50 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 5329945E48 for ; Tue, 20 Oct 2020 11:10:50 +0200 (CEST) From: Thomas Lamprecht To: pbs-devel@lists.proxmox.com Date: Tue, 20 Oct 2020 11:10:41 +0200 Message-Id: <20201020091044.6971-1-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.130 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [logrotate.rs] Subject: [pbs-devel] applied: [PATCH backup 1/4] log rotate: do NOT overwrite file with possible writers X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Oct 2020 09:11:21 -0000 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 --- 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