OLD | NEW |
(Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import logging |
| 6 import os |
| 7 import stat |
| 8 |
| 9 from autotest_lib.client.bin import test, utils |
| 10 from autotest_lib.client.common_lib import error |
| 11 from autotest_lib.client.cros import constants, cros_ui_test, login |
| 12 |
| 13 class security_ProfilePermissions(cros_ui_test.UITest): |
| 14 version = 1 |
| 15 _HOMEDIR_MODE = 040700 |
| 16 auto_login = False |
| 17 username = None |
| 18 password = None |
| 19 |
| 20 def run_once(self, creds=None): |
| 21 """ |
| 22 Check permissions within cryptohome for anything too permissive. |
| 23 """ |
| 24 if creds: |
| 25 self.username = constants.CREDENTIALS[creds][0] |
| 26 self.password = constants.CREDENTIALS[creds][1] |
| 27 |
| 28 self.login(self.username, self.password) |
| 29 login.wait_for_initial_chrome_window() |
| 30 |
| 31 homepath = constants.CRYPTOHOME_MOUNT_PT |
| 32 homemode = os.stat(homepath)[stat.ST_MODE] |
| 33 |
| 34 if (homemode != self._HOMEDIR_MODE): |
| 35 raise error.TestFail('%s permissions were %s' % (homepath, |
| 36 oct(homemode))) |
| 37 |
| 38 # Writable by anyone else is bad, as is owned by anyone else. |
| 39 cmd = 'find -L "%s" -perm /022 -o \\! -user chronos -ls' % homepath |
| 40 cmd_output = utils.system_output(cmd, ignore_status=True) |
| 41 |
| 42 if (cmd_output != '') : |
| 43 logging.error(cmd_output) |
| 44 raise error.TestFail('Bad permissions found on cryptohome files') |
OLD | NEW |