Rudiments

Public Member Functions | Static Public Member Functions | List of all members
groupentry Class Reference

## Public Member Functions
| groupentry ()
| groupentry (const groupentry &g)
groupentry & | operator= (const groupentry &g)
| ~groupentry ()
bool | initialize (const char *groupname)
bool | initialize (gid_t groupid)
const char * | getName () const
gid_t | getGroupId () const
const char * | getSidString () const
const void * | getSid () const
uint64_t | getSidSize () const
const char *const * | getMembers () const

## Static Public Member Functions
static gid_t | getGroupId (const char *groupname)
static char * | getName (gid_t groupid)
static char * | getSidString (const char *groupname)
static bool | platformSupportsFormalSid ()
static bool | needsMutex ()
static void | setMutex (threadmutex *mtx)

## Detailed Description

The groupentry class provides methods for retrieving information about user groups.

## Constructor & Destructor Documentation

## ◆ groupentry() [1/2]

groupentry::groupentry | ( |  | ) |

Creates an instance of the groupentry class.

## ◆ groupentry() [2/2]

groupentry::groupentry | ( | const groupentry & | g | ) |

Creates an instance of the groupentry class that is a copy of "g".

## ◆ ~groupentry()

groupentry::~groupentry | ( |  | ) |

Deletes this instance of the groupentry class.

## Member Function Documentation

## ◆ getGroupId() [1/2]

gid_t groupentry::getGroupId | ( |  | ) | const

Returns the id of the group.

Note: On platforms (like Windows) where the platformSupportsFormalSid method returns true, groups don't have simple numeric ids. On those platforms, the value returned by this method is simply an index into an internal structure that methods of other rudiments classes know how to access and ultimately translate to a group. It should not be passed in to functions or methods of other libraries that don't ultimately use rudiments methods.

## ◆ getGroupId() [2/2]

static gid_t groupentry::getGroupId | ( | const char * | groupname | ) |
| static

Convenience method. Returns the id for "groupname".

Returns -1 if "groupname" was invalid or if an error occurred.

## ◆ getMembers()

const char* const* groupentry::getMembers | ( |  | ) | const

Returns a NULL-terminated list of the names of the members of the group.

## ◆ getName() [1/2]

const char* groupentry::getName | ( |  | ) | const

Returns the name of the group.

## ◆ getName() [2/2]

static char* groupentry::getName | ( | gid_t | groupid | ) |
| static

Convenience method. Returns the name of "groupid". Note that the return value is allocated internally and returned. The calling program must free the buffer.

Returns NULL if "groupid" was invalid or if an error occurred.

## ◆ getSidString() [1/2]

const char* groupentry::getSidString | ( |  | ) | const

Returns a string representation of the SID (security id) of this group.

Note: On platforms (like non-Windows platforms) where the platformSupportsFormalSid method returns false, the value returned is just a string representation of the number returned by getGroupId().

## ◆ getSidString() [2/2]

static char* groupentry::getSidString | ( | const char * | groupname | ) |
| static

Convenience method. Returns a string representation of the SID (security id) of the group specified by "groupname". See non-static version of this method for more information.

Note that the return value is allocated internally and returned. The calling program must free the buffer.

Returns NULL if an error occurred or if "groupname" is invalid.

## ◆ initialize() [1/2]

bool groupentry::initialize | ( | const char * | groupname | ) |

Looks up a group entry by name. Returns true on success and false on failure.

## ◆ initialize() [2/2]

bool groupentry::initialize | ( | gid_t | groupid | ) |

Looks up a group entry by group id. Returns true on success and false on failure.

## ◆ needsMutex()

static bool groupentry::needsMutex | ( |  | ) |
| static

Returns true if this class needs a mutex to operate safely in a threaded environment and false otherwise.

## ◆ operator=()

groupentry& groupentry::operator= | ( | const groupentry & | g | ) |

Makes this instance of the groupentry class identical to "g".

## ◆ platformSupportsFormalSid()

static bool groupentry::platformSupportsFormalSid | ( |  | ) |
| static

Returns true if the platform supports a formal group SID (security id) and false if not.

Windows and windows-like platforms do. Unix and unix-like platforms (including Mac OS X) do not.

## ◆ setMutex()

static void groupentry::setMutex | ( | threadmutex * | mtx | ) |
| static

Allows you to supply a mutex is the class needs it (see needsMutex()). If your application is not multithreaded, then there is no need to supply a mutex.