2023-10-04 22:03:34 +03:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2023-10-11 21:07:22 +03:00
|
|
|
#include <string.h>
|
2023-10-04 22:03:34 +03:00
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
struct passwd *pw = getpwuid(getuid());
|
|
|
|
if (!pw) {
|
|
|
|
fprintf(stderr, "whoami: %s\n", strerror(errno));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
puts(pw->pw_name);
|
|
|
|
return 0;
|
|
|
|
}
|