xref: /csrg-svn/old/whoami/whoami.c (revision 46897)
121591Sdist /*
234691Sbostic  * Copyright (c) 1988 Regents of the University of California.
334691Sbostic  * All rights reserved.
434691Sbostic  *
542788Sbostic  * %sccs.include.redist.c%
621591Sdist  */
721591Sdist 
821591Sdist #ifndef lint
921591Sdist char copyright[] =
1034691Sbostic "@(#) Copyright (c) 1988 Regents of the University of California.\n\
1121591Sdist  All rights reserved.\n";
1234691Sbostic #endif /* not lint */
1321591Sdist 
1421591Sdist #ifndef lint
15*46897Sbostic static char sccsid[] = "@(#)whoami.c	5.5 (Berkeley) 03/02/91";
1634691Sbostic #endif /* not lint */
1721591Sdist 
1834691Sbostic #include <sys/types.h>
191167Sbill #include <pwd.h>
201167Sbill 
main()211167Sbill main()
221167Sbill {
23*46897Sbostic 	struct passwd *p;
2434691Sbostic 	uid_t uid;
251167Sbill 
2634691Sbostic 	uid = geteuid();
2734691Sbostic 	if (!(p = getpwuid(uid))) {
2834691Sbostic 		printf("whoami: no login associated with uid %u.\n", uid);
291167Sbill 		exit(1);
301167Sbill 	}
3134691Sbostic 	printf("%s\n", p->pw_name);
321167Sbill 	exit(0);
331167Sbill }
34