From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id E6B0C1FF15C for ; Wed, 27 Nov 2024 16:07:36 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D21E319DA4; Wed, 27 Nov 2024 16:07:37 +0100 (CET) From: Fiona Ebner To: pbs-devel@lists.proxmox.com Date: Wed, 27 Nov 2024 16:06:58 +0100 Message-Id: <20241127150658.107034-3-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241127150658.107034-1-f.ebner@proxmox.com> References: <20241127150658.107034-1-f.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.054 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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. [directory.rs] Subject: [pbs-devel] [PATCH proxmox-backup 2/2] api: disks: directory: fail if mount unit already exists 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: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Without this check, if a mount unit is present, but the file system is not mounted, it will just get overwritten. The unit might belong to an existing datastore. There already is a check against a duplicate datastore, but only after the mount unit is already overwritten and having the add-datastore flag present is not a precondition to trigger the issue. The check is done even if the newly created directory datastore is removable. While in that case, the mount unit is not overwritten, the conflict for the mount point is still present, so it is nice to fail early. Signed-off-by: Fiona Ebner --- src/api2/node/disks/directory.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/api2/node/disks/directory.rs b/src/api2/node/disks/directory.rs index 7bdf0111..d4690d45 100644 --- a/src/api2/node/disks/directory.rs +++ b/src/api2/node/disks/directory.rs @@ -204,6 +204,11 @@ pub fn create_datastore_disk( } } + let (mount_unit_path, _) = datastore_mount_unit_path_info(&mount_point); + if std::path::PathBuf::from(&mount_unit_path).exists() { + bail!("systemd mount unit {mount_unit_path:?} already exists"); + } + let upid_str = WorkerTask::new_thread( "dircreate", Some(name.clone()), -- 2.39.5 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel