Home | History | Annotate | Download | only in cros

Lines Matching refs:user

28 def get_user_hash(user):
29 """Get the user hash for the given user."""
31 '--user=%s' % user])
34 def user_path(user):
35 """Get the user mount point for the given user."""
36 return utils.system_output(['cryptohome-path', 'user', user])
39 def system_path(user):
40 """Get the system mount point for the given user."""
41 return utils.system_output(['cryptohome-path', 'system', user])
44 def temporary_mount_path(user):
45 """Get the vault mount path used during crypto-migration for the user.
47 @param user: user the temporary mount should be for
49 return TEMP_MOUNT_PATTERN % (get_user_hash(user))
52 def vault_path(user):
53 """ Get the vault path for the given user.
55 @param user: The user who's vault path should be returned.
57 return VAULT_PATH_PATTERN % (get_user_hash(user))
60 def ensure_clean_cryptohome_for(user, password=None):
61 """Ensure a fresh cryptohome exists for user.
63 @param user: user who needs a shiny new cryptohome.
68 unmount_vault(user)
69 remove_vault(user)
70 mount_vault(user, password, create=True)
259 def remove_vault(user):
260 """Remove the given user's vault from the shadow directory."""
261 logging.debug('user is %s', user)
262 user_hash = get_user_hash(user)
263 logging.debug('Removing vault for user %s with hash %s', user, user_hash)
264 cmd = CRYPTOHOME_CMD + ' --action=remove --force --user=%s' % user
268 raise ChromiumOSError('Cryptohome could not remove the user\'s vault.')
279 logging.debug('Removing vault for user with hash %s', item)
283 def mount_vault(user, password, create=False, key_label='bar'):
284 """Mount the given user's vault. Mounts should be created by calling this
289 args = [CRYPTOHOME_CMD, '--action=mount_ex', '--user=%s' % user,
295 user_hash = get_user_hash(user)
303 # TODO: Remove this additional call to get_user_hash(user) when
305 user_hash = get_user_hash(user)
312 if not is_permanent_vault_mounted(user=user, allow_fail=True):
325 def test_auth(user, password):
326 cmd = [CRYPTOHOME_CMD, '--action=check_key_ex', '--user=%s' % user,
333 def unmount_vault(user):
334 """Unmount the given user's vault.
336 Once unmounting for a specific user is supported, the user parameter will
337 name the target user. See crosbug.com/20778.
341 if is_vault_mounted(user, allow_fail=True):
342 raise ChromiumOSError('Cryptohome did not unmount the user.')
362 def __get_user_mount_info(user, allow_fail=False):
363 """Get information about the active mounts for a given user.
365 Returns the active mounts at the user's user and system mount points. If no
366 user is given, the active mount at the shared mount point is returned
368 compatibility; the guest user has a mount at this mount point only).
370 return [__get_mount_info(mount_point=user_path(user),
372 __get_mount_info(mount_point=system_path(user),
375 def is_vault_mounted(user, regexes=None, allow_fail=False):
376 """Check whether a vault is mounted for the given user.
378 user: If no user is given, the shared mount point is checked, determining
379 whether a vault is mounted for any user.
381 The mount filesystem for the user's user and system mounts point must
392 user_mount_info = __get_user_mount_info(user=user, allow_fail=allow_fail)
395 # user user/system mount (/home/user/.... /home/root/...)
435 """Check whether a vault is mounted for the guest user.
440 user=GUEST_USER_NAME,
451 def is_permanent_vault_mounted(user, allow_fail=False):
452 """Check if user is mounted over ecryptfs or ext4 crypto. """
454 user=user,
463 def get_mounted_vault_path(user, allow_fail=False):
464 """Get the path where the decrypted data for the user is located."""
465 return os.path.join(constants.SHADOW_ROOT, get_user_hash(user), 'mount')
509 def create_ecryptfs_homedir(user, password):
512 If a home directory for the user exists already, it will be removed.
515 @param user: Username to create the home directory for.
518 unmount_vault(user)
519 remove_vault(user)
523 '--user=%s' % user,
529 if not is_vault_mounted(user, regexes={
536 def do_dircrypto_migration(user, password, timeout=600):
537 """Start dircrypto migration for the user.
539 @param user: The user to migrate.
544 unmount_vault(user)
549 '--user=%s' % user,
552 if not __get_mount_info(temporary_mount_path(user), allow_fail=True):
554 args = [CRYPTOHOME_CMD, '--action=migrate_to_dircrypto', '--user=%s' % user]
558 temporary_mount_path(user), allow_fail=True),
564 def change_password(user, password, new_password):
569 '--user=%s' % user,
659 def mount(self, user, password, create=False, async=True):
663 TODO(ellyjones): Migrate mount_vault() to use a multi-user-safe
667 return self.__async_call(self.iface.AsyncMount, user, password,
669 out = self.__call(self.iface.Mount, user, password, create, False, [])
674 def unmount(self, user):
678 TODO(ellyjones): Once there's a per-user unmount method, use it. See
684 def is_mounted(self, user):
685 """Tests whether a user's cryptohome is mounted."""
686 return (utils.is_mountpoint(user_path(user))
687 and utils.is_mountpoint(system_path(user)))
690 def require_mounted(self, user):
691 """Raises a test failure if a user's cryptohome is not mounted."""
692 utils.require_mountpoint(user_path(user))
693 utils.require_mountpoint(system_path(user))
696 def migrate(self, user, oldkey, newkey, async=True):
697 """Migrates the specified user's cryptohome from one key to another."""
700 user, oldkey, newkey)['return_status']
701 return self.__call(self.iface.MigrateKey, user, oldkey, newkey)
704 def remove(self, user, async=True):
707 user)['return_status']
708 return self.__call(self.iface.Remove, user)
711 def ensure_clean_cryptohome_for(self, user, password=None):
712 """Ensure a fresh cryptohome exists for user.
714 @param user: user who needs a shiny new cryptohome.
719 self.remove(user)
720 self.mount(user, password, create=True)