[pve-devel] [PATCH storage v2] fix #5181: pbs: store and read passwords as unicode

Maximiliano Sandoval m.sandoval at proxmox.com
Fri Jun 13 15:11:59 CEST 2025


Maximiliano Sandoval <m.sandoval at proxmox.com> writes:

> At the moment calling
> ```
> pvesm add pbs test --password="bär12345" --datastore='test' # ..other params
> ```
>
> Will result in the API handler getting the param->{passowrd} as a utf-8
> encoded string. When dumped with Debug::Peek's Dump() one can see:
>
> ```
> SV = PV(0x5a02c1a3ff10) at 0x5a02bd713670
>   REFCNT = 1
>   FLAGS = (POK,IsCOW,pPOK,UTF8)
>   PV = 0x5a02c1a409b0 "b\xC3\xA4r12345"\0 [UTF8 "b\x{e4}r12345"]
>   CUR = 9
>   LEN = 11
>   COW_REFCNT = 0
> ```
>
> Then when writing the file via file_set_contents (using syswrite
> internally) will result in perl encoding the password as latin1 and a
> file with contents:
>
> ```
> $ hexdump -C /etc/pve/priv/storage/test.pw
> 00000000  62 e4 72 31 32 33 34 35                           |b.r12345|
> 00000008
> ```
>
> when the correct contents should have been:
> ```
> 00000000  62 c3 a4 72 31 32 33 34  35                       |b..r12345|
> 00000009
> ```
>
> Later when the file is read via file_read_firstline it will result in
>
> ```
> SV = PV(0x5e8baa411090) at 0x5e8baa5a96b8
>   REFCNT = 1
>   FLAGS = (POK,pPOK)
>   PV = 0x5e8baa43ee20 "b\xE4r12345"\0
>   CUR = 8
>   LEN = 81
> ```
>
> which is a different string than the original.
>
> At the moment, adding the storage will work as the utf8 password is
> still in memory, however, however subsequent uses (e.g. pvestatd) will
> fail.
>
> This patch fixes the issue by encoding the string as utf8 both when
> reading and storing it to disk. The user was able in the past to go
> around the issue by writing the right password in
> /etc/pve/priv/{storage}.pw and this fix is compatible with that.
>
> It is documented at
> https://pbs.proxmox.com/docs/backup-client.html#environment-variables
> that the Backup Server password must be valid utf-8.
>
> Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>

Differences from v1:
 - Just the commit message




More information about the pve-devel mailing list