1 /* 2 * Copyright (c) 1988 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 char copyright[] = 10 "@(#) Copyright (c) 1988 Regents of the University of California.\n\ 11 All rights reserved.\n"; 12 #endif /* not lint */ 13 14 #ifndef lint 15 static char sccsid[] = "@(#)whoami.c 5.4 (Berkeley) 06/01/90"; 16 #endif /* not lint */ 17 18 #include <sys/types.h> 19 #include <pwd.h> 20 21 main() 22 { 23 struct passwd *p, *getpwuid(); 24 uid_t uid; 25 26 uid = geteuid(); 27 if (!(p = getpwuid(uid))) { 28 printf("whoami: no login associated with uid %u.\n", uid); 29 exit(1); 30 } 31 printf("%s\n", p->pw_name); 32 exit(0); 33 } 34