1a627ac61SEd Schouten.\" Copyright (c) 2010 Ed Schouten <ed@FreeBSD.org> 2a627ac61SEd Schouten.\" All rights reserved. 3a627ac61SEd Schouten.\" 4a627ac61SEd Schouten.\" Redistribution and use in source and binary forms, with or without 5a627ac61SEd Schouten.\" modification, are permitted provided that the following conditions 6a627ac61SEd Schouten.\" are met: 7a627ac61SEd Schouten.\" 1. Redistributions of source code must retain the above copyright 8a627ac61SEd Schouten.\" notice, this list of conditions and the following disclaimer. 9a627ac61SEd Schouten.\" 2. Redistributions in binary form must reproduce the above copyright 10a627ac61SEd Schouten.\" notice, this list of conditions and the following disclaimer in the 11a627ac61SEd Schouten.\" documentation and/or other materials provided with the distribution. 12a627ac61SEd Schouten.\" 13a627ac61SEd Schouten.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14a627ac61SEd Schouten.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15a627ac61SEd Schouten.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16a627ac61SEd Schouten.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17a627ac61SEd Schouten.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18a627ac61SEd Schouten.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19a627ac61SEd Schouten.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20a627ac61SEd Schouten.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21a627ac61SEd Schouten.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22a627ac61SEd Schouten.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23a627ac61SEd Schouten.\" SUCH DAMAGE. 24a627ac61SEd Schouten.\" 25ad033677SEd Schouten.Dd October 27, 2011 26a627ac61SEd Schouten.Dt GETUTXENT 3 27aa12cea2SUlrich Spörlein.Os 28a627ac61SEd Schouten.Sh NAME 29a627ac61SEd Schouten.Nm endutxent , 30a627ac61SEd Schouten.Nm getutxent , 31a627ac61SEd Schouten.Nm getutxid , 32a627ac61SEd Schouten.Nm getutxline , 33a627ac61SEd Schouten.Nm getutxuser , 34a627ac61SEd Schouten.Nm pututxline , 35a627ac61SEd Schouten.Nm setutxdb , 36a627ac61SEd Schouten.Nm setutxent 37a627ac61SEd Schouten.Nd user accounting database functions 38a627ac61SEd Schouten.Sh LIBRARY 39a627ac61SEd Schouten.Lb libc 40a627ac61SEd Schouten.Sh SYNOPSIS 41a627ac61SEd Schouten.In utmpx.h 42a627ac61SEd Schouten.Ft void 43a627ac61SEd Schouten.Fn endutxent "void" 44a627ac61SEd Schouten.Ft struct utmpx * 45a627ac61SEd Schouten.Fn getutxent "void" 46a627ac61SEd Schouten.Ft struct utmpx * 47a627ac61SEd Schouten.Fn getutxid "const struct utmpx *id" 48a627ac61SEd Schouten.Ft struct utmpx * 49a627ac61SEd Schouten.Fn getutxline "const struct utmpx *line" 50a627ac61SEd Schouten.Ft struct utmpx * 51a627ac61SEd Schouten.Fn getutxuser "const char *user" 52a627ac61SEd Schouten.Ft struct utmpx * 53a627ac61SEd Schouten.Fn pututxline "const struct utmpx *utmpx" 54a627ac61SEd Schouten.Ft int 55a627ac61SEd Schouten.Fn setutxdb "int type" "const char *file" 56a627ac61SEd Schouten.Ft void 57a627ac61SEd Schouten.Fn setutxent "void" 58a627ac61SEd Schouten.Sh DESCRIPTION 59a627ac61SEd SchoutenThese functions operate on the user accounting database which stores 60a627ac61SEd Schoutenrecords of various system activities, such as user login and logouts, 61a627ac61SEd Schoutenbut also system startups and shutdowns and modifications to the system's 62a627ac61SEd Schoutenclock. 63a627ac61SEd SchoutenThe system stores these records in three databases, each having a 64a627ac61SEd Schoutendifferent purpose: 65a627ac61SEd Schouten.Bl -tag -width indent 66a627ac61SEd Schouten.It Pa /var/run/utx.active 67a627ac61SEd SchoutenLog of currently active user login sessions. 68a627ac61SEd SchoutenThis file is similar to the traditional 69a627ac61SEd Schouten.Pa utmp 70a627ac61SEd Schoutenfile. 71a627ac61SEd SchoutenThis file only contains process related entries, such as user login and 72a627ac61SEd Schoutenlogout records. 73a627ac61SEd Schouten.It Pa /var/log/utx.lastlogin 74a627ac61SEd SchoutenLog of last user login entries per user. 75a627ac61SEd SchoutenThis file is similar to the traditional 76a627ac61SEd Schouten.Pa lastlog 77a627ac61SEd Schoutenfile. 78a627ac61SEd SchoutenThis file only contains user login records for users who have at least 79a627ac61SEd Schoutenlogged in once. 80a627ac61SEd Schouten.It Pa /var/log/utx.log 81a627ac61SEd SchoutenLog of all entries, sorted by date of addition. 82a627ac61SEd SchoutenThis file is similar to the traditional 83a627ac61SEd Schouten.Pa wtmp 84a627ac61SEd Schoutenfile. 85a627ac61SEd SchoutenThis file may contain any type of record described below. 86a627ac61SEd Schouten.El 87a627ac61SEd Schouten.Pp 88a627ac61SEd SchoutenEach entry in these databases is defined by the structure 89a627ac61SEd Schouten.Vt utmpx 90a627ac61SEd Schoutenfound in the include file 91a627ac61SEd Schouten.In utmpx.h : 92a627ac61SEd Schouten.Bd -literal -offset indent 93a627ac61SEd Schoutenstruct utmpx { 94a627ac61SEd Schouten short ut_type; /* Type of entry. */ 95a627ac61SEd Schouten struct timeval ut_tv; /* Time entry was made. */ 96a627ac61SEd Schouten char ut_id[]; /* Record identifier. */ 97a627ac61SEd Schouten pid_t ut_pid; /* Process ID. */ 98a627ac61SEd Schouten char ut_user[]; /* User login name. */ 99a627ac61SEd Schouten char ut_line[]; /* Device name. */ 100a627ac61SEd Schouten char ut_host[]; /* Remote hostname. */ 101a627ac61SEd Schouten}; 102a627ac61SEd Schouten.Ed 103a627ac61SEd Schouten.Pp 104a627ac61SEd SchoutenThe 105a627ac61SEd Schouten.Fa ut_type 106a627ac61SEd Schoutenfield indicates the type of the log entry, which can have one of the 107a627ac61SEd Schoutenfollowing values: 108a627ac61SEd Schouten.Bl -tag -width LOGIN_PROCESS 109a627ac61SEd Schouten.It Dv EMPTY 110a627ac61SEd SchoutenNo valid user accounting information. 111a627ac61SEd Schouten.It Dv BOOT_TIME 112a627ac61SEd SchoutenIdentifies time of system boot. 113a627ac61SEd Schouten.It Dv SHUTDOWN_TIME 114a627ac61SEd SchoutenIdentifies time of system shutdown. 115a627ac61SEd Schouten.It Dv OLD_TIME 116a627ac61SEd SchoutenIdentifies time when system clock changed. 117a627ac61SEd Schouten.It Dv NEW_TIME 118a627ac61SEd SchoutenIdentifies time after system clock changed. 119a627ac61SEd Schouten.It Dv USER_PROCESS 120a627ac61SEd SchoutenIdentifies a process. 121a627ac61SEd Schouten.It Dv INIT_PROCESS 122a627ac61SEd SchoutenIdentifies a process spawned by the init process. 123a627ac61SEd Schouten.It Dv LOGIN_PROCESS 124a627ac61SEd SchoutenIdentifies the session leader of a logged-in user. 125a627ac61SEd Schouten.It Dv DEAD_PROCESS 126a627ac61SEd SchoutenIdentifies a session leader who has exited. 127a627ac61SEd Schouten.El 128a627ac61SEd Schouten.Pp 129a627ac61SEd SchoutenEntries of type 130a627ac61SEd Schouten.Dv INIT_PROCESS 131a627ac61SEd Schoutenand 132a627ac61SEd Schouten.Dv LOGIN_PROCESS 133a627ac61SEd Schoutenare not processed by this implementation. 134a627ac61SEd Schouten.Pp 135a627ac61SEd SchoutenOther fields inside the structure are: 136a627ac61SEd Schouten.Bl -tag -width ut_user 137a627ac61SEd Schouten.It Fa ut_tv 138edfa427cSJoel DahlThe time the event occurred. 1399d98195dSEd SchoutenThis field is used for all types of entries, except 1409d98195dSEd Schouten.Dv EMPTY . 141a627ac61SEd Schouten.It Fa ut_id 142a627ac61SEd SchoutenAn identifier that is used to refer to the entry. 143a627ac61SEd SchoutenThis identifier can be used to remove or replace a login entry by 144a627ac61SEd Schoutenwriting a new entry to the database containing the same value for 145a627ac61SEd Schouten.Fa ut_id . 146a627ac61SEd SchoutenThis field is only applicable to entries of type 147a627ac61SEd Schouten.Dv USER_PROCESS , 148a627ac61SEd Schouten.Dv INIT_PROCESS , 149a627ac61SEd Schouten.Dv LOGIN_PROCESS 150a627ac61SEd Schoutenand 151a627ac61SEd Schouten.Dv DEAD_PROCESS . 152a627ac61SEd Schouten.It Fa ut_pid 153a627ac61SEd SchoutenThe process identifier of the session leader of the login session. 154a627ac61SEd SchoutenThis field is only applicable to entries of type 155a627ac61SEd Schouten.Dv USER_PROCESS , 156a627ac61SEd Schouten.Dv INIT_PROCESS , 157a627ac61SEd Schouten.Dv LOGIN_PROCESS 158a627ac61SEd Schoutenand 159a627ac61SEd Schouten.Dv DEAD_PROCESS . 160a627ac61SEd Schouten.It Fa ut_user 161a627ac61SEd SchoutenThe user login name corresponding with the login session. 162a627ac61SEd SchoutenThis field is only applicable to entries of type 163a627ac61SEd Schouten.Dv USER_PROCESS 164a627ac61SEd Schoutenand 165a627ac61SEd Schouten.Dv INIT_PROCESS . 166a627ac61SEd SchoutenFor 167a627ac61SEd Schouten.Dv INIT_PROCESS 168a627ac61SEd Schoutenentries this entry typically contains the name of the login process. 169a627ac61SEd Schouten.It Fa ut_line 170a627ac61SEd SchoutenThe name of the TTY character device, without the leading 171a627ac61SEd Schouten.Pa /dev/ 172a627ac61SEd Schoutenprefix, corresponding with the device used to facilitate the user login 173a627ac61SEd Schoutensession. 174a627ac61SEd SchoutenIf no TTY character device is used, this field is left blank. 175a627ac61SEd SchoutenThis field is only applicable to entries of type 17698c63a48SEd Schouten.Dv USER_PROCESS 17798c63a48SEd Schoutenand 17898c63a48SEd Schouten.Dv LOGIN_PROCESS . 179a627ac61SEd Schouten.It Fa ut_host 180a627ac61SEd SchoutenThe network hostname of the remote system, connecting to perform a user 181a627ac61SEd Schoutenlogin. 182a627ac61SEd SchoutenIf the user login session is not performed across a network, this field 183a627ac61SEd Schoutenis left blank. 184a627ac61SEd SchoutenThis field is only applicable to entries of type 185a627ac61SEd Schouten.Dv USER_PROCESS . 186a627ac61SEd Schouten.El 187a627ac61SEd Schouten.Pp 188a627ac61SEd SchoutenThis implementation guarantees all inapplicable fields are discarded. 189a627ac61SEd SchoutenThe 190a627ac61SEd Schouten.Fa ut_user , 191a627ac61SEd Schouten.Fa ut_line 192a627ac61SEd Schoutenand 193a627ac61SEd Schouten.Fa ut_host 194a627ac61SEd Schoutenfields of the structure returned by the library functions are also 195a627ac61SEd Schoutenguaranteed to be null-terminated in this implementation. 196a627ac61SEd Schouten.Pp 197a627ac61SEd SchoutenThe 198a627ac61SEd Schouten.Fn getutxent 199a627ac61SEd Schoutenfunction can be used to read the next entry from the user accounting 200a627ac61SEd Schoutendatabase. 201a627ac61SEd Schouten.Pp 202a627ac61SEd SchoutenThe 203a627ac61SEd Schouten.Fn getutxid 204a627ac61SEd Schoutenfunction searches for the next entry in the database of which the 205a627ac61SEd Schoutenbehaviour is based on the 206a627ac61SEd Schouten.Fa ut_type 207a627ac61SEd Schoutenfield of 208a627ac61SEd Schouten.Fa id . 209a627ac61SEd SchoutenIf 210a627ac61SEd Schouten.Fa ut_type 211a627ac61SEd Schoutenhas a value of 212a627ac61SEd Schouten.Dv BOOT_TIME , 213a627ac61SEd Schouten.Dv SHUTDOWN_TIME , 214a627ac61SEd Schouten.Dv OLD_TIME 215a627ac61SEd Schoutenor 216a627ac61SEd Schouten.Dv NEW_TIME , 217a627ac61SEd Schoutenit will return the next entry whose 218a627ac61SEd Schouten.Fa ut_type 219a627ac61SEd Schoutenhas an equal value. 220a627ac61SEd SchoutenIf 221a627ac61SEd Schouten.Fa ut_type 222a627ac61SEd Schoutenhas a value of 223a627ac61SEd Schouten.Dv USER_PROCESS , 224a627ac61SEd Schouten.Dv INIT_PROCESS , 225a627ac61SEd Schouten.Dv LOGIN_PROCESS 226a627ac61SEd Schoutenor 227a627ac61SEd Schouten.Dv DEAD_PROCESS , 228a627ac61SEd Schoutenit will return the next entry whose 229a627ac61SEd Schouten.Fa ut_type 230a627ac61SEd Schoutenhas one of the previously mentioned values and whose 231a627ac61SEd Schouten.Fa ut_id 232a627ac61SEd Schoutenis equal. 233a627ac61SEd Schouten.Pp 234a627ac61SEd SchoutenThe 235a627ac61SEd Schouten.Fn getutxline 236a627ac61SEd Schoutenfunction searches for the next entry in the database whose 237a627ac61SEd Schouten.Fa ut_type 238a627ac61SEd Schoutenhas a value of 239a627ac61SEd Schouten.Dv USER_PROCESS 240a627ac61SEd Schoutenor 241a627ac61SEd Schouten.Dv LOGIN_PROCESS 242a627ac61SEd Schoutenand whose 243a627ac61SEd Schouten.Fa ut_line 24436daf049SEitan Adleris equal to the same field in 245a627ac61SEd Schouten.Fa line . 246a627ac61SEd Schouten.Pp 247a627ac61SEd SchoutenThe 248a627ac61SEd Schouten.Fn getutxuser 249a627ac61SEd Schoutenfunction searches for the next entry in the database whose 250a627ac61SEd Schouten.Fa ut_type 251a627ac61SEd Schoutenhas a value of 252a627ac61SEd Schouten.Dv USER_PROCESS 253a627ac61SEd Schoutenand whose 254a627ac61SEd Schouten.Fa ut_user 255a627ac61SEd Schoutenis equal to 256a627ac61SEd Schouten.Fa user . 257a627ac61SEd Schouten.Pp 258a627ac61SEd SchoutenThe previously mentioned functions will automatically try to open the 259a627ac61SEd Schoutenuser accounting database if not already done so. 260a627ac61SEd SchoutenThe 261a627ac61SEd Schouten.Fn setutxdb 262a627ac61SEd Schoutenand 263a627ac61SEd Schouten.Fn setutxent 264a627ac61SEd Schoutenfunctions allow the database to be opened manually, causing the offset 265a627ac61SEd Schoutenwithin the user accounting database to be rewound. 266a627ac61SEd SchoutenThe 267a627ac61SEd Schouten.Fn endutxent 268a627ac61SEd Schoutenfunction closes the database. 269a627ac61SEd Schouten.Pp 270a627ac61SEd SchoutenThe 271a627ac61SEd Schouten.Fn setutxent 272a627ac61SEd Schoutendatabase always opens the active sessions database. 273a627ac61SEd SchoutenThe 274a627ac61SEd Schouten.Fn setutxdb 275a627ac61SEd Schoutenfunction opens the database identified by 276a627ac61SEd Schouten.Fa type , 277a627ac61SEd Schoutenwhose value is either 278a627ac61SEd Schouten.Dv UTXDB_ACTIVE , 279a627ac61SEd Schouten.Dv UTXDB_LASTLOGIN 280a627ac61SEd Schoutenor 281a627ac61SEd Schouten.Dv UTXDB_LOG . 282a627ac61SEd SchoutenIt will open a custom file with filename 283a627ac61SEd Schouten.Fa file 284a627ac61SEd Schouteninstead of the system-default if 285a627ac61SEd Schouten.Fa file 286a627ac61SEd Schoutenis not null. 287a627ac61SEd SchoutenCare must be taken that when using a custom filename, 288a627ac61SEd Schouten.Fa type 289a627ac61SEd Schoutenstill has to match with the actual format, since each database may use 290a627ac61SEd Schoutenits own file format. 291a627ac61SEd Schouten.Pp 292a627ac61SEd SchoutenThe 293a627ac61SEd Schouten.Fn pututxline 294a627ac61SEd Schoutenfunction writes record 295a627ac61SEd Schouten.Fa utmpx 296a627ac61SEd Schoutento the system-default user accounting databases. 297a627ac61SEd SchoutenThe value of 298a627ac61SEd Schouten.Fa ut_type 299a627ac61SEd Schoutendetermines which databases are modified. 300a627ac61SEd Schouten.Pp 301a627ac61SEd SchoutenEntries of type 302a627ac61SEd Schouten.Dv SHUTDOWN_TIME , 303a627ac61SEd Schouten.Dv OLD_TIME 304a627ac61SEd Schoutenand 305a627ac61SEd Schouten.Dv NEW_TIME 306a627ac61SEd Schoutenwill only be written to 307a627ac61SEd Schouten.Pa /var/log/utx.log . 308a627ac61SEd Schouten.Pp 309a627ac61SEd SchoutenEntries of type 310a627ac61SEd Schouten.Dv USER_PROCESS 311a627ac61SEd Schoutenwill also be written to 312a7607816SEd Schouten.Pa /var/run/utx.active 313a7607816SEd Schoutenand 314a7607816SEd Schouten.Pa /var/log/utx.lastlogin . 315a627ac61SEd Schouten.Pp 316a627ac61SEd SchoutenEntries of type 317a627ac61SEd Schouten.Dv DEAD_PROCESS 318a627ac61SEd Schoutenwill only be written to 319a627ac61SEd Schouten.Pa /var/log/utx.log 320a627ac61SEd Schoutenand 321a627ac61SEd Schouten.Pa /var/run/utx.active 322a627ac61SEd Schoutenif a corresponding 323a627ac61SEd Schouten.Dv USER_PROCESS , 324a627ac61SEd Schouten.Dv INIT_PROCESS 325a627ac61SEd Schoutenor 326a627ac61SEd Schouten.Dv LOGIN_PROCESS 327a627ac61SEd Schoutenentry whose 328a627ac61SEd Schouten.Fa ut_id 329a627ac61SEd Schoutenis equal has been found in the latter. 330a627ac61SEd Schouten.Pp 331a627ac61SEd SchoutenIn addition, entries of type 332a627ac61SEd Schouten.Dv BOOT_TIME 333a627ac61SEd Schoutenand 334a627ac61SEd Schouten.Dv SHUTDOWN_TIME 335c5cf53fcSEd Schoutenwill cause all existing entries in 336a627ac61SEd Schouten.Pa /var/run/utx.active 337a627ac61SEd Schoutento be discarded. 338a627ac61SEd Schouten.Pp 339a627ac61SEd SchoutenAll entries whose type has not been mentioned previously, are discarded 340a627ac61SEd Schoutenby this implementation of 341a627ac61SEd Schouten.Fn pututxline . 342a7607816SEd SchoutenThis implementation also ignores the value of 343a7607816SEd Schouten.Fa ut_tv . 344a627ac61SEd Schouten.Sh RETURN VALUES 345a627ac61SEd SchoutenThe 346a627ac61SEd Schouten.Fn getutxent , 347a627ac61SEd Schouten.Fn getutxid , 348a627ac61SEd Schouten.Fn getutxline , 349a627ac61SEd Schoutenand 350a627ac61SEd Schouten.Fn getutxuser 351a627ac61SEd Schoutenfunctions return a pointer to an 352a627ac61SEd Schouten.Vt utmpx 353a627ac61SEd Schoutenstructure that matches the mentioned constraints on success or 354a627ac61SEd Schouten.Dv NULL 355a627ac61SEd Schoutenwhen reaching the end-of-file or when an error occurs. 356a627ac61SEd Schouten.Pp 357a627ac61SEd SchoutenThe 358a627ac61SEd Schouten.Fn pututxline 359a627ac61SEd Schoutenfunction returns a pointer to an 360a627ac61SEd Schouten.Vt utmpx 361a627ac61SEd Schoutenstructure containing a copy of the structure written to disk upon 362a627ac61SEd Schoutensuccess. 363a627ac61SEd SchoutenIt returns 364a627ac61SEd Schouten.Dv NULL 365a627ac61SEd Schoutenwhen the provided 366a627ac61SEd Schouten.Vt utmpx 3671ae6a21dSEd Schoutenis invalid, or 368a627ac61SEd Schouten.Fa ut_type 369a627ac61SEd Schoutenhas a value of 370a627ac61SEd Schouten.Dv DEAD_PROCESS 371a627ac61SEd Schoutenand an entry with an identifier with a value equal to the field 372a627ac61SEd Schouten.Fa ut_id 3731ae6a21dSEd Schoutenwas not found; the global variable 3741ae6a21dSEd Schouten.Va errno 3751ae6a21dSEd Schoutenis set to indicate the error. 376a627ac61SEd Schouten.Pp 377a627ac61SEd SchoutenThe 378a627ac61SEd Schouten.Fn setutxdb 379a627ac61SEd Schoutenfunction returns 0 if the user accounting database was opened 380a627ac61SEd Schoutensuccessfully. 381a627ac61SEd SchoutenOtherwise, -1 is returned and the global variable 382a627ac61SEd Schouten.Va errno 383a627ac61SEd Schoutenis set to indicate the error. 384a627ac61SEd Schouten.Sh ERRORS 385a627ac61SEd SchoutenIn addition to the error conditions described in 3867112398cSSergey Kandaurov.Xr open 2 , 3871ae6a21dSEd Schouten.Xr fdopen 3 , 3881ae6a21dSEd Schouten.Xr fopen 3 , 3891ae6a21dSEd Schouten.Xr fseek 3 , 3901ae6a21dSEd Schoutenthe 3911ae6a21dSEd Schouten.Fn pututxline 3921ae6a21dSEd Schoutenfunction can generate the following errors: 3931ae6a21dSEd Schouten.Bl -tag -width Er 3941ae6a21dSEd Schouten.It Bq Er ESRCH 3951ae6a21dSEd SchoutenThe value of 3961ae6a21dSEd Schouten.Fa ut_type 3971ae6a21dSEd Schoutenis DEAD_PROCESS, and the process entry could not be found. 3981ae6a21dSEd Schouten.It Bq Er EINVAL 3991ae6a21dSEd SchoutenThe value of 4001ae6a21dSEd Schouten.Fa ut_type 4011ae6a21dSEd Schoutenis not supported by this implementation. 4021ae6a21dSEd Schouten.El 4031ae6a21dSEd SchoutenIn addition to the error conditions described in 404a627ac61SEd Schouten.Xr fopen 3 , 405a627ac61SEd Schoutenthe 406a627ac61SEd Schouten.Fn setutxdb 407a627ac61SEd Schoutenfunction can generate the following errors: 408a627ac61SEd Schouten.Bl -tag -width Er 409a627ac61SEd Schouten.It Bq Er EINVAL 410a627ac61SEd SchoutenThe 411a627ac61SEd Schouten.Fa type 412a627ac61SEd Schoutenargument contains a value not supported by this implementation. 413a627ac61SEd Schouten.It Bq Er EFTYPE 414a627ac61SEd SchoutenThe file format is invalid. 415a627ac61SEd Schouten.El 416a627ac61SEd Schouten.Sh SEE ALSO 417a627ac61SEd Schouten.Xr last 1 , 418a627ac61SEd Schouten.Xr write 1 , 419a627ac61SEd Schouten.Xr getpid 2 , 420a627ac61SEd Schouten.Xr gettimeofday 2 , 421a627ac61SEd Schouten.Xr tty 4 , 422a627ac61SEd Schouten.Xr ac 8 , 423b30bfd43SEd Schouten.Xr newsyslog 8 , 42471d8432fSEd Schouten.Xr utx 8 425a627ac61SEd Schouten.Sh STANDARDS 426a627ac61SEd SchoutenThe 427a627ac61SEd Schouten.Fn endutxent , 428a627ac61SEd Schouten.Fn getutxent , 429a627ac61SEd Schouten.Fn getutxid , 4305b2e6b2aSEd Schouten.Fn getutxline 431a627ac61SEd Schoutenand 432a627ac61SEd Schouten.Fn setutxent 433a627ac61SEd Schoutenfunctions are expected to conform to 434a627ac61SEd Schouten.St -p1003.1-2008 . 435a627ac61SEd Schouten.Pp 436a627ac61SEd SchoutenThe 4375b2e6b2aSEd Schouten.Fn pututxline 4385b2e6b2aSEd Schoutenfunction deviates from the standard by writing its records to multiple 4395b2e6b2aSEd Schoutendatabase files, depending on its 4405b2e6b2aSEd Schouten.Fa ut_type . 4415b2e6b2aSEd SchoutenThis prevents the need for special utility functions to update the other 4425b2e6b2aSEd Schoutendatabases, such as the 4431e7a0844SEd Schouten.Fn updlastlogx 4441e7a0844SEd Schoutenand 4455b2e6b2aSEd Schouten.Fn updwtmpx 4461e7a0844SEd Schoutenfunctions which are available in other implementations. 4475b2e6b2aSEd SchoutenIt also tries to replace 4485b2e6b2aSEd Schouten.Dv DEAD_PROCESS 4495b2e6b2aSEd Schoutenentries in the active sessions database when storing 4505b2e6b2aSEd Schouten.Dv USER_PROCESS 4515b2e6b2aSEd Schoutenentries and no entry with the same value for 4525b2e6b2aSEd Schouten.Fa ut_id 4535b2e6b2aSEd Schoutenhas been found. 4545b2e6b2aSEd SchoutenThe standard always requires a new entry to be allocated, which could 455f5ec5ddeSEd Schoutencause an unbounded growth of the database. 4565b2e6b2aSEd Schouten.Pp 4575b2e6b2aSEd SchoutenThe 458a627ac61SEd Schouten.Fn getutxuser 459a627ac61SEd Schoutenand 460a627ac61SEd Schouten.Fn setutxdb 461a627ac61SEd Schoutenfunctions, 462a627ac61SEd Schoutenthe 463a627ac61SEd Schouten.Fa ut_host 464a627ac61SEd Schoutenfield of the 465a627ac61SEd Schouten.Vt utmpx 466a627ac61SEd Schoutenstructure and 467a627ac61SEd Schouten.Dv SHUTDOWN_TIME 468a627ac61SEd Schoutenare extensions. 469a627ac61SEd Schouten.Sh HISTORY 470a627ac61SEd SchoutenThese functions appeared in 471a627ac61SEd Schouten.Fx 9.0 . 472a627ac61SEd SchoutenThey replaced the 473a627ac61SEd Schouten.In utmp.h 474a627ac61SEd Schouteninterface. 475a627ac61SEd Schouten.Sh AUTHORS 476*7acd8260SBaptiste Daroussin.An \&Ed Schouten Aq Mt ed@FreeBSD.org 477