45 G_EXCEPTION( NoSuchUser ,
"no such user" ) ;
46 G_EXCEPTION( NoSuchGroup ,
"no such group" ) ;
47 G_EXCEPTION( Error ,
"cannot read user database" ) ;
49 explicit Identity(
const std::string & username ,
50 const std::string & group_name_override = std::string() ) ;
57 static Identity real(
bool with_cache =
true ) noexcept ;
70 bool isRoot()
const noexcept ;
73 std::string
str()
const ;
76 uid_t
userid()
const noexcept ;
79 gid_t
groupid()
const noexcept ;
88 static std::pair<uid_t,gid_t>
lookupUser(
const std::string & user ) ;
91 static gid_t
lookupGroup(
const std::string & group ) ;
107 std::ostream & operator<<( std::ostream & stream ,
const Identity & identity )
109 return stream << identity.
str() ;
A combination of user-id and group-id, with a very low-level interface to the get/set/e/uid/gid funct...
static std::pair< uid_t, gid_t > lookupUser(const std::string &user)
Does a username lookup. Throws on error.
gid_t groupid() const noexcept
Returns the group part.
bool isRoot() const noexcept
Returns true if the userid is zero.
uid_t userid() const noexcept
Returns the user part.
static Identity invalid() noexcept
Returns an invalid identity.
bool operator==(const Identity &) const noexcept
Comparison operator.
static Identity root() noexcept
Returns the superuser identity.
static gid_t lookupGroup(const std::string &group)
Does a groupname lookup. Throws on error.
std::string str() const
Returns a string representation.
static Identity effective() noexcept
Returns the current effective identity.
bool operator!=(const Identity &) const noexcept
Comparison operator.
static Identity real(bool with_cache=true) noexcept
Returns the calling process's real identity.
An empty structure that is used to indicate a signal-safe, reentrant implementation.