Commit 83792d68 authored by Lamarque Souza's avatar Lamarque Souza
Browse files

Applying secrets: do not save secrets if user asked for it.

Thanks Andrey Borzenkov for this patch.

REVIEW: 100859
BUG: 257777
parent 9e167b9f
......@@ -216,6 +216,7 @@ void ConnectionPersistence::loadSecrets()
EnumError::type errorCode = EnumError::NoError;
if (m_storageMode != ConnectionPersistence::Secure) {
/* This implicitly covers DontStore as well */
if (!m_connection->secretsAvailable()){
errorCode = EnumError::MissingContents;
......
......@@ -2248,7 +2248,7 @@ int main( int argc, char **argv )
if ((*itEntry)->secret()) {
pC << " // SECRET" << endl;
pC << " if (m_storageMode != ConnectionPersistence::Secure) {" << endl << " ";
pC << " if (m_storageMode == ConnectionPersistence::PlainText) {" << endl << " ";
}
if (t == "Enum") {
const CfgEntry::Choices &choices = (*itEntry)->choices();
......@@ -2297,7 +2297,7 @@ int main( int argc, char **argv )
if ((*itEntry)->secret()) {
pC << " // SECRET" << endl;
pC << " if (m_storageMode != ConnectionPersistence::Secure) {" << endl << " ";
pC << " if (m_storageMode == ConnectionPersistence::PlainText) {" << endl << " ";
}
if (t == "Enum") {
const CfgEntry::Choices &choices = (*itEntry)->choices();
......
......@@ -70,7 +70,7 @@ void WirelessSecurityPersistence::load()
setting->setGroup(m_config->readEntry("group", QStringList()));
setting->setLeapusername(m_config->readEntry("leapusername", ""));
// SECRETS
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
setting->setWepkey0(m_config->readEntry("wepkey0", ""));
setting->setWepkey1(m_config->readEntry("wepkey1", ""));
setting->setWepkey2(m_config->readEntry("wepkey2", ""));
......@@ -152,31 +152,31 @@ void WirelessSecurityPersistence::save()
m_config->writeEntry("group", setting->group());
m_config->writeEntry("leapusername", setting->leapusername());
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
m_config->writeEntry("wepkey0", setting->wepkey0());
}
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
m_config->writeEntry("wepkey1", setting->wepkey1());
}
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
m_config->writeEntry("wepkey2", setting->wepkey2());
}
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
m_config->writeEntry("wepkey3", setting->wepkey3());
}
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
m_config->writeEntry("psk", setting->psk());
}
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
m_config->writeEntry("leappassword", setting->leappassword());
}
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
m_config->writeEntry("weppassphrase", setting->weppassphrase());
}
}
......
......@@ -80,19 +80,19 @@ void Security8021xPersistence::load()
setting->setPhase2clientcert(m_config->readEntry("phase2clientcert", QByteArray()));
setting->setPhase2clientcertpath(m_config->readEntry("phase2clientcertpath", ""));
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
setting->setPassword(m_config->readEntry("password", ""));
}
setting->setPrivatekey(m_config->readEntry("privatekey", QByteArray()));
setting->setPrivatekeypath(m_config->readEntry("privatekeypath", ""));
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
setting->setPrivatekeypassword(m_config->readEntry("privatekeypassword", ""));
}
setting->setPhase2privatekey(m_config->readEntry("phase2privatekey", QByteArray()));
setting->setPhase2privatekeypath(m_config->readEntry("phase2privatekeypath", ""));
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
setting->setPhase2privatekeypassword(m_config->readEntry("phase2privatekeypassword", ""));
setting->setSecretsAvailable(true);
}
......@@ -178,19 +178,19 @@ void Security8021xPersistence::save()
m_config->writeEntry("phase2clientcert", setting->phase2clientcert());
m_config->writeEntry("phase2clientcertpath", setting->phase2clientcertpath());
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
m_config->writeEntry("password", setting->password());
}
m_config->writeEntry("privatekey", setting->privatekey());
m_config->writeEntry("privatekeypath", setting->privatekeypath());
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
m_config->writeEntry("privatekeypassword", setting->privatekeypassword());
}
m_config->writeEntry("phase2privatekey", setting->phase2privatekey());
m_config->writeEntry("phase2privatekeypath", setting->phase2privatekeypath());
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
m_config->writeEntry("phase2privatekeypassword", setting->phase2privatekeypassword());
}
m_config->writeEntry("pin", setting->pin());
......
......@@ -21,7 +21,7 @@ void CdmaPersistence::load()
setting->setNumber(m_config->readEntry("number", ""));
setting->setUsername(m_config->readEntry("username", ""));
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
setting->setPassword(m_config->readEntry("password", ""));
setting->setSecretsAvailable(true);
}
......@@ -34,7 +34,7 @@ void CdmaPersistence::save()
m_config->writeEntry("number", setting->number());
m_config->writeEntry("username", setting->username());
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
m_config->writeEntry("password", setting->password());
}
}
......
......@@ -25,7 +25,7 @@ void GsmPersistence::load()
setting->setNetworktype(m_config->readEntry("networktype", 0));
setting->setBand(m_config->readEntry("band", 0));
// SECRETS
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
setting->setPassword(m_config->readEntry("password", ""));
setting->setPin(m_config->readEntry("pin", ""));
setting->setPuk(m_config->readEntry("puk", ""));
......@@ -40,7 +40,7 @@ void GsmPersistence::save()
m_config->writeEntry("number", setting->number());
m_config->writeEntry("username", setting->username());
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
m_config->writeEntry("password", setting->password());
}
m_config->writeEntry("apn", setting->apn());
......@@ -48,11 +48,11 @@ void GsmPersistence::save()
m_config->writeEntry("networktype", setting->networktype());
m_config->writeEntry("band", setting->band());
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
m_config->writeEntry("pin", setting->pin());
}
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
m_config->writeEntry("puk", setting->puk());
}
}
......
......@@ -21,7 +21,7 @@ void PppoePersistence::load()
setting->setService(m_config->readEntry("service", ""));
setting->setUsername(m_config->readEntry("username", ""));
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
setting->setPassword(m_config->readEntry("password", ""));
}
setting->setInitialized();
......@@ -33,7 +33,7 @@ void PppoePersistence::save()
m_config->writeEntry("service", setting->service());
m_config->writeEntry("username", setting->username());
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
m_config->writeEntry("password", setting->password());
}
}
......
......@@ -25,7 +25,7 @@ void VpnPersistence::load()
setting->setSecretsStorageType(stringMapFromStringList(m_config->readEntry("SecretsStorageType", QStringList())));
setting->setUserName(KUser().loginName());
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
// the map is flattened to a list of key,value,key,value
setting->setVpnSecrets(variantMapFromStringList(m_config->readEntry("VpnSecrets", QStringList())));
setting->setSecretsAvailable(true);
......@@ -41,7 +41,7 @@ void VpnPersistence::save()
m_config->writeEntry("Data", stringMapToStringList(setting->data()));
m_config->writeEntry("SecretsStorageType", stringMapToStringList(setting->secretsStorageType()));
// SECRET
if (m_storageMode != ConnectionPersistence::Secure) {
if (m_storageMode == ConnectionPersistence::PlainText) {
/*
* Save only secrets with storage type == "save"
* For compatibility treat empty storage type as "save"
......
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