1# Copyright (c) 2017 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 5import logging 6import os 7 8from autotest_lib.client.bin import test 9from autotest_lib.client.common_lib import error 10from autotest_lib.client.common_lib.cros import chrome 11from autotest_lib.client.cros import cryptohome 12 13 14class login_CryptohomeDataLeak(test.test): 15 """Verify decrypted user data is cleared after end of session. 16 """ 17 version = 1 18 19 20 def run_once(self): 21 """Entry point of test""" 22 username = '' 23 test_file = '' 24 25 with chrome.Chrome() as cr: 26 username = cr.username 27 if not cryptohome.is_permanent_vault_mounted(username): 28 raise error.TestError('Expected to find a mounted vault.') 29 30 test_file = '/home/.shadow/%s/mount/hello' \ 31 % cryptohome.get_user_hash(username) 32 33 logging.info("Test file: %s", test_file) 34 open(test_file, 'w').close() 35 36 if cryptohome.is_vault_mounted(user=username, allow_fail=True): 37 raise error.TestError('Expected to not find a mounted vault.') 38 39 # At this point, the session is not active and the file name is expected 40 # to be encrypted again. 41 42 if os.path.isfile(test_file): 43 raise error.TestFail('File still visible after end of session.') 44 45 cryptohome.remove_vault(username) 46