OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium 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 #include "chrome/browser/chromeos/arc/arc_util.h" | 5 #include "chrome/browser/chromeos/arc/arc_util.h" |
6 | 6 |
7 #include <linux/magic.h> | 7 #include <linux/magic.h> |
8 #include <sys/statfs.h> | 8 #include <sys/statfs.h> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 constexpr char kLsbReleaseArcVersionKey[] = "CHROMEOS_ARC_ANDROID_SDK_VERSION"; | 29 constexpr char kLsbReleaseArcVersionKey[] = "CHROMEOS_ARC_ANDROID_SDK_VERSION"; |
30 constexpr char kAndroidMSdkVersion[] = "23"; | 30 constexpr char kAndroidMSdkVersion[] = "23"; |
31 | 31 |
32 // Let IsAllowedForProfile() return "false" for any profile. | 32 // Let IsAllowedForProfile() return "false" for any profile. |
33 bool g_disallow_for_testing = false; | 33 bool g_disallow_for_testing = false; |
34 | 34 |
35 } // namespace | 35 } // namespace |
36 | 36 |
37 bool IsArcAllowedForProfile(const Profile* profile) { | 37 bool IsArcAllowedForProfile(const Profile* profile) { |
| 38 if (!IsArcAllowedInAppListForProfile(profile)) |
| 39 return false; |
| 40 |
| 41 if (base::SysInfo::IsRunningOnChromeOS()) { |
| 42 // Do not allow newer version of ARC on old filesystem. |
| 43 // Check this condition only on real Chrome OS devices. Test runs on Linux |
| 44 // workstation does not have expected /etc/lsb-release field nor profile |
| 45 // creation step. |
| 46 if (!IsProfileVerifiedToBeOnArcCompatibleFilesystem(profile)) |
| 47 return false; |
| 48 } |
| 49 |
| 50 return true; |
| 51 } |
| 52 |
| 53 bool IsArcAllowedInAppListForProfile(const Profile* profile) { |
38 if (g_disallow_for_testing) { | 54 if (g_disallow_for_testing) { |
39 VLOG(1) << "ARC is disallowed for testing."; | 55 VLOG(1) << "ARC is disallowed for testing."; |
40 return false; | 56 return false; |
41 } | 57 } |
42 | 58 |
43 // ARC Kiosk can be enabled even if ARC is not yet supported on the device. | 59 // ARC Kiosk can be enabled even if ARC is not yet supported on the device. |
44 // In that case IsArcKioskMode() should return true as profile is already | 60 // In that case IsArcKioskMode() should return true as profile is already |
45 // created. | 61 // created. |
46 if (!IsArcAvailable() && !(IsArcKioskMode() && IsArcKioskAvailable())) { | 62 if (!IsArcAvailable() && !(IsArcKioskMode() && IsArcKioskAvailable())) { |
47 VLOG(1) << "ARC is not available."; | 63 VLOG(1) << "ARC is not available."; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 return false; | 110 return false; |
95 } | 111 } |
96 | 112 |
97 // Do not allow for Ephemeral data user. cf) b/26402681 | 113 // Do not allow for Ephemeral data user. cf) b/26402681 |
98 if (user_manager::UserManager::Get() | 114 if (user_manager::UserManager::Get() |
99 ->IsCurrentUserCryptohomeDataEphemeral()) { | 115 ->IsCurrentUserCryptohomeDataEphemeral()) { |
100 VLOG(1) << "Users with ephemeral data are not supported in ARC."; | 116 VLOG(1) << "Users with ephemeral data are not supported in ARC."; |
101 return false; | 117 return false; |
102 } | 118 } |
103 | 119 |
104 // Do not allow newer version of ARC on old filesystem. | 120 return true; |
105 // Check this condition only on real Chrome OS devices. Test runs on Linux | 121 } |
106 // workstation does not have expected /etc/lsb-release field nor profile | 122 |
107 // creation step. | 123 bool IsProfileVerifiedToBeOnArcCompatibleFilesystem(const Profile* profile) { |
108 if (base::SysInfo::IsRunningOnChromeOS()) { | 124 // chromeos::UserSessionManager::PrepareProfile does the actual file system |
109 // chromeos::UserSessionManager::PrepareProfile does the actual file system | 125 // check and stores the result to prefs, so that it survives crash-restart. |
110 // check and stores the result to prefs, so that it survives crash-restart. | 126 const bool is_filesystem_compatible = |
111 const bool is_filesystem_compatible = | 127 profile->GetPrefs()->GetBoolean(prefs::kArcCompatibleFilesystemChosen); |
112 profile->GetPrefs()->GetBoolean(prefs::kArcCompatibleFilesystemChosen); | 128 std::string arc_sdk_version; |
113 std::string arc_sdk_version; | 129 const bool is_M = base::SysInfo::GetLsbReleaseValue(kLsbReleaseArcVersionKey, |
114 const bool is_M = base::SysInfo::GetLsbReleaseValue( | 130 &arc_sdk_version) && |
115 kLsbReleaseArcVersionKey, &arc_sdk_version) && | 131 arc_sdk_version == kAndroidMSdkVersion; |
116 arc_sdk_version == kAndroidMSdkVersion; | 132 |
117 // To run ARC we want to make sure either | 133 // To run ARC we want to make sure either |
118 // - Underlying file system is compatible with ARC, or | 134 // - Underlying file system is compatible with ARC, or |
119 // - SDK version is M. | 135 // - SDK version is M. |
120 if (!is_filesystem_compatible && !is_M) { | 136 if (!is_filesystem_compatible && !is_M) { |
121 VLOG(1) | 137 VLOG(1) |
122 << "Users with SDK version (" << arc_sdk_version | 138 << "Users with SDK version (" << arc_sdk_version |
123 << ") are not supported when they postponed to migrate to dircrypto."; | 139 << ") are not supported when they postponed to migrate to dircrypto."; |
124 return false; | 140 return false; |
125 } | |
126 } | 141 } |
127 | 142 |
128 return true; | 143 return true; |
129 } | 144 } |
130 | 145 |
131 void DisallowArcForTesting() { | 146 void DisallowArcForTesting() { |
132 g_disallow_for_testing = true; | 147 g_disallow_for_testing = true; |
133 } | 148 } |
134 | 149 |
135 bool IsArcPlayStoreEnabledForProfile(const Profile* profile) { | 150 bool IsArcPlayStoreEnabledForProfile(const Profile* profile) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 base::ThreadRestrictions::AssertIOAllowed(); | 193 base::ThreadRestrictions::AssertIOAllowed(); |
179 | 194 |
180 // If it can be verified it is not on ecryptfs, then it is ok. | 195 // If it can be verified it is not on ecryptfs, then it is ok. |
181 struct statfs statfs_buf; | 196 struct statfs statfs_buf; |
182 if (statfs(path.value().c_str(), &statfs_buf) < 0) | 197 if (statfs(path.value().c_str(), &statfs_buf) < 0) |
183 return false; | 198 return false; |
184 return statfs_buf.f_type != ECRYPTFS_SUPER_MAGIC; | 199 return statfs_buf.f_type != ECRYPTFS_SUPER_MAGIC; |
185 } | 200 } |
186 | 201 |
187 } // namespace arc | 202 } // namespace arc |
OLD | NEW |