Commit 04b56acd authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

When a user requests a system connection also store the password system-wide

This links together the "All users can connect" checkbox on the general
connection page to the "Storage password" combobox in the wireless
security page. When "All users can connect" is checked, we change things
so we store secrets system wide as well, as otherwise you end up with a
connection that does not contain secrets, which makes it rather hard to
use a system connection.
parent 8f5687b1
......@@ -195,6 +195,7 @@ void ConnectionEditorBase::initialize()
// General configuration common to all connection types
auto connectionWidget = new ConnectionWidget(m_connection);
addConnectionWidget(connectionWidget, i18nc("General", "General configuration"));
connect(connectionWidget, &ConnectionWidget::allUsersChanged, this, &ConnectionEditorBase::onAllUsersChanged);
// Add the rest of widgets
QString serviceType;
......@@ -212,6 +213,7 @@ void ConnectionEditorBase::initialize()
this);
addSettingWidget(wifiSecurity, i18n("Wi-Fi Security"));
connect(wifiWidget, QOverload<const QString &>::of(&WifiConnectionWidget::ssidChanged), wifiSecurity, &WifiSecurity::onSsidChanged);
m_wifiSecurity = wifiSecurity;
} else if (type == NetworkManager::ConnectionSettings::Pppoe) { // DSL
auto pppoeWidget = new PppoeWidget(m_connection->setting(NetworkManager::Setting::Pppoe), this);
addSettingWidget(pppoeWidget, i18n("DSL"));
......@@ -514,3 +516,13 @@ void ConnectionEditorBase::validChanged(bool valid)
m_valid = true;
Q_EMIT validityChanged(true);
}
void ConnectionEditorBase::onAllUsersChanged()
{
if (!m_wifiSecurity) {
return;
}
auto allUsers = m_connectionWidget->allUsers();
m_wifiSecurity->setStoreSecretsSystemWide(allUsers);
}
......@@ -14,6 +14,7 @@
class ConnectionWidget;
class SettingWidget;
class WifiSecurity;
class Q_DECL_EXPORT ConnectionEditorBase : public QWidget
{
......@@ -45,6 +46,7 @@ Q_SIGNALS:
private Q_SLOTS:
void replyFinished(QDBusPendingCallWatcher *watcher);
void validChanged(bool valid);
void onAllUsersChanged();
protected:
// Subclassed widget is supposed to take care of layouting for setting widgets
......@@ -63,6 +65,7 @@ private:
NetworkManager::ConnectionSettings::Ptr m_connection;
ConnectionWidget *m_connectionWidget;
QList<SettingWidget *> m_settingWidgets;
WifiSecurity *m_wifiSecurity = nullptr;
void addConnectionWidget(ConnectionWidget *widget, const QString &text);
void addSettingWidget(SettingWidget *widget, const QString &text);
......
......@@ -53,6 +53,7 @@ ConnectionWidget::ConnectionWidget(const NetworkManager::ConnectionSettings::Ptr
connect(m_widget->autoconnect, &QCheckBox::stateChanged, this, &ConnectionWidget::settingChanged);
connect(m_widget->allUsers, &QCheckBox::stateChanged, this, &ConnectionWidget::settingChanged);
connect(m_widget->allUsers, &QCheckBox::stateChanged, this, &ConnectionWidget::allUsersChanged);
connect(m_widget->autoconnectVpn, &QCheckBox::stateChanged, this, &ConnectionWidget::settingChanged);
connect(m_widget->pushButtonPermissions, &QPushButton::clicked, this, &ConnectionWidget::settingChanged);
connect(m_widget->firewallZone, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ConnectionWidget::settingChanged);
......@@ -141,6 +142,11 @@ NMVariantMapMap ConnectionWidget::setting() const
return settings.toMap();
}
bool ConnectionWidget::allUsers() const
{
return m_widget->allUsers->isChecked();
}
void ConnectionWidget::autoVpnToggled(bool on)
{
m_widget->vpnCombobox->setEnabled(on);
......
......@@ -30,12 +30,15 @@ public:
NMVariantMapMap setting() const;
bool allUsers() const;
private Q_SLOTS:
void autoVpnToggled(bool on);
void openAdvancedPermissions();
Q_SIGNALS:
void settingChanged();
void allUsersChanged();
private:
// list of VPN: UUID, name
......
......@@ -508,6 +508,17 @@ QVariantMap Security8021x::setting() const
return setting.toMap();
}
void Security8021x::setPasswordOption(PasswordField::PasswordOption option)
{
m_ui->fastPassword->setPasswordOption(option);
m_ui->leapPassword->setPasswordOption(option);
m_ui->md5Password->setPasswordOption(option);
m_ui->peapPassword->setPasswordOption(option);
m_ui->pwdPassword->setPasswordOption(option);
m_ui->tlsPrivateKeyPassword->setPasswordOption(option);
m_ui->ttlsPassword->setPasswordOption(option);
}
void Security8021x::altSubjectMatchesButtonClicked()
{
QPointer<EditListDialog> editor = new EditListDialog(this);
......
......@@ -12,6 +12,7 @@
#include <NetworkManagerQt/Security8021xSetting>
#include "passwordfield.h"
#include "settingwidget.h"
namespace Ui
......@@ -36,6 +37,8 @@ public:
bool isValid() const override;
void setPasswordOption(PasswordField::PasswordOption option);
private Q_SLOTS:
void altSubjectMatchesButtonClicked();
void connectToServersButtonClicked();
......
......@@ -109,6 +109,23 @@ bool WifiSecurity::isValid() const
return true;
}
void WifiSecurity::setStoreSecretsSystemWide(bool system)
{
if (system) {
m_ui->wepKey->setPasswordOption(PasswordField::StoreForAllUsers);
m_ui->leapPassword->setPasswordOption(PasswordField::StoreForAllUsers);
m_ui->psk->setPasswordOption(PasswordField::StoreForAllUsers);
m_8021xWidget->setPasswordOption(PasswordField::StoreForAllUsers);
m_WPA2Widget->setPasswordOption(PasswordField::StoreForAllUsers);
} else {
m_ui->wepKey->setPasswordOption(PasswordField::StoreForUser);
m_ui->leapPassword->setPasswordOption(PasswordField::StoreForUser);
m_ui->psk->setPasswordOption(PasswordField::StoreForUser);
m_8021xWidget->setPasswordOption(PasswordField::StoreForUser);
m_WPA2Widget->setPasswordOption(PasswordField::StoreForUser);
}
}
void WifiSecurity::loadConfig(const NetworkManager::Setting::Ptr &setting)
{
NetworkManager::WirelessSecuritySetting::Ptr wifiSecurity = setting.staticCast<NetworkManager::WirelessSecuritySetting>();
......
......@@ -44,6 +44,8 @@ public:
bool isValid() const override;
void setStoreSecretsSystemWide(bool system);
public Q_SLOTS:
void onSsidChanged(const QString &ssid);
......@@ -56,6 +58,7 @@ private:
Security8021x *m_8021xWidget = nullptr;
Security8021x *m_WPA2Widget = nullptr;
NetworkManager::WirelessSecuritySetting::Ptr m_wifiSecurity;
bool m_systemWideDefault = false;
};
#endif // PLASMA_NM_WIFI_SECURITY_H
Supports Markdown
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