all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH storage] fix #5181: pbs: store and read passwords as unicode
@ 2025-04-09  8:30 Maximiliano Sandoval
  0 siblings, 0 replies; only message in thread
From: Maximiliano Sandoval @ 2025-04-09  8:30 UTC (permalink / raw)
  To: pve-devel

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-04-09  8:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-09  8:30 [pve-devel] [PATCH storage] fix #5181: pbs: store and read passwords as unicode Maximiliano Sandoval

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal