* [pve-devel] [PATCH storage v2] dirplugin: fix #3986: check for trailing slashes
@ 2024-11-22 13:13 Daniel Herzig
2024-11-22 14:52 ` Thomas Lamprecht
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Herzig @ 2024-11-22 13:13 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 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pve-devel] [PATCH storage v2] dirplugin: fix #3986: check for trailing slashes
2024-11-22 13:13 [pve-devel] [PATCH storage v2] dirplugin: fix #3986: check for trailing slashes Daniel Herzig
@ 2024-11-22 14:52 ` Thomas Lamprecht
2024-11-22 16:35 ` Daniel Herzig
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Lamprecht @ 2024-11-22 14:52 UTC (permalink / raw)
To: Proxmox VE development discussion, Daniel Herzig
Am 22.11.24 um 14:13 schrieb Daniel Herzig:
> 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|;
If we want to use the always available File::Spec module, like Max wanted to
in a recent series, this could be changed to
$opts->{path} = File::Spec->canonpath($opts->{path});
> return $opts;
> }
>
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pve-devel] [PATCH storage v2] dirplugin: fix #3986: check for trailing slashes
2024-11-22 14:52 ` Thomas Lamprecht
@ 2024-11-22 16:35 ` Daniel Herzig
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Herzig @ 2024-11-22 16:35 UTC (permalink / raw)
To: Thomas Lamprecht; +Cc: Proxmox VE development discussion
Thomas Lamprecht <t.lamprecht@proxmox.com> writes:
> Am 22.11.24 um 14:13 schrieb Daniel Herzig:
>> 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|;
>
> If we want to use the always available File::Spec module, like Max wanted to
> in a recent series, this could be changed to
>
> $opts->{path} = File::Spec->canonpath($opts->{path});
>
Thanks! Well, this would look the cleanest to me, I did not have this module on my
radar yet.
Will use it in v3!
>> return $opts;
>> }
>>
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-22 16:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-22 13:13 [pve-devel] [PATCH storage v2] dirplugin: fix #3986: check for trailing slashes Daniel Herzig
2024-11-22 14:52 ` Thomas Lamprecht
2024-11-22 16:35 ` Daniel Herzig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox