How do you programmatically (in a C program) query the real and effective UIDs /GIDs? Here are the system calls to do so:
#include <unistd.h>#include <sys/types.h>uid_t getuid(void);uid_t geteuid(void);gid_t getgid(void);gid_t getegid(void);
This is pretty straightforward:
- getuid(2) returns the real UID; geteuid(2) returns the effective UID
- getgid(2) returns the real GID; getegid(2) returns the effective GID
- uid_t and gid_t are glibc typedefs for an unsigned integer