def initialize(self): super(login_OwnershipNotRetaken, self).initialize() # Start clean, wrt ownership and the desired user. ownership.restart_ui_to_clear_ownership_files() bus_loop = DBusGMainLoop(set_as_default=True) self._cryptohome_proxy = cryptohome.CryptohomeProxy(bus_loop)
def run_once(self): test_user = '******' test_password = '******' # Get the hash for the test user account user_hash = cryptohome.get_user_hash(test_user) proxy = cryptohome.CryptohomeProxy() # Remove the test user account proxy.remove(test_user) # Mount the test user account if not proxy.mount(test_user, test_password, create=True): raise error.TestFail('Failed to create and mount the test user') # Unmount the directory if not proxy.unmount(test_user): raise error.TestFail('Failed to unmount test user') # Ensure that the user directory is not mounted if proxy.is_mounted(test_user): raise error.TestFail('Cryptohome mounted after unmount!') # Make sure that an incorrect password fails incorrect_password = '******' if proxy.mount(test_user, incorrect_password): raise error.TestFail('Cryptohome mounted with a bad password.') # Ensure that the user directory is not mounted if proxy.is_mounted(test_user): raise error.TestFail( 'Cryptohome mounted even though mount() failed') # Remove the test user account if not proxy.remove(test_user): raise error.TestFail('Cryptohome could not clean up vault')
def initialize(self): # Start with a clean slate wrt ownership ownership.restart_ui_to_clear_ownership_files() super(login_RemoteOwnership, self).initialize() bus_loop = DBusGMainLoop(set_as_default=True) self._cryptohome_proxy = cryptohome.CryptohomeProxy(bus_loop) self._sm = session_manager.connect(bus_loop)
def run_once(self): self.cryptohome_proxy = cryptohome.CryptohomeProxy() # Leaf element of user path not owned by user. user = utils.random_username() path = cryptohome.user_path(user) os.mkdir(path) os.chown(path, 0, 0) try: self.require_mount_fail(user) finally: os.rmdir(path) # Leaf element of system path not owned by root. user = utils.random_username() path = cryptohome.system_path(user) os.mkdir(path) os.chown(path, 1, 1) self.require_mount_fail(user) try: self.require_mount_fail(user) finally: os.rmdir(path) # Leaf element of path too permissive. user = utils.random_username() path = cryptohome.user_path(user) os.mkdir(path) os.chmod(path, 0777) self.require_mount_fail(user) try: self.require_mount_fail(user) finally: os.rmdir(path) # Non-leaf element of path not owned by root. user = utils.random_username() path = cryptohome.user_path(user) parent_path = os.path.dirname(path) os.chown(parent_path, 1, 1) try: self.require_mount_fail(user) finally: os.chown(parent_path, 0, 0) # Non-leaf element of path too permissive. user = utils.random_username() path = cryptohome.user_path(user) parent_path = os.path.dirname(path) old_perm = os.stat(parent_path).st_mode & 0777 os.chmod(parent_path, 0777) try: self.require_mount_fail(user) finally: os.chmod(parent_path, old_perm) os.chown(parent_path, 0, 0)
def initialize(self): super(login_UserPolicyKeys, self).initialize() self._bus_loop = DBusGMainLoop(set_as_default=True) self._cryptohome_proxy = cryptohome.CryptohomeProxy(self._bus_loop) # Clear the user's vault, to make sure the test starts without any # policy or key lingering around. At this stage the session isn't # started and there's no user signed in. ownership.restart_ui_to_clear_ownership_files() self._cryptohome_proxy.remove(ownership.TESTUSER)
def initialize(self): super(login_OwnershipRetaken, self).initialize() # Start clean, wrt ownership and the desired user. ownership.restart_ui_to_clear_ownership_files() bus_loop = DBusGMainLoop(set_as_default=True) self._cryptohome_proxy = cryptohome.CryptohomeProxy(bus_loop) self._cryptohome_proxy.remove(ownership.TESTUSER) self._sm = session_manager.connect(bus_loop)
def initialize(self): super(login_CryptohomeOwnerQuery, self).initialize() # Ensure a clean beginning. ownership.restart_ui_to_clear_ownership_files() bus_loop = DBusGMainLoop(set_as_default=True) self._session_manager = session_manager.connect(bus_loop) self._listener = session_manager.OwnershipSignalListener( gobject.MainLoop()) self._listener.listen_for_new_key_and_policy() self._cryptohome_proxy = cryptohome.CryptohomeProxy(bus_loop)
def initialize(self): super(login_MultiUserPolicy, self).initialize() policy.install_protobufs(self.autodir, self.job) self._bus_loop = DBusGMainLoop(set_as_default=True) # Clear the user's vault, to make sure the test starts without any # policy or key lingering around. At this stage the session isn't # started and there's no user signed in. ownership.restart_ui_to_clear_ownership_files() cryptohome_proxy = cryptohome.CryptohomeProxy(self._bus_loop, self.autodir, self.job) cryptohome_proxy.ensure_clean_cryptohome_for(self._user1) cryptohome_proxy.ensure_clean_cryptohome_for(self._user2)
def initialize(self): super(login_MultipleSessions, self).initialize() policy.install_protobufs(self.autodir, self.job) # Ensure a clean beginning. ownership.restart_ui_to_clear_ownership_files() self._bus_loop = DBusGMainLoop(set_as_default=True) self._session_manager = session_manager.connect(self._bus_loop) self._listener = session_manager.OwnershipSignalListener( gobject.MainLoop()) self._listener.listen_for_new_key_and_policy() self._cryptohome_proxy = cryptohome.CryptohomeProxy( self._bus_loop, self.autodir, self.job)
def run_once(self): bus_loop = DBusGMainLoop(set_as_default=True) sm = session_manager.connect(bus_loop) cryptohome_proxy = cryptohome.CryptohomeProxy(bus_loop) users = ['*****@*****.**', '*****@*****.**'] for user in users: cryptohome_proxy.ensure_clean_cryptohome_for(user) sm.StartSession(users[0], '') self.__check_for_users_in_actives(users[:1], sm.RetrieveActiveSessions()) sm.StartSession(users[1], '') self.__check_for_users_in_actives(users, sm.RetrieveActiveSessions())
def initialize(self): super(login_OwnershipApi, self).initialize() self._bus_loop = DBusGMainLoop(set_as_default=True) self._cryptohome_proxy = cryptohome.CryptohomeProxy(self._bus_loop) # Clear existing ownership and inject known keys. cros_ui.stop() ownership.clear_ownership_files_no_restart() # Make device already owned by ownership.TESTUSER. self._cryptohome_proxy.mount(ownership.TESTUSER, ownership.TESTPASS, create=True) ownership.use_known_ownerkeys(ownership.TESTUSER) self._tempdir = autotemp.tempdir(unique_id=self.__class__.__name__) cros_ui.start()
def run_once(self): bus_loop = DBusGMainLoop(set_as_default=True) sm = session_manager.connect(bus_loop) user = '******' cryptohome.CryptohomeProxy(bus_loop).ensure_clean_cryptohome_for(user) sm.StartSession(user, '') try: sm.StartSession(user, '') except dbus.DBusException as d: # If I knew how to get our custom dbus errors mapped into real # exceptions in PyDBus, I'd use that here :-/ if 'already started a session' not in d.message: raise error.TestFail(d) else: raise error.TestFail('Started second session for ' + user)
def run_once(self): self.cryptohome_proxy = cryptohome.CryptohomeProxy() # Leaf element of user path is non-dir. user = utils.random_username() path = cryptohome.user_path(user) utils.open_write_close(path, '') try: self.require_mount_fail(user) finally: os.remove(path) # Leaf element of system path is non-dir. user = utils.random_username() path = cryptohome.system_path(user) os.symlink('/etc', path) try: self.require_mount_fail(user) finally: os.remove(path) # Non-leaf element of user path is non-dir. user = utils.random_username() path = cryptohome.user_path(user) parent_path = os.path.dirname(path) os.rename(parent_path, parent_path + '.old') try: utils.open_write_close(parent_path, '') self.require_mount_fail(user) finally: # We can't just rely on the rename() to blow away the file - # rename() will refuse to rename directories to non-directory names. self.replace(parent_path + '.old', parent_path) # Non-leaf element of system path is non-dir. user = utils.random_username() path = cryptohome.system_path(user) parent_path = os.path.dirname(path) os.rename(parent_path, parent_path + '.old') try: utils.open_write_close(parent_path, '') self.require_mount_fail(user) finally: self.replace(parent_path + '.old', parent_path)
def run_once(self): self.proxy = cryptohome.CryptohomeProxy() self.good() self.bad_password() self.nonexistent_user()
def initialize(self): super(platform_CryptohomeMigrateChapsTokenClient, self).initialize() self._cryptohome_proxy = cryptohome.CryptohomeProxy()
def initialize(self): super(platform_CryptohomeKeyEviction, self).initialize() self._cryptohome_proxy = cryptohome.CryptohomeProxy()
def initialize(self): super(platform_CryptohomeMigrateChapsTokenClient, self).initialize() bus_loop = DBusGMainLoop(set_as_default=True) self._cryptohome_proxy = cryptohome.CryptohomeProxy( bus_loop, self.autodir, self.job)
def run_once(self): self.cryptohome_proxy = cryptohome.CryptohomeProxy() self.test_mount_single()