8990 /opt/onbld/gk is useless
[unleashed.git] / usr / src / ucbcmd / whoami / whoami.c
blobe1344a723f02cdb9a19ac1e19b53ab9fcc63a487
1 /*
2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
9 /*
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
17 #include <unistd.h>
18 #include <sys/types.h>
19 #include <pwd.h>
20 #include <locale.h>
21 #include <stdlib.h>
23 #define MSG "whoami: no login associated with uid %u.\n"
26 * whoami
29 int
30 main(int argc, char *argv[])
31 /*ARGSUSED*/
33 struct passwd *pp;
34 uid_t euid;
36 /* Set locale environment variables local definitions */
37 (void) setlocale(LC_ALL, "");
38 #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
39 #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it wasn't */
40 #endif
41 (void) textdomain(TEXT_DOMAIN);
43 euid = geteuid();
44 pp = getpwuid(euid);
45 if (pp == 0) {
46 (void) printf(gettext(MSG), euid);
47 exit(1);
49 (void) printf("%s\n", pp->pw_name);
50 return (0);