Commit 70bc7c6f authored by Jan Blackquill's avatar Jan Blackquill 🌈
Browse files

Use Cracklib for password checking

parent e33ae373
......@@ -15,7 +15,7 @@ set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
include(KDEInstallDirs)
find_package(Qt5 COMPONENTS Core Quick QuickControls2 DBus REQUIRED)
find_package(Qt5 COMPONENTS Core Widgets Quick QuickControls2 DBus REQUIRED)
find_package(KF5I18n)
find_package(KF5Config)
find_package(PkgConfig REQUIRED)
......
......@@ -22,9 +22,10 @@ target_compile_definitions(org.kde.initialsystemsetup
)
target_link_libraries(org.kde.initialsystemsetup
PRIVATE
Qt5::Core Qt5::Quick Qt5::QuickControls2 Qt5::DBus
Qt5::Core Qt5::Widgets Qt5::Quick Qt5::QuickControls2 Qt5::DBus
KF5::I18n KF5::ConfigCore
PkgConfig::GIO
crack
)
configure_file(org.kde.initialsystemsetup.service.in org.kde.initialsystemsetup.service @ONLY)
......
import QtQuick 2.5
import QtQuick.Controls 2.10
import QtQuick.Layouts 1.10
import org.kde.kirigami 2.10 as Kirigami
Item {
......@@ -26,14 +27,14 @@ Item {
TextField {
id: name
text: KISS.username
text: KISS.realname
Kirigami.FormData.label: "Realname:"
}
TextField {
id: user
text: KISS.password
text: KISS.username
Kirigami.FormData.label: "Username:"
}
......@@ -44,5 +45,12 @@ Item {
Kirigami.FormData.label: "Password:"
}
Kirigami.InlineMessage {
text: KISS.checkPassword(user.text, name.text, pass.text)
type: Kirigami.MessageType.Error
visible: pass.text !== "" && text !== ""
Layout.fillWidth: true
}
}
}
......@@ -16,6 +16,8 @@
#include "Settings.h"
#include "DisplayManagerBackends/SDDM.h"
#include <crack.h>
#include <optional>
static auto backends = QMap<QString,std::function<Backend*()>> {
......@@ -115,4 +117,18 @@ public: void reset_ ## name() {\
Systemd::instance()->stopService("org.kde.initialsystemsetup");
}
public: Q_INVOKABLE QString checkPassword(const QString& username, const QString& realname, const QString& password)
{
auto usernameData = username.toLocal8Bit();
auto realnameData = realname.toLocal8Bit();
auto passwordData = password.toLocal8Bit();
usernameData.data();
auto data = FascistCheckUser(passwordData.data(), GetDefaultCracklibDict(), usernameData.data(), realnameData.data());
if (data == nullptr) {
return QString();
}
return QString::fromLocal8Bit(data);
}
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment