banan-os/userspace/whoami/main.cpp

17 lines
239 B
C++

#include <pwd.h>
#include <stdio.h>
#include <unistd.h>
int main()
{
auto* pw = getpwuid(geteuid());
if (pw == nullptr)
{
printf("unknown user %d\n", geteuid());
return 1;
}
printf("%s\n", pw->pw_name);
endpwent();
return 0;
}