Fix an signed settings serialization issue.

Calling CrosSettings::Set when the DeviseSettingsProvider is in untrusted
state on owned device leads to endless loop.
Also there was a race condition between storing the signed settings cache and
setting values in the signed settings on device owning which might lead to
loosing values from the memory cache stored there before the ownership has
been acquired.

BUG=chromium-os:23805
TEST=See bug description.

Review URL: http://codereview.chromium.org/8815015

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113365 0039d316-1c4b-4281-b951-d872f2087c98
parent f2a73291
......@@ -300,6 +300,10 @@ void DeviceSettingsProvider::FinishSetInPolicy(
Reload();
return;
}
// Update the internal caches and set the trusted flag to true so that we
// can pass the trustedness check in the second call to SetInPolicy.
OnRetrievePolicyCompleted(code, policy);
SetInPolicy(prop, *value);
}
......
......@@ -53,19 +53,18 @@ void SessionManagerObserver::OwnerKeySet(bool success) {
if (!success)
result = chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_FAILED;
// We stored some settings in transient storage before owner was assigned.
// Now owner is assigned and key is generated and we should persist
// those settings into signed storage.
if (success && g_browser_process && g_browser_process->local_state())
signed_settings_cache::Finalize(g_browser_process->local_state());
// Whether we exported the public key or not, send a notification
// indicating that we're done with this attempt.
content::NotificationService::current()->Notify(
result,
content::NotificationService::AllSources(),
content::NotificationService::NoDetails());
// We stored some settings in transient storage before owner was assigned.
// Now owner is assigned and key is generated and we should persist
// those settings into signed storage.
if (g_browser_process && g_browser_process->local_state()) {
signed_settings_cache::Finalize(g_browser_process->local_state());
}
}
void SessionManagerObserver::PropertyChangeComplete(bool success) {
......
......@@ -7,6 +7,7 @@
#include "base/base64.h"
#include "base/bind.h"
#include "base/values.h"
#include "chrome/browser/chromeos/cros_settings.h"
#include "chrome/browser/chromeos/login/ownership_service.h"
#include "chrome/browser/chromeos/login/signed_settings_helper.h"
#include "chrome/browser/prefs/pref_service.h"
......@@ -22,6 +23,8 @@ namespace {
void OnStorePolicyCompleted(SignedSettings::ReturnCode code) {
if (code != SignedSettings::SUCCESS)
LOG(ERROR) << "Couldn't save temp store to the policy blob. code: " << code;
else
CrosSettings::Get()->ReloadProviders();
}
void FinishFinalize(PrefService* local_state,
......
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