]>
Commit | Line | Data |
---|---|---|
a1eaacb1 | 1 | '\" t |
4054a215 MK |
2 | .\" Derived from text written by Martin Schulze (or taken from glibc.info) |
3 | .\" and text written by Paul Thompson - both copyright 2002. | |
4 | .\" | |
e4a74ca8 | 5 | .\" SPDX-License-Identifier: GPL-2.0-or-later |
fea681da | 6 | .\" |
4c1c5274 | 7 | .TH login 3 (date) "Linux man-pages (unreleased)" |
fea681da MK |
8 | .SH NAME |
9 | login, logout \- write utmp and wtmp entries | |
c5a6dbf9 AC |
10 | .SH LIBRARY |
11 | System utilities library | |
8fc3b2cf | 12 | .RI ( libutil ", " \-lutil ) |
fea681da | 13 | .SH SYNOPSIS |
7b5d39f4 | 14 | .nf |
fea681da | 15 | .B #include <utmp.h> |
c6d039a3 | 16 | .P |
fea681da | 17 | .BI "void login(const struct utmp *" ut ); |
fea681da | 18 | .BI "int logout(const char *" ut_line ); |
7b5d39f4 | 19 | .fi |
fea681da MK |
20 | .SH DESCRIPTION |
21 | The utmp file records who is currently using the system. | |
c13182ef MK |
22 | The wtmp file records all logins and logouts. |
23 | See | |
fea681da | 24 | .BR utmp (5). |
c6d039a3 | 25 | .P |
fea681da MK |
26 | The function |
27 | .BR login () | |
c6fa0841 MK |
28 | takes the supplied |
29 | .IR "struct utmp" , | |
fea681da | 30 | .IR ut , |
d9a10d9d | 31 | and writes it to both the utmp and the wtmp file. |
c6d039a3 | 32 | .P |
fea681da MK |
33 | The function |
34 | .BR logout () | |
35 | clears the entry in the utmp file again. | |
73d8cece | 36 | .SS GNU details |
fea681da MK |
37 | More precisely, |
38 | .BR login () | |
39 | takes the argument | |
40 | .I ut | |
41 | struct, fills the field | |
94e9d9fe | 42 | .I ut\->ut_type |
fea681da MK |
43 | (if there is such a field) with the value |
44 | .BR USER_PROCESS , | |
45 | and fills the field | |
94e9d9fe | 46 | .I ut\->ut_pid |
fea681da MK |
47 | (if there is such a field) with the process ID of the calling process. |
48 | Then it tries to fill the field | |
94e9d9fe | 49 | .IR ut\->ut_line . |
c6fa0841 MK |
50 | It takes the first of |
51 | .IR stdin , | |
52 | .IR stdout , | |
53 | .I stderr | |
1285ff3d | 54 | that is a terminal, and |
c6fa0841 MK |
55 | stores the corresponding pathname minus a possible leading |
56 | .I /dev/ | |
fea681da | 57 | into this field, and then writes the struct to the utmp file. |
c6fa0841 MK |
58 | On the other hand, |
59 | if no terminal name was found, this field is filled with "???" | |
fea681da MK |
60 | and the struct is not written to the utmp file. |
61 | After this, the struct is written to the wtmp file. | |
c6d039a3 | 62 | .P |
fea681da MK |
63 | The |
64 | .BR logout () | |
65 | function searches the utmp file for an entry matching the | |
66 | .I ut_line | |
c13182ef MK |
67 | argument. |
68 | If a record is found, it is updated by zeroing out the | |
fea681da MK |
69 | .I ut_name |
70 | and | |
71 | .I ut_host | |
72 | fields, updating the | |
73 | .I ut_tv | |
74 | timestamp field and setting | |
75 | .I ut_type | |
76 | (if there is such a field) to | |
77 | .BR DEAD_PROCESS . | |
47297adb | 78 | .SH RETURN VALUE |
fea681da MK |
79 | The |
80 | .BR logout () | |
81 | function returns 1 if the entry was successfully written to the | |
82 | database, or 0 if an error occurred. | |
2b2581ee MK |
83 | .SH FILES |
84 | .TP | |
85 | .I /var/run/utmp | |
2f0af33b MK |
86 | user accounting database, configured through |
87 | .B _PATH_UTMP | |
88 | in | |
2b2581ee MK |
89 | .I <paths.h> |
90 | .TP | |
91 | .I /var/log/wtmp | |
2f0af33b MK |
92 | user accounting log file, configured through |
93 | .B _PATH_WTMP | |
94 | in | |
2b2581ee | 95 | .I <paths.h> |
a330706c ZL |
96 | .SH ATTRIBUTES |
97 | For an explanation of the terms used in this section, see | |
98 | .BR attributes (7). | |
99 | .TS | |
100 | allbox; | |
c466875e | 101 | lb lb lbx |
a330706c ZL |
102 | l l l. |
103 | Interface Attribute Value | |
104 | T{ | |
9e54434e BR |
105 | .na |
106 | .nh | |
a330706c | 107 | .BR login (), |
a330706c ZL |
108 | .BR logout () |
109 | T} Thread safety T{ | |
9e54434e BR |
110 | .na |
111 | .nh | |
a330706c | 112 | MT-Unsafe race:utent |
a330706c ZL |
113 | sig:ALRM timer |
114 | T} | |
115 | .TE | |
c6d039a3 | 116 | .P |
a330706c ZL |
117 | In the above table, |
118 | .I utent | |
119 | in | |
120 | .I race:utent | |
121 | signifies that if any of the functions | |
122 | .BR setutent (3), | |
123 | .BR getutent (3), | |
124 | or | |
125 | .BR endutent (3) | |
126 | are used in parallel in different threads of a program, | |
127 | then data races could occur. | |
bf7bc8b8 | 128 | .BR login () |
a330706c | 129 | and |
bf7bc8b8 | 130 | .BR logout () |
a330706c ZL |
131 | calls those functions, |
132 | so we use race:utent to remind users. | |
4131356c AC |
133 | .SH VERSIONS |
134 | The member | |
8478ee02 | 135 | .I ut_user |
c13182ef MK |
136 | of |
137 | .I struct utmp | |
8478ee02 MK |
138 | is called |
139 | .I ut_name | |
1c44bd5b MK |
140 | in BSD. |
141 | Therefore, | |
8478ee02 | 142 | .I ut_name |
fea681da | 143 | is defined as an alias for |
8478ee02 | 144 | .I ut_user |
fea681da | 145 | in |
8478ee02 | 146 | .IR <utmp.h> . |
4131356c AC |
147 | .SH STANDARDS |
148 | BSD. | |
47297adb | 149 | .SH SEE ALSO |
fea681da MK |
150 | .BR getutent (3), |
151 | .BR utmp (5) |