ladybird/Userland/id.cpp

18 lines
382 B
C++
Raw Normal View History

2018-10-22 15:06:22 +03:00
#include <LibC/unistd.h>
#include <LibC/stdio.h>
#include <LibC/pwd.h>
2018-11-07 00:27:51 +03:00
#include <LibC/grp.h>
2018-10-22 15:06:22 +03:00
int main(int c, char** v)
{
uid_t uid = getuid();
gid_t gid = getgid();
struct passwd* pw = getpwuid(uid);
2018-11-07 00:27:51 +03:00
struct group* gr = getgrgid(gid);
2018-11-07 00:27:51 +03: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 15:06:22 +03:00
return 0;
}