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

Unified Diff: telemetry/telemetry/core/cros_interface.py

Issue 2651343002: CrOS: Make IsCryptohomeMounted compatible with ext4-encryption backend. (Closed)
Patch Set: Made the test more descriptive Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | telemetry/telemetry/core/cros_interface_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: telemetry/telemetry/core/cros_interface.py
diff --git a/telemetry/telemetry/core/cros_interface.py b/telemetry/telemetry/core/cros_interface.py
index 80a4a24172d432122987711db495e099705a3928..bf98d3f7a4c18ffb32836f39fed7cede227a3a39 100644
--- a/telemetry/telemetry/core/cros_interface.py
+++ b/telemetry/telemetry/core/cros_interface.py
@@ -467,17 +467,20 @@ class CrOSInterface(object):
return True
- def FilesystemMountedAt(self, path):
- """Returns the filesystem mounted at |path|"""
- df_out, _ = self.RunCmdOnDevice(['/bin/df', path])
+ def _GetMountSourceAndTarget(self, path):
+ df_out, _ = self.RunCmdOnDevice(['/bin/df', '--output=source,target', path])
df_ary = df_out.split('\n')
# 3 lines for title, mount info, and empty line.
if len(df_ary) == 3:
line_ary = df_ary[1].split()
- if line_ary:
- return line_ary[0]
+ return line_ary if len(line_ary) == 2 else None
return None
+ def FilesystemMountedAt(self, path):
+ """Returns the filesystem mounted at |path|"""
+ mount_info = self._GetMountSourceAndTarget(path)
+ return mount_info[0] if mount_info else None
+
def CryptohomePath(self, user):
"""Returns the cryptohome mount point for |user|."""
stdout, stderr = self.RunCmdOnDevice(['cryptohome-path', 'user', "'%s'" %
@@ -489,9 +492,13 @@ class CrOSInterface(object):
def IsCryptohomeMounted(self, username, is_guest):
"""Returns True iff |user|'s cryptohome is mounted."""
profile_path = self.CryptohomePath(username)
- mount = self.FilesystemMountedAt(profile_path)
- mount_prefix = 'guestfs' if is_guest else '/home/.shadow/'
- return mount and mount.startswith(mount_prefix)
+ mount_info = self._GetMountSourceAndTarget(profile_path)
+ if mount_info:
+ # Checks if the filesytem at |profile_path| is mounted on |profile_path|
+ # itself. Before mounting cryptohome, it shows an upper directory (/home).
+ is_guestfs = (mount_info[0] == 'guestfs')
+ return is_guestfs == is_guest and mount_info[1] == profile_path
+ return False
def TakeScreenshot(self, file_path):
stdout, stderr = self.RunCmdOnDevice(
« no previous file with comments | « no previous file | telemetry/telemetry/core/cros_interface_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698