Commit ecf7a6f3 authored by Sergey Poromov's avatar Sergey Poromov Committed by Commit Bot

Drop "enterprise.owned" install attribute support.

|enterprise.owned| == true is the same as
|enterprise.mode| == "enterprise" ||
|enterprise.mode| == "enterprise_ad" ||
|enterprise.mode| == "demo_mode" from M19:
https://crrev.com/9403010

All such old devices (pre-2012) are EOL:
mario(56), alex(58), zgb(58), lumpy(65), stumpy(65),
snow(75), parrot(69), stout(69).
So we effectively can deprecate the field.

See https://crrev.com/c/2043892 for Chrome OS change.

TBR=antrim@chromium.org

Bug: 725918
Test: Unit tests updated.
Change-Id: I9c07991d09d1016b819015e5b8a3157de5d24e12
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2043836
Commit-Queue: Sergey Poromov <poromov@chromium.org>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Reviewed-by: default avatarIgor <igorcov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742162}
parent 9d36e5f1
...@@ -44,8 +44,6 @@ cryptohome::SerializedInstallAttributes BuildInstallAttributes( ...@@ -44,8 +44,6 @@ cryptohome::SerializedInstallAttributes BuildInstallAttributes(
install_attrs_["enterprise.domain"] = domain; install_attrs_["enterprise.domain"] = domain;
install_attrs_["enterprise.realm"] = realm; install_attrs_["enterprise.realm"] = realm;
install_attrs_["enterprise.device_id"] = device_id; install_attrs_["enterprise.device_id"] = device_id;
if (!mode.empty())
install_attrs_["enterprise.owned"] = "true";
cryptohome::SerializedInstallAttributes install_attrs; cryptohome::SerializedInstallAttributes install_attrs;
install_attrs.set_version(1); install_attrs.set_version(1);
......
...@@ -121,7 +121,6 @@ class DeviceCloudPolicyStoreChromeOSTest ...@@ -121,7 +121,6 @@ class DeviceCloudPolicyStoreChromeOSTest
void ResetToNonEnterprise() { void ResetToNonEnterprise() {
store_->RemoveObserver(&observer_); store_->RemoveObserver(&observer_);
store_.reset(); store_.reset();
chromeos::tpm_util::InstallAttributesSet("enterprise.owned", std::string());
install_attributes_.reset( install_attributes_.reset(
new chromeos::InstallAttributes(chromeos::FakeCryptohomeClient::Get())); new chromeos::InstallAttributes(chromeos::FakeCryptohomeClient::Get()));
store_.reset(new DeviceCloudPolicyStoreChromeOS( store_.reset(new DeviceCloudPolicyStoreChromeOS(
......
...@@ -191,10 +191,9 @@ void InstallAttributes::ReadAttributesIfReady(base::OnceClosure callback, ...@@ -191,10 +191,9 @@ void InstallAttributes::ReadAttributesIfReady(base::OnceClosure callback,
device_locked_ = true; device_locked_ = true;
static const char* const kEnterpriseAttributes[] = { static const char* const kEnterpriseAttributes[] = {
kAttrEnterpriseDeviceId, kAttrEnterpriseDomain, kAttrEnterpriseDeviceId, kAttrEnterpriseDomain,
kAttrEnterpriseRealm, kAttrEnterpriseMode, kAttrEnterpriseRealm, kAttrEnterpriseMode,
kAttrEnterpriseOwned, kAttrEnterpriseUser, kAttrEnterpriseUser, kAttrConsumerKioskEnabled,
kAttrConsumerKioskEnabled,
}; };
std::map<std::string, std::string> attr_map; std::map<std::string, std::string> attr_map;
for (size_t i = 0; i < base::size(kEnterpriseAttributes); ++i) { for (size_t i = 0; i < base::size(kEnterpriseAttributes); ++i) {
...@@ -320,16 +319,12 @@ void InstallAttributes::LockDeviceIfAttributesIsReady( ...@@ -320,16 +319,12 @@ void InstallAttributes::LockDeviceIfAttributesIsReady(
} }
// Set values in the InstallAttrs. // Set values in the InstallAttrs.
std::string kiosk_enabled, enterprise_owned; std::string kiosk_enabled;
if (device_mode == policy::DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH) { if (device_mode == policy::DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH)
kiosk_enabled = "true"; kiosk_enabled = "true";
} else {
enterprise_owned = "true";
}
std::string mode = GetDeviceModeString(device_mode); std::string mode = GetDeviceModeString(device_mode);
if (!tpm_util::InstallAttributesSet(kAttrConsumerKioskEnabled, if (!tpm_util::InstallAttributesSet(kAttrConsumerKioskEnabled,
kiosk_enabled) || kiosk_enabled) ||
!tpm_util::InstallAttributesSet(kAttrEnterpriseOwned, enterprise_owned) ||
!tpm_util::InstallAttributesSet(kAttrEnterpriseMode, mode) || !tpm_util::InstallAttributesSet(kAttrEnterpriseMode, mode) ||
!tpm_util::InstallAttributesSet(kAttrEnterpriseDomain, domain) || !tpm_util::InstallAttributesSet(kAttrEnterpriseDomain, domain) ||
!tpm_util::InstallAttributesSet(kAttrEnterpriseRealm, realm) || !tpm_util::InstallAttributesSet(kAttrEnterpriseRealm, realm) ||
...@@ -461,7 +456,6 @@ const char InstallAttributes::kAttrEnterpriseDeviceId[] = ...@@ -461,7 +456,6 @@ const char InstallAttributes::kAttrEnterpriseDeviceId[] =
const char InstallAttributes::kAttrEnterpriseDomain[] = "enterprise.domain"; const char InstallAttributes::kAttrEnterpriseDomain[] = "enterprise.domain";
const char InstallAttributes::kAttrEnterpriseRealm[] = "enterprise.realm"; const char InstallAttributes::kAttrEnterpriseRealm[] = "enterprise.realm";
const char InstallAttributes::kAttrEnterpriseMode[] = "enterprise.mode"; const char InstallAttributes::kAttrEnterpriseMode[] = "enterprise.mode";
const char InstallAttributes::kAttrEnterpriseOwned[] = "enterprise.owned";
const char InstallAttributes::kAttrEnterpriseUser[] = "enterprise.user"; const char InstallAttributes::kAttrEnterpriseUser[] = "enterprise.user";
const char InstallAttributes::kAttrConsumerKioskEnabled[] = const char InstallAttributes::kAttrConsumerKioskEnabled[] =
"consumer.app_kiosk_enabled"; "consumer.app_kiosk_enabled";
...@@ -512,7 +506,10 @@ policy::DeviceMode InstallAttributes::GetDeviceModeFromString( ...@@ -512,7 +506,10 @@ policy::DeviceMode InstallAttributes::GetDeviceModeFromString(
return policy::DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH; return policy::DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH;
if (mode == InstallAttributes::kDemoDeviceMode) if (mode == InstallAttributes::kDemoDeviceMode)
return policy::DEVICE_MODE_DEMO; return policy::DEVICE_MODE_DEMO;
return policy::DEVICE_MODE_NOT_SET; if (mode.empty())
return policy::DEVICE_MODE_NOT_SET;
NOTREACHED() << "Invalid device mode: " << mode;
return policy::DEVICE_MODE_ENTERPRISE;
} }
void InstallAttributes::DecodeInstallAttributes( void InstallAttributes::DecodeInstallAttributes(
...@@ -523,8 +520,6 @@ void InstallAttributes::DecodeInstallAttributes( ...@@ -523,8 +520,6 @@ void InstallAttributes::DecodeInstallAttributes(
registration_realm_.clear(); registration_realm_.clear();
registration_device_id_.clear(); registration_device_id_.clear();
const std::string enterprise_owned =
ReadMapKey(attr_map, kAttrEnterpriseOwned);
const std::string consumer_kiosk_enabled = const std::string consumer_kiosk_enabled =
ReadMapKey(attr_map, kAttrConsumerKioskEnabled); ReadMapKey(attr_map, kAttrConsumerKioskEnabled);
const std::string mode = ReadMapKey(attr_map, kAttrEnterpriseMode); const std::string mode = ReadMapKey(attr_map, kAttrEnterpriseMode);
...@@ -533,21 +528,14 @@ void InstallAttributes::DecodeInstallAttributes( ...@@ -533,21 +528,14 @@ void InstallAttributes::DecodeInstallAttributes(
const std::string device_id = ReadMapKey(attr_map, kAttrEnterpriseDeviceId); const std::string device_id = ReadMapKey(attr_map, kAttrEnterpriseDeviceId);
const std::string user_deprecated = ReadMapKey(attr_map, kAttrEnterpriseUser); const std::string user_deprecated = ReadMapKey(attr_map, kAttrEnterpriseUser);
if (enterprise_owned == "true") { registration_mode_ = GetDeviceModeFromString(mode);
if (registration_mode_ == policy::DEVICE_MODE_ENTERPRISE ||
registration_mode_ == policy::DEVICE_MODE_ENTERPRISE_AD ||
registration_mode_ == policy::DEVICE_MODE_DEMO) {
WarnIfNonempty(attr_map, kAttrConsumerKioskEnabled); WarnIfNonempty(attr_map, kAttrConsumerKioskEnabled);
registration_device_id_ = device_id; registration_device_id_ = device_id;
// Set registration_mode_.
registration_mode_ = GetDeviceModeFromString(mode);
if (registration_mode_ != policy::DEVICE_MODE_ENTERPRISE &&
registration_mode_ != policy::DEVICE_MODE_ENTERPRISE_AD &&
registration_mode_ != policy::DEVICE_MODE_DEMO) {
if (!mode.empty()) {
LOG(WARNING) << "Bad " << kAttrEnterpriseMode << ": " << mode;
}
registration_mode_ = policy::DEVICE_MODE_ENTERPRISE;
}
if (registration_mode_ == policy::DEVICE_MODE_ENTERPRISE || if (registration_mode_ == policy::DEVICE_MODE_ENTERPRISE ||
registration_mode_ == policy::DEVICE_MODE_DEMO) { registration_mode_ == policy::DEVICE_MODE_DEMO) {
// Either set registration_domain_ ... // Either set registration_domain_ ...
...@@ -574,7 +562,6 @@ void InstallAttributes::DecodeInstallAttributes( ...@@ -574,7 +562,6 @@ void InstallAttributes::DecodeInstallAttributes(
return; return;
} }
WarnIfNonempty(attr_map, kAttrEnterpriseOwned);
WarnIfNonempty(attr_map, kAttrEnterpriseDomain); WarnIfNonempty(attr_map, kAttrEnterpriseDomain);
WarnIfNonempty(attr_map, kAttrEnterpriseRealm); WarnIfNonempty(attr_map, kAttrEnterpriseRealm);
WarnIfNonempty(attr_map, kAttrEnterpriseDeviceId); WarnIfNonempty(attr_map, kAttrEnterpriseDeviceId);
......
...@@ -264,8 +264,9 @@ TEST_F(InstallAttributesTest, DeviceLockedFromOlderVersion) { ...@@ -264,8 +264,9 @@ TEST_F(InstallAttributesTest, DeviceLockedFromOlderVersion) {
install_attributes_->Init(GetTempPath()); install_attributes_->Init(GetTempPath());
EXPECT_EQ(policy::DEVICE_MODE_PENDING, install_attributes_->GetMode()); EXPECT_EQ(policy::DEVICE_MODE_PENDING, install_attributes_->GetMode());
// Lock the attributes as if it was done from older Chrome version. // Lock the attributes as if it was done from older Chrome version.
ASSERT_TRUE(tpm_util::InstallAttributesSet( ASSERT_TRUE(
InstallAttributes::kAttrEnterpriseOwned, "true")); tpm_util::InstallAttributesSet(InstallAttributes::kAttrEnterpriseMode,
InstallAttributes::kEnterpriseDeviceMode));
ASSERT_TRUE(tpm_util::InstallAttributesSet( ASSERT_TRUE(tpm_util::InstallAttributesSet(
InstallAttributes::kAttrEnterpriseUser, kTestUserDeprecated)); InstallAttributes::kAttrEnterpriseUser, kTestUserDeprecated));
ASSERT_TRUE(tpm_util::InstallAttributesFinalize()); ASSERT_TRUE(tpm_util::InstallAttributesFinalize());
...@@ -282,8 +283,8 @@ TEST_F(InstallAttributesTest, DeviceLockedFromOlderVersion) { ...@@ -282,8 +283,8 @@ TEST_F(InstallAttributesTest, DeviceLockedFromOlderVersion) {
TEST_F(InstallAttributesTest, Init) { TEST_F(InstallAttributesTest, Init) {
cryptohome::SerializedInstallAttributes install_attrs_proto; cryptohome::SerializedInstallAttributes install_attrs_proto;
SetAttribute(&install_attrs_proto, InstallAttributes::kAttrEnterpriseOwned, SetAttribute(&install_attrs_proto, InstallAttributes::kAttrEnterpriseMode,
"true"); InstallAttributes::kEnterpriseDeviceMode);
SetAttribute(&install_attrs_proto, InstallAttributes::kAttrEnterpriseUser, SetAttribute(&install_attrs_proto, InstallAttributes::kAttrEnterpriseUser,
kTestUserDeprecated); kTestUserDeprecated);
const std::string blob(install_attrs_proto.SerializeAsString()); const std::string blob(install_attrs_proto.SerializeAsString());
...@@ -320,8 +321,9 @@ TEST_F(InstallAttributesTest, VerifyFakeInstallAttributesCache) { ...@@ -320,8 +321,9 @@ TEST_F(InstallAttributesTest, VerifyFakeInstallAttributesCache) {
EXPECT_EQ(policy::DEVICE_MODE_PENDING, install_attributes_->GetMode()); EXPECT_EQ(policy::DEVICE_MODE_PENDING, install_attributes_->GetMode());
// Write test values. // Write test values.
ASSERT_TRUE(tpm_util::InstallAttributesSet( ASSERT_TRUE(
InstallAttributes::kAttrEnterpriseOwned, "true")); tpm_util::InstallAttributesSet(InstallAttributes::kAttrEnterpriseMode,
InstallAttributes::kEnterpriseDeviceMode));
ASSERT_TRUE(tpm_util::InstallAttributesSet( ASSERT_TRUE(tpm_util::InstallAttributesSet(
InstallAttributes::kAttrEnterpriseUser, kTestUserDeprecated)); InstallAttributes::kAttrEnterpriseUser, kTestUserDeprecated));
ASSERT_TRUE(tpm_util::InstallAttributesFinalize()); ASSERT_TRUE(tpm_util::InstallAttributesFinalize());
......
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