ladybird/Userland/id.cpp

18 lines
382 B
C++
Raw Normal View History

2018-10-22 12:06:22 +00:00
#include <LibC/unistd.h>
#include <LibC/stdio.h>
#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();
struct passwd* pw = getpwuid(uid);
2018-11-06 21:27:51 +00:00
struct group* gr = getgrgid(gid);
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;
}