Penguin
Annotated edit history of getlogin(3) version 1, including all changes. View license author blame.
Rev Author # Line
1 perry 1 GETLOGIN
2 !!!GETLOGIN
3 NAME
4 SYNOPSIS
5 DESCRIPTION
6 ERRORS
7 FILES
8 CONFORMING TO
9 BUGS
10 SEE ALSO
11 ----
12 !!NAME
13
14
15 getlogin, cuserid - get user name
16 !!SYNOPSIS
17
18
19 __#include __
20
21
22 __char * getlogin ( void );__
23
24
25 __#include __
26
27
28 __char * cuserid ( char *__''string''
29 __);__
30 !!DESCRIPTION
31
32
33 __getlogin__ returns a pointer to a string containing the
34 name of the user logged in on the controlling terminal of
35 the process, or a null pointer if this information cannot be
36 determined. The string is statically allocated and might be
37 overwritten on subsequent calls to this function or to
38 __cuserid__.
39
40
41 __cuserid__ returns a pointer to a string containing a
42 user name associated with the effective user ID of the
43 process. If ''string'' is not a null pointer, it should
44 be an array that can hold at least __L_cuserid__
45 characters; the string is returned in this array. Otherwise,
46 a pointer to a string in a static area is returned. This
47 string is statically allocated and might be overwritten on
48 subsequent calls to this function or to
49 __getlogin__.
50
51
52 The macro __L_cuserid__ is an integer constant that
53 indicates how long an array you might need to store a user
54 name. __L_cuserid__ is declared in
55 __stdio.h__.
56
57
58 These functions let your program identify positively the
59 user who is running (__cuserid__) or the user who logged
60 in this session (__getlogin__). (These can differ when
61 setuid programs are involved.)
62
63
64 For most purposes, it is more useful to use the environment
65 variable __LOGNAME__ to find out who the user is. This is
66 more flexible precisely because the user can set
67 __LOGNAME__ arbitrarily.
68 !!ERRORS
69
70
71 __ENOMEM__
72
73
74 Insufficient memory to allocate passwd
75 structure.
76 !!FILES
77
78
79 ''/etc/passwd'' password database file
80 ''/var/run/utmp'' (traditionally ''/etc/utmp'';
81 some libc versions used ''/var/adm/utmp'')
82 !!CONFORMING TO
83
84
85 POSIX.1. System V has a __cuserid__ function which uses
86 the real user ID rather than the effective user ID. The
87 __cuserid__ function was included in the 1988 version of
88 POSIX, but removed from the 1990 version.
89 !!BUGS
90
91
92 Unfortunately, it is often rather easy to fool getlogin().
93 Sometimes it does not work at all, because some program
94 messed up the utmp file. Often, it gives only the first 8
95 characters of the login name. The user currently logged in
96 on the controlling tty of our program need not be the user
97 who started it. Avoid getlogin() for security-related
98 purposes.
99
100
101 Nobody knows precisely what cuserid() does - avoid it in
102 portable programs - avoid it altogether - use
103 getpwuid(geteuid()) instead, if that is what you meant. DO
104 NOT USE cuserid().
105 !!SEE ALSO
106
107
108 geteuid(2), getuid(2)
109 ----
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.