Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getlogin_r(3C) — SunOS 5.2

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cuserid(3S)

getgrnam(3C)

getpwnam(3C)

utmp(4)

getlogin(3C)

NAME

getlogin, getlogin_r − get login name

SYNOPSIS

#include <stdlib.h>

char ∗getlogin(void);

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

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 a buffer name with length namelen has to be supplied by the caller to store the result.  name must be at least LOGNAME_MAX bytes in size (defined in limits.h). 

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. 

FILES

/var/adm/utmp

SEE ALSO

cuserid(3S), getgrnam(3C), getpwnam(3C), utmp(4)

NOTES

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

getlogin() is unsafe in multithreaded applications.  getlogin_r() should be used instead. 

SunOS 5.2  —  Last change: 22 Jan 1993

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026