Commit 2f5cebda authored by Owen Min's avatar Owen Min Committed by Commit Bot

Load cloud management enrollment option on Linux

Read $policy_dir/enrollment/CloudManagementEnrollmentOptions file. If it
contains 'Mandatory', then the enrollment is forced.

Bug: 904983
Change-Id: I44452f1c016a0432bf541b3ee6605f24ec3898ff
Reviewed-on: https://chromium-review.googlesource.com/c/1349773
Commit-Queue: Owen Min <zmin@chromium.org>
Reviewed-by: default avatarGeorges Khalil <georgesak@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611313}
parent aed90203
...@@ -38,6 +38,11 @@ const char kEnrollmentTokenOldFilename[] = ...@@ -38,6 +38,11 @@ const char kEnrollmentTokenOldFilename[] =
FILE_PATH_LITERAL("enrollment/enrollment_token"); FILE_PATH_LITERAL("enrollment/enrollment_token");
const char kMachineIdFilename[] = FILE_PATH_LITERAL("/etc/machine-id"); const char kMachineIdFilename[] = FILE_PATH_LITERAL("/etc/machine-id");
// Enrollment Mandatory Option.
const char kEnrollmentOptionsFilePath[] =
FILE_PATH_LITERAL("enrollment/CloudManagementEnrollmentOptions");
const char kEnrollmentMandatoryOption[] = "Mandatory";
bool GetDmTokenFilePath(base::FilePath* token_file_path, bool GetDmTokenFilePath(base::FilePath* token_file_path,
const std::string& client_id, const std::string& client_id,
bool create_dir) { bool create_dir) {
...@@ -145,8 +150,22 @@ std::string BrowserDMTokenStorageLinux::InitDMToken() { ...@@ -145,8 +150,22 @@ std::string BrowserDMTokenStorageLinux::InitDMToken() {
} }
bool BrowserDMTokenStorageLinux::InitEnrollmentErrorOption() { bool BrowserDMTokenStorageLinux::InitEnrollmentErrorOption() {
// TODO(crbug/904983): Load the policy value for this option. std::string options;
return true; base::FilePath dir_policy_files_path;
if (!base::PathService::Get(chrome::DIR_POLICY_FILES,
&dir_policy_files_path)) {
return false;
}
base::FilePath options_file_path =
dir_policy_files_path.Append(kEnrollmentOptionsFilePath);
if (!base::ReadFileToString(options_file_path, &options))
return false;
return base::TrimWhitespaceASCII(options, base::TRIM_ALL).as_string() ==
kEnrollmentMandatoryOption;
} }
void BrowserDMTokenStorageLinux::SaveDMToken(const std::string& token) { void BrowserDMTokenStorageLinux::SaveDMToken(const std::string& token) {
......
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