]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/login.3
alloca.3: Prevent any misunderstanding about when allocated memory is released
[thirdparty/man-pages.git] / man3 / login.3
CommitLineData
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
27login, 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 35Link with \fI\-lutil\fP.
fea681da
MK
36.SH DESCRIPTION
37The utmp file records who is currently using the system.
c13182ef
MK
38The wtmp file records all logins and logouts.
39See
fea681da 40.BR utmp (5).
dd3568a1 41.PP
fea681da
MK
42The function
43.BR login ()
c6fa0841
MK
44takes the supplied
45.IR "struct utmp" ,
fea681da 46.IR ut ,
d9a10d9d 47and writes it to both the utmp and the wtmp file.
dd3568a1 48.PP
fea681da
MK
49The function
50.BR logout ()
51clears the entry in the utmp file again.
73d8cece 52.SS GNU details
fea681da
MK
53More precisely,
54.BR login ()
55takes the argument
56.I ut
57struct, 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 ,
61and 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.
64Then it tries to fill the field
94e9d9fe 65.IR ut\->ut_line .
c6fa0841
MK
66It takes the first of
67.IR stdin ,
68.IR stdout ,
69.I stderr
1285ff3d 70that is a terminal, and
c6fa0841
MK
71stores the corresponding pathname minus a possible leading
72.I /dev/
fea681da 73into this field, and then writes the struct to the utmp file.
c6fa0841
MK
74On the other hand,
75if no terminal name was found, this field is filled with "???"
fea681da
MK
76and the struct is not written to the utmp file.
77After this, the struct is written to the wtmp file.
dd3568a1 78.PP
fea681da
MK
79The
80.BR logout ()
81function searches the utmp file for an entry matching the
82.I ut_line
c13182ef
MK
83argument.
84If a record is found, it is updated by zeroing out the
fea681da
MK
85.I ut_name
86and
87.I ut_host
88fields, updating the
89.I ut_tv
90timestamp 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
95The
96.BR logout ()
97function returns 1 if the entry was successfully written to the
98database, or 0 if an error occurred.
2b2581ee
MK
99.SH FILES
100.TP
101.I /var/run/utmp
2f0af33b
MK
102user accounting database, configured through
103.B _PATH_UTMP
104in
2b2581ee
MK
105.I <paths.h>
106.TP
107.I /var/log/wtmp
2f0af33b
MK
108user accounting log file, configured through
109.B _PATH_WTMP
110in
2b2581ee 111.I <paths.h>
a330706c
ZL
112.SH ATTRIBUTES
113For an explanation of the terms used in this section, see
114.BR attributes (7).
115.TS
116allbox;
117lb lb lbw20
118l l l.
119Interface Attribute Value
120T{
121.BR login (),
122.br
123.BR logout ()
124T} Thread safety T{
125MT-Unsafe race:utent
126.br
127sig:ALRM timer
128T}
129.TE
847e0d88 130.sp 1
a330706c
ZL
131In the above table,
132.I utent
133in
134.I race:utent
135signifies that if any of the functions
136.BR setutent (3),
137.BR getutent (3),
138or
139.BR endutent (3)
140are used in parallel in different threads of a program,
141then data races could occur.
bf7bc8b8 142.BR login ()
a330706c 143and
bf7bc8b8 144.BR logout ()
a330706c
ZL
145calls those functions,
146so we use race:utent to remind users.
47297adb 147.SH CONFORMING TO
3007948e 148Not in POSIX.1.
2b2581ee 149Present on the BSDs.
19c98696 150.SH NOTES
fea681da
MK
151Note that the
152member
8478ee02 153.I ut_user
c13182ef
MK
154of
155.I struct utmp
8478ee02
MK
156is called
157.I ut_name
1c44bd5b
MK
158in BSD.
159Therefore,
8478ee02 160.I ut_name
fea681da 161is defined as an alias for
8478ee02 162.I ut_user
fea681da 163in
8478ee02 164.IR <utmp.h> .
47297adb 165.SH SEE ALSO
fea681da
MK
166.BR getutent (3),
167.BR utmp (5)