Print this page
11622 clean up rarer mandoc lint warnings
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/man/man3c/getlogin.3c.man.txt
+++ new/usr/src/man/man3c/getlogin.3c.man.txt
1 1 GETLOGIN(3C) Standard C Library Functions GETLOGIN(3C)
2 2
3 3
4 4
5 5 NAME
6 6 getlogin, getlogin_r - get login name
7 7
8 8 SYNOPSIS
9 9 #include <unistd.h>
10 10
11 11 char *getlogin(void);
12 12
13 13
14 14 char *getlogin_r(char *name, int namelen);
15 15
16 16
17 17 Standard conforming
18 18 cc [ flag ... ] file... -D_POSIX_PTHREAD_SEMANTICS [ library ... ]
19 19
20 20 int getlogin_r(char *name, size_t namesize);
21 21
22 22
23 23 DESCRIPTION
24 24 The getlogin() function returns a pointer to the login name as found in
25 25 /var/adm/utmpx. It can be used in conjunction with getpwnam(3C) to
26 26 locate the correct password file entry when the same user ID is shared
27 27 by several login names.
28 28
29 29
30 30 The login name plus the terminating null byte can be up to 33
31 31 characters in length. Newly-compiled programs should use the
32 32 LOGIN_NAME_MAX symbol, defined in <limits.h>, to size the buffer.
33 33 Older programs that call getlogin() expect only the legacy 9-character
34 34 length. These automatically link to a version of the getlogin()
35 35 functions that truncates longer login names. It's also possible to
36 36 compile new programs that link to truncating versions of these
37 37 functions by defining __USE_LEGACY_LOGNAME__ in the compile
38 38 environment.
39 39
40 40
41 41 Some older programs will correctly handle long login names returned by
42 42 the getlogin() function. For this case, the user compatibility library
43 43 /usr/lib/getloginx.so.1 redirects to a version of the getlogin()
44 44 function that returns the long name. This library should be added to
45 45 such an application at runtime using LD_PRELOAD.
46 46
47 47
48 48 If getlogin() is called within a process that is not attached to a
49 49 terminal, it returns a null pointer. The correct procedure for
50 50 determining the login name is to call cuserid(3C), or to call
51 51 getlogin() and if it fails to call getpwuid(3C).
52 52
53 53
54 54 The getlogin_r() function has the same functionality as getlogin()
55 55 except that the caller must supply a buffer name with length namelen to
56 56 store the result. The name buffer should be at least LOGIN_NAME_MAX
57 57 bytes in size (defined in <limits.h>). The POSIX version (see
58 58 standards(5)) of getlogin_r() takes a namesize parameter of type
59 59 size_t. If the size of the supplied buffer is less than the size of
60 60 LOGIN_NAME_MAX and the name, including the null terminator, does not
61 61 fit inside the buffer, than an error will be generated. Otherwise, the
62 62 buffer name will be updated with the login name.
63 63
64 64
65 65 RETURN VALUES
66 66 Upon successful completion, getlogin() returns a pointer to the login
67 67 name or a null pointer if the user's login name cannot be found.
68 68 Otherwise it returns a null pointer and sets errno to indicate the
69 69 error.
70 70
71 71
72 72 The standard-conforming getlogin_r() returns 0 if successful, or the
73 73 error number upon failure.
74 74
75 75 ERRORS
76 76 The getlogin_r() function will fail if:
77 77
78 78 ERANGE
79 79 The size of the buffer is smaller than the result to be
80 80 returned.
81 81
82 82
83 83 EINVAL
84 84 And entry for the current user was not found in the
85 85 /var/adm/utmpx file.
86 86
87 87
88 88
89 89 The getlogin() and getlogin_r() functions may fail if:
90 90
91 91 EMFILE
92 92 There are {OPEN_MAX} file descriptors currently open in the
93 93 calling process.
94 94
95 95
96 96 ENFILE
97 97 The maximum allowable number of files is currently open in
98 98 the system.
99 99
100 100
101 101 ENXIO
102 102 The calling process has no controlling terminal.
103 103
104 104
105 105
106 106 The getlogin_r() function may fail if:
107 107
108 108 ERANGE
109 109 The size of the buffer is smaller than the result to be
110 110 returned.
111 111
112 112
113 113 USAGE
114 114 The return value of getlogin() points to thread-specific data whose
115 115 content is overwritten on each call by the same thread.
116 116
117 117
118 118 Three names associated with the current process can be determined:
119 119 getpwuid(geteuid()) returns the name associated with the effective user
120 120 ID of the process; getlogin() returns the name associated with the
121 121 current login activity; and getpwuid(getuid()) returns the name
122 122 associated with the real user ID of the process.
123 123
124 124 FILES
125 125 /var/adm/utmpx
126 126 user access and administration information
127 127
128 128
129 129 /usr/lib/getloginx.so.1
130 130 A compatibility library that returns long login names
131 131 to older applications.
132 132
133 133
134 134 /usr/lib/64/getloginx.so.1
135 135 A 64-bit compatibility library to return long login
136 136 names.
137 137
138 138
139 139 ATTRIBUTES
140 140 See attributes(5) for descriptions of the following attributes:
141 141
142 142
143 143
144 144
145 145 +--------------------+-----------------+
146 146 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
147 147 +--------------------+-----------------+
148 148 |Interface Stability | Standard |
149 149 +--------------------+-----------------+
150 150 |MT-Level | See below. |
151 151 +--------------------+-----------------+
152 152
153 153 SEE ALSO
154 154 geteuid(2), getuid(2), cuserid(3C), getgrnam(3C), getpwnam(3C),
155 155 getpwuid(3C), utmpx(4), attributes(5), standards(5)
156 156
157 157 NOTES
158 158 When compiling multithreaded programs, see Intro(3).
159 159
160 160
161 161 The getlogin() function is safe to use in multithreaded applications,
162 162 but is discouraged. The getlogin_r() function should be used instead.
163 163
164 164
165 165 Solaris 2.4 and earlier releases provided a getlogin_r() as specified
166 166 in POSIX.1c Draft 6. The final POSIX.1c standard changed the interface
167 167 as described above. Support for the Draft 6 interface is provided for
168 168 compatibility only and may not be supported in future releases. New
169 169 applications and libraries should use the standard-conforming
170 170 interface.
171 171
172 172
173 173
174 174 March 15, 2014 GETLOGIN(3C)
↓ open down ↓ |
174 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX