banan-os/userspace/whoami/main.cpp

17 lines
239 B
C++
Raw Normal View History

2023-08-15 09:03:51 +03:00
#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;
}