157513Sbostic /*- 2*61246Sbostic * Copyright (c) 1992, 1993 3*61246Sbostic * The Regents of the University of California. All rights reserved. 457513Sbostic * 557513Sbostic * %sccs.include.redist.c% 657513Sbostic */ 757513Sbostic 857513Sbostic #if defined(LIBC_SCCS) && !defined(lint) 9*61246Sbostic static char sccsid[] = "@(#)cuserid.c 8.1 (Berkeley) 06/04/93"; 1057513Sbostic #endif /* LIBC_SCCS and not lint */ 1157513Sbostic 1257513Sbostic #include <pwd.h> 1357513Sbostic #include <stdio.h> 1457513Sbostic #include <string.h> 1557513Sbostic #include <unistd.h> 1657513Sbostic 1757513Sbostic char * cuserid(s)1857513Sbosticcuserid(s) 1957513Sbostic char *s; 2057513Sbostic { 2157513Sbostic register struct passwd *pwd; 2257513Sbostic 2357513Sbostic if ((pwd = getpwuid(geteuid())) == NULL) { 2457513Sbostic if (s) 2557513Sbostic *s = '\0'; 2657513Sbostic return (s); 2757513Sbostic } 2857513Sbostic if (s) { 2957513Sbostic (void)strncpy(s, pwd->pw_name, L_cuserid); 3057513Sbostic return (s); 3157513Sbostic } 3257513Sbostic return (pwd->pw_name); 3357513Sbostic } 34