[pve-devel] [PATCH RFC container] fix 1153: let crypt() handle unicode CT passwords

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Jan 23 13:20:30 CET 2017


according to "perldoc -f crypt", crypt() should downgrade
unicode strings anyway:

If using crypt() on a Unicode string (which potentially has
characters with codepoints above 255), Perl tries to make
sense of the situation by trying to downgrade (a copy of)
the string back to an eight-bit byte string before calling
crypt() (on that copy).  If that works, good.  If not,
crypt() dies with "Wide character in crypt".

login via Spice and ssh works now at least, the noVNC /
vncterm combo seems to be broken because of an unrelated
unicode issue..

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 src/PVE/LXC/Setup/Base.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/LXC/Setup/Base.pm b/src/PVE/LXC/Setup/Base.pm
index 7bf66ca..8cd7255 100644
--- a/src/PVE/LXC/Setup/Base.pm
+++ b/src/PVE/LXC/Setup/Base.pm
@@ -363,7 +363,7 @@ sub set_user_password {
     if (defined($opt_password)) {
 	if ($opt_password !~ m/^\$/) {
 	    my $time = substr (Digest::SHA::sha1_base64 (time), 0, 8);
-	    $opt_password = crypt(encode("utf8", $opt_password), "\$1\$$time\$");
+	    $opt_password = crypt($opt_password, "\$1\$$time\$");
 	};
     } else {
 	$opt_password = '*';
-- 
2.1.4





More information about the pve-devel mailing list