[pve-devel] [RFC PATCH pve-storage 1/1] fix #3256: Storage: PBS: ensure passwords are saved and loaded as UTF-8
Laurențiu Leahu-Vlăducu
l.leahu-vladucu at proxmox.com
Fri Feb 14 16:40:39 CET 2025
Previously, no decoding happened, meaning that Perl interpreted the
string as single bytes instead of Unicode code points when reading
the password.
Also, passwords are now explicitly encoded as UTF-8, preventing issues
the other way around.
For more information, please read:
https://perldoc.perl.org/perlunifaq#When-should-I-decode-or-encode?
Signed-off-by: Laurențiu Leahu-Vlăducu <l.leahu-vladucu at proxmox.com>
---
src/PVE/Storage/PBSPlugin.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/PVE/Storage/PBSPlugin.pm b/src/PVE/Storage/PBSPlugin.pm
index 0808bcc..6d89440 100644
--- a/src/PVE/Storage/PBSPlugin.pm
+++ b/src/PVE/Storage/PBSPlugin.pm
@@ -86,7 +86,7 @@ sub pbs_set_password {
my $pwfile = pbs_password_file_name($scfg, $storeid);
mkdir "/etc/pve/priv/storage";
- PVE::Tools::file_set_contents($pwfile, "$password\n");
+ PVE::Tools::file_set_contents($pwfile, "$password\n", undef, 1);
}
sub pbs_delete_password {
@@ -102,7 +102,7 @@ sub pbs_get_password {
my $pwfile = pbs_password_file_name($scfg, $storeid);
- return PVE::Tools::file_read_firstline($pwfile);
+ return Encode::decode('UTF-8', PVE::Tools::file_read_firstline($pwfile));
}
sub pbs_encryption_key_file_name {
--
2.39.5
More information about the pve-devel
mailing list