47 G_EXCEPTION( NoSuchUser ,
tx(
"no such user") )
48 G_EXCEPTION( NoSuchGroup ,
tx(
"no such group") )
49 G_EXCEPTION( Error ,
tx(
"cannot read user database") )
51 explicit Identity(
const std::string & username ,
52 const std::string & group_name_override = {} ) ;
72 bool isRoot()
const noexcept ;
75 std::string
str()
const ;
78 uid_t
userid()
const noexcept ;
81 gid_t
groupid()
const noexcept ;
84 std::string
sid()
const ;
93 static std::pair<Identity,std::string>
lookup( std::string_view user ) ;
97 static std::pair<Identity,std::string>
lookup( std::string_view user , std::nothrow_t ) ;
102 static gid_t
lookupGroup(
const std::string & group ) ;
106 bool match( std::pair<int,int> uid_range )
const ;
114 Identity( uid_t , gid_t ,
const std::string & ) ;
125 std::ostream & operator<<( std::ostream & stream ,
const Identity & identity )
127 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...
gid_t groupid() const noexcept
Returns the group part (Unix).
std::string sid() const
Returns the sid (Windows).
bool isRoot() const noexcept
Returns true if the userid is zero.
uid_t userid() const noexcept
Returns the user part (Unix).
static Identity invalid() noexcept
Returns an invalid identity.
bool operator==(const Identity &) const noexcept
Comparison operator.
bool match(std::pair< int, int > uid_range) const
Returns true if the user-id is in the given range or if not implemented.
static Identity root() noexcept
Returns the superuser identity.
static gid_t lookupGroup(const std::string &group)
Does a groupname lookup.
static std::pair< Identity, std::string > lookup(std::string_view user)
Does a username lookup returning the identity and the canonical name.
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() noexcept
Returns the calling process's real identity.
An empty structure that is used to indicate a signal-safe, reentrant implementation.
constexpr const char * tx(const char *p) noexcept
A briefer alternative to G::gettext_noop().