From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 113351FF164 for ; Fri, 22 Nov 2024 14:13:40 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2C7F212CC0; Fri, 22 Nov 2024 14:13:47 +0100 (CET) From: Daniel Herzig To: pve-devel@lists.proxmox.com Date: Fri, 22 Nov 2024 14:13:05 +0100 Message-Id: <20241122131305.59062-1-d.herzig@proxmox.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.059 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 Subject: [pve-devel] [PATCH storage v2] dirplugin: fix #3986: check for trailing slashes X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Currently, setting up a directory storage with trailing slashes in the path results in log messages with double slashes, if this path gets expanded by an action like vzdump. This patch removes those trailing slashes once the directory storage class config gets updated. Signed-off-by: Daniel Herzig --- changes since v1: * rebased onto master * added a comment in the code * merged Stoikos on- and Miras offlist input into a new regex v1: https://lore.proxmox.com/pve-devel/20241113163249.76434-1-d.herzig@proxmox.com/ Notes: Functionality can be tested by adding new directory storage with trailing slashes either via the GUI or `pvesm add dir $STORAGENAME --path /some/path/`. `/new/path/` will show up as `/new/path` in `/etc/pve/storage.cfg`, and trailing slashes from earlier defined directory storage paths will be removed. src/PVE/Storage/DirPlugin.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PVE/Storage/DirPlugin.pm b/src/PVE/Storage/DirPlugin.pm index fb23e0a..c72c321 100644 --- a/src/PVE/Storage/DirPlugin.pm +++ b/src/PVE/Storage/DirPlugin.pm @@ -245,6 +245,8 @@ sub check_config { if ($opts->{path} !~ m|^/[-/a-zA-Z0-9_.@]+$|) { die "illegal path for directory storage: $opts->{path}\n"; } + # remove trailing slashes from path + $opts->{path} =~ s|(.*[^/])/+$|$1|; return $opts; } -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel