up | Inhaltsverzeichniss | Kommentar

Manual page for getlogin(3C)

getlogin, getlogin_r - get login name

SYNOPSIS

#include <stdlib.h>

char *getlogin(void);

char *getlogin_r(char *name, int namelen);

POSIX

cc [ flag... ] file ... -D_POSIX_PTHREAD_SEMANTICS [ library... ]

int getlogin_r(char *name, size_t namesize);

MT-LEVEL

See the NOTES section of this page.

DESCRIPTION

getlogin() returns a pointer to the login name as found in /var/adm/utmp. It may be used in conjunction with getpwnam() to locate the correct password file entry when the same user id is shared by several login names.

If getlogin() is called within a process that is not attached to a terminal, it returns a null pointer. The correct procedure for determining the login name is to call cuserid(), or to call getlogin() and if it fails to call getpwuid().

getlogin_r() has the same functionality as getlogin() except that the caller must supply a buffer name with length namelen to store the result. The name buffer must be at least LOGNAME_MAX bytes in size (defined in <limits.h>). The POSIX version of getlogin_r() takes a namesize parameter of type size_t.

RETURN VALUES

Returns a null pointer if the login name is not found.

ERRORS

getlogin_r() will fail if the following is true:

ERANGE
The size of the buffer is smaller than the result to be returned.

The POSIX getlogin_r() returns zero if successful, or the error number upon failure.

FILES

/var/adm/utmp

SEE ALSO

cuserid.3s getgrnam.3c getpwnam.3c utmp.4

NOTES

When compiling multithread programs, see Intro.3 Notes On Multithread Applications.

The return values point to static data whose content is overwritten by each call.

getlogin() is unsafe in multi-thread applications. getlogin_r() should be used instead.

Solaris 2.4 and earlier releases provided a getlogin_r() as specified in POSIX.1c Draft 6. The final POSIX.1c standard changed the interface as described above. Support for the Draft 6 interface is provided for compatibility only and may not be supported in future releases. New applications and libraries should use the POSIX standard interface.


index | Inhaltsverzeichniss | Kommentar

Created by unroff & hp-tools. © by Hans-Peter Bischof. All Rights Reserved (1997).

Last modified 21/April/97