1 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 2 /* All Rights Reserved */ 3 4 5 /* 6 * Copyright (c) 1980 Regents of the University of California. 7 * All rights reserved. The Berkeley software License Agreement 8 * specifies the terms and conditions for redistribution. 9 */ 10 11 /* 12 * Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, Sun Microsystems, Inc. 13 * All Rights Reserved. 14 */ 15 16 #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ 17 18 19 #include <unistd.h> 20 #include <sys/types.h> 21 #include <pwd.h> 22 #include <locale.h> 23 #include <stdlib.h> 24 25 #define MSG "whoami: no login associated with uid %u.\n" 26 27 /* 28 * whoami 29 */ 30 struct passwd *getpwuid(); 31 32 void 33 main() 34 { 35 register struct passwd *pp; 36 uid_t euid; 37 38 /* Set locale environment variables local definitions */ 39 (void) setlocale(LC_ALL, ""); 40 #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ 41 #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it wasn't */ 42 #endif 43 (void) textdomain(TEXT_DOMAIN); 44 45 euid = geteuid(); 46 pp = getpwuid(euid); 47 if (pp == 0) { 48 (void) printf(gettext(MSG), euid); 49 exit(1); 50 } 51 printf("%s\n", pp->pw_name); 52 exit(0); 53 /*NOTREACHED*/ 54 } 55