Add whoami
This commit is contained in:
parent
7ac4821420
commit
39a1cc73d3
25
apps/whoami.c
Normal file
25
apps/whoami.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* 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(getuid());
|
||||
if (!p) return 0;
|
||||
|
||||
fprintf(stdout, "%s\n", p->pw_name);
|
||||
|
||||
endpwent();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user