From: "Laurențiu Leahu-Vlăducu" <l.leahu-vladucu@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [RFC PATCH pve-storage 1/1] fix #3256: Storage: PBS: ensure passwords are saved and loaded as UTF-8
Date: Fri, 14 Feb 2025 16:40:39 +0100 [thread overview]
Message-ID: <20250214154040.159607-3-l.leahu-vladucu@proxmox.com> (raw)
In-Reply-To: <20250214154040.159607-1-l.leahu-vladucu@proxmox.com>
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@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
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-02-14 15:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-14 15:40 [pve-devel] [RFC PATCH pve-storage/common] fix #3256: allow special characters in storage-related config files Laurențiu Leahu-Vlăducu
2025-02-14 15:40 ` [pve-devel] [RFC PATCH pve-common 1/2] fix #3256: SectionConfig: ensure UTF-8 encoding for general configs Laurențiu Leahu-Vlăducu
2025-02-14 15:40 ` Laurențiu Leahu-Vlăducu [this message]
2025-02-14 15:40 ` [pve-devel] [RFC PATCH pve-common 2/2] SectionConfig: add unit test for UTF-8 configs Laurențiu Leahu-Vlăducu
2025-02-17 10:15 ` [pve-devel] [RFC PATCH pve-storage/common] fix #3256: allow special characters in storage-related config files Fiona Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250214154040.159607-3-l.leahu-vladucu@proxmox.com \
--to=l.leahu-vladucu@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal