143f8178fSAlex Hornung.\" $NetBSD: endutxent.3,v 1.4 2004/05/04 02:38:35 atatat Exp $ 243f8178fSAlex Hornung.\" 343f8178fSAlex Hornung.\" Copyright (c) 2002 The NetBSD Foundation, Inc. 443f8178fSAlex Hornung.\" All rights reserved. 543f8178fSAlex Hornung.\" 643f8178fSAlex Hornung.\" This code is derived from software contributed to The NetBSD Foundation 743f8178fSAlex Hornung.\" by Thomas Klausner. 843f8178fSAlex Hornung.\" 943f8178fSAlex Hornung.\" Redistribution and use in source and binary forms, with or without 1043f8178fSAlex Hornung.\" modification, are permitted provided that the following conditions 1143f8178fSAlex Hornung.\" are met: 1243f8178fSAlex Hornung.\" 1. Redistributions of source code must retain the above copyright 1343f8178fSAlex Hornung.\" notice, this list of conditions and the following disclaimer. 1443f8178fSAlex Hornung.\" 2. Redistributions in binary form must reproduce the above copyright 1543f8178fSAlex Hornung.\" notice, this list of conditions and the following disclaimer in the 1643f8178fSAlex Hornung.\" documentation and/or other materials provided with the distribution. 1743f8178fSAlex Hornung.\" 1843f8178fSAlex Hornung.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 1943f8178fSAlex Hornung.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2043f8178fSAlex Hornung.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2143f8178fSAlex Hornung.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2243f8178fSAlex Hornung.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2343f8178fSAlex Hornung.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2443f8178fSAlex Hornung.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2543f8178fSAlex Hornung.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2643f8178fSAlex Hornung.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2743f8178fSAlex Hornung.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2843f8178fSAlex Hornung.\" POSSIBILITY OF SUCH DAMAGE. 2943f8178fSAlex Hornung.\" 30974aa081SSascha Wildner.Dd September 10, 2019 3143f8178fSAlex Hornung.Dt ENDUTXENT 3 3243f8178fSAlex Hornung.Os 3343f8178fSAlex Hornung.Sh NAME 3443f8178fSAlex Hornung.Nm endutxent , 3543f8178fSAlex Hornung.Nm getutxent , 3643f8178fSAlex Hornung.Nm getutxid , 3743f8178fSAlex Hornung.Nm getutxline , 38974aa081SSascha Wildner.Nm getutxuser , 3943f8178fSAlex Hornung.Nm pututxline , 4043f8178fSAlex Hornung.Nm setutxent , 4143f8178fSAlex Hornung.Nm setutxdb 4243f8178fSAlex Hornung.Nd user accounting database functions 4343f8178fSAlex Hornung.Sh LIBRARY 4443f8178fSAlex Hornung.Lb libc 4543f8178fSAlex Hornung.Sh SYNOPSIS 4643f8178fSAlex Hornung.In utmpx.h 4743f8178fSAlex Hornung.Ft void 4843f8178fSAlex Hornung.Fn endutxent void 4943f8178fSAlex Hornung.Ft struct utmpx * 5043f8178fSAlex Hornung.Fn getutxent void 5143f8178fSAlex Hornung.Ft struct utmpx * 5243f8178fSAlex Hornung.Fn getutxid "const struct utmpx *" 5343f8178fSAlex Hornung.Ft struct utmpx * 5443f8178fSAlex Hornung.Fn getutxline "const struct utmpx *" 5543f8178fSAlex Hornung.Ft struct utmpx * 56974aa081SSascha Wildner.Fn getutxuser "const char *user" 57974aa081SSascha Wildner.Ft struct utmpx * 5843f8178fSAlex Hornung.Fn pututxline "const struct utmpx *" 5943f8178fSAlex Hornung.Ft void 6043f8178fSAlex Hornung.Fn setutxent void 6143f8178fSAlex Hornung.Ft int 627bb7a6edSSascha Wildner.Fn setutxdb "utx_db_t db" "const char *fname" 6343f8178fSAlex Hornung.Sh DESCRIPTION 6443f8178fSAlex HornungThese functions provide access to the 6543f8178fSAlex Hornung.Xr utmpx 5 6643f8178fSAlex Hornungand 6743f8178fSAlex Hornung.Xr wtmpx 5 6843f8178fSAlex Hornunguser accounting database. 6943f8178fSAlex Hornung.Pp 7043f8178fSAlex Hornung.Fn getutxent 7143f8178fSAlex Hornungreads the next entry from the database; 7243f8178fSAlex Hornungif the database was not yet open, it also opens it. 7343f8178fSAlex Hornung.Fn setutxent 7443f8178fSAlex Hornungresets the database, so that the next 7543f8178fSAlex Hornung.Fn getutxent 7643f8178fSAlex Hornungcall will get the first entry. 7743f8178fSAlex Hornung.Fn endutxent 7843f8178fSAlex Hornungcloses the database. 7943f8178fSAlex Hornung.Pp 8043f8178fSAlex Hornung.Fn getutxid 8143f8178fSAlex Hornungreturns the next entry of the type specified in its argument's 8243f8178fSAlex Hornung.Va ut_type 8343f8178fSAlex Hornungfield, or 8443f8178fSAlex Hornung.Dv NULL 8543f8178fSAlex Hornungif none is found. 8643f8178fSAlex Hornung.Fn getutxline 8743f8178fSAlex Hornungreturns the next 8843f8178fSAlex Hornung.Dv LOGIN_PROCESS 8943f8178fSAlex Hornungor 9043f8178fSAlex Hornung.Dv USER_PROCESS 9143f8178fSAlex Hornungentry which has the same name as specified in the 9243f8178fSAlex Hornung.Va ut_line 9343f8178fSAlex Hornungfield, or 9443f8178fSAlex Hornung.Dv NULL 9543f8178fSAlex Hornungif no match is found. 9643f8178fSAlex Hornung.Pp 97974aa081SSascha Wildner.Fn getutxuser 98974aa081SSascha Wildnersearches for the next entry in the database whose 99974aa081SSascha Wildner.Fa ut_type 100974aa081SSascha Wildnerhas a value of 101974aa081SSascha Wildner.Dv USER_PROCESS 102974aa081SSascha Wildnerand whose 103974aa081SSascha Wildner.Fa ut_user 104974aa081SSascha Wildneris equal to 105974aa081SSascha Wildner.Fa user . 106974aa081SSascha Wildner.Pp 10743f8178fSAlex Hornung.Fn pututxline 10843f8178fSAlex Hornungadds the argument 10943f8178fSAlex Hornung.Xr utmpx 5 11043f8178fSAlex Hornungentry line to the accounting database, replacing a previous entry for 11143f8178fSAlex Hornungthe same user if it exists. 11243f8178fSAlex Hornung.Pp 11343f8178fSAlex HornungBy default the aforementioned functions work on the default 11443f8178fSAlex Hornung.Xr utmpx 5 11543f8178fSAlex Hornungdatabase. The function 11643f8178fSAlex Hornung.Fn setutxdb 11743f8178fSAlex Hornungallows to change the database type being operated on, as well 11843f8178fSAlex Hornungas changing the path to that database. 11943f8178fSAlex HornungThe first parameter 12043f8178fSAlex Hornung.Ar db 12143f8178fSAlex Hornungcan be 12243f8178fSAlex Hornung.Dv UTX_DB_UTMPX 12343f8178fSAlex Hornungor 12443f8178fSAlex Hornung.Dv UTX_DB_WTMPX 12543f8178fSAlex Hornungand specifies which database to open. If 12643f8178fSAlex Hornung.Ar fname 12743f8178fSAlex Hornungis 12843f8178fSAlex Hornung.Dv NULL 12943f8178fSAlex Hornungthe default path for each of these is used as described in 13043f8178fSAlex Hornung.Xr utmpx 5 13143f8178fSAlex Hornungand 13243f8178fSAlex Hornung.Xr wtmpx 5 . 13343f8178fSAlex HornungOtherwise the path specified in 13443f8178fSAlex Hornung.Ar fname 13543f8178fSAlex Hornungis used as the database. 13643f8178fSAlex Hornung.Ss The utmpx structure 13743f8178fSAlex HornungThe 13843f8178fSAlex Hornung.Nm utmpx 13943f8178fSAlex Hornungstructure has the following definition: 14043f8178fSAlex Hornung.Bd -literal 14143f8178fSAlex Hornungstruct utmpx { 14243f8178fSAlex Hornung char ut_name[_UTX_USERSIZE]; /* login name */ 14343f8178fSAlex Hornung char ut_id[_UTX_IDSIZE]; /* inittab id */ 14443f8178fSAlex Hornung char ut_line[_UTX_LINESIZE]; /* tty name */ 14543f8178fSAlex Hornung char ut_host[_UTX_HOSTSIZE]; /* host name */ 14643f8178fSAlex Hornung uint16_t ut_session; /* session id used for windowing */ 14714f65205SSascha Wildner short ut_type; /* type of this entry */ 14843f8178fSAlex Hornung pid_t ut_pid; /* process id creating the entry */ 14943f8178fSAlex Hornung struct { 15043f8178fSAlex Hornung uint16_t e_termination; /* process termination signal */ 15143f8178fSAlex Hornung uint16_t e_exit; /* process exit status */ 15243f8178fSAlex Hornung } ut_exit; 15343f8178fSAlex Hornung struct sockaddr_storage ut_ss; /* address where entry was made from */ 15443f8178fSAlex Hornung struct timeval ut_tv; /* time entry was created */ 15543f8178fSAlex Hornung uint32_t ut_pad[10]; /* reserved for future use */ 15643f8178fSAlex Hornung}; 15743f8178fSAlex Hornung.Ed 15843f8178fSAlex Hornung.Pp 15943f8178fSAlex HornungValid entries for 16043f8178fSAlex Hornung.Fa ut_type 16143f8178fSAlex Hornungare: 16243f8178fSAlex Hornung.Bl -tag -width LOGIN_PROCESSXX -compact -offset indent 16343f8178fSAlex Hornung.It Dv BOOT_TIME 16443f8178fSAlex HornungTime of a system boot. 16543f8178fSAlex Hornung.It Dv DEAD_PROCESS 16643f8178fSAlex HornungA session leader exited. 16743f8178fSAlex Hornung.It Dv EMPTY 16843f8178fSAlex HornungNo valid user accounting information. 16943f8178fSAlex Hornung.It Dv INIT_PROCESS 17043f8178fSAlex HornungA process spawned by 17143f8178fSAlex Hornung.Xr init 8 . 17243f8178fSAlex Hornung.It Dv LOGIN_PROCESS 17343f8178fSAlex HornungThe session leader of a logged-in user. 17443f8178fSAlex Hornung.It Dv NEW_TIME 17543f8178fSAlex HornungTime after system clock change. 17643f8178fSAlex Hornung.It Dv OLD_TIME 17743f8178fSAlex HornungTime before system clock change. 17843f8178fSAlex Hornung.It Dv RUN_LVL 17943f8178fSAlex HornungRun level. 18043f8178fSAlex HornungProvided for compatibility, not used on 18143f8178fSAlex Hornung.Nx . 18243f8178fSAlex Hornung.It Dv USER_PROCESS 18343f8178fSAlex HornungA user process. 18443f8178fSAlex Hornung.El 18543f8178fSAlex Hornung.Sh RETURN VALUES 18643f8178fSAlex Hornung.Fn getutxent 18743f8178fSAlex Hornungreturns the next entry, or 18843f8178fSAlex Hornung.Dv NULL 18943f8178fSAlex Hornungon failure (end of database or problems reading from the database). 19043f8178fSAlex Hornung.Fn getutxid 19143f8178fSAlex Hornungand 19243f8178fSAlex Hornung.Fn getutxline 19343f8178fSAlex Hornungreturn the matching structure on success, or 19443f8178fSAlex Hornung.Dv NULL 19543f8178fSAlex Hornungif no match was found. 19643f8178fSAlex Hornung.Fn pututxline 19743f8178fSAlex Hornungreturns the structure that was successfully written, or 19843f8178fSAlex Hornung.Dv NULL . 19943f8178fSAlex Hornung.Fn setutxdb 20043f8178fSAlex Hornungreturns 20143f8178fSAlex Hornung.Dv 0 20243f8178fSAlex Hornungon success. Otherwise a negative value is returned and the global 20343f8178fSAlex Hornungvariable 20443f8178fSAlex Hornung.Va errno 20543f8178fSAlex Hornungis set to indicate the error. 20643f8178fSAlex Hornung.Sh SEE ALSO 207*7c4f4eeeSSascha Wildner.Xr wtmpcvt 1 , 20843f8178fSAlex Hornung.Xr logwtmpx 3 , 20943f8178fSAlex Hornung.Xr utmpx 5 21043f8178fSAlex Hornung.Sh STANDARDS 21143f8178fSAlex HornungThe 21243f8178fSAlex Hornung.Fn endutxent , 21343f8178fSAlex Hornung.Fn getutxent , 21443f8178fSAlex Hornung.Fn getutxid , 21543f8178fSAlex Hornung.Fn getutxline , 21643f8178fSAlex Hornung.Fn pututxline , 21743f8178fSAlex Hornung.Fn setutxent 21843f8178fSAlex Hornungall conform to 21943f8178fSAlex Hornung.St -p1003.1-2001 22043f8178fSAlex Hornung(XSI extension), and previously to 22143f8178fSAlex Hornung.St -xpg4.2 . 22243f8178fSAlex HornungThe fields 22343f8178fSAlex Hornung.Fa ut_user , 22443f8178fSAlex Hornung.Fa ut_id , 22543f8178fSAlex Hornung.Fa ut_line , 22643f8178fSAlex Hornung.Fa ut_pid , 22743f8178fSAlex Hornung.Fa ut_type , 22843f8178fSAlex Hornungand 22943f8178fSAlex Hornung.Fa ut_tv 23043f8178fSAlex Hornungconform to 23143f8178fSAlex Hornung.St -p1003.1-2001 23243f8178fSAlex Hornung(XSI extension), and previously to 23343f8178fSAlex Hornung.St -xpg4.2 . 23443f8178fSAlex Hornung.\" .Fa ut_host , 23543f8178fSAlex Hornung.\" .Fa ut_session , 23643f8178fSAlex Hornung.\" .Fa ut_exit , 23743f8178fSAlex Hornung.\" and 23843f8178fSAlex Hornung.\" .Fa ut_ss 23943f8178fSAlex Hornung.\" are from 24043f8178fSAlex Hornung.\" SVR3/4? 24143f8178fSAlex Hornung.\" .Dv RUN_LVL 24243f8178fSAlex Hornung.\" is for compatibility with 24343f8178fSAlex Hornung.\" what exactly? 24443f8178fSAlex Hornung.\" .Sh HISTORY 24543f8178fSAlex Hornung.\" The 24643f8178fSAlex Hornung.\" .Nm utmpx , 24743f8178fSAlex Hornung.\" .Nm wtmpx , 24843f8178fSAlex Hornung.\" and 24943f8178fSAlex Hornung.\" .Nm lastlogx 25043f8178fSAlex Hornung.\" files first appeared in 25143f8178fSAlex Hornung.\" SVR3? 4? 252