]>
Commit | Line | Data |
---|---|---|
4054a215 MK |
1 | .\" Derived from text written by Martin Schulze (or taken from glibc.info) |
2 | .\" and text written by Paul Thompson - both copyright 2002. | |
3 | .\" | |
1dd72f9c | 4 | .\" %%%LICENSE_START(GPLv2+_DOC_FULL) |
fea681da MK |
5 | .\" This is free documentation; you can redistribute it and/or |
6 | .\" modify it under the terms of the GNU General Public License as | |
7 | .\" published by the Free Software Foundation; either version 2 of | |
8 | .\" the License, or (at your option) any later version. | |
9 | .\" | |
10 | .\" The GNU General Public License's references to "object code" | |
11 | .\" and "executables" are to be interpreted as the output of any | |
12 | .\" document formatting or typesetting system, including | |
13 | .\" intermediate and printed output. | |
14 | .\" | |
15 | .\" This manual is distributed in the hope that it will be useful, | |
16 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | .\" GNU General Public License for more details. | |
19 | .\" | |
20 | .\" You should have received a copy of the GNU General Public | |
c715f741 MK |
21 | .\" License along with this manual; if not, see |
22 | .\" <http://www.gnu.org/licenses/>. | |
6a8d8745 | 23 | .\" %%%LICENSE_END |
fea681da | 24 | .\" |
4b8c67d9 | 25 | .TH LOGIN 3 2017-09-15 "GNU" "Linux Programmer's Manual" |
fea681da MK |
26 | .SH NAME |
27 | login, logout \- write utmp and wtmp entries | |
28 | .SH SYNOPSIS | |
29 | .B #include <utmp.h> | |
68e4db0a | 30 | .PP |
fea681da | 31 | .BI "void login(const struct utmp *" ut ); |
68e4db0a | 32 | .PP |
fea681da | 33 | .BI "int logout(const char *" ut_line ); |
68e4db0a | 34 | .PP |
3ed66e68 | 35 | Link with \fI\-lutil\fP. |
fea681da MK |
36 | .SH DESCRIPTION |
37 | The utmp file records who is currently using the system. | |
c13182ef MK |
38 | The wtmp file records all logins and logouts. |
39 | See | |
fea681da | 40 | .BR utmp (5). |
dd3568a1 | 41 | .PP |
fea681da MK |
42 | The function |
43 | .BR login () | |
c6fa0841 MK |
44 | takes the supplied |
45 | .IR "struct utmp" , | |
fea681da | 46 | .IR ut , |
d9a10d9d | 47 | and writes it to both the utmp and the wtmp file. |
dd3568a1 | 48 | .PP |
fea681da MK |
49 | The function |
50 | .BR logout () | |
51 | clears the entry in the utmp file again. | |
73d8cece | 52 | .SS GNU details |
fea681da MK |
53 | More precisely, |
54 | .BR login () | |
55 | takes the argument | |
56 | .I ut | |
57 | struct, fills the field | |
94e9d9fe | 58 | .I ut\->ut_type |
fea681da MK |
59 | (if there is such a field) with the value |
60 | .BR USER_PROCESS , | |
61 | and fills the field | |
94e9d9fe | 62 | .I ut\->ut_pid |
fea681da MK |
63 | (if there is such a field) with the process ID of the calling process. |
64 | Then it tries to fill the field | |
94e9d9fe | 65 | .IR ut\->ut_line . |
c6fa0841 MK |
66 | It takes the first of |
67 | .IR stdin , | |
68 | .IR stdout , | |
69 | .I stderr | |
1285ff3d | 70 | that is a terminal, and |
c6fa0841 MK |
71 | stores the corresponding pathname minus a possible leading |
72 | .I /dev/ | |
fea681da | 73 | into this field, and then writes the struct to the utmp file. |
c6fa0841 MK |
74 | On the other hand, |
75 | if no terminal name was found, this field is filled with "???" | |
fea681da MK |
76 | and the struct is not written to the utmp file. |
77 | After this, the struct is written to the wtmp file. | |
dd3568a1 | 78 | .PP |
fea681da MK |
79 | The |
80 | .BR logout () | |
81 | function searches the utmp file for an entry matching the | |
82 | .I ut_line | |
c13182ef MK |
83 | argument. |
84 | If a record is found, it is updated by zeroing out the | |
fea681da MK |
85 | .I ut_name |
86 | and | |
87 | .I ut_host | |
88 | fields, updating the | |
89 | .I ut_tv | |
90 | timestamp field and setting | |
91 | .I ut_type | |
92 | (if there is such a field) to | |
93 | .BR DEAD_PROCESS . | |
47297adb | 94 | .SH RETURN VALUE |
fea681da MK |
95 | The |
96 | .BR logout () | |
97 | function returns 1 if the entry was successfully written to the | |
98 | database, or 0 if an error occurred. | |
2b2581ee MK |
99 | .SH FILES |
100 | .TP | |
101 | .I /var/run/utmp | |
2f0af33b MK |
102 | user accounting database, configured through |
103 | .B _PATH_UTMP | |
104 | in | |
2b2581ee MK |
105 | .I <paths.h> |
106 | .TP | |
107 | .I /var/log/wtmp | |
2f0af33b MK |
108 | user accounting log file, configured through |
109 | .B _PATH_WTMP | |
110 | in | |
2b2581ee | 111 | .I <paths.h> |
a330706c ZL |
112 | .SH ATTRIBUTES |
113 | For an explanation of the terms used in this section, see | |
114 | .BR attributes (7). | |
115 | .TS | |
116 | allbox; | |
117 | lb lb lbw20 | |
118 | l l l. | |
119 | Interface Attribute Value | |
120 | T{ | |
121 | .BR login (), | |
122 | .br | |
123 | .BR logout () | |
124 | T} Thread safety T{ | |
125 | MT-Unsafe race:utent | |
126 | .br | |
127 | sig:ALRM timer | |
128 | T} | |
129 | .TE | |
847e0d88 | 130 | .sp 1 |
a330706c ZL |
131 | In the above table, |
132 | .I utent | |
133 | in | |
134 | .I race:utent | |
135 | signifies that if any of the functions | |
136 | .BR setutent (3), | |
137 | .BR getutent (3), | |
138 | or | |
139 | .BR endutent (3) | |
140 | are used in parallel in different threads of a program, | |
141 | then data races could occur. | |
bf7bc8b8 | 142 | .BR login () |
a330706c | 143 | and |
bf7bc8b8 | 144 | .BR logout () |
a330706c ZL |
145 | calls those functions, |
146 | so we use race:utent to remind users. | |
47297adb | 147 | .SH CONFORMING TO |
3007948e | 148 | Not in POSIX.1. |
2b2581ee | 149 | Present on the BSDs. |
19c98696 | 150 | .SH NOTES |
fea681da MK |
151 | Note that the |
152 | member | |
8478ee02 | 153 | .I ut_user |
c13182ef MK |
154 | of |
155 | .I struct utmp | |
8478ee02 MK |
156 | is called |
157 | .I ut_name | |
1c44bd5b MK |
158 | in BSD. |
159 | Therefore, | |
8478ee02 | 160 | .I ut_name |
fea681da | 161 | is defined as an alias for |
8478ee02 | 162 | .I ut_user |
fea681da | 163 | in |
8478ee02 | 164 | .IR <utmp.h> . |
47297adb | 165 | .SH SEE ALSO |
fea681da MK |
166 | .BR getutent (3), |
167 | .BR utmp (5) |