Home | History | Annotate | Download | only in vold

Lines Matching refs:user_id

106 static std::string get_de_key_path(userid_t user_id) {
107 return StringPrintf("%s/de/%d", user_key_dir.c_str(), user_id);
110 static std::string get_ce_key_directory_path(userid_t user_id) {
111 return StringPrintf("%s/ce/%d", user_key_dir.c_str(), user_id);
182 static bool read_and_fixate_user_ce_key(userid_t user_id,
185 auto const directory_path = get_ce_key_directory_path(user_id);
195 LOG(ERROR) << "Failed to find working ce key for user " << user_id;
199 static bool read_and_install_user_ce_key(userid_t user_id,
201 if (s_ce_key_raw_refs.count(user_id) != 0) return true;
203 if (!read_and_fixate_user_ce_key(user_id, auth, &ce_key)) return false;
206 s_ce_keys[user_id] = std::move(ce_key);
207 s_ce_key_raw_refs[user_id] = ce_raw_ref;
208 LOG(DEBUG) << "Installed ce key for user " << user_id;
232 static bool create_and_install_user_keys(userid_t user_id, bool create_ephemeral) {
238 s_ephemeral_users.insert(user_id);
240 auto const directory_path = get_ce_key_directory_path(user_id);
249 if (!android::vold::storeKeyAtomically(get_de_key_path(user_id), user_key_temp,
254 s_de_key_raw_refs[user_id] = de_raw_ref;
257 s_ce_keys[user_id] = ce_key;
258 s_ce_key_raw_refs[user_id] = ce_raw_ref;
259 LOG(DEBUG) << "Created keys for user " << user_id;
263 static bool lookup_key_ref(const std::map<userid_t, std::string>& key_map, userid_t user_id,
265 auto refi = key_map.find(user_id);
267 LOG(ERROR) << "Cannot find key for " << user_id;
317 userid_t user_id = std::stoi(entry->d_name);
318 if (s_de_key_raw_refs.count(user_id) == 0) {
324 s_de_key_raw_refs[user_id] = raw_ref;
325 LOG(DEBUG) << "Installed de key for user " << user_id;
395 bool e4crypt_vold_create_user_key(userid_t user_id, int serial, bool ephemeral) {
396 LOG(DEBUG) << "e4crypt_vold_create_user_key for " << user_id << " serial " << serial;
401 if (s_ce_key_raw_refs.count(user_id) != 0) {
402 LOG(ERROR) << "Already exists, can't e4crypt_vold_create_user_key for " << user_id
407 if (!create_and_install_user_keys(user_id, ephemeral)) {
422 static bool evict_ce_key(userid_t user_id) {
423 s_ce_keys.erase(user_id);
427 if (lookup_key_ref(s_ce_key_raw_refs, user_id, &raw_ref)) {
431 s_ce_key_raw_refs.erase(user_id);
435 bool e4crypt_destroy_user_key(userid_t user_id) {
436 LOG(DEBUG) << "e4crypt_destroy_user_key(" << user_id << ")";
442 success &= evict_ce_key(user_id);
443 success &= lookup_key_ref(s_de_key_raw_refs, user_id, &raw_ref)
445 s_de_key_raw_refs.erase(user_id);
446 auto it = s_ephemeral_users.find(user_id);
450 for (auto const path: get_ce_key_paths(get_ce_key_directory_path(user_id))) {
453 user_id);
550 bool e4crypt_add_user_key_auth(userid_t user_id, int serial, const std::string& token_hex,
552 LOG(DEBUG) << "e4crypt_add_user_key_auth " << user_id << " serial=" << serial
555 if (s_ephemeral_users.count(user_id) != 0) return true;
561 auto it = s_ce_keys.find(user_id);
563 LOG(ERROR) << "Key not loaded into memory, can't change for user " << user_id;
567 auto const directory_path = get_ce_key_directory_path(user_id);
575 bool e4crypt_fixate_newest_user_key_auth(userid_t user_id) {
576 LOG(DEBUG) << "e4crypt_fixate_newest_user_key_auth " << user_id;
578 if (s_ephemeral_users.count(user_id) != 0) return true;
579 auto const directory_path = get_ce_key_directory_path(user_id);
582 LOG(ERROR) << "No ce keys present, cannot fixate for user " << user_id;
590 bool e4crypt_unlock_user_key(userid_t user_id, int serial, const std::string& token_hex,
592 LOG(DEBUG) << "e4crypt_unlock_user_key " << user_id << " serial=" << serial
595 if (s_ce_key_raw_refs.count(user_id) != 0) {
596 LOG(WARNING) << "Tried to unlock already-unlocked key for user " << user_id;
603 if (!read_and_install_user_ce_key(user_id, auth)) {
604 LOG(ERROR) << "Couldn't read key for " << user_id;
611 if (!emulated_unlock(android::vold::BuildDataSystemCePath(user_id), 0771) ||
612 !emulated_unlock(android::vold::BuildDataMiscCePath(user_id), 01771) ||
613 !emulated_unlock(android::vold::BuildDataMediaCePath("", user_id), 0770) ||
614 !emulated_unlock(android::vold::BuildDataUserCePath("", user_id), 0771)) {
615 LOG(ERROR) << "Failed to unlock user " << user_id;
623 bool e4crypt_lock_user_key(userid_t user_id) {
624 LOG(DEBUG) << "e4crypt_lock_user_key " << user_id;
626 return evict_ce_key(user_id);
629 if (!emulated_lock(android::vold::BuildDataSystemCePath(user_id)) ||
630 !emulated_lock(android::vold::BuildDataMiscCePath(user_id)) ||
631 !emulated_lock(android::vold::BuildDataMediaCePath("", user_id)) ||
632 !emulated_lock(android::vold::BuildDataUserCePath("", user_id))) {
633 LOG(ERROR) << "Failed to lock user " << user_id;
642 userid_t user_id, int flags) {
645 std::to_string(user_id), std::to_string(flags)})) {
652 bool e4crypt_prepare_user_storage(const std::string& volume_uuid, userid_t user_id, int serial,
655 << ", user " << user_id << ", serial " << serial << ", flags " << flags;
659 auto system_legacy_path = android::vold::BuildDataSystemLegacyPath(user_id);
660 auto misc_legacy_path = android::vold::BuildDataMiscLegacyPath(user_id);
661 auto profiles_de_path = android::vold::BuildDataProfilesDePath(user_id);
664 auto system_de_path = android::vold::BuildDataSystemDePath(user_id);
665 auto misc_de_path = android::vold::BuildDataMiscDePath(user_id);
666 auto vendor_de_path = android::vold::BuildDataVendorDePath(user_id);
667 auto user_de_path = android::vold::BuildDataUserDePath(volume_uuid, user_id);
672 if (!prepare_dir(misc_legacy_path, 0750, multiuser_get_uid(user_id, AID_SYSTEM),
673 multiuser_get_uid(user_id, AID_EVERYBODY))) return false;
686 if (!lookup_key_ref(s_de_key_raw_refs, user_id, &de_ref.key_raw_ref)) return false;
700 auto system_ce_path = android::vold::BuildDataSystemCePath(user_id);
701 auto misc_ce_path = android::vold::BuildDataMiscCePath(user_id);
702 auto vendor_ce_path = android::vold::BuildDataVendorCePath(user_id);
703 auto media_ce_path = android::vold::BuildDataMediaCePath(volume_uuid, user_id);
704 auto user_ce_path = android::vold::BuildDataUserCePath(volume_uuid, user_id);
717 if (!lookup_key_ref(s_ce_key_raw_refs, user_id, &ce_ref.key_raw_ref)) return false;
738 if (!prepare_subdirs("prepare", volume_uuid, user_id, flags)) return false;
743 bool e4crypt_destroy_user_storage(const std::string& volume_uuid, userid_t user_id, int flags) {
745 << ", user " << user_id << ", flags " << flags;
748 res &= prepare_subdirs("destroy", volume_uuid, user_id, flags);
752 auto system_ce_path = android::vold::BuildDataSystemCePath(user_id);
753 auto misc_ce_path = android::vold::BuildDataMiscCePath(user_id);
754 auto vendor_ce_path = android::vold::BuildDataVendorCePath(user_id);
755 auto media_ce_path = android::vold::BuildDataMediaCePath(volume_uuid, user_id);
756 auto user_ce_path = android::vold::BuildDataUserCePath(volume_uuid, user_id);
773 auto system_legacy_path = android::vold::BuildDataSystemLegacyPath(user_id);
774 auto misc_legacy_path = android::vold::BuildDataMiscLegacyPath(user_id);
775 auto profiles_de_path = android::vold::BuildDataProfilesDePath(user_id);
778 auto system_de_path = android::vold::BuildDataSystemDePath(user_id);
779 auto misc_de_path = android::vold::BuildDataMiscDePath(user_id);
780 auto vendor_de_path = android::vold::BuildDataVendorDePath(user_id);
781 auto user_de_path = android::vold::BuildDataUserDePath(volume_uuid, user_id);