toaruos/apps/whoami.c
2018-10-31 10:28:41 +09:00

26 lines
492 B
C

/* vim: tabstop=4 shiftwidth=4 noexpandtab
* This file is part of ToaruOS and is released under the terms
* of the NCSA / University of Illinois License - see LICENSE.md
* Copyright (C) 2013-2014 K. Lange
*
* Who Am I?
*
*/
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <pwd.h>
int main(int argc, char ** argv) {
struct passwd * p = getpwuid(geteuid());
if (!p) return 0;
fprintf(stdout, "%s\n", p->pw_name);
endpwent();
return 0;
}