1 .\" $NetBSD: endutxent.3,v 1.4 2004/05/04 02:38:35 atatat Exp $
3 .\" Copyright (c) 2002 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Thomas Klausner.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
17 .\" 3. All advertising materials mentioning features or use of this software
18 .\" must display the following acknowledgement:
19 .\" This product includes software developed by the NetBSD
20 .\" Foundation, Inc. and its contributors.
21 .\" 4. Neither the name of The NetBSD Foundation nor the names of its
22 .\" contributors may be used to endorse or promote products derived
23 .\" from this software without specific prior written permission.
25 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 .\" POSSIBILITY OF SUCH DAMAGE.
47 .Nd user accounting database functions
57 .Fn getutxid "const struct utmpx *id"
59 .Fn getutxline "const struct utmpx *line"
61 .Fn pututxline "const struct utmpx *utx"
65 These functions provide access to the
67 user accounting database.
70 reads the next entry from the database;
71 if the database was not yet open, it also opens it.
73 resets the database, so that the next
75 call will get the first entry.
80 returns the next entry of the type specified in its argument's
90 entry which has the same name as specified in the
99 entry line to the accounting database, replacing a previous entry for
100 the same user if it exists.
101 Only the superuser may write to the accounting database.
102 .Ss The utmpx structure
105 structure has the following definition:
109 char ut_user[_UTX_USERSIZE]; /* login name */
110 char ut_id[_UTX_IDSIZE]; /* id */
111 char ut_line[_UTX_LINESIZE]; /* tty name */
112 pid_t ut_pid; /* process id creating the entry */
113 short ut_type; /* type of this entry */
114 struct timeval ut_tv; /* time entry was created */
115 char ut_host[_UTX_HOSTSIZE]; /* host name */
116 __uint32_t ut_pad[16]; /* reserved for future use */
123 .Bl -tag -width ".Dv LOGIN_PROCESSXX" -compact -offset indent
125 Time of a system boot.
127 A session leader exited.
129 No valid user accounting information.
134 The session leader of a logged-in user.
136 Time after system clock change.
138 Time before system clock change.
141 Provided for compatibility, not used.
145 Time of system shutdown (extension to the standards).
150 the other fields with meaningful values are as follows:
151 .Bl -tag -width ".Dv LOGIN_PROCESSXX" -compact -offset indent
167 (implementation-defined name of the login process),
179 (login name of the user),
183 (hostname of remote user)
188 .Ss Other extensions to the standards
191 value may also be OR-ed with the following masks:
192 .Bl -tag -width XXXX -compact -offset indent
193 .It Dv UTMPX_AUTOFILL_MASK
196 value, other fields are automatically filled in (as specified in the
197 meaningful fields table above).
200 field will be set using the convention of the last four characters of the
202 field (itself filled in automatically from the tty name of the device connected
203 to the standard input, output or error, whichever is available).
204 Note that it is more efficient to fill in as many values as are already
205 available beforehand, rather than have then automatically filled in.
206 .It Dv UTMPX_DEAD_IF_CORRESPONDING_MASK
210 .Dv DEAD_PROCESS, a call to
212 will succeed only if a corresponding entry already exists with a
218 Note that the above mask values do not show up in any file format, or in
219 any subsequent reads of the data.
225 equivalent capability,
227 automatically writes to the appropriate files.
228 Additional APIs to read these files is available in
232 .Ss Backward compatibility
235 will automatically write equivalent entries into the
241 Programs that read these old files should work as expected.
242 However, directly writing to these files does not make corresponding
249 equivalent files, so such write-access is deprecated.
252 returns the next entry, or
254 on failure (end of database or problems reading from the database).
258 return the matching structure on success, or
260 if no match was found.
263 returns the structure that was successfully written, or
265 is returned and the global variable
267 is set to indicate the error.
269 No errors are defined for the
280 function may fail if:
283 The process does not have appropriate privileges.
286 .Dv UTMPX_DEAD_IF_CORRESPONDING_MASK
287 flags was specified along with
289 but no corresponding entry with
294 Other errors may be returned if
295 .Dv UTMPX_AUTOFILL_MASK
296 was specified, and a field could not be auto-filled.
298 .Xr endutxent_wtmp 3 ,
311 (XSI extension), and previously to
323 (XSI extension), and previously to
333 .\" is for compatibility with
341 .\" files first appeared in