From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH storage] fix #5181: pbs: store and read passwords as unicode
Date: Wed, 9 Apr 2025 10:30:19 +0200 [thread overview]
Message-ID: <20250409083019.104537-1-m.sandoval@proxmox.com> (raw)
Previously a password "bär12345" would be stored as "b�r12345".
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
This has the potential for breaking existing setups. However, given that it is
not possible to create such a storage in the first place (without performing a
rare encoding dance and/or editing the config files manually), I suspect the
fallback should be minimial.
This was tested via creating a user test@pbs with password 'bär12345' and then running:
```
pvesm add pbs test --server .. --datastore .. --username test@pbs --password 'bär12345' --fingerprint ..
cat /etc/pve/priv/storage/test.pw
```
src/PVE/Storage/PBSPlugin.pm | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/PVE/Storage/PBSPlugin.pm b/src/PVE/Storage/PBSPlugin.pm
index 9f75794e..7ecddd32 100644
--- a/src/PVE/Storage/PBSPlugin.pm
+++ b/src/PVE/Storage/PBSPlugin.pm
@@ -5,6 +5,7 @@ package PVE::Storage::PBSPlugin;
use strict;
use warnings;
+use Encode qw(decode);
use Fcntl qw(F_GETFD F_SETFD FD_CLOEXEC);
use IO::File;
use JSON;
@@ -91,7 +92,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 {
@@ -107,7 +108,9 @@ sub pbs_get_password {
my $pwfile = pbs_password_file_name($scfg, $storeid);
- return PVE::Tools::file_read_firstline($pwfile);
+ my $contents = PVE::Tools::file_read_firstline($pwfile);
+
+ return eval { decode('UTF-8', $contents, 1) } // $contents;
}
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
reply other threads:[~2025-04-09 8:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250409083019.104537-1-m.sandoval@proxmox.com \
--to=m.sandoval@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