OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man3 / login.3
1 .\" Derived from text written by Martin Schulze (or taken from glibc.info)
2 .\" and text written by Paul Thompson - both copyright 2002.
3 .\"
4 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
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
21 .\" License along with this manual; if not, see
22 .\" <http://www.gnu.org/licenses/>.
23 .\" %%%LICENSE_END
24 .\"
25 .TH LOGIN 3 2004-05-06 "GNU" "Linux Programmer's Manual"
26 .SH NAME
27 login, logout \- write utmp and wtmp entries
28 .SH SYNOPSIS
29 .B #include <utmp.h>
30 .sp
31 .BI "void login(const struct utmp *" ut );
32 .sp
33 .BI "int logout(const char *" ut_line );
34 .sp
35 Link with \fI\-lutil\fP.
36 .SH DESCRIPTION
37 The utmp file records who is currently using the system.
38 The wtmp file records all logins and logouts.
39 See
40 .BR utmp (5).
41 .LP
42 The function
43 .BR login ()
44 takes the supplied
45 .IR "struct utmp" ,
46 .IR ut ,
47 and writes it to both the utmp and the wtmp file.
48 .LP
49 The function
50 .BR logout ()
51 clears the entry in the utmp file again.
52 .SS GNU details
53 More precisely,
54 .BR login ()
55 takes the argument
56 .I ut
57 struct, fills the field
58 .I ut\->ut_type
59 (if there is such a field) with the value
60 .BR USER_PROCESS ,
61 and fills the field
62 .I ut\->ut_pid
63 (if there is such a field) with the process ID of the calling process.
64 Then it tries to fill the field
65 .IR ut\->ut_line .
66 It takes the first of
67 .IR stdin ,
68 .IR stdout ,
69 .I stderr
70 that is a terminal, and
71 stores the corresponding pathname minus a possible leading
72 .I /dev/
73 into this field, and then writes the struct to the utmp file.
74 On the other hand,
75 if no terminal name was found, this field is filled with "???"
76 and the struct is not written to the utmp file.
77 After this, the struct is written to the wtmp file.
78 .LP
79 The
80 .BR logout ()
81 function searches the utmp file for an entry matching the
82 .I ut_line
83 argument.
84 If a record is found, it is updated by zeroing out the
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 .
94 .SH RETURN VALUE
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.
99 .SH FILES
100 .TP
101 .I /var/run/utmp
102 user accounting database, configured through
103 .B _PATH_UTMP
104 in
105 .I <paths.h>
106 .TP
107 .I /var/log/wtmp
108 user accounting log file, configured through
109 .B _PATH_WTMP
110 in
111 .I <paths.h>
112 .SH CONFORMING TO
113 Not in POSIX.1-2001.
114 Present on the BSDs.
115 .SH NOTES
116 Note that the
117 member
118 .I ut_user
119 of
120 .I struct utmp
121 is called
122 .I ut_name
123 in BSD.
124 Therefore,
125 .I ut_name
126 is defined as an alias for
127 .I ut_user
128 in
129 .IR <utmp.h> .
130 .SH SEE ALSO
131 .BR getutent (3),
132 .BR utmp (5)
133 .SH COLOPHON
134 This page is part of release 3.79 of the Linux
135 .I man-pages
136 project.
137 A description of the project,
138 information about reporting bugs,
139 and the latest version of this page,
140 can be found at
141 \%http://www.kernel.org/doc/man\-pages/.