* [pve-devel] [PATCH storage v3] dirplugin: fix #3986: check for trailing slashes
@ 2024-11-22 16:57 Daniel Herzig
0 siblings, 0 replies; only message in thread
From: Daniel Herzig @ 2024-11-22 16:57 UTC (permalink / raw)
To: 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 <d.herzig@proxmox.com>
---
changes since v2:
* make use of File::Spec->canonpath() for better readability
v2: https://lore.proxmox.com/pve-devel/20241122131305.59062-1-d.herzig@proxmox.com/
Thanks for the hint, Thomas!
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 | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/PVE/Storage/DirPlugin.pm b/src/PVE/Storage/DirPlugin.pm
index fb23e0a..15b67ee 100644
--- a/src/PVE/Storage/DirPlugin.pm
+++ b/src/PVE/Storage/DirPlugin.pm
@@ -6,6 +6,7 @@ use warnings;
use Cwd;
use Encode qw(decode encode);
use File::Path;
+use File::Spec;
use IO::File;
use POSIX;
@@ -245,6 +246,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} = File::Spec->canonpath($opts->{path});
return $opts;
}
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-11-22 16:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-22 16:57 [pve-devel] [PATCH storage v3] dirplugin: fix #3986: check for trailing slashes Daniel Herzig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox