Open Lighting Architecture  0.10.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Files | Classes
Credentials

Detailed Description

User & Group Information.

Files

file  Credentials.cpp
 
file  Credentials.h
 User & Group Information.
 

Classes

struct  ola::PasswdEntry
 Contains information about a user. More...
 
struct  ola::GroupEntry
 Contains information about a group. More...
 

Get / Set User ID

bool ola::SupportsUIDs ()
 Check whether the current platform supports User and Group IDs. More...
 
bool ola::GetUID (uid_t *uid)
 Get the real UID of the process. More...
 
bool ola::GetEUID (uid_t *euid)
 Get the effective UID of the process. More...
 
bool ola::SetUID (uid_t new_uid)
 Set the effective UID of the process. More...
 

Get / Set Group ID

bool ola::GetGID (gid_t *gid)
 Get the real Group ID. More...
 
bool ola::GetEGID (gid_t *egid)
 Get the effective group ID. More...
 
bool ola::SetGID (gid_t new_gid)
 Set the effective Group ID of the process. More...
 

Get / Set supplementary group IDs

int ola::GetGroups (int size, gid_t list[])
 Get the supplementary group ID's of the process. More...
 
bool ola::SetGroups (size_t size, const gid_t *list)
 Set the supplementary group ID's of the process. More...
 

Lookup User Information

bool ola::GetPasswdName (const std::string &name, PasswdEntry *passwd)
 Lookup a user account by username. More...
 
bool ola::GetPasswdUID (uid_t uid, PasswdEntry *passwd)
 Lookup a user account by UID. More...
 

Lookup Group Information.

bool ola::GetGroupName (const std::string &name, GroupEntry *passwd)
 Lookup a group account by name. More...
 
bool ola::GetGroupGID (gid_t gid, GroupEntry *passwd)
 Lookup a group account by GID. More...
 

Function Documentation

bool ola::GetEGID ( gid_t *  egid)

Get the effective group ID.

Parameters
[out]egidis the variable to receive the effective Group ID
Returns
true on success, false otherwise
bool ola::GetEUID ( uid_t *  euid)

Get the effective UID of the process.

Parameters
[out]euidis the variable to receive the effective UID
Returns
true on success, false otherwise
bool ola::GetGID ( gid_t *  gid)

Get the real Group ID.

Parameters
[out]gidis the variable to receive the real Group ID
Returns
true on success, false otherwise
bool ola::GetGroupGID ( gid_t  gid,
GroupEntry *  passwd 
)

Lookup a group account by GID.

Note
This is only thread safe & reentrant if the underlying OS supports it.
Wraps getgrpid()/getgrpid_r().
Parameters
[in]gidis the Group ID to match against
[out]passwdis a GroupEntry to be populated upon success
Returns
true on success and false otherwise
bool ola::GetGroupName ( const std::string &  name,
GroupEntry *  passwd 
)

Lookup a group account by name.

Note
This is only thread safe & reentrant if the underlying OS supports it.
Wraps getgrnam()/getgrnam_r().
Parameters
[in]namethe name of the group to match
[out]passwdis a GroupEntry to be populated upon success
Returns
true on success and false otherwise
int ola::GetGroups ( int  size,
gid_t  list[] 
)

Get the supplementary group ID's of the process.

Parameters
sizethe size of the list to place group ID's in
[out]listthe list to place group ID's
Note
when size 0 is given, the list remain's untouched and only the number of group ID's is returned
Returns
on error -1, otherwise the number of group ID's
bool ola::GetPasswdName ( const std::string &  name,
PasswdEntry *  passwd 
)

Lookup a user account by username.

Note
Only thread safe and reentrant if the underlying OS supports it.
Wraps getpwnam() / getpwnam_r().
Parameters
[in]nameusername to search for.
[out]passwdstruct to hold information for username name
Returns
true on success, false otherwise
bool ola::GetPasswdUID ( uid_t  uid,
PasswdEntry *  passwd 
)

Lookup a user account by UID.

Note
Only thread safe and reentrant if the underlying OS supports it.
Wraps getpwuid()/getpwuid_r().
Parameters
[in]uidis the User ID to match against
[out]passwdstruct to hold information for uid
Returns
true on success, false otherwise
bool ola::GetUID ( uid_t *  uid)

Get the real UID of the process.

Parameters
[out]uidis the variable to receive the real UID
Returns
true on success, false otherwise
bool ola::SetGID ( gid_t  new_gid)

Set the effective Group ID of the process.

Note
This is a one way street. Only valid if the current egid is 0, or egid == new_gid
Parameters
new_gidnew Group ID to set process group to
Returns
true on success, false otherwise
bool ola::SetGroups ( size_t  size,
const gid_t *  list 
)

Set the supplementary group ID's of the process.

Parameters
sizethe size of the list of ID's
listpointer to the list of ID's
Returns
true on success, false otherwise
bool ola::SetUID ( uid_t  new_uid)

Set the effective UID of the process.

Note
This is a one way street, and is only valid if the current euid is 0, or euid == new_uid
Parameters
new_uidis the user id to set the processes to
Returns
true on success, false otherwise
bool ola::SupportsUIDs ( )

Check whether the current platform supports User and Group IDs.

Returns
true on *nix, false on Windows