Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: ubuntu installer doesnt work with some specific chars #831

Open
ethicnology opened this issue Sep 20, 2024 · 2 comments
Open

FIX: ubuntu installer doesnt work with some specific chars #831

ethicnology opened this issue Sep 20, 2024 · 2 comments
Labels
bug Something isn't working jira

Comments

@ethicnology
Copy link

On Ubuntu 24.04, I attempted various password combinations, both with and without special characters, but the password I entered during installation didn't work on the installed OS.

I specifically tried using the character 'ù' but couldn’t log in after the installation.

To work around this installer bug, use a simple password during installation, and then change it to a more complex one afterward.

@d-loose
Copy link
Member

d-loose commented Sep 20, 2024

Thanks for your report! I can confirm that this is a bug on the UI side - the crypt hash generated by the dart package used here seems to be wrong when non-ASCII characters are involved.

Examples with salt 12345678

password mkpasswd Crypt.sha512
hello $6$12345678$LIIJIY7.EbVD/LwIjfwOC0PYfvX90XcOScQMlpyv3xUff9MKFQSdLfuepqfqwxYwptrLm2UC0taHvIA9b5/sD/ $6$12345678$LIIJIY7.EbVD/LwIjfwOC0PYfvX90XcOScQMlpyv3xUff9MKFQSdLfuepqfqwxYwptrLm2UC0taHvIA9b5/sD/
ù $6$12345678$wcHIA6EC7x/76SOvEHylmFw.QcH6cIRlFzKuNlLpudCCPrvxgrI8h3GtwMpigDKHlWDjfVZg1bNhwbxWmKjFW1 $6$12345678$6oUTEB76nUlZkgknUBtmuHPJcPN/zrMCJm1NUSGbCSYY/1jVyYUgk1gMBx3kBVBkqzJ84S23UJ0iKpk8Bkb3b0
ü $6$12345678$rhIhNycaj44wWxFOKSGEtq0IeUZjRAN9OIpCdL.Cf82NhgHfVnzygeV0MaoUGsyN6zrnemPdB14uCc63O7Y71/ $6$12345678$YryBcvGbiFvnVnRMfenm49V/gbrpfXLDwGvTfntn7YZ1I1yN0RxKOefKgaH6lVwFZGeQb9E2id0KLwbnAp5Ak/

I'll have a closer look at this next week.

@d-loose d-loose added bug Something isn't working jira labels Sep 20, 2024
@d-loose
Copy link
Member

d-loose commented Sep 20, 2024

Ok, got a bit nerd-sniped by this: the problem is that Dart uses UTF-16 encoding for strings and the crypt.dart used here iterates over the UTF-16 code units of the password, while ubuntu is probably expecting UTF-8 during login.

A simple fix would be:

diff --git a/packages/ubuntu_bootstrap/lib/services/identity_service.dart b/packages/ubuntu_bootstrap/lib/services/identity_service.dart
index ff99d7ee9..f57e300d7 100644
--- a/packages/ubuntu_bootstrap/lib/services/identity_service.dart
+++ b/packages/ubuntu_bootstrap/lib/services/identity_service.dart
@@ -1,3 +1,5 @@
+import 'dart:convert';
+
 import 'package:crypt/crypt.dart';
 import 'package:meta/meta.dart';
 import 'package:subiquity_client/subiquity_client.dart';
@@ -37,7 +39,9 @@ class SubiquityIdentityService implements IdentityService {
       IdentityData(
         realname: identity.realname,
         username: identity.username,
-        cryptedPassword: Crypt.sha512(identity.password).toString(),
+        cryptedPassword:
+            Crypt.sha512(String.fromCharCodes(utf8.encode(identity.password)))
+                .toString(),
         hostname: identity.hostname,
       ),
     );

although it feels a bit hacky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working jira
Projects
None yet
Development

No branches or pull requests

2 participants