From cfa3086d95c3a39b584b2d60aa53938e1f30b3dc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabian=20Gr=C3=BCnbichler?= Date: Mon, 23 Jan 2017 13:20:30 +0100 Subject: [PATCH] fix 1153: let crypt() handle unicode CT passwords MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- 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.39.2