A class to manage informations obtained from the output of the busybox applet id command.
More...
#include <userInfo.h>
|
| UserInfo (const int iUid, const int iGid, const std::set< int > &groups) |
|
| UserInfo (const char *pcUserInfo) |
| Initialize this object with the specified user id and groups. More...
|
|
virtual | ~UserInfo () |
|
int | access (const int iUid, const int iGid, const unsigned int uiRawMode, const int iMask) const |
| This is the similar to the access(2) system call. More...
|
|
|
| UserInfo () |
|
bool | belongs2Group (const int iGuid) const |
| Tests if this user belongs to the specified group,. More...
|
|
int | testAccesss (const int iMode, const int iMask) const |
| Test requested access permissions against the mode;. More...
|
|
void | parseUserInfoString (const char *pcUserInfo) |
| Parse the specified user info string and store the results in the corresponding member variables. More...
|
|
A class to manage informations obtained from the output of the busybox applet id command.
External resources
busybox
Definition at line 37 of file userInfo.h.
UserInfo::UserInfo |
( |
const int |
iUid, |
|
|
const int |
iGid, |
|
|
const std::set< int > & |
groups |
|
) |
| |
|
inline |
UserInfo::UserInfo |
( |
const char * |
pcUserInfo | ) |
|
Initialize this object with the specified user id and groups.
The accepted format for the user info parameter is one that the busybox applet id returns.
Example: uid=2000 gid=2000 groups=1003,1004,1007,1011,1015,1028,3001,3002,3003,3006
- Parameters
-
pcUserInfo | string containing user informations as described above. |
Definition at line 44 of file userInfo.cpp.
virtual UserInfo::~UserInfo |
( |
| ) |
|
|
inlinevirtual |
int UserInfo::access |
( |
const int |
iUid, |
|
|
const int |
iGid, |
|
|
const unsigned int |
uiRawMode, |
|
|
const int |
iMask |
|
) |
| const |
This is the similar to the access(2) system call.
It returns -EACCESS if the requested permission for this user isn't available, or 0 for success.
The following flags are defined for the uiRawMode argument:
S_IFMT 0170000 bit mask for the file type bit fields S_IFSOCK 0140000 socket S_IFLNK 0120000 symbolic link S_IFREG 0100000 regular file S_IFBLK 0060000 block device S_IFDIR 0040000 directory S_IFCHR 0020000 character device S_IFIFO 0010000 FIFO S_ISUID 0004000 set UID bit S_ISGID 0002000 set-group-ID bit (see below) S_ISVTX 0001000 sticky bit (see below) S_IRWXU 00700 mask for file owner permissions S_IRUSR 00400 owner has read permission S_IWUSR 00200 owner has write permission S_IXUSR 00100 owner has execute permission S_IRWXG 00070 mask for group permissions S_IRGRP 00040 group has read permission S_IWGRP 00020 group has write permission S_IXGRP 00010 group has execute permission S_IRWXO 00007 mask for permissions for others (not in group) S_IROTH 00004 others have read permission S_IWOTH 00002 others have write permission S_IXOTH 00001 others have execute permission This is a bit field, and we can see that the last four digits match the access mode
- Parameters
-
iUid | check access for an object with this user id. |
iGid | check access for an object with this group id. |
uiRawMode | the mode to check for, as defined in struct stat st_mode field, it is described in the programmer's manual for the stat function (man 2 stat). |
iMask | specifies the accessibility check(s) to be performed. is either bitwise OR of one or more of R_OK, W_OK, and X_OK as defined in unistd.h. |
- Returns
- -EACCESS if access is denied or 0 if access is granted.
Definition at line 94 of file userInfo.cpp.
bool UserInfo::belongs2Group |
( |
const int |
iGuid | ) |
const |
|
private |
Tests if this user belongs to the specified group,.
- Parameters
-
iGuid | the group id to test for. |
- Returns
- true if and only if this user belongs to the specified group, false otherwise.
Definition at line 115 of file userInfo.cpp.
void UserInfo::parseUserInfoString |
( |
const char * |
pcUserInfo | ) |
|
|
private |
Parse the specified user info string and store the results in the corresponding member variables.
The accepted format for the user info parameter is one that the busybox applet id returns.
Example: uid=2000 gid=2000 groups=1003,1004,1007,1011,1015,1028,3001,3002,3003,3006
- Parameters
-
pcUserInfo | string containing user informations as described above. |
Definition at line 144 of file userInfo.cpp.
int UserInfo::testAccesss |
( |
const int |
iMode, |
|
|
const int |
iMask |
|
) |
| const |
|
private |
Test requested access permissions against the mode;.
- Parameters
-
iMode | permissions to test for. |
iMask | the requested access permissions. |
Definition at line 126 of file userInfo.cpp.
std::set<int> UserInfo::m_Groups |
|
private |
The documentation for this class was generated from the following files: