CUSERID(3) BSD Library Functions Manual CUSERID(3)
cuserid -- get user name
Compatibility Library (libcompat, -lcompat)
This interface is available from the compatibility library, libcompat and
has been obsoleted by getlogin(2).
The cuserid() function returns a character string representation of the
user name associated with the effective user ID of the calling process.
If buf is not the NULL pointer, the user name is copied into the memory
referenced by buf. The argument buf is assumed to point to an array at
least L_cuserid (as defined in the include file <stdio.h>) bytes long.
Otherwise, the user name is copied to a static buffer.
If buf is not the NULL pointer, buf is returned; otherwise the address of
the static buffer is returned.
If the user name could not be determined, if buf is not the NULL pointer,
the null character '\0' will be stored at *buf; otherwise the NULL
pointer is returned.
The cuserid() function conforms to IEEE Std 1003.1-1988 (``POSIX.1'').
Due to irreconcilable differences in historic implementations, cuserid()
was removed from the ISO/IEC 9945-1:1990 (``POSIX.1'') standard. This
implementation exists purely for compatibility with existing programs.
New programs should use one of the following three alternatives to obtain
the user name:
1. getlogin() to return the user's login name.
2. getpwuid(geteuid()) to return the user name associated with
the calling process' effective user ID.
3. getpwuid(getuid()) to return the user name associated with the
calling process' real user ID.
The cuserid() function uses getpwuid(); thus the results of a user's call
to getpwent(), getpwnam() or getpwuid() will be overwritten by subsequent
calls to cuserid().
BSD November 28, 1993 BSD