[plasma-nm/Plasma/5.15] kded: Reject invalid keys
Oleg Solovyov
null at kde.org
Tue Apr 30 14:21:43 BST 2019
Git commit 257b03b185d30312a8c3308092f77ca7a6b9c84d by Oleg Solovyov.
Committed on 30/04/2019 at 13:21.
Pushed by osolovyov into branch 'Plasma/5.15'.
Reject invalid keys
Summary:
PasswordDialog accepted invalid keys, which causes storing them in user's
wallet. In that case, no new secrets will be requested from user:
plasma-nm will silently fail to connect unless key is edited or deleted.
GUI: OK button is disabled when key is invalid
Reviewers: jgrulich
Reviewed By: jgrulich
Subscribers: plasma-devel
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D20900
M +24 -0 kded/passworddialog.cpp
https://commits.kde.org/plasma-nm/257b03b185d30312a8c3308092f77ca7a6b9c84d
diff --git a/kded/passworddialog.cpp b/kded/passworddialog.cpp
index 410d7085..59992ebc 100644
--- a/kded/passworddialog.cpp
+++ b/kded/passworddialog.cpp
@@ -28,6 +28,7 @@
#include <NetworkManagerQt/WirelessSetting>
#include <NetworkManagerQt/VpnSetting>
+#include <NetworkManagerQt/Utils>
#include <KServiceTypeTrader>
#include <KLocalizedString>
@@ -69,6 +70,29 @@ void PasswordDialog::initializeUi()
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &PasswordDialog::accept);
connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &PasswordDialog::reject);
+ connect(m_ui->password, &PasswordField::textChanged, [this](const QString &text){
+ if (m_connectionSettings->connectionType() == NetworkManager::ConnectionSettings::Wireless) {
+ NetworkManager::WirelessSecuritySetting::Ptr wirelessSecuritySetting =
+ m_connectionSettings->setting(NetworkManager::Setting::WirelessSecurity).staticCast<NetworkManager::WirelessSecuritySetting>();
+ bool valid = true;
+
+ if (wirelessSecuritySetting) {
+ switch (wirelessSecuritySetting->keyMgmt()) {
+ case NetworkManager::WirelessSecuritySetting::WpaPsk:
+ valid = wpaPskIsValid(text);
+ break;
+ case NetworkManager::WirelessSecuritySetting::Wep:
+ valid = wepKeyIsValid(text, wirelessSecuritySetting->wepKeyType());
+ break;
+ default:
+ break;
+ }
+ }
+
+ // disable button if key is not valid
+ m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDisabled(!valid);
+ }
+ });
if (m_connectionSettings->connectionType() != NetworkManager::ConnectionSettings::Vpn) {
NetworkManager::Setting::Ptr setting = m_connectionSettings->setting(m_settingName);
More information about the kde-doc-english
mailing list