aboutsummaryrefslogtreecommitdiff
path: root/whoami.c
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-03-17 23:54:19 +1300
committerTom Ryder <tom@sanctum.geek.nz>2016-03-17 23:54:19 +1300
commit52306a7f6ac1dd89a0dad17024db222dd36e80a9 (patch)
tree5727030d122490ebfb5fd55b898139007266bd82 /whoami.c
parentUse sizeof rather than constant (diff)
downloadtunics-52306a7f6ac1dd89a0dad17024db222dd36e80a9.tar.gz
tunics-52306a7f6ac1dd89a0dad17024db222dd36e80a9.zip
Wrote whoami(1)
Diffstat (limited to 'whoami.c')
-rw-r--r--whoami.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/whoami.c b/whoami.c
new file mode 100644
index 0000000..b692abe
--- /dev/null
+++ b/whoami.c
@@ -0,0 +1,14 @@
+#include "whoami.h"
+
+int main(void) {
+ struct passwd *p;
+
+ if ((p = getpwuid(getuid())) == NULL) {
+ exit(EXIT_FAILURE);
+ }
+
+ printf("%s\n", p->pw_name);
+
+ exit(EXIT_SUCCESS);
+}
+