1.\" Copyright (c) 1990, 1991 The Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. All advertising materials mentioning features or use of this software 13.\" must display the following acknowledgement: 14.\" This product includes software developed by the University of 15.\" California, Berkeley and its contributors. 16.\" 4. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" from: @(#)ctermid.3 5.2 (Berkeley) 4/19/91 33.\" $Id: cuserid.3,v 1.1 1994/05/19 06:20:26 jtc Exp $ 34.\" 35.Dd November 28, 1993 36.Dt CUSERID 3 37.Os 38.Sh NAME 39.Nm cuserid 40.Nd get user name 41.Sh SYNOPSIS 42.Fd #include <stdio.h> 43.Ft char * 44.Fn cuserid "char *buf" 45.Sh DESCRIPTION 46The 47.Fn cuserid 48function returns a character string representation of the user name 49associated with the effective user ID of the calling process. 50.Pp 51If 52.Fa buf 53is not the 54.Dv NULL 55pointer, the user name is copied into the memory referenced by 56.Fa buf . 57The argument 58.Fa buf 59is assumed to point to an array at least 60.Dv L_cuserid 61(as defined in the include 62file 63.Aq Pa stdio.h ) 64bytes long. 65Otherwise, the user name is copied to a static buffer. 66.Pp 67.Sh RETURN VALUES 68If 69.Fa buf 70is not the 71.Dv NULL 72pointer, 73.Fa buf 74is returned; 75otherwise the address of the static buffer is returned. 76.Pp 77If the user name could not be determined, if 78.Fa buf 79is not the 80.Dv NULL 81pointer, the null character 82.Sq \e0 83will be stored at 84.Fa *buf ; 85otherwise 86the 87.Dv NULL 88pointer is returned. 89.Sh SEE ALSO 90.Xr getlogin 2 , 91.Xr getpwent 3 92.Sh STANDARDS 93The 94.Fn cuserid 95function conforms to 96.St -p1003.1-88 . 97.Sh BUGS 98Due to irreconcilable differences in historic implementations, 99.Fn cuserid 100was removed from the 101.St -p1003.1-90 102standard. 103This implementation exists purely for compatibility with existing programs. 104New programs should use one of the following three alternatives to 105obtain the user name: 106.Pp 107.Bl -enum -offset indent -compact 108.It 109.Fn getlogin 110to return the user's login name. 111.It 112.Nm getpwuid Ns Pq Fn geteuid 113to return the user name associated with the calling process' effective user ID. 114.It 115.Nm getpwuid Ns Pq Fn getuid 116to return the user name associated with the calling process' real user ID. 117.El 118.Pp 119The 120.Fn cuserid 121function uses 122.Fn getpwuid ; 123thus the results of a user's call to 124.Fn getpwent , 125.Fn getpwnam 126or 127.Fn getpwuid 128will be overwritten by subsequent calls to 129.Fn cuserid . 130