Commit e432cbc9 authored by Daniel Erat's avatar Daniel Erat Committed by Commit Bot

chromeos: Speculative fix for segfault with missing owner.

Try to avoid a crash in a situation we've seen where a lab
system has a policy file referencing an owner but the user
list in the Local State file is empty.

Bug: 850139
Change-Id: I4fad13685d8a8975e6b8f1e41a65bf37cdfcd89d
Reviewed-on: https://chromium-review.googlesource.com/1121377Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Commit-Queue: Dan Erat <derat@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572221}
parent bb109a1a
...@@ -113,10 +113,15 @@ bool AreSupervisedUsersAllowed(const CrosSettings* cros_settings) { ...@@ -113,10 +113,15 @@ bool AreSupervisedUsersAllowed(const CrosSettings* cros_settings) {
bool IsGuestSessionAllowed(const CrosSettings* cros_settings) { bool IsGuestSessionAllowed(const CrosSettings* cros_settings) {
const AccountId& owner_account_id = const AccountId& owner_account_id =
user_manager::UserManager::Get()->GetOwnerAccountId(); user_manager::UserManager::Get()->GetOwnerAccountId();
if (owner_account_id.is_valid() && if (owner_account_id.is_valid()) {
user_manager::UserManager::Get()->FindUser(owner_account_id)->GetType() == // Some Autotest policy tests appear to wipe the user list in Local State
user_manager::UserType::USER_TYPE_CHILD) { // but preserve a policy file referencing an owner: https://crbug.com/850139
return false; const user_manager::User* owner_user =
user_manager::UserManager::Get()->FindUser(owner_account_id);
if (owner_user &&
owner_user->GetType() == user_manager::UserType::USER_TYPE_CHILD) {
return false;
}
} }
// In tests CrosSettings might not be initialized. // In tests CrosSettings might not be initialized.
......
...@@ -413,10 +413,15 @@ void GaiaScreenHandler::LoadGaiaWithPartitionAndVersionAndConsent( ...@@ -413,10 +413,15 @@ void GaiaScreenHandler::LoadGaiaWithPartitionAndVersionAndConsent(
const AccountId& owner_account_id = const AccountId& owner_account_id =
user_manager::UserManager::Get()->GetOwnerAccountId(); user_manager::UserManager::Get()->GetOwnerAccountId();
params.SetBoolean("hasDeviceOwner", owner_account_id.is_valid()); params.SetBoolean("hasDeviceOwner", owner_account_id.is_valid());
if (owner_account_id.is_valid() && if (owner_account_id.is_valid()) {
user_manager::UserManager::Get()->FindUser(owner_account_id)->GetType() == // Some Autotest policy tests appear to wipe the user list in Local State
user_manager::UserType::USER_TYPE_CHILD) { // but preserve a policy file referencing an owner: https://crbug.com/850139
params.SetString("obfuscatedOwnerId", owner_account_id.GetGaiaId()); const user_manager::User* owner_user =
user_manager::UserManager::Get()->FindUser(owner_account_id);
if (owner_user &&
owner_user->GetType() == user_manager::UserType::USER_TYPE_CHILD) {
params.SetString("obfuscatedOwnerId", owner_account_id.GetGaiaId());
}
} }
params.SetString("chromeType", GetChromeType()); params.SetString("chromeType", GetChromeType());
......
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