121591Sdist /* 2*34691Sbostic * Copyright (c) 1988 Regents of the University of California. 3*34691Sbostic * All rights reserved. 4*34691Sbostic * 5*34691Sbostic * Redistribution and use in source and binary forms are permitted 6*34691Sbostic * provided that this notice is preserved and that due credit is given 7*34691Sbostic * to the University of California at Berkeley. The name of the University 8*34691Sbostic * may not be used to endorse or promote products derived from this 9*34691Sbostic * software without specific prior written permission. This software 10*34691Sbostic * is provided ``as is'' without express or implied warranty. 1121591Sdist */ 1221591Sdist 1321591Sdist #ifndef lint 1421591Sdist char copyright[] = 15*34691Sbostic "@(#) Copyright (c) 1988 Regents of the University of California.\n\ 1621591Sdist All rights reserved.\n"; 17*34691Sbostic #endif /* not lint */ 1821591Sdist 1921591Sdist #ifndef lint 20*34691Sbostic static char sccsid[] = "@(#)whoami.c 5.2 (Berkeley) 06/09/88"; 21*34691Sbostic #endif /* not lint */ 2221591Sdist 23*34691Sbostic #include <sys/types.h> 241167Sbill #include <pwd.h> 251167Sbill 261167Sbill main() 271167Sbill { 28*34691Sbostic struct passwd *p, *getpwuid(); 29*34691Sbostic uid_t uid; 301167Sbill 31*34691Sbostic uid = geteuid(); 32*34691Sbostic if (!(p = getpwuid(uid))) { 33*34691Sbostic printf("whoami: no login associated with uid %u.\n", uid); 341167Sbill exit(1); 351167Sbill } 36*34691Sbostic printf("%s\n", p->pw_name); 371167Sbill exit(0); 381167Sbill } 39