Lines Matching full:user

52 static utils::optional< passwd_ns::user > fake_current_user;
56 static std::vector< passwd_ns::user > mock_users;
59 /// Formats a user for logging purposes.
61 /// \param user The user to format.
63 /// \return The user as a string.
65 format_user(const passwd_ns::user& user) in format_user() argument
67 return F("name=%s, uid=%s, gid=%s") % user.name % user.uid % user.gid; in format_user()
74 /// Constructs a new user.
76 /// \param name_ The name of the user.
77 /// \param uid_ The user identifier.
79 passwd_ns::user::user(const std::string& name_, const unsigned int uid_, in user() function in passwd_ns::user
88 /// Checks if the user has superpowers or not.
90 /// \return True if the user is root, false otherwise.
92 passwd_ns::user::is_root(void) const in is_root()
98 /// Gets the current user.
100 /// \return The current user.
101 passwd_ns::user
105 const user u = fake_current_user.get(); in current_user()
106 LD(F("Current user is fake: %s") % format_user(u)); in current_user()
109 const user u = find_user_by_uid(::getuid()); in current_user()
110 LD(F("Current user is: %s") % format_user(u)); in current_user()
116 /// Gets information about a user by its name.
118 /// \param name The name of the user to query.
120 /// \return The information about the user.
122 /// \throw std::runtime_error If the user does not exist.
123 passwd_ns::user
130 "user '%s'") % name); in find_user_by_name()
132 return user(pw->pw_name, pw->pw_uid, pw->pw_gid); in find_user_by_name()
134 for (std::vector< user >::const_iterator iter = mock_users.begin(); in find_user_by_name()
140 "user '%s'") % name); in find_user_by_name()
145 /// Gets information about a user by its identifier.
147 /// \param uid The identifier of the user to query.
149 /// \return The information about the user.
151 /// \throw std::runtime_error If the user does not exist.
152 passwd_ns::user
159 "user with UID %s") % uid); in find_user_by_uid()
161 return user(pw->pw_name, pw->pw_uid, pw->pw_gid); in find_user_by_uid()
163 for (std::vector< user >::const_iterator iter = mock_users.begin(); in find_user_by_uid()
169 "user with UID %s") % uid); in find_user_by_uid()
174 /// Overrides the current user for testing purposes.
178 /// \param new_current_user The new current user.
180 passwd_ns::set_current_user_for_testing(const user& new_current_user) in set_current_user_for_testing()
190 passwd_ns::set_mock_users_for_testing(const std::vector< user >& users) in set_mock_users_for_testing()