Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: chrome/browser/chromeos/arc/arc_util.cc

Issue 2890843002: Policy implementation for encryptfs to ext4 migration strategy (Closed)
Patch Set: Changed flag value Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/callback.h" 10 #include "base/callback.h"
11 #include "base/command_line.h"
11 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/sys_info.h" 14 #include "base/sys_info.h"
14 #include "base/task_scheduler/post_task.h" 15 #include "base/task_scheduler/post_task.h"
15 #include "base/threading/thread_restrictions.h" 16 #include "base/threading/thread_restrictions.h"
17 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/chromeos/arc/arc_session_manager.h" 18 #include "chrome/browser/chromeos/arc/arc_session_manager.h"
17 #include "chrome/browser/chromeos/login/user_flow.h" 19 #include "chrome/browser/chromeos/login/user_flow.h"
18 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" 20 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
21 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
22 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
19 #include "chrome/browser/chromeos/profiles/profile_helper.h" 23 #include "chrome/browser/chromeos/profiles/profile_helper.h"
20 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
26 #include "chromeos/chromeos_switches.h"
22 #include "components/arc/arc_util.h" 27 #include "components/arc/arc_util.h"
23 #include "components/prefs/pref_service.h" 28 #include "components/prefs/pref_service.h"
24 #include "components/user_manager/known_user.h" 29 #include "components/user_manager/known_user.h"
25 #include "components/user_manager/user.h" 30 #include "components/user_manager/user.h"
26 #include "components/user_manager/user_manager.h" 31 #include "components/user_manager/user_manager.h"
27 32
28 namespace arc { 33 namespace arc {
29 34
30 namespace { 35 namespace {
31 36
32 constexpr char kLsbReleaseArcVersionKey[] = "CHROMEOS_ARC_ANDROID_SDK_VERSION"; 37 constexpr char kLsbReleaseArcVersionKey[] = "CHROMEOS_ARC_ANDROID_SDK_VERSION";
33 constexpr char kAndroidMSdkVersion[] = "23"; 38 constexpr char kAndroidMSdkVersion[] = "23";
34 39
35 // Let IsAllowedForProfile() return "false" for any profile. 40 // Let IsAllowedForProfile() return "false" for any profile.
36 bool g_disallow_for_testing = false; 41 bool g_disallow_for_testing = false;
37 42
38 // Let IsArcBlockedDueToIncompatibleFileSystem() return the specified value 43 // Let IsArcBlockedDueToIncompatibleFileSystem() return the specified value
39 // during test runs. 44 // during test runs.
40 bool g_arc_blocked_due_to_incomaptible_filesystem_for_testing = false; 45 bool g_arc_blocked_due_to_incomaptible_filesystem_for_testing = false;
41 46
47 // This flag is set only in case the command line flag is set to mark the device
48 // as requiring the migration. The value is set the first time the policy fetch
49 // is done, and remains unchanged after that.
50 // TODO(igorcov): Remove this after migration. crbug.com/725493
51 base::Optional<bool> g_is_arc_migration_allowed;
52
42 // Returns whether ARC can run on the filesystem mounted at |path|. 53 // Returns whether ARC can run on the filesystem mounted at |path|.
43 // This function should run only on threads where IO operations are allowed. 54 // This function should run only on threads where IO operations are allowed.
44 bool IsArcCompatibleFilesystem(const base::FilePath& path) { 55 bool IsArcCompatibleFilesystem(const base::FilePath& path) {
45 base::ThreadRestrictions::AssertIOAllowed(); 56 base::ThreadRestrictions::AssertIOAllowed();
46 57
47 // If it can be verified it is not on ecryptfs, then it is ok. 58 // If it can be verified it is not on ecryptfs, then it is ok.
48 struct statfs statfs_buf; 59 struct statfs statfs_buf;
49 if (statfs(path.value().c_str(), &statfs_buf) < 0) 60 if (statfs(path.value().c_str(), &statfs_buf) < 0)
50 return false; 61 return false;
51 return statfs_buf.f_type != ECRYPTFS_SUPER_MAGIC; 62 return statfs_buf.f_type != ECRYPTFS_SUPER_MAGIC;
(...skipping 13 matching lines...) Expand all
65 } 76 }
66 77
67 FileSystemCompatibilityState GetFileSystemCompatibilityPref( 78 FileSystemCompatibilityState GetFileSystemCompatibilityPref(
68 const AccountId& account_id) { 79 const AccountId& account_id) {
69 int pref_value = kFileSystemIncompatible; 80 int pref_value = kFileSystemIncompatible;
70 user_manager::known_user::GetIntegerPref( 81 user_manager::known_user::GetIntegerPref(
71 account_id, prefs::kArcCompatibleFilesystemChosen, &pref_value); 82 account_id, prefs::kArcCompatibleFilesystemChosen, &pref_value);
72 return static_cast<FileSystemCompatibilityState>(pref_value); 83 return static_cast<FileSystemCompatibilityState>(pref_value);
73 } 84 }
74 85
86 bool IsArcMigrationAllowedInternal() {
87 // If the device is not managed, then the migration allowed.
88 if (!g_browser_process->platform_part()
89 ->browser_policy_connector_chromeos()
90 ->IsEnterpriseManaged()) {
91 return true;
92 }
93
94 const PrefService* pref_service =
95 user_manager::UserManager::Get()->GetLocalState();
96 const PrefService::Preference* pref =
97 pref_service->FindPreference(prefs::kDeviceEcryptfsMigrationStrategy);
98
99 return pref && pref->GetValue() &&
100 pref->GetValue()->GetInt() ==
101 enterprise_management::DeviceEcryptfsMigrationStrategyProto::
102 ALLOW_MIGRATION;
103 }
104
75 } // namespace 105 } // namespace
76 106
77 bool IsArcAllowedForProfile(const Profile* profile) { 107 bool IsArcAllowedForProfile(const Profile* profile) {
78 if (g_disallow_for_testing) { 108 if (g_disallow_for_testing) {
79 VLOG(1) << "ARC is disallowed for testing."; 109 VLOG(1) << "ARC is disallowed for testing.";
80 return false; 110 return false;
81 } 111 }
82 112
83 // ARC Kiosk can be enabled even if ARC is not yet supported on the device. 113 // ARC Kiosk can be enabled even if ARC is not yet supported on the device.
84 // In that case IsArcKioskMode() should return true as profile is already 114 // In that case IsArcKioskMode() should return true as profile is already
(...skipping 29 matching lines...) Expand all
114 // users do this through GAIA, but Kiosk and Active Directory users use 144 // users do this through GAIA, but Kiosk and Active Directory users use
115 // different application install mechanism. ARC is not allowed otherwise 145 // different application install mechanism. ARC is not allowed otherwise
116 // (e.g. in public sessions). cf) crbug.com/605545 146 // (e.g. in public sessions). cf) crbug.com/605545
117 const user_manager::User* user = 147 const user_manager::User* user =
118 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); 148 chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
119 if (!IsArcAllowedForUser(user)) { 149 if (!IsArcAllowedForUser(user)) {
120 VLOG(1) << "ARC is not allowed for the user."; 150 VLOG(1) << "ARC is not allowed for the user.";
121 return false; 151 return false;
122 } 152 }
123 153
154 const auto* command_line = base::CommandLine::ForCurrentProcess();
155 // In the case the initial encryption was ecryptfs, the user data require
hidehiko 2017/06/09 09:40:39 This comment looks now stale. Maybe; If migration
156 // migration to ext4 in order to have ARC available. The migration is
157 // forbidden if the device is managed and the policy is set to disable
158 // migration. This makes the ARC unavailable too.
159 // TODO(igorcov): Remove this after migration. crbug.com/725493
160 if (command_line->HasSwitch(
161 chromeos::switches::kNeedArcMigrationPolicyCheck) &&
162 !IsMigrationAllowed()) {
163 VLOG(1) << "ARC requires migration, but is not allowed by the policy.";
164 return false;
165 }
166
124 // Do not run ARC instance when supervised user is being created. 167 // Do not run ARC instance when supervised user is being created.
125 // Otherwise noisy notification may be displayed. 168 // Otherwise noisy notification may be displayed.
126 chromeos::UserFlow* user_flow = 169 chromeos::UserFlow* user_flow =
127 chromeos::ChromeUserManager::Get()->GetUserFlow(user->GetAccountId()); 170 chromeos::ChromeUserManager::Get()->GetUserFlow(user->GetAccountId());
128 if (!user_flow || !user_flow->CanStartArc()) { 171 if (!user_flow || !user_flow->CanStartArc()) {
129 VLOG(1) << "ARC is not allowed in the current user flow."; 172 VLOG(1) << "ARC is not allowed in the current user flow.";
130 return false; 173 return false;
131 } 174 }
132 175
133 return true; 176 return true;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 297
255 // Otherwise, check the underlying filesystem. 298 // Otherwise, check the underlying filesystem.
256 base::PostTaskWithTraitsAndReplyWithResult( 299 base::PostTaskWithTraitsAndReplyWithResult(
257 FROM_HERE, 300 FROM_HERE,
258 {base::MayBlock(), base::TaskPriority::USER_BLOCKING, 301 {base::MayBlock(), base::TaskPriority::USER_BLOCKING,
259 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, 302 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
260 base::Bind(&IsArcCompatibleFilesystem, profile_path), 303 base::Bind(&IsArcCompatibleFilesystem, profile_path),
261 base::Bind(&StoreCompatibilityCheckResult, account_id, callback)); 304 base::Bind(&StoreCompatibilityCheckResult, account_id, callback));
262 } 305 }
263 306
307 bool IsMigrationAllowed() {
308 if (!g_is_arc_migration_allowed.has_value())
309 g_is_arc_migration_allowed = IsArcMigrationAllowedInternal();
310 return g_is_arc_migration_allowed.value();
311 }
312
313 void ResetGlobalDataForTesting() {
314 g_is_arc_migration_allowed.reset();
315 }
316
264 } // namespace arc 317 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698