![]() |
![]()
| ![]() |
![]()
NAMEgetlogin , getlogin_r ,
setlogin —
get/set login name
LIBRARYStandard C Library (libc, -lc)SYNOPSIS#include <unistd.h>
char *
int
int
DESCRIPTIONThegetlogin () routine returns the login name of the
user associated with the current session, as previously set by
setlogin (). The name is normally associated with a
login shell at the time a session is created, and is inherited by all
processes descended from the login shell. (This is true even if some of those
processes assume another user ID, for example when
su(1) is
used).
The The NOTE: There is only one login name per session. It is CRITICALLY important to ensure that
In particular, doing a
Once a parent process does a This is not the same as the traditional UNIX behavior of inheriting privilege. Since the RETURN VALUESIf a call togetlogin () succeeds, it returns a pointer
to a null-terminated string in a static buffer, or
NULL if the name has not been set. The
getlogin_r () function returns zero if successful, or
the error number upon failure.
ERRORSThe following errors may be returned by these calls:
SEE ALSOsetsid(2), daemon(3)STANDARDSThegetlogin () system call and the
getlogin_r () function conform to
ISO/IEC 9945-1:1996 (“POSIX.1”).
HISTORYThegetlogin () system call first appeared in
4.4BSD. The return value of
getlogin_r () was changed from earlier versions of
FreeBSD to be conformant with ISO/IEC
9945-1:1996 (“POSIX.1”).
BUGSIn earlier versions of the system,getlogin () failed
unless the process was associated with a login terminal. The current
implementation (using setlogin ()) allows getlogin to
succeed even when the process has no controlling terminal. In earlier versions
of the system, the value returned by getlogin () could
not be trusted without checking the user ID. Portable programs should probably
still make this check.
|