]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/login.3
man*/: srcfix (Use .P instead of .PP or .LP)
[thirdparty/man-pages.git] / man3 / login.3
CommitLineData
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
9login, logout \- write utmp and wtmp entries
c5a6dbf9
AC
10.SH LIBRARY
11System 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
21The utmp file records who is currently using the system.
c13182ef
MK
22The wtmp file records all logins and logouts.
23See
fea681da 24.BR utmp (5).
c6d039a3 25.P
fea681da
MK
26The function
27.BR login ()
c6fa0841
MK
28takes the supplied
29.IR "struct utmp" ,
fea681da 30.IR ut ,
d9a10d9d 31and writes it to both the utmp and the wtmp file.
c6d039a3 32.P
fea681da
MK
33The function
34.BR logout ()
35clears the entry in the utmp file again.
73d8cece 36.SS GNU details
fea681da
MK
37More precisely,
38.BR login ()
39takes the argument
40.I ut
41struct, 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 ,
45and 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.
48Then it tries to fill the field
94e9d9fe 49.IR ut\->ut_line .
c6fa0841
MK
50It takes the first of
51.IR stdin ,
52.IR stdout ,
53.I stderr
1285ff3d 54that is a terminal, and
c6fa0841
MK
55stores the corresponding pathname minus a possible leading
56.I /dev/
fea681da 57into this field, and then writes the struct to the utmp file.
c6fa0841
MK
58On the other hand,
59if no terminal name was found, this field is filled with "???"
fea681da
MK
60and the struct is not written to the utmp file.
61After this, the struct is written to the wtmp file.
c6d039a3 62.P
fea681da
MK
63The
64.BR logout ()
65function searches the utmp file for an entry matching the
66.I ut_line
c13182ef
MK
67argument.
68If a record is found, it is updated by zeroing out the
fea681da
MK
69.I ut_name
70and
71.I ut_host
72fields, updating the
73.I ut_tv
74timestamp 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
79The
80.BR logout ()
81function returns 1 if the entry was successfully written to the
82database, or 0 if an error occurred.
2b2581ee
MK
83.SH FILES
84.TP
85.I /var/run/utmp
2f0af33b
MK
86user accounting database, configured through
87.B _PATH_UTMP
88in
2b2581ee
MK
89.I <paths.h>
90.TP
91.I /var/log/wtmp
2f0af33b
MK
92user accounting log file, configured through
93.B _PATH_WTMP
94in
2b2581ee 95.I <paths.h>
a330706c
ZL
96.SH ATTRIBUTES
97For an explanation of the terms used in this section, see
98.BR attributes (7).
99.TS
100allbox;
c466875e 101lb lb lbx
a330706c
ZL
102l l l.
103Interface Attribute Value
104T{
9e54434e
BR
105.na
106.nh
a330706c 107.BR login (),
a330706c
ZL
108.BR logout ()
109T} Thread safety T{
9e54434e
BR
110.na
111.nh
a330706c 112MT-Unsafe race:utent
a330706c
ZL
113sig:ALRM timer
114T}
115.TE
c6d039a3 116.P
a330706c
ZL
117In the above table,
118.I utent
119in
120.I race:utent
121signifies that if any of the functions
122.BR setutent (3),
123.BR getutent (3),
124or
125.BR endutent (3)
126are used in parallel in different threads of a program,
127then data races could occur.
bf7bc8b8 128.BR login ()
a330706c 129and
bf7bc8b8 130.BR logout ()
a330706c
ZL
131calls those functions,
132so we use race:utent to remind users.
4131356c
AC
133.SH VERSIONS
134The member
8478ee02 135.I ut_user
c13182ef
MK
136of
137.I struct utmp
8478ee02
MK
138is called
139.I ut_name
1c44bd5b
MK
140in BSD.
141Therefore,
8478ee02 142.I ut_name
fea681da 143is defined as an alias for
8478ee02 144.I ut_user
fea681da 145in
8478ee02 146.IR <utmp.h> .
4131356c
AC
147.SH STANDARDS
148BSD.
47297adb 149.SH SEE ALSO
fea681da
MK
150.BR getutent (3),
151.BR utmp (5)