home *** CD-ROM | disk | FTP | other *** search
-
- GETLOGIN(2) UNIX Programmer's Manual GETLOGIN(2)
-
- NNAAMMEE
- ggeettllooggiinn, sseettllooggiinn - get/set login name
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<uunniissttdd..hh>>
-
- _c_h_a_r _*
- ggeettllooggiinn(_v_o_i_d)
-
- _i_n_t
- sseettllooggiinn(_c_o_n_s_t _c_h_a_r _*_n_a_m_e)
-
- DDEESSCCRRIIPPTTIIOONN
- The ggeettllooggiinn() routine returns the login name of the user associated with
- the current session, as previously set by sseettllooggiinn(). The name is nor
- mally 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.)
-
- SSeettllooggiinn() sets the login name of the user associated with the current
- session to _n_a_m_e. This call is restricted to the superuser, and is nor
- mally used only when a new session is being created on behalf of the
- named user (for example, at login time, or when a remote shell is in
- voked).
-
- RREETTUURRNN VVAALLUUEESS
- If a call to ggeettllooggiinn() succeeds, it returns a pointer to a null
- terminated string in a static buffer. If the name has not been set, it
- returns NULL. If a call to sseettllooggiinn() succeeds, a value of 0 is returned.
- If sseettllooggiinn() fails, a value of 1 is returned and an error code is
- placed in the global location _e_r_r_n_o.
-
- EERRRROORRSS
- The following errors may be returned by these calls:
-
- [EFAULT] The _n_a_m_e parameter gave an invalid address.
-
- [EINVAL] The _n_a_m_e parameter pointed to a string that was too long.
- Login names are limited to MAXLOGNAME (from <_s_y_s_/_p_a_r_a_m_._h>)
- characters, currently 12.
-
- [EPERM] The caller tried to set the login name and was not the su
- peruser.
-
- SSEEEE AALLSSOO
- setsid(2)
-
- BBUUGGSS
- Login names are limited in length by sseettllooggiinn(). However, lower limits
- are placed on login names elsewhere in the system (UT_NAMESIZE in
- <_u_t_m_p_._h>).
-
- In earlier versions of the system, ggeettllooggiinn() failed unless the process
- was associated with a login terminal. The current implementation (using
- sseettllooggiinn()) allows getlogin to succeed even when the process has no con
- trolling terminal. In earlier versions of the system, the value returned
- by ggeettllooggiinn() could not be trusted without checking the user ID.
- Portable programs should probably still make this check.
-
- HHIISSTTOORRYY
- The ggeettllooggiinn function call is currently under development.
-
-