@@ -19,6 +19,7 @@
1919#include "../Greeter.h"
2020#include "../GreeterPrivate.h"
2121#include <QtCore/QDir>
22+#include <QtCore/QProcess>
2223#include <QtCore/QSettings>
2324
2425namespace QLightDM
@@ -55,15 +56,25 @@ void GreeterPrivate::handleRespond(const QString &response)
5556
5657 QSettings settings(QDir::homePath() + "/.unity8-greeter-demo", QSettings::NativeFormat);
5758 settings.beginGroup(authenticationUser);
58− QVariant password = settings.value("password", "none");
59+ QVariant passwordValue(settings.value("passwordValue", QString()));
60+ QStringList passwordParts = passwordValue.toString().split('$', QString::SkipEmptyParts);
5961
60− QString passwordValue;
61− if (password == "pin") {
62− passwordValue = settings.value("passwordValue", "1234").toString();
62+ // We only support passwd type 6 (sha512) for now
63+ if (passwordParts.length() == 3 && passwordParts[0] == "6") {
64+ QString command = "mkpasswd --method=sha-512 --stdin --salt=" + passwordParts[1];
65+
66+ QProcess process;
67+ process.start(command);
68+ process.write(response.toLatin1());
69+ process.closeWriteChannel();
70+ process.waitForFinished();
71+
72+ QString result = QString(process.readAllStandardOutput()).trimmed();
73+ authenticated = result == passwordValue;
6374 } else {
64− passwordValue = settings.value("passwordValue", "password").toString();
75+ authenticated = false;
6576 }
66− authenticated = (response == passwordValue);
77+
6778 Q_EMIT q->authenticationComplete();
6879}
6980