2018-10-22 12:06:22 +00:00
|
|
|
#include <LibC/unistd.h>
|
|
|
|
#include <LibC/stdio.h>
|
2018-10-31 18:49:22 +00:00
|
|
|
#include <LibC/pwd.h>
|
2018-11-06 21:27:51 +00:00
|
|
|
#include <LibC/grp.h>
|
2018-10-22 12:06:22 +00:00
|
|
|
|
|
|
|
int main(int c, char** v)
|
|
|
|
{
|
|
|
|
uid_t uid = getuid();
|
|
|
|
gid_t gid = getgid();
|
2018-10-31 18:49:22 +00:00
|
|
|
|
|
|
|
struct passwd* pw = getpwuid(uid);
|
2018-11-06 21:27:51 +00:00
|
|
|
struct group* gr = getgrgid(gid);
|
2018-10-31 18:49:22 +00:00
|
|
|
|
2018-11-06 21:27:51 +00:00
|
|
|
printf("uid=%u(%s), gid=%u(%s)\n", uid, pw ? pw->pw_name : "n/a", gid, gr ? gr->gr_name : "n/a", getpid());
|
2018-10-22 12:06:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|