CUSERID(3V)

NAME
cuserid - get character login name of the user

SYNOPSIS
#include <stdio.h>

char *cuserid(s)
char *s;

DESCRIPTION

cuserid() returns a pointer to a string representing the login name under which the owner of the current process is logged in. If s is a NULL pointer, this string is placed in an internal static area, the address of which is returned. Otherwise, s is assumed to point to an array of at least L_cuserid characters; the representation is left in this array. The constant L_cuserid is defined in the <stdio.h> header file.

SEE ALSO
cc(1V), ld(1), getlogin(3V), getpwent(3V)

RETURN VALUES

cuserid() returns a pointer to the login name on success. On failure, cuserid() returns NULL, and if s is not NULL, places a null character ('\0') at s[0].

NOTES

The internal static area to which cuserid() writes when s is NULL will be overwritten by a subsequent call to getpwnam() (see getpwent(3V)).

A compatibility problem has been identified with the cuserid() function. The traditional version of this library routine in SunOS Release 3.2 and later releases and all System V releases calls the getlogin() function, and if it fails uses the getpwuid() function to try to return a name associated with the real user ID associated with the calling process. POSIX.1 requires that the cuserid() function try to return a name associated with the effective user ID associated with the calling process. Although this usually yields the same results, use of set-uid programs may yield different results.

A binding interpretation has been issued by IEEE saying that the POSIX.1 functionality has to be provided for compliance with POSIX.1. However, balloting on the first update to POSIX.1, P1003.1a, has led to the removal of the cuserid() function from the standard. (This is the state in the second recirculation ballot of P1003.1a dated 11 December 1989.) The objections leading to this resolution had both users and implementors arguing for the historical version and for the version specified by POSIX.1. The only way to reach consensus appears to be to remove the function from the standard.

To further complicate the issue, System V Release 4.0 has kept the traditional version of cuserid(). XPG3 specifies the POSIX.1 version of cuserid(), but the test suite for conformance to XPG3 promises to accept either implementation. Both of these are anticipating the final approval of P1003.1a as a standard with the cuserid() function removed.

Since we also expect the cuserid() function to be dropped from the standard when P1003.1a is approved, SunOS Release 4.1 provides the traditional cuserid() function in the C library. However, for users that need the version specified by POSIX.1, it is provided in a POSIX library available in the System V environment. This library can be accessed by specifying -lposix on the cc(1V) or ld(1) command line.