cuserid.c (1574) | cuserid.c (92913) |
---|---|
1/*- 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 20 unchanged lines hidden (view full) --- 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#if defined(LIBC_SCCS) && !defined(lint) 35static char sccsid[] = "@(#)cuserid.c 8.1 (Berkeley) 6/4/93"; 36#endif /* LIBC_SCCS and not lint */ | 1/*- 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 20 unchanged lines hidden (view full) --- 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#if defined(LIBC_SCCS) && !defined(lint) 35static char sccsid[] = "@(#)cuserid.c 8.1 (Berkeley) 6/4/93"; 36#endif /* LIBC_SCCS and not lint */ |
37#include <sys/cdefs.h> 38__FBSDID("$FreeBSD: head/lib/libcompat/4.4/cuserid.c 92913 2002-03-21 23:39:28Z obrien $"); |
|
37 38#include <pwd.h> 39#include <stdio.h> 40#include <string.h> 41#include <unistd.h> 42 43char * 44cuserid(s) 45 char *s; 46{ | 39 40#include <pwd.h> 41#include <stdio.h> 42#include <string.h> 43#include <unistd.h> 44 45char * 46cuserid(s) 47 char *s; 48{ |
47 register struct passwd *pwd; | 49 struct passwd *pwd; |
48 49 if ((pwd = getpwuid(geteuid())) == NULL) { 50 if (s) 51 *s = '\0'; 52 return (s); 53 } 54 if (s) { 55 (void)strncpy(s, pwd->pw_name, L_cuserid); 56 return (s); 57 } 58 return (pwd->pw_name); 59} | 50 51 if ((pwd = getpwuid(geteuid())) == NULL) { 52 if (s) 53 *s = '\0'; 54 return (s); 55 } 56 if (s) { 57 (void)strncpy(s, pwd->pw_name, L_cuserid); 58 return (s); 59 } 60 return (pwd->pw_name); 61} |