Mercurial > hg > toybox
annotate toys/whoami.c @ 524:2247cdb73f2d
whoami: fix toy description, no code changes
author | Pere Orga <gotrunks@gmail.com> |
---|---|
date | Mon, 05 Mar 2012 00:25:32 +0100 |
parents | b64064a044a4 |
children | 878b94b32866 |
rev | line source |
---|---|
520 | 1 /* vi: set sw=4 ts=4: |
2 * | |
524
2247cdb73f2d
whoami: fix toy description, no code changes
Pere Orga <gotrunks@gmail.com>
parents:
521
diff
changeset
|
3 * whoami.c - Print effective user name |
520 | 4 * |
5 * Copyright 2012 Georgi Chorbadzhiyski <georgi@unixsol.org> | |
6 * | |
7 | |
8 USE_WHOAMI(NEWTOY(whoami, NULL, TOYFLAG_USR|TOYFLAG_BIN)) | |
9 | |
10 config WHOAMI | |
11 bool "whoami" | |
12 default y | |
13 help | |
14 usage: whoami | |
15 | |
16 Print effective user id. | |
17 */ | |
18 | |
19 #include "toys.h" | |
20 | |
21 void whoami_main(void) | |
22 { | |
23 struct passwd *pw = getpwuid(geteuid()); | |
24 | |
25 if (!pw) { | |
26 perror("getpwuid"); | |
27 toys.exitval = 1; | |
28 return; | |
29 } | |
30 | |
521 | 31 xputs(pw->pw_name); |
520 | 32 } |