|
|
|
#include "connectionsettingsengine.h"
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
QString ConnectionSettingsEngine::targetConnUuidStr = QString();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The configuration map:
|
|
|
|
*
|
|
|
|
* connName: QString
|
|
|
|
* autoconnectEnabled: bool
|
|
|
|
* autoconnectPriority: int
|
|
|
|
* allUsersMayConnect: bool
|
|
|
|
* vpnAutoconnectEnabled: bool
|
|
|
|
* autoconnectVpn: QString
|
|
|
|
* meteredConnection: ConnectionSettingsEngine::Metered
|
|
|
|
* device: QString
|
|
|
|
* clonedMacAddress: QString
|
|
|
|
* mtu: int
|
|
|
|
*
|
|
|
|
* All things IPv4:
|
|
|
|
*
|
|
|
|
* ipv4Method: ConnectionSettingsEngine::Ipv4Method
|
|
|
|
* ipv4DnsServers: QString
|
|
|
|
* ipv4SearchDomains: QString
|
|
|
|
* ipv4DhcpClientId: QString
|
|
|
|
* ipv4AddressList: QList<NetworkManager::IpAddress>
|
|
|
|
* ipv4Required: bool
|
|
|
|
*
|
|
|
|
* All things IPv6:
|
|
|
|
*
|
|
|
|
* ipv6Method: ConnectionSettingsEngine::Ipv6Method
|
|
|
|
* ipv6DnsServers: QString
|
|
|
|
* ipv6SearchDomains: QString
|
|
|
|
* ipv6Privacy: ConnectionSettingsEngine::Ipv6Privacy
|
|
|
|
* ipv6AddressList: QList<NetworkManager::IpAddress>
|
|
|
|
* ipv6Required: bool
|
|
|
|
*
|
|
|
|
* All things 802.1x:
|
|
|
|
*
|
|
|
|
* NOTE: File names begin with "file://"!
|
|
|
|
*
|
|
|
|
* 802.1xEnabled: bool
|
|
|
|
* 802.1xAuthMode: ConnectionSettingsEngine::Security802_1xAuthMode
|
|
|
|
* 802.1xPasswordStore: ConnectionSettingsEngine::Security802_1xPasswordStoreMode
|
|
|
|
* MD5:
|
|
|
|
* 802.1xMd5Username: QString
|
|
|
|
* 802.1xMd5Password: QString
|
|
|
|
* TLS:
|
|
|
|
* 802.1xTlsIdentity: QString
|
|
|
|
* 802.1xTlsDomain: QString
|
|
|
|
* 802.1xTlsCaCertificate: QString (file path)
|
|
|
|
* 802.1xTlsUserCertificate: QString (file path)
|
|
|
|
* 802.1xTlsUserPrivateKey: QString (file path)
|
|
|
|
* 802.1xTlsUserKeyPassword: QString
|
|
|
|
* PWD:
|
|
|
|
* 802.1xPwdUsername: QString
|
|
|
|
* 802.1xPwdPassword: QString
|
|
|
|
* FAST:
|
|
|
|
* 802.1xFastAnonymousIdentity: QString
|
|
|
|
* 802.1xFastProvisioningMode: ConnectionSettingsEngine::Security802_1xFastProvisioningMode
|
|
|
|
* 802.1xFastPacFile: QString
|
|
|
|
* 802.1xFastAuthMethod: ConnectionSettingsEngine::Security802_1xAuthMethod
|
|
|
|
* 802.1xFastUsername: QString
|
|
|
|
* 802.1xFastPassword: QString
|
|
|
|
* Tunneled TLS:
|
|
|
|
* 802.1xTtlsAnonymousIdentity: QString
|
|
|
|
* 802.1xTtlsDomain: QString
|
|
|
|
* 802.1xTtlsCaCertificate: QString (file path)
|
|
|
|
* 802.1xTtlsAuthMethod: ConnectionSettingsEngine::Security802_1xAuthMethod
|
|
|
|
* 802.1xTtlsUsername: QString
|
|
|
|
* 802.1xTtlePassword: QString
|
|
|
|
* Protected EAP:
|
|
|
|
* 802.1xPeapAnonymousIdentity: QString
|
|
|
|
* 802.1xPeapDomain: QString
|
|
|
|
* 802.1xPeapCaCertificate: QByteArray (file path)
|
|
|
|
* 802.1xPeapVersion: ConnectionSettingsEngine::Security802_1xPeapVersion
|
|
|
|
* 802.1xPeapAuthMethod: ConnectionSettingsEngine::Security802_1xAuthMethod
|
|
|
|
* 802.1xPeapUsername: QString
|
|
|
|
* 802.1xPeapPassword: QString
|
|
|
|
*
|
|
|
|
* For Ethernet devices only:
|
|
|
|
* autoLinkNegotiation: ConnectionSettingsEngine::LinkNegotiation
|
|
|
|
* linkSpeed: ConnectionSettingsEngine::LinkSpeed
|
|
|
|
* duplexMode: ConnectionSettingsEngine::DuplexMode
|
|
|
|
*/
|
|
|
|
|
|
|
|
ConnectionSettingsEngine::ConnectionSettingsEngine()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariantMap ConnectionSettingsEngine::readConnectionSettings(QString connUuidStr)
|
|
|
|
{
|
|
|
|
// Contains adapted code from plasma-nm
|
|
|
|
NetworkManager::Connection::Ptr conn = NetworkManager::findConnectionByUuid(connUuidStr);
|
|
|
|
NetworkManager::ConnectionSettings::Ptr connSettings = conn->settings();
|
|
|
|
NetworkManager::Security8021xSetting::Ptr connSecurity802_1xSetting = connSettings->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
|
|
|
NetworkManager::WiredSetting::Ptr connWiredSetting = connSettings->setting(NetworkManager::Setting::Wired).dynamicCast<NetworkManager::WiredSetting>();
|
|
|
|
NetworkManager::WirelessSetting::Ptr connWirelessSetting = connSettings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
|
|
|
NetworkManager::Ipv4Setting::Ptr connIpv4Setting = connSettings->setting(NetworkManager::Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>();
|
|
|
|
NetworkManager::Ipv6Setting::Ptr connIpv6Setting = connSettings->setting(NetworkManager::Setting::Ipv6).dynamicCast<NetworkManager::Ipv6Setting>();
|
|
|
|
QVariantMap result;
|
|
|
|
result.insert("connName", connSettings->id());
|
|
|
|
result.insert("autoconnectEnabled", connSettings->autoconnect());
|
|
|
|
result.insert("autoconnectPriority", connSettings->autoconnectPriority());
|
|
|
|
result.insert("allUsersMayConnect", connSettings->permissions().isEmpty() ? true : false);
|
|
|
|
|
|
|
|
QStringList secondaryConns = connSettings->secondaries();
|
|
|
|
|
|
|
|
NetworkManager::Connection::List list = NetworkManager::listConnections();
|
|
|
|
QStringList vpnList;
|
|
|
|
|
|
|
|
for (const NetworkManager::Connection::Ptr &conn : list) {
|
|
|
|
NetworkManager::ConnectionSettings::Ptr conSet = conn->settings();
|
|
|
|
if (conSet->connectionType() == NetworkManager::ConnectionSettings::Vpn
|
|
|
|
|| conSet->connectionType() == NetworkManager::ConnectionSettings::WireGuard) {
|
|
|
|
vpnList.append(conSet->uuid());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (secondaryConns.isEmpty() || vpnList.isEmpty()) {
|
|
|
|
result.insert("vpnAutoconnectEnabled", false);
|
|
|
|
result.insert("autoconnectVpn", "");
|
|
|
|
} else {
|
|
|
|
for (const QString &vpnKey : vpnList) {
|
|
|
|
if (secondaryConns.contains(vpnKey)) {
|
|
|
|
result.insert("vpnAutoconnectEnabled", true);
|
|
|
|
result.insert("autoconnectVpn", vpnKey);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(connSettings->metered()) {
|
|
|
|
case NetworkManager::ConnectionSettings::MeteredUnknown:
|
|
|
|
case NetworkManager::ConnectionSettings::MeteredGuessYes:
|
|
|
|
case NetworkManager::ConnectionSettings::MeteredGuessNo:
|
|
|
|
result.insert("meteredConnection", ConnectionSettingsEngine::MeteredAutomatic);
|
|
|
|
break;
|
|
|
|
case NetworkManager::ConnectionSettings::MeteredYes:
|
|
|
|
result.insert("meteredConnection", ConnectionSettingsEngine::MeteredYes);
|
|
|
|
break;
|
|
|
|
case NetworkManager::ConnectionSettings::MeteredNo:
|
|
|
|
result.insert("meteredConnection", ConnectionSettingsEngine::MeteredNo);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
result.insert("device", connSettings->interfaceName());
|
|
|
|
|
|
|
|
if (!connIpv4Setting.isNull()) {
|
|
|
|
switch (connIpv4Setting->method()) {
|
|
|
|
case NetworkManager::Ipv4Setting::Automatic:
|
|
|
|
if (connIpv4Setting->ignoreAutoDns()) {
|
|
|
|
result.insert("ipv4Method", ConnectionSettingsEngine::Ipv4AutomaticAddressOnly);
|
|
|
|
} else {
|
|
|
|
result.insert("ipv4Method", ConnectionSettingsEngine::Ipv4Automatic);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NetworkManager::Ipv4Setting::LinkLocal:
|
|
|
|
result.insert("ipv4Method", ConnectionSettingsEngine::Ipv4LinkLocal);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Ipv4Setting::Manual:
|
|
|
|
result.insert("ipv4Method", ConnectionSettingsEngine::Ipv4Manual);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Ipv4Setting::Shared:
|
|
|
|
result.insert("ipv4Method", ConnectionSettingsEngine::Ipv4Shared);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Ipv4Setting::Disabled:
|
|
|
|
result.insert("ipv4Method", ConnectionSettingsEngine::Ipv4Disabled);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
QStringList dnsStringList;
|
|
|
|
for (const QHostAddress &addr : connIpv4Setting->dns()) {
|
|
|
|
dnsStringList.append(addr.toString());
|
|
|
|
}
|
|
|
|
result.insert("ipv4DnsServers", dnsStringList.join(","));
|
|
|
|
result.insert("ipv4SearchDomains", connIpv4Setting->dnsSearch().join(","));
|
|
|
|
result.insert("ipv4DhcpClientId", connIpv4Setting->dhcpClientId());
|
|
|
|
result.insert("ipv4AddressList", QVariant::fromValue(connIpv4Setting->addresses()));
|
|
|
|
result.insert("ipv4Required", !connIpv4Setting->mayFail());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!connIpv6Setting.isNull()) {
|
|
|
|
switch (connIpv6Setting->method()) {
|
|
|
|
case NetworkManager::Ipv6Setting::Automatic:
|
|
|
|
if (connIpv6Setting->ignoreAutoDns()) {
|
|
|
|
result.insert("ipv6Method", ConnectionSettingsEngine::Ipv6AutomaticAddressOnly);
|
|
|
|
} else {
|
|
|
|
result.insert("ipv6Method", ConnectionSettingsEngine::Ipv6Automatic);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NetworkManager::Ipv6Setting::Dhcp:
|
|
|
|
result.insert("ipv6Method", ConnectionSettingsEngine::Ipv6AutomaticDhcpOnly);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Ipv6Setting::LinkLocal:
|
|
|
|
result.insert("ipv6Method", ConnectionSettingsEngine::Ipv6LinkLocal);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Ipv6Setting::Manual:
|
|
|
|
result.insert("ipv6Method", ConnectionSettingsEngine::Ipv6Manual);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Ipv6Setting::Ignored:
|
|
|
|
result.insert("ipv6Method", ConnectionSettingsEngine::Ipv6Ignored);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Ipv6Setting::ConfigDisabled:
|
|
|
|
result.insert("ipv6Method", ConnectionSettingsEngine::Ipv6Disabled);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
QStringList dnsStringList;
|
|
|
|
for (const QHostAddress &addr : connIpv6Setting->dns()) {
|
|
|
|
dnsStringList.append(addr.toString());
|
|
|
|
}
|
|
|
|
result.insert("ipv6DnsServers", dnsStringList.join(","));
|
|
|
|
result.insert("ipv6SearchDomains", connIpv6Setting->dnsSearch().join(","));
|
|
|
|
switch (connIpv6Setting->privacy()) {
|
|
|
|
case NetworkManager::Ipv6Setting::Unknown:
|
|
|
|
result.insert("ipv6Privacy", ConnectionSettingsEngine::Ipv6PrivacyDefault);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Ipv6Setting::Disabled:
|
|
|
|
result.insert("ipv6Privacy", ConnectionSettingsEngine::Ipv6PrivacyDisabled);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Ipv6Setting::PreferPublic:
|
|
|
|
result.insert("ipv6Privacy", ConnectionSettingsEngine::Ipv6PrivacyEnabledPublicAddress);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Ipv6Setting::PreferTemporary:
|
|
|
|
result.insert("ipv6Privacy", ConnectionSettingsEngine::Ipv6PrivacyEnabledTempAddress);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
result.insert("ipv6AddressList", QVariant::fromValue(connIpv6Setting->addresses()));
|
|
|
|
result.insert("ipv6Required", !connIpv6Setting->mayFail());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!connSecurity802_1xSetting.isNull()) {
|
|
|
|
QList<NetworkManager::Security8021xSetting::EapMethod> eapMethods = connSecurity802_1xSetting->eapMethods();
|
|
|
|
if (eapMethods.length() != 0) {
|
|
|
|
result.insert("802.1xEnabled", true);
|
|
|
|
switch (eapMethods[0]) {
|
|
|
|
case NetworkManager::Security8021xSetting::EapMethodMd5:
|
|
|
|
result.insert("802.1xAuthMode", ConnectionSettingsEngine::Security802_1xAuthMd5);
|
|
|
|
result.insert("802.1xMd5Username", connSecurity802_1xSetting->identity());
|
|
|
|
result.insert("802.1xMd5Password", connSecurity802_1xSetting->password());
|
|
|
|
break;
|
|
|
|
case NetworkManager::Security8021xSetting::EapMethodTls:
|
|
|
|
result.insert("802.1xAuthMode", ConnectionSettingsEngine::Security802_1xAuthTls);
|
|
|
|
result.insert("802.1xTlsIdentity", connSecurity802_1xSetting->identity());
|
|
|
|
result.insert("802.1xTlsDomain", connSecurity802_1xSetting->domainSuffixMatch());
|
|
|
|
result.insert("802.1xTlsCaCertificate", QString(connSecurity802_1xSetting->caCertificate()));
|
|
|
|
result.insert("802.1xTlsUserCertificate", QString(connSecurity802_1xSetting->clientCertificate()));
|
|
|
|
result.insert("802.1xTlsUserPrivateKey", QString(connSecurity802_1xSetting->privateKey()));
|
|
|
|
result.insert("802.1xTlsUserKeyPassword", connSecurity802_1xSetting->privateKeyPassword());
|
|
|
|
break;
|
|
|
|
case NetworkManager::Security8021xSetting::EapMethodPwd:
|
|
|
|
result.insert("802.1xAuthMode", ConnectionSettingsEngine::Security802_1xAuthPwd);
|
|
|
|
result.insert("802.1xPwdUsername", connSecurity802_1xSetting->identity());
|
|
|
|
result.insert("802.1xPwdPassword", connSecurity802_1xSetting->password());
|
|
|
|
break;
|
|
|
|
case NetworkManager::Security8021xSetting::EapMethodFast:
|
|
|
|
result.insert("802.1xAuthMode", ConnectionSettingsEngine::Security802_1xAuthFast);
|
|
|
|
result.insert("802.1xFastAnonymousIdentity", connSecurity802_1xSetting->anonymousIdentity());
|
|
|
|
switch (connSecurity802_1xSetting->phase1FastProvisioning()) {
|
|
|
|
case NetworkManager::Security8021xSetting::FastProvisioningAllowUnauthenticated:
|
|
|
|
result.insert("802.1xFastProvisioningMode", ConnectionSettingsEngine::Security802_1xFastProvisioningAnonymous);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Security8021xSetting::FastProvisioningAllowAuthenticated:
|
|
|
|
result.insert("802.1xFastProvisioningMode", ConnectionSettingsEngine::Security802_1xFastProvisioningAuthenticated);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Security8021xSetting::FastProvisioningAllowBoth:
|
|
|
|
result.insert("802.1xFastProvisioningMode", ConnectionSettingsEngine::Security802_1xFastProvisioningBoth);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
result.insert("802.1xFastProvisioningMode", ConnectionSettingsEngine::Security802_1xFastProvisioningOff);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
result.insert("802.1xFastPacFile", connSecurity802_1xSetting->pacFile());
|
|
|
|
switch (connSecurity802_1xSetting->phase2AuthMethod()) {
|
|
|
|
case NetworkManager::Security8021xSetting::AuthMethodGtc:
|
|
|
|
result.insert("802.1xFastAuthMethod", ConnectionSettingsEngine::Security802_1xAuthMethodGtc);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Security8021xSetting::AuthMethodMschapv2:
|
|
|
|
result.insert("802.1xFastAuthMethod", ConnectionSettingsEngine::Security802_1xAuthMethodMschapv2);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
result.insert("802.1xFastAuthMethod", ConnectionSettingsEngine::Security802_1xAuthMethodUnknown);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
result.insert("802.1xFastUsername", connSecurity802_1xSetting->identity());
|
|
|
|
result.insert("802.1xFastPassword", connSecurity802_1xSetting->password());
|
|
|
|
break;
|
|
|
|
case NetworkManager::Security8021xSetting::EapMethodTtls:
|
|
|
|
result.insert("802.1xAuthMode", ConnectionSettingsEngine::Security802_1xAuthTtls);
|
|
|
|
result.insert("802.1xTtlsAnonymousIdentity", connSecurity802_1xSetting->anonymousIdentity());
|
|
|
|
result.insert("802.1xTtlsDomain", connSecurity802_1xSetting->domainSuffixMatch());
|
|
|
|
result.insert("802.1xTtlsCaCertificate", QString(connSecurity802_1xSetting->caCertificate()));
|
|
|
|
switch (connSecurity802_1xSetting->phase2AuthMethod()) {
|
|
|
|
case NetworkManager::Security8021xSetting::AuthMethodPap:
|
|
|
|
result.insert("802.1xTtlsAuthMethod", ConnectionSettingsEngine::Security802_1xAuthMethodPap);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Security8021xSetting::AuthMethodChap:
|
|
|
|
result.insert("802.1xTtlsAuthMethod", ConnectionSettingsEngine::Security802_1xAuthMethodChap);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Security8021xSetting::AuthMethodMschap:
|
|
|
|
result.insert("802.1xTtlsAuthMethod", ConnectionSettingsEngine::Security802_1xAuthMethodMschap);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Security8021xSetting::AuthMethodMschapv2:
|
|
|
|
result.insert("802.1xTtlsAuthMethod", ConnectionSettingsEngine::Security802_1xAuthMethodMschapv2);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
result.insert("802.1xTtlsUsername", connSecurity802_1xSetting->identity());
|
|
|
|
result.insert("802.1xTtlsPassword", connSecurity802_1xSetting->password());
|
|
|
|
break;
|
|
|
|
case NetworkManager::Security8021xSetting::EapMethodPeap:
|
|
|
|
result.insert("802.1xAuthMode", ConnectionSettingsEngine::Security802_1xAuthPeap);
|
|
|
|
result.insert("802.1xPeapAnonymousIdentity", connSecurity802_1xSetting->anonymousIdentity());
|
|
|
|
result.insert("802.1xPeapDomain", connSecurity802_1xSetting->domainSuffixMatch());
|
|
|
|
result.insert("802.1xPeapCaCertificate", QString(connSecurity802_1xSetting->caCertificate()));
|
|
|
|
switch (connSecurity802_1xSetting->phase1PeapVersion()) {
|
|
|
|
case NetworkManager::Security8021xSetting::PeapVersionUnknown:
|
|
|
|
result.insert("802.1xPeapVersion", ConnectionSettingsEngine::Security802_1xPeapVersionUnknown);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Security8021xSetting::PeapVersionZero:
|
|
|
|
result.insert("802.1xPeapVersion", ConnectionSettingsEngine::Security802_1xPeapVersionZero);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Security8021xSetting::PeapVersionOne:
|
|
|
|
result.insert("802.1xPeapVersion", ConnectionSettingsEngine::Security802_1xPeapVersionOne);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (connSecurity802_1xSetting->phase2AuthMethod()) {
|
|
|
|
case NetworkManager::Security8021xSetting::AuthMethodMschapv2:
|
|
|
|
result.insert("802.1xPeapAuthMethod", ConnectionSettingsEngine::Security802_1xAuthMethodMschapv2);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Security8021xSetting::AuthMethodMd5:
|
|
|
|
result.insert("802.1xPeapAuthMethod", ConnectionSettingsEngine::Security802_1xAuthMethodMd5);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Security8021xSetting::AuthMethodGtc:
|
|
|
|
result.insert("802.1xPeapAuthMethod", ConnectionSettingsEngine::Security802_1xAuthMethodGtc);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
result.insert("802.1xPeapUsername", connSecurity802_1xSetting->identity());
|
|
|
|
result.insert("802.1xPeapPassword", connSecurity802_1xSetting->password());
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
switch (connSecurity802_1xSetting->passwordFlags()) {
|
|
|
|
case NetworkManager::Setting::None:
|
|
|
|
result.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreForAllUsers);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Setting::AgentOwned:
|
|
|
|
result.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreForOneUser);
|
|
|
|
break;
|
|
|
|
case NetworkManager::Setting::NotSaved:
|
|
|
|
result.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreNotSaved);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
result.insert("802.1xEnabled", false);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
result.insert("802.1xEnabled", false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!connWiredSetting.isNull()) {
|
|
|
|
result.insert("clonedMacAddress", NetworkManager::macAddressAsString(connWiredSetting->clonedMacAddress()));
|
|
|
|
result.insert("mtu", connWiredSetting->mtu());
|
|
|
|
|
|
|
|
if (connWiredSetting->autoNegotiate()) {
|
|
|
|
result.insert("autoLinkNegotiation", ConnectionSettingsEngine::NegotiationAutomatic);
|
|
|
|
result.insert("linkSpeed", ConnectionSettingsEngine::SpeedUnknown);
|
|
|
|
result.insert("duplexMode", ConnectionSettingsEngine::DuplexUnknown);
|
|
|
|
} else if (connWiredSetting->speed() != 0 && connWiredSetting->duplexType() != NetworkManager::WiredSetting::UnknownDuplexType) {
|
|
|
|
result.insert("autoLinkNegotiation", ConnectionSettingsEngine::NegotiationManual);
|
|
|
|
switch (connWiredSetting->speed()) {
|
|
|
|
case 10:
|
|
|
|
result.insert("linkSpeed", ConnectionSettingsEngine::Speed10Mbps);
|
|
|
|
break;
|
|
|
|
case 100:
|
|
|
|
result.insert("linkSpeed", ConnectionSettingsEngine::Speed100Mbps);
|
|
|
|
break;
|
|
|
|
case 1000:
|
|
|
|
result.insert("linkSpeed", ConnectionSettingsEngine::Speed1Gbps);
|
|
|
|
break;
|
|
|
|
case 2500:
|
|
|
|
result.insert("linkSpeed", ConnectionSettingsEngine::Speed2_5Gbps);
|
|
|
|
break;
|
|
|
|
case 5000:
|
|
|
|
result.insert("linkSpeed", ConnectionSettingsEngine::Speed5Gbps);
|
|
|
|
break;
|
|
|
|
case 10000:
|
|
|
|
result.insert("linkSpeed", ConnectionSettingsEngine::Speed10Gbps);
|
|
|
|
break;
|
|
|
|
case 40000:
|
|
|
|
result.insert("linkSpeed", ConnectionSettingsEngine::Speed40Gbps);
|
|
|
|
break;
|
|
|
|
case 100000:
|
|
|
|
result.insert("linkSpeed", ConnectionSettingsEngine::Speed100Gbps);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (connWiredSetting->duplexType()) {
|
|
|
|
case NetworkManager::WiredSetting::UnknownDuplexType:
|
|
|
|
result.insert("duplexType", ConnectionSettingsEngine::DuplexUnknown);
|
|
|
|
break;
|
|
|
|
case NetworkManager::WiredSetting::Half:
|
|
|
|
result.insert("duplexType", ConnectionSettingsEngine::DuplexHalf);
|
|
|
|
break;
|
|
|
|
case NetworkManager::WiredSetting::Full:
|
|
|
|
result.insert("duplexType", ConnectionSettingsEngine::DuplexFull);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
result.insert("duplexMode", connWiredSetting->duplexType());
|
|
|
|
} else {
|
|
|
|
result.insert("autoLinkNegotiation", ConnectionSettingsEngine::NegotiationIgnore);
|
|
|
|
result.insert("linkSpeed", ConnectionSettingsEngine::SpeedUnknown);
|
|
|
|
result.insert("duplexMode", ConnectionSettingsEngine::DuplexUnknown);
|
|
|
|
}
|
|
|
|
} else if (!connWirelessSetting.isNull()) {
|
|
|
|
result.insert("clonedMacAddress", NetworkManager::macAddressAsString(connWirelessSetting->clonedMacAddress()));
|
|
|
|
result.insert("mtu", connWirelessSetting->mtu());
|
|
|
|
}
|
|
|
|
// TODO: pick up here
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConnectionSettingsEngine::modifyConnectionSettings(QString connUuidStr, QVariantMap settings)
|
|
|
|
{
|
|
|
|
// Contains adapted code from plasma-nm
|
|
|
|
bool wipeClonedMacAddress = false;
|
|
|
|
bool ensure802_1xSettings = false;
|
|
|
|
NetworkManager::Connection::Ptr conn = NetworkManager::findConnectionByUuid(connUuidStr);
|
|
|
|
NetworkManager::ConnectionSettings::Ptr connSettings = conn->settings();
|
|
|
|
NetworkManager::WiredSetting::Ptr connWiredSetting = connSettings->setting(NetworkManager::Setting::Wired).dynamicCast<NetworkManager::WiredSetting>();
|
|
|
|
NetworkManager::WirelessSetting::Ptr connWirelessSetting = connSettings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
|
|
|
NetworkManager::Security8021xSetting secSetting;
|
|
|
|
NetworkManager::Ipv4Setting::Ptr connIpv4Setting = connSettings->setting(NetworkManager::Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>();
|
|
|
|
NetworkManager::Ipv6Setting::Ptr connIpv6Setting = connSettings->setting(NetworkManager::Setting::Ipv6).dynamicCast<NetworkManager::Ipv6Setting>();
|
|
|
|
if (settings["connName"].isValid()) {
|
|
|
|
connSettings->setId(settings["connName"].toString());
|
|
|
|
}
|
|
|
|
if (settings["autoconnectEnabled"].isValid()) {
|
|
|
|
connSettings->setAutoconnect(settings["autoconnectEnabled"].toBool());
|
|
|
|
}
|
|
|
|
if (settings["autoconnectPriority"].isValid()) {
|
|
|
|
connSettings->setAutoconnectPriority(settings["autoconnectPriority"].toInt());
|
|
|
|
}
|
|
|
|
if (settings["allUsersMayConnect"].isValid()) {
|
|
|
|
if (settings["allUsersMayConnect"].toBool()) {
|
|
|
|
connSettings->setPermissions(QHash<QString, QString>());
|
|
|
|
} else {
|
|
|
|
if (connSettings->permissions().isEmpty()) {
|
|
|
|
connSettings->addToPermissions(userName(), QString());
|
|
|
|
} // Otherwise we just leave the permissions as-is
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings["vpnAutoconnectEnabled"].isValid()) {
|
|
|
|
if (settings["vpnAutoconnectEnabled"].toBool()) {
|
|
|
|
connSettings->setSecondaries(QStringList() << settings["autoconnectVpn"].toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings["meteredConnection"].isValid()) {
|
|
|
|
switch (settings["meteredConnection"].toInt()) {
|
|
|
|
case ConnectionSettingsEngine::MeteredAutomatic:
|
|
|
|
connSettings->setMetered(NetworkManager::ConnectionSettings::MeteredUnknown);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::MeteredYes:
|
|
|
|
connSettings->setMetered(NetworkManager::ConnectionSettings::MeteredYes);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::MeteredNo:
|
|
|
|
connSettings->setMetered(NetworkManager::ConnectionSettings::MeteredNo);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings["device"].isValid()) {
|
|
|
|
connSettings->setInterfaceName(settings["device"].toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings["ipv4Method"].isValid()) {
|
|
|
|
switch (settings["ipv4Method"].toInt()) {
|
|
|
|
case ConnectionSettingsEngine::Ipv4Automatic:
|
|
|
|
connIpv4Setting->setMethod(NetworkManager::Ipv4Setting::Automatic);
|
|
|
|
connIpv4Setting->setIgnoreAutoDns(false);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Ipv4AutomaticAddressOnly:
|
|
|
|
connIpv4Setting->setMethod(NetworkManager::Ipv4Setting::Automatic);
|
|
|
|
connIpv4Setting->setIgnoreAutoDns(true);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Ipv4LinkLocal:
|
|
|
|
connIpv4Setting->setMethod(NetworkManager::Ipv4Setting::LinkLocal);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Ipv4Manual:
|
|
|
|
connIpv4Setting->setMethod(NetworkManager::Ipv4Setting::Manual);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Ipv4Shared:
|
|
|
|
connIpv4Setting->setMethod(NetworkManager::Ipv4Setting::Shared);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Ipv4Disabled:
|
|
|
|
connIpv4Setting->setMethod(NetworkManager::Ipv4Setting::Disabled);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings["ipv4DnsServers"].isValid()) {
|
|
|
|
QStringList dnsStringList = settings["ipv4DnsServers"].toString().split(',');
|
|
|
|
QList<QHostAddress> dnsAddrList;
|
|
|
|
for (const QString &dnsStr : dnsStringList) {
|
|
|
|
QHostAddress dnsAddr(dnsStr);
|
|
|
|
if (!dnsAddr.isNull()) {
|
|
|
|
dnsAddrList.append(dnsAddr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
connIpv4Setting->setDns(dnsAddrList);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings["ipv4SearchDomains"].isValid()) {
|
|
|
|
connIpv4Setting->setDnsSearch(settings["ipv4SearchDomains"].toString().split(','));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings["ipv4DhcpClientId"].isValid()) {
|
|
|
|
connIpv4Setting->setDhcpClientId(settings["ipv4DhcpClientId"].toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings["ipv4AddressList"].isValid()) {
|
|
|
|
QList<NetworkManager::IpAddress> ipv4AddrList = settings["ipv4AddressList"].value<QList<NetworkManager::IpAddress>>();
|
|
|
|
if (!ipv4AddrList.isEmpty()) {
|
|
|
|
connIpv4Setting->setAddresses(ipv4AddrList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings["ipv4Required"].isValid()) {
|
|
|
|
connIpv4Setting->setMayFail(!settings["ipv4Required"].toBool());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings["ipv6Method"].isValid()) {
|
|
|
|
switch(settings["ipv6Method"].toInt()) {
|
|
|
|
case ConnectionSettingsEngine::Ipv6Automatic:
|
|
|
|
connIpv6Setting->setMethod(NetworkManager::Ipv6Setting::Automatic);
|
|
|
|
connIpv6Setting->setIgnoreAutoDns(false);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Ipv6AutomaticAddressOnly:
|
|
|
|
connIpv6Setting->setMethod(NetworkManager::Ipv6Setting::Automatic);
|
|
|
|
connIpv6Setting->setIgnoreAutoDns(true);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Ipv6AutomaticDhcpOnly:
|
|
|
|
connIpv6Setting->setMethod(NetworkManager::Ipv6Setting::Dhcp);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Ipv6LinkLocal:
|
|
|
|
connIpv6Setting->setMethod(NetworkManager::Ipv6Setting::LinkLocal);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Ipv6Manual:
|
|
|
|
connIpv6Setting->setMethod(NetworkManager::Ipv6Setting::Manual);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Ipv6Ignored:
|
|
|
|
connIpv6Setting->setMethod(NetworkManager::Ipv6Setting::Ignored);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Ipv6Disabled:
|
|
|
|
connIpv6Setting->setMethod(NetworkManager::Ipv6Setting::ConfigDisabled);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings["ipv6DnsServers"].isValid()) {
|
|
|
|
QStringList dnsStringList = settings["ipv46nsServers"].toString().split(',');
|
|
|
|
QList<QHostAddress> dnsAddrList;
|
|
|
|
for (const QString &dnsStr : dnsStringList) {
|
|
|
|
QHostAddress dnsAddr(dnsStr);
|
|
|
|
if (!dnsAddr.isNull()) {
|
|
|
|
dnsAddrList.append(dnsAddr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
connIpv6Setting->setDns(dnsAddrList);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings["ipv6SearchDomains"].isValid()) {
|
|
|
|
connIpv6Setting->setDnsSearch(settings["ipv6SearchDomains"].toString().split(','));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings["ipv6Privacy"].isValid()) {
|
|
|
|
switch (settings["ipv6Privacy"].toInt()) {
|
|
|
|
case ConnectionSettingsEngine::Ipv6PrivacyDefault:
|
|
|
|
connIpv6Setting->setPrivacy(NetworkManager::Ipv6Setting::Unknown);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Ipv6PrivacyDisabled:
|
|
|
|
connIpv6Setting->setPrivacy(NetworkManager::Ipv6Setting::Disabled);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Ipv6PrivacyEnabledPublicAddress:
|
|
|
|
connIpv6Setting->setPrivacy(NetworkManager::Ipv6Setting::PreferPublic);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Ipv6PrivacyEnabledTempAddress:
|
|
|
|
connIpv6Setting->setPrivacy(NetworkManager::Ipv6Setting::PreferTemporary);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings["ipv6AddressList"].isValid()) {
|
|
|
|
QList<NetworkManager::IpAddress> ipv6AddrList = settings["ipv6AddressList"].value<QList<NetworkManager::IpAddress>>();
|
|
|
|
if (!ipv6AddrList.isEmpty()) {
|
|
|
|
connIpv6Setting->setAddresses(ipv6AddrList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings["ipv6Required"].isValid()) {
|
|
|
|
connIpv6Setting->setMayFail(!settings["ipv6Required"].toBool());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings["802.1xEnabled"].isValid() && settings["802.1xEnabled"].toBool()) {
|
|
|
|
QList<NetworkManager::Security8021xSetting::EapMethod> eapMethodsList;
|
|
|
|
switch (settings["802.1xAuthMode"].toInt()) {
|
|
|
|
case ConnectionSettingsEngine::Security802_1xAuthMd5:
|
|
|
|
eapMethodsList.append(NetworkManager::Security8021xSetting::EapMethodMd5);
|
|
|
|
secSetting.setIdentity(settings["802.1xMd5Username"].toString());
|
|
|
|
secSetting.setPassword(settings["802.1xMd5Password"].toString());
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Security802_1xAuthTls:
|
|
|
|
eapMethodsList.append(NetworkManager::Security8021xSetting::EapMethodTls);
|
|
|
|
secSetting.setIdentity(settings["802.1xTlsIdentity"].toString());
|
|
|
|
secSetting.setDomainSuffixMatch(settings["802.1xTlsDomain"].toString());
|
|
|
|
secSetting.setCaCertificate(settings["802.1xTlsCaCertificate"].toString().toUtf8().append('\0'));
|
|
|
|
secSetting.setClientCertificate(settings["802.1xTlsUserCertificate"].toString().toUtf8().append('\0'));
|
|
|
|
secSetting.setPrivateKey(settings["802.1xTlsUserPrivateKey"].toString().toUtf8().append('\0'));
|
|
|
|
secSetting.setPrivateKeyPassword(settings["802.1xTlsUserKeyPassword"].toString());
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Security802_1xAuthPwd:
|
|
|
|
eapMethodsList.append(NetworkManager::Security8021xSetting::EapMethodPwd);
|
|
|
|
secSetting.setIdentity(settings["802.1xPwdUsername"].toString());
|
|
|
|
secSetting.setPassword(settings["802.1xPwdPassword"].toString());
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Security802_1xAuthFast:
|
|
|
|
eapMethodsList.append(NetworkManager::Security8021xSetting::EapMethodFast);
|
|
|
|
secSetting.setAnonymousIdentity(settings["802.1xFastAnonymousIdentity"].toString());
|
|
|
|
switch (settings["802.1xFastProvisioningMode"].toInt()) {
|
|
|
|
case ConnectionSettingsEngine::Security802_1xFastProvisioningAnonymous:
|
|
|
|
secSetting.setPhase1FastProvisioning(NetworkManager::Security8021xSetting::FastProvisioningAllowUnauthenticated);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Security802_1xFastProvisioningAuthenticated:
|
|
|
|
secSetting.setPhase1FastProvisioning(NetworkManager::Security8021xSetting::FastProvisioningAllowAuthenticated);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Security802_1xFastProvisioningBoth:
|
|
|
|
secSetting.setPhase1FastProvisioning(NetworkManager::Security8021xSetting::FastProvisioningAllowBoth);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
secSetting.setPhase1FastProvisioning(NetworkManager::Security8021xSetting::FastProvisioningDisabled);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
secSetting.setPacFile(settings["802.1xFastPacFile"].toString());
|
|
|
|
switch (settings["802.1xFastAuthMethod"].toInt()) {
|
|
|
|
case ConnectionSettingsEngine::Security802_1xAuthMethodGtc:
|
|
|
|
secSetting.setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethodGtc);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Security802_1xAuthMethodMschapv2:
|
|
|
|
secSetting.setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethodMschapv2);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
secSetting.setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethodUnknown);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
secSetting.setIdentity(settings["802.1xFastUsername"].toString());
|
|
|
|
secSetting.setPassword(settings["802.1xFastPassword"].toString());
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Security802_1xAuthTtls:
|
|
|
|
eapMethodsList.append(NetworkManager::Security8021xSetting::EapMethodTtls);
|
|
|
|
secSetting.setAnonymousIdentity(settings["802.1xTtlsAnonymousIdentity"].toString());
|
|
|
|
secSetting.setDomainSuffixMatch(settings["802.1xTtlsDomain"].toString());
|
|
|
|
secSetting.setCaCertificate(settings["802.1xTtlsCaCertificate"].toString().toUtf8().append('\0'));
|
|
|
|
switch (settings["802.1xTtlsAuthMethod"].toInt()) {
|
|
|
|
case ConnectionSettingsEngine::Security802_1xAuthMethodPap:
|
|
|
|
secSetting.setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethodPap);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Security802_1xAuthMethodChap:
|
|
|
|
secSetting.setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethodChap);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Security802_1xAuthMethodMschap:
|
|
|
|
secSetting.setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethodMschap);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Security802_1xAuthMethodMschapv2:
|
|
|
|
secSetting.setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethodMschapv2);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
secSetting.setIdentity(settings["802.1xTtlsUsername"].toString());
|
|
|
|
secSetting.setPassword(settings["802.1xTtlsPassword"].toString());
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Security802_1xAuthPeap:
|
|
|
|
eapMethodsList.append(NetworkManager::Security8021xSetting::EapMethodPeap);
|
|
|
|
secSetting.setAnonymousIdentity(settings["802.1xPeapAnonymousIdentity"].toString());
|
|
|
|
secSetting.setDomainSuffixMatch(settings["802.1xPeapDomain"].toString());
|
|
|
|
secSetting.setCaCertificate(settings["802.1xPeapCaCertificate"].toString().toUtf8().append('\0'));
|
|
|
|
switch (settings["802.1xPeapVersion"].toInt()) {
|
|
|
|
case ConnectionSettingsEngine::Security802_1xPeapVersionUnknown:
|
|
|
|
secSetting.setPhase1PeapVersion(NetworkManager::Security8021xSetting::PeapVersionUnknown);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Security802_1xPeapVersionZero:
|
|
|
|
secSetting.setPhase1PeapVersion(NetworkManager::Security8021xSetting::PeapVersionZero);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Security802_1xPeapVersionOne:
|
|
|
|
secSetting.setPhase1PeapVersion(NetworkManager::Security8021xSetting::PeapVersionOne);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (settings["802.1xPeapAuthMethod"].toInt()) {
|
|
|
|
case ConnectionSettingsEngine::Security802_1xAuthMethodMschapv2:
|
|
|
|
secSetting.setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethodMschapv2);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Security802_1xAuthMethodMd5:
|
|
|
|
secSetting.setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethodMd5);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Security802_1xAuthMethodGtc:
|
|
|
|
secSetting.setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethodGtc);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
secSetting.setIdentity(settings["802.1xPeapUsername"].toString());
|
|
|
|
secSetting.setPassword(settings["802.1xPeapPassword"].toString());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (settings["802.1xPasswordStore"].toInt()) {
|
|
|
|
case ConnectionSettingsEngine::Security802_1xPasswordStoreForAllUsers:
|
|
|
|
secSetting.setPasswordFlags(NetworkManager::Setting::None);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Security802_1xPasswordStoreForOneUser:
|
|
|
|
secSetting.setPasswordFlags(NetworkManager::Setting::AgentOwned);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Security802_1xPasswordStoreNotSaved:
|
|
|
|
secSetting.setPasswordFlags(NetworkManager::Setting::NotSaved);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
secSetting.setEapMethods(eapMethodsList);
|
|
|
|
ensure802_1xSettings = true;
|
|
|
|
} else {
|
|
|
|
ensure802_1xSettings = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray macBin = NetworkManager::macAddressFromString(settings["clonedMacAddress"].toString());
|
|
|
|
if (settings["clonedMacAddress"].toString().length() != 17) {
|
|
|
|
wipeClonedMacAddress = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!connWiredSetting.isNull()) {
|
|
|
|
if (!wipeClonedMacAddress) {
|
|
|
|
connWiredSetting->setClonedMacAddress(macBin);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings["mtu"].isValid()) {
|
|
|
|
connWiredSetting->setMtu(settings["mtu"].toUInt());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings["autoLinkNegotiation"].isValid()) {
|
|
|
|
if (settings["autoLinkNegotiation"].toInt() == ConnectionSettingsEngine::NegotiationAutomatic) {
|
|
|
|
connWiredSetting->setAutoNegotiate(true);
|
|
|
|
connWiredSetting->setSpeed(0);
|
|
|
|
connWiredSetting->setDuplexType(NetworkManager::WiredSetting::UnknownDuplexType);
|
|
|
|
} else if (settings["autoLinkNegotiation"].toInt() == ConnectionSettingsEngine::NegotiationManual) {
|
|
|
|
connWiredSetting->setAutoNegotiate(false);
|
|
|
|
switch (settings["linkSpeed"].toInt()) {
|
|
|
|
case ConnectionSettingsEngine::Speed10Mbps:
|
|
|
|
connWiredSetting->setSpeed(10);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Speed100Mbps:
|
|
|
|
connWiredSetting->setSpeed(100);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Speed1Gbps:
|
|
|
|
connWiredSetting->setSpeed(1000);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Speed2_5Gbps:
|
|
|
|
connWiredSetting->setSpeed(2500);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Speed5Gbps:
|
|
|
|
connWiredSetting->setSpeed(5000);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Speed10Gbps:
|
|
|
|
connWiredSetting->setSpeed(10000);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Speed40Gbps:
|
|
|
|
connWiredSetting->setSpeed(40000);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::Speed100Gbps:
|
|
|
|
connWiredSetting->setSpeed(100000);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (settings["duplexMode"].toInt()) {
|
|
|
|
case ConnectionSettingsEngine::DuplexUnknown:
|
|
|
|
connWiredSetting->setDuplexType(NetworkManager::WiredSetting::UnknownDuplexType);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::DuplexHalf:
|
|
|
|
connWiredSetting->setDuplexType(NetworkManager::WiredSetting::Half);
|
|
|
|
break;
|
|
|
|
case ConnectionSettingsEngine::DuplexFull:
|
|
|
|
connWiredSetting->setDuplexType(NetworkManager::WiredSetting::Full);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
connWiredSetting->setAutoNegotiate(false);
|
|
|
|
connWiredSetting->setSpeed(0);
|
|
|
|
connWiredSetting->setDuplexType(NetworkManager::WiredSetting::UnknownDuplexType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (!connWirelessSetting.isNull()) {
|
|
|
|
if (!wipeClonedMacAddress) {
|
|
|
|
connWirelessSetting->setClonedMacAddress(macBin);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings["mtu"].isValid()) {
|
|
|
|
connWirelessSetting->setMtu(settings["mtu"].toUInt());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: pick up here
|
|
|
|
|
|
|
|
targetConnUuidStr = connUuidStr;
|
|
|
|
NMVariantMapMap connSettingsMap = connSettings->toMap();
|
|
|
|
connSettingsMap.remove("802-1x");
|
|
|
|
if (ensure802_1xSettings) {
|
|
|
|
connSettingsMap.insert("802-1x", secSetting.toMap());
|
|
|
|
}
|
|
|
|
if (wipeClonedMacAddress) {
|
|
|
|
QVariantMap ethSettingsMap = connSettingsMap.value("802-3-ethernet");
|
|
|
|
if (!ethSettingsMap.isEmpty()) {
|
|
|
|
ethSettingsMap.remove("cloned-mac-address");
|
|
|
|
ethSettingsMap.remove("assigned-mac-address");
|
|
|
|
connSettingsMap.remove("802-3-ethernet");
|
|
|
|
connSettingsMap.insert("802-3-ethernet", ethSettingsMap);
|
|
|
|
}
|
|
|
|
// TODO: Handle WiFi here
|
|
|
|
}
|
|
|
|
qWarning() << connSettingsMap;
|
|
|
|
// TODO: Do something to surpress app exit here
|
|
|
|
QDBusPendingReply<> reply = conn->update(connSettingsMap);
|
|
|
|
auto watcher = new QDBusPendingCallWatcher(reply);
|
|
|
|
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, saveReplyFinished);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConnectionSettingsEngine::saveReplyFinished()
|
|
|
|
{
|
|
|
|
// TODO: Do something to unsupress app exit here
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ConnectionSettingsEngine::userName()
|
|
|
|
{
|
|
|
|
QProcess userNameGetter;
|
|
|
|
userNameGetter.setProgram("whoami");
|
|
|
|
userNameGetter.start();
|
|
|
|
userNameGetter.waitForFinished();
|
|
|
|
return QString(userNameGetter.readAllStandardOutput());
|
|
|
|
}
|