blob: df15ab326ed1aac90b2819b96f77a51114a47f87 [file] [log] [blame]
Alex Deymof9f12632014-04-17 13:51:26 -07001// Copyright 2014 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "update_engine/policy_manager/real_config_provider.h"
6
7#include <base/logging.h>
8
9#include "update_engine/constants.h"
10#include "update_engine/policy_manager/generic_variables.h"
11#include "update_engine/simple_key_value_store.h"
12#include "update_engine/utils.h"
13
14using chromeos_update_engine::KeyValueStore;
15using std::string;
16
17namespace {
18
19const char* kConfigFilePath = "/etc/policy_manager.conf";
20
21// Config options:
22const char* kConfigOptsIsOOBEEnabled = "is_oobe_enabled";
23
24} // namespace
25
26namespace chromeos_policy_manager {
27
Alex Deymo42c30c32014-04-24 18:41:18 -070028bool RealConfigProvider::Init() {
Alex Deymof9f12632014-04-17 13:51:26 -070029 KeyValueStore store;
30
31 if (hardware_->IsNormalBootMode()) {
32 store.Load(root_prefix_ + kConfigFilePath);
33 } else {
34 if (store.Load(root_prefix_ + chromeos_update_engine::kStatefulPartition +
35 kConfigFilePath)) {
36 LOG(INFO) << "PolicyManager Config loaded from stateful partition.";
37 } else {
38 store.Load(root_prefix_ + kConfigFilePath);
39 }
40 }
41
42 bool is_oobe_enabled;
43 if (!store.GetBoolean(kConfigOptsIsOOBEEnabled, &is_oobe_enabled))
44 is_oobe_enabled = true; // Default value.
45 var_is_oobe_enabled_.reset(
46 new ConstCopyVariable<bool>(kConfigOptsIsOOBEEnabled, is_oobe_enabled));
47
48 return true;
49}
50
51} // namespace chromeos_policy_manager