E-MailRelay
|
A combination of user-id and group-id, with a very low-level interface to the get/set/e/uid/gid functions. More...
#include <gidentity.h>
Public Member Functions | |
Identity (const std::string &username, const std::string &group_name_override={}) | |
Constructor for the named identity. More... | |
bool | isRoot () const noexcept |
Returns true if the userid is zero. More... | |
std::string | str () const |
Returns a string representation. More... | |
uid_t | userid () const noexcept |
Returns the user part (Unix). More... | |
gid_t | groupid () const noexcept |
Returns the group part (Unix). More... | |
std::string | sid () const |
Returns the sid (Windows). More... | |
bool | operator== (const Identity &) const noexcept |
Comparison operator. More... | |
bool | operator!= (const Identity &) const noexcept |
Comparison operator. More... | |
bool | match (std::pair< int, int > uid_range) const |
Returns true if the user-id is in the given range or if not implemented. More... | |
Static Public Member Functions | |
static Identity | effective () noexcept |
Returns the current effective identity. More... | |
static Identity | real () noexcept |
Returns the calling process's real identity. More... | |
static Identity | root () noexcept |
Returns the superuser identity. More... | |
static Identity | invalid () noexcept |
Returns an invalid identity. More... | |
static Identity | invalid (SignalSafe) noexcept |
Returns an invalid identity, with a signal-safe guarantee. More... | |
static std::pair< Identity, std::string > | lookup (std::string_view user) |
Does a username lookup returning the identity and the canonical name. More... | |
static std::pair< Identity, std::string > | lookup (std::string_view user, std::nothrow_t) |
Does a username lookup returning the identity and the canonical name. More... | |
static gid_t | lookupGroup (const std::string &group) |
Does a groupname lookup. More... | |
A combination of user-id and group-id, with a very low-level interface to the get/set/e/uid/gid functions.
Uses getpwnam() to do username lookups.
Definition at line 44 of file gidentity.h.
|
explicit |
Constructor for the named identity.
Throws NoSuchUser on error.
Definition at line 59 of file gidentity_unix.cpp.
|
staticnoexcept |
Returns the current effective identity.
Definition at line 70 of file gidentity_unix.cpp.
|
noexcept |
Returns the group part (Unix).
Definition at line 111 of file gidentity_unix.cpp.
|
staticnoexcept |
Returns an invalid identity.
Definition at line 80 of file gidentity_unix.cpp.
|
staticnoexcept |
Returns an invalid identity, with a signal-safe guarantee.
Definition at line 86 of file gidentity_unix.cpp.
|
noexcept |
Returns true if the userid is zero.
Definition at line 116 of file gidentity_unix.cpp.
|
static |
Does a username lookup returning the identity and the canonical name.
Throws if no such user or on error.
Definition at line 132 of file gidentity_unix.cpp.
|
static |
Does a username lookup returning the identity and the canonical name.
Returns with Identitiy::invalid() if no such user. Throws on error.
Definition at line 142 of file gidentity_unix.cpp.
|
static |
Does a groupname lookup.
Returns -1 if no such group. Throws on error.
Definition at line 150 of file gidentity_unix.cpp.
bool G::Identity::match | ( | std::pair< int, int > | uid_range | ) | const |
Returns true if the user-id is in the given range or if not implemented.
Definition at line 157 of file gidentity_unix.cpp.
|
noexcept |
Comparison operator.
Definition at line 126 of file gidentity_unix.cpp.
|
noexcept |
Comparison operator.
Definition at line 121 of file gidentity_unix.cpp.
|
staticnoexcept |
Returns the calling process's real identity.
Definition at line 75 of file gidentity_unix.cpp.
|
staticnoexcept |
Returns the superuser identity.
Definition at line 92 of file gidentity_unix.cpp.
std::string G::Identity::sid | ( | ) | const |
Returns the sid (Windows).
Definition at line 127 of file gidentity_win32.cpp.
std::string G::Identity::str | ( | ) | const |
Returns a string representation.
Definition at line 98 of file gidentity_unix.cpp.
|
noexcept |
Returns the user part (Unix).
Definition at line 106 of file gidentity_unix.cpp.