t_user* find_user_by_torrent_pass(str_ref v, str_ref info_hash) { if (v.size() != 32) return NULL; if (t_user* user = find_user_by_uid(read_int(4, hex_decode(v.substr(0, 8))))) { if (Csha1((boost::format("%s %d %d %s") % m_config.m_torrent_pass_private_key % user->torrent_pass_version % user->uid % info_hash).str()).read().substr(0, 12) == hex_decode(v.substr(8, 24))) return user; } return find_ptr2(m_users_torrent_passes, to_array<char, 32>(v)); }
/// Gets the current user. /// /// \return The current user. passwd_ns::user passwd_ns::current_user(void) { if (fake_current_user) { const user u = fake_current_user.get(); LD(F("Current user is fake: %s") % format_user(u)); return u; } else { const user u = find_user_by_uid(::getuid()); LD(F("Current user is: %s") % format_user(u)); return u; } }