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

#include <groupentry.h>

Inherits object.

Public Member Functions

 groupentry ()
 
 ~groupentry ()
 
bool open (const char *groupname)
 
bool open (gid_t groupid)
 
const chargetName ()
 
gid_t getGroupId ()
 
const chargetSidString ()
 
const voidgetSid ()
 
uint64_t getSidSize ()
 
const char *constgetMembers ()
 
- Public Member Functions inherited from object
virtual ~object ()
 

Static Public Member Functions

static gid_t getGroupId (const char *groupname)
 
static chargetName (gid_t groupid)
 
static chargetSidString (const char *groupname)
 
static bool supportsFormalSid ()
 
static bool getNeedsMutex ()
 
static void setMutex (threadmutex *mtx)
 

Detailed Description

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

Constructor & Destructor Documentation

◆ groupentry()

groupentry::groupentry ( )

Creates an instance of the groupentry class.

◆ ~groupentry()

groupentry::~groupentry ( )

Deletes this instance of the groupentry class.

Member Function Documentation

◆ getGroupId() [1/2]

gid_t groupentry::getGroupId ( )

Returns the id of the group.

Note: On platforms (like Windows) where the supportsFormalSid 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 ( )

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

◆ getName() [1/2]

const char * groupentry::getName ( )

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.

◆ getNeedsMutex()

static bool groupentry::getNeedsMutex ( )
static

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

◆ getSidString() [1/2]

const char * groupentry::getSidString ( )

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

Note: On platforms (like non-Windows platforms) where the supportsFormalSid 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.

◆ open() [1/2]

bool groupentry::open ( const char * groupname)

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

◆ open() [2/2]

bool groupentry::open ( gid_t groupid)

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

◆ setMutex()

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

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

◆ supportsFormalSid()

static bool groupentry::supportsFormalSid ( )
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.