| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H__ |
| 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H__ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include <base/basictypes.h> | 10 #include <base/basictypes.h> |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // false otherwise. | 79 // false otherwise. |
| 80 bool SetTrack(const std::string& track); | 80 bool SetTrack(const std::string& track); |
| 81 static bool SetDeviceTrack(const std::string& track); | 81 static bool SetDeviceTrack(const std::string& track); |
| 82 | 82 |
| 83 // Returns the release track. On error, returns an empty string. | 83 // Returns the release track. On error, returns an empty string. |
| 84 static std::string GetDeviceTrack(); | 84 static std::string GetDeviceTrack(); |
| 85 | 85 |
| 86 // For unit-tests. | 86 // For unit-tests. |
| 87 void set_root(const std::string& root) { root_ = root; } | 87 void set_root(const std::string& root) { root_ = root; } |
| 88 | 88 |
| 89 // Force build type for testing purposes. | 89 // Enforce security mode for testing purposes. |
| 90 void SetBuildTypeOfficial(bool is_official); | 90 void SetLockDown(bool lock); |
| 91 | 91 |
| 92 private: | 92 private: |
| 93 FRIEND_TEST(OmahaRequestDeviceParamsTest, IsValidTrackTest); | 93 FRIEND_TEST(OmahaRequestDeviceParamsTest, IsValidTrackTest); |
| 94 FRIEND_TEST(OmahaRequestDeviceParamsTest, ShouldLockDownTest); |
| 94 | 95 |
| 95 // Use a validator that is a non-static member of this class so that its | 96 // Use a validator that is a non-static member of this class so that its |
| 96 // inputs can be mocked in unit tests (e.g., build type for IsValidTrack). | 97 // inputs can be mocked in unit tests (e.g., build type for IsValidTrack). |
| 97 typedef bool(OmahaRequestDeviceParams::*ValueValidator)( | 98 typedef bool(OmahaRequestDeviceParams::*ValueValidator)( |
| 98 const std::string&) const; | 99 const std::string&) const; |
| 99 | 100 |
| 100 // Returns true if this is an official build, false otherwise. | 101 // Returns true if parameter values should be locked down for security |
| 101 bool IsOfficialBuild() const; | 102 // reasons. If this is an official build running in normal boot mode, all |
| 103 // values except the release track are parsed only from the read-only rootfs |
| 104 // partition and the track values are restricted to a pre-approved set. |
| 105 bool ShouldLockDown() const; |
| 102 | 106 |
| 103 // Returns true if |track| is a valid track, false otherwise. This method | 107 // Returns true if |track| is a valid track, false otherwise. This method |
| 104 // restricts the track value only if the image is official (see | 108 // restricts the track value only if the image is official (see |
| 105 // IsOfficialBuild). | 109 // IsOfficialBuild). |
| 106 bool IsValidTrack(const std::string& track) const; | 110 bool IsValidTrack(const std::string& track) const; |
| 107 | 111 |
| 108 // Fetches the value for a given key from | 112 // Fetches the value for a given key from |
| 109 // /mnt/stateful_partition/etc/lsb-release if possible and |stateful_override| | 113 // /mnt/stateful_partition/etc/lsb-release if possible and |stateful_override| |
| 110 // is true. Failing that, it looks for the key in /etc/lsb-release. If | 114 // is true. Failing that, it looks for the key in /etc/lsb-release. If |
| 111 // |validator| is non-NULL, uses it to validate and ignore invalid valies. | 115 // |validator| is non-NULL, uses it to validate and ignore invalid valies. |
| 112 std::string GetLsbValue(const std::string& key, | 116 std::string GetLsbValue(const std::string& key, |
| 113 const std::string& default_value, | 117 const std::string& default_value, |
| 114 ValueValidator validator, | 118 ValueValidator validator, |
| 115 bool stateful_override) const; | 119 bool stateful_override) const; |
| 116 | 120 |
| 117 // Gets the machine type (e.g. "i686"). | 121 // Gets the machine type (e.g. "i686"). |
| 118 std::string GetMachineType() const; | 122 std::string GetMachineType() const; |
| 119 | 123 |
| 120 // Returns the hardware qualification ID of the system, or empty | 124 // Returns the hardware qualification ID of the system, or empty |
| 121 // string if the HWID is unavailable. | 125 // string if the HWID is unavailable. |
| 122 std::string GetHardwareClass() const; | 126 std::string GetHardwareClass() const; |
| 123 | 127 |
| 124 // When reading files, prepend root_ to the paths. Useful for testing. | 128 // When reading files, prepend root_ to the paths. Useful for testing. |
| 125 std::string root_; | 129 std::string root_; |
| 126 | 130 |
| 127 // Force build type for testing purposes. | 131 // Force security lock down for testing purposes. |
| 128 bool force_build_type_; | 132 bool force_lock_down_; |
| 129 bool forced_official_build_; | 133 bool forced_lock_down_; |
| 130 | 134 |
| 131 DISALLOW_COPY_AND_ASSIGN(OmahaRequestDeviceParams); | 135 DISALLOW_COPY_AND_ASSIGN(OmahaRequestDeviceParams); |
| 132 }; | 136 }; |
| 133 | 137 |
| 134 } // namespace chromeos_update_engine | 138 } // namespace chromeos_update_engine |
| 135 | 139 |
| 136 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H__ | 140 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H__ |
| OLD | NEW |