whoami.c 492 B

12345678910111213141516171819202122232425
  1. /* vim: tabstop=4 shiftwidth=4 noexpandtab
  2. * This file is part of ToaruOS and is released under the terms
  3. * of the NCSA / University of Illinois License - see LICENSE.md
  4. * Copyright (C) 2013-2014 K. Lange
  5. *
  6. * Who Am I?
  7. *
  8. */
  9. #include <unistd.h>
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <stdlib.h>
  13. #include <pwd.h>
  14. int main(int argc, char ** argv) {
  15. struct passwd * p = getpwuid(geteuid());
  16. if (!p) return 0;
  17. fprintf(stdout, "%s\n", p->pw_name);
  18. endpwent();
  19. return 0;
  20. }