Annotation of 43BSDReno/lib/libc/sys/getlogin.2, revision 1.1.1.1

1.1       root        1: .\" Copyright (c) 1989 The Regents of the University of California.
                      2: .\" All rights reserved.
                      3: .\"
                      4: .\" Redistribution and use in source and binary forms are permitted provided
                      5: .\" that: (1) source distributions retain this entire copyright notice and
                      6: .\" comment, and (2) distributions including binaries display the following
                      7: .\" acknowledgement:  ``This product includes software developed by the
                      8: .\" University of California, Berkeley and its contributors'' in the
                      9: .\" documentation or other materials provided with the distribution and in
                     10: .\" all advertising materials mentioning features or use of this software.
                     11: .\" Neither the name of the University nor the names of its contributors may
                     12: .\" be used to endorse or promote products derived from this software without
                     13: .\" specific prior written permission.
                     14: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     15: .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     16: .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     17: .\"
                     18: .\"    @(#)getlogin.2  6.1 (Berkeley) 6/25/90
                     19: .\"
                     20: .TH GETLOGIN 2 "June 25, 1990"
                     21: .UC 5
                     22: .SH NAME
                     23: getlogin, setlogin \- get/set login name
                     24: .SH SYNOPSIS
                     25: .nf
                     26: .ft B
                     27: char *getlogin()
                     28: .PP
                     29: .ft B
                     30: setlogin(name)
                     31: char *name;
                     32: .fi
                     33: .SH DESCRIPTION
                     34: The
                     35: .I getlogin
                     36: routine
                     37: returns the login name of the user associated with the current session,
                     38: as previously set by
                     39: .IR setlogin .
                     40: The name is normally associated with a login shell
                     41: at the time a session is created,
                     42: and is inherited by all processes descended from the login shell.
                     43: (This is true even if some of those processes assume another user ID,
                     44: for example when
                     45: .IR su (1)
                     46: is used.)
                     47: .PP
                     48: .I Setlogin
                     49: sets the login name of the user associated with the current session to
                     50: .IR name .
                     51: This call is restricted to the super-user, and
                     52: is normally used only when a new session is being created on behalf
                     53: of the named user
                     54: (for example, at login time, or when a remote shell is invoked).
                     55: .SH "RETURN VALUE
                     56: If a call to
                     57: .I getlogin
                     58: succeeds, it returns a pointer to a null-terminated string in a static buffer.
                     59: If the name has not been set, it returns NULL.
                     60: If a call to
                     61: .I setlogin
                     62: succeeds, a value of 0 is returned.  If
                     63: .I setlogin
                     64: fails, then a value of \-1 is returned and an error code is
                     65: placed in the global location \fIerrno\fP.
                     66: .SH "ERRORS
                     67: The following errors may be returned by these calls:
                     68: .TP 15
                     69: [EFAULT]
                     70: The \fIname\fP parameter gave an
                     71: invalid address.
                     72: .TP 15
                     73: [EINVAL]
                     74: The \fIname\fP parameter
                     75: pointed to a string that was too long.
                     76: Login names are limited to MAXLOGNAME (from
                     77: .IR <sys/param.h> )
                     78: characters, currently 12.
                     79: .TP 15
                     80: [EPERM]
                     81: The caller tried to set the login name and was not the super-user.
                     82: .SH SEE ALSO
                     83: setsid(2)
                     84: .SH BUGS
                     85: Login names are limited in length by
                     86: .IR setlogin .
                     87: However, lower limits are placed on login names elsewhere in the system
                     88: (UT_NAMESIZE in
                     89: .IR <utmp.h> ).
                     90: .PP
                     91: In earlier versions of the system,
                     92: .I getlogin
                     93: failed unless the process was associated with a login terminal.
                     94: The current implementation (using
                     95: .IR setlogin )
                     96: allows getlogin to succeed even when the process has no controlling terminal.
                     97: In earlier versions of the system, the value returned by
                     98: .I getlogin
                     99: could not be trusted without checking the user ID.
                    100: Portable programs should probably still make this check.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.