Skip to content

Commit

Permalink
Added flag for enterprise zero-touch enrollment and force enrollment if
Browse files Browse the repository at this point in the history
its value is the string forced.

BUG=624187,b/29833682

Review-Url: https://codereview.chromium.org/2107033002
Cr-Commit-Position: refs/heads/master@{#403278}
  • Loading branch information
drcrash authored and Commit bot committed Jun 30, 2016
1 parent c36b54a commit 00baf53
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@ namespace policy {

namespace {

// Well-known requisition types.
const char kNoRequisition[] = "none";
const char kRemoraRequisition[] = "remora";
const char kSharkRequisition[] = "shark";

// Zero-touch enrollment flag values.
const char kZeroTouchEnrollmentForced[] = "forced";

// These are the machine serial number keys that we check in order until we
// find a non-empty serial number. The VPD spec says the serial number should be
// in the "serial_number" key for v2+ VPDs. However, legacy devices used a
Expand Down Expand Up @@ -136,6 +140,7 @@ void DeviceCloudPolicyManagerChromeOS::Initialize(PrefService* local_state) {
base::Unretained(this)));

InitializeRequisition();
InitializeEnrollment();
}

void DeviceCloudPolicyManagerChromeOS::AddDeviceCloudPolicyManagerObserver(
Expand Down Expand Up @@ -175,8 +180,7 @@ void DeviceCloudPolicyManagerChromeOS::SetDeviceRequisition(
local_state_->ClearPref(prefs::kDeviceEnrollmentAutoStart);
local_state_->ClearPref(prefs::kDeviceEnrollmentCanExit);
} else {
local_state_->SetBoolean(prefs::kDeviceEnrollmentAutoStart, true);
local_state_->SetBoolean(prefs::kDeviceEnrollmentCanExit, false);
SetDeviceEnrollmentAutoStart();
}
}
}
Expand Down Expand Up @@ -320,8 +324,7 @@ void DeviceCloudPolicyManagerChromeOS::InitializeRequisition() {
requisition);
if (requisition == kRemoraRequisition ||
requisition == kSharkRequisition) {
local_state_->SetBoolean(prefs::kDeviceEnrollmentAutoStart, true);
local_state_->SetBoolean(prefs::kDeviceEnrollmentCanExit, false);
SetDeviceEnrollmentAutoStart();
} else {
local_state_->SetBoolean(
prefs::kDeviceEnrollmentAutoStart,
Expand All @@ -336,6 +339,21 @@ void DeviceCloudPolicyManagerChromeOS::InitializeRequisition() {
}
}

void DeviceCloudPolicyManagerChromeOS::InitializeEnrollment() {
// Enrollment happens during OOBE only.
if (chromeos::StartupUtils::IsOobeCompleted())
return;

base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(
chromeos::switches::kEnterpriseEnableZeroTouchEnrollment) &&
command_line->GetSwitchValueASCII(
chromeos::switches::kEnterpriseEnableZeroTouchEnrollment) ==
kZeroTouchEnrollmentForced) {
SetDeviceEnrollmentAutoStart();
}
}

void DeviceCloudPolicyManagerChromeOS::NotifyConnected() {
FOR_EACH_OBSERVER(
Observer, observers_, OnDeviceCloudPolicyManagerConnected());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ class DeviceCloudPolicyManagerChromeOS : public CloudPolicyManager {

// Initializes requisition settings at OOBE with values from VPD.
void InitializeRequisition();
// Initializes enrollment settings at OOBE with values from flags.
void InitializeEnrollment();

void NotifyConnected();
void NotifyDisconnected();
Expand Down
4 changes: 4 additions & 0 deletions chromeos/chromeos_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ const char kEnterpriseEnrollmentInitialModulus[] =
const char kEnterpriseEnrollmentModulusLimit[] =
"enterprise-enrollment-modulus-limit";

// Enables the zero-touch enterprise enrollment flow.
const char kEnterpriseEnableZeroTouchEnrollment[] =
"enterprise-enable-zero-touch-enrollment";

// Enables the chromecast support for video player app.
const char kEnableVideoPlayerChromecastSupport[] =
"enable-video-player-chromecast-support";
Expand Down
1 change: 1 addition & 0 deletions chromeos/chromeos_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ CHROMEOS_EXPORT extern const char kEnterpriseDisableArc[];
CHROMEOS_EXPORT extern const char kEnterpriseEnableForcedReEnrollment[];
CHROMEOS_EXPORT extern const char kEnterpriseEnrollmentInitialModulus[];
CHROMEOS_EXPORT extern const char kEnterpriseEnrollmentModulusLimit[];
CHROMEOS_EXPORT extern const char kEnterpriseEnableZeroTouchEnrollment[];
CHROMEOS_EXPORT extern const char kFirstExecAfterBoot[];
CHROMEOS_EXPORT extern const char kForceFirstRunUI[];
CHROMEOS_EXPORT extern const char kForceLoginManagerInTests[];
Expand Down

0 comments on commit 00baf53

Please sign in to comment.