KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
Loading...
Searching...
No Matches
UserUtil Class Reference

UserUtil. More...

#include <userutil.h>

Static Public Member Functions

static gid_t gidFromName (const QString &name)
 Look up the numeric GID for a group name.
 
static uid_t uidFromName (const QString &name)
 Look up the numeric UID for a user name.
 
static QString nameFromGid (gid_t gid)
 Return the group name for a numeric GID.
 
static QString nameFromUid (uid_t uid)
 Return the user name for a numeric UID.
 
static uid_t currentUser ()
 Return the UID of the process owner.
 
static QString currentUserFullName ()
 Return the full (display) name of the process owner.
 
static bool isUserMemberOfGroup (uid_t uid, gid_t gid)
 Test whether a user is a member of a group.
 
static QString currentUserName ()
 Return the login name of the current user (cross-platform).
 

Detailed Description

UserUtil.

Some static helper methods for Linux users / groups

Stephen Punak, July 08 2019

Static helper methods for querying Unix user and group information.

POSIX-only methods are guarded by #ifndef __WIN32 and are unavailable on Windows.

Definition at line 24 of file userutil.h.

Member Function Documentation

◆ currentUser()

static uid_t UserUtil::currentUser ( )
static

Return the UID of the process owner.

Returns
UID of the currently running process

◆ currentUserFullName()

static QString UserUtil::currentUserFullName ( )
static

Return the full (display) name of the process owner.

Returns
GECOS full name string, or empty string on error

◆ currentUserName()

static QString UserUtil::currentUserName ( )
static

Return the login name of the current user (cross-platform).

Returns
User name string

◆ gidFromName()

static gid_t UserUtil::gidFromName ( const QString &  name)
static

Look up the numeric GID for a group name.

Parameters
nameGroup name string
Returns
Group ID, or (gid_t)-1 if not found

◆ isUserMemberOfGroup()

static bool UserUtil::isUserMemberOfGroup ( uid_t  uid,
gid_t  gid 
)
static

Test whether a user is a member of a group.

Parameters
uidUser ID to check
gidGroup ID to check membership in
Returns
true if the user is a member of the group

◆ nameFromGid()

static QString UserUtil::nameFromGid ( gid_t  gid)
static

Return the group name for a numeric GID.

Parameters
gidGroup ID to look up
Returns
Group name string, or empty string if not found

◆ nameFromUid()

static QString UserUtil::nameFromUid ( uid_t  uid)
static

Return the user name for a numeric UID.

Parameters
uidUser ID to look up
Returns
User name string, or empty string if not found

◆ uidFromName()

static uid_t UserUtil::uidFromName ( const QString &  name)
static

Look up the numeric UID for a user name.

Parameters
nameUser name string
Returns
User ID, or (uid_t)-1 if not found

The documentation for this class was generated from the following file: