2 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * This code is derived from software contributed to The NetBSD Foundation
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
33 #include <sys/cdefs.h>
34 #include <sys/socket.h>
37 #define _PATH_UTMPX "/var/run/utmpx"
38 #define _PATH_WTMPX "/var/log/wtmpx"
39 #define _PATH_LASTLOGX "/var/log/lastlogx"
40 #define _PATH_UTMP_UPDATE "/usr/libexec/utmp_update"
42 #define _UTX_USERSIZE 32
43 #define _UTX_LINESIZE 32
45 #define _UTX_HOSTSIZE 256
47 #define UTX_USERSIZE _UTX_USERSIZE
48 #define UTX_LINESIZE _UTX_LINESIZE
49 #define UTX_IDSIZE _UTX_IDSIZE
50 #define UTX_HOSTSIZE _UTX_HOSTSIZE
58 #define INIT_PROCESS 5
59 #define LOGIN_PROCESS 6
60 #define USER_PROCESS 7
61 #define DEAD_PROCESS 8
68 * Strings placed in the ut_line field to indicate special type entries
70 #define RUNLVL_MSG "run-level %c"
71 #define BOOT_MSG "system boot"
72 #define OTIME_MSG "old time"
73 #define NTIME_MSG "new time"
74 #define DOWN_MSG "system down"
76 #define ut_user ut_name
77 #define ut_xtime ut_tv.tv_sec
87 uint16_t e_termination
; /* termination status */
88 uint16_t e_exit
; /* exit status */
92 char ut_name
[_UTX_USERSIZE
]; /* login name */
93 char ut_id
[_UTX_IDSIZE
]; /* inittab id */
94 char ut_line
[_UTX_LINESIZE
]; /* tty name */
95 char ut_host
[_UTX_HOSTSIZE
]; /* host name */
96 uint8_t ut_unused
[16]; /* reserved for future use */
97 uint16_t ut_session
; /* session id used for windowing */
98 uint16_t ut_type
; /* type of this entry */
99 pid_t ut_pid
; /* process id creating the entry */
100 struct exit_status ut_exit
; /* process termination/exit status */
101 struct sockaddr_storage ut_ss
; /* address where entry was made from */
102 struct timeval ut_tv
; /* time entry was created */
103 uint8_t ut_unused2
[16]; /* reserved for future use */
107 struct timeval ll_tv
; /* time entry was created */
108 char ll_line
[_UTX_LINESIZE
]; /* tty name */
109 char ll_host
[_UTX_HOSTSIZE
]; /* host name */
110 struct sockaddr_storage ll_ss
; /* address where entry was made from */
114 void endutxent(void);
115 struct utmpx
*getutxent(void);
116 struct utmpx
*getutxid(const struct utmpx
*);
117 struct utmpx
*getutxline(const struct utmpx
*);
118 struct utmpx
*pututxline(const struct utmpx
*);
119 void setutxent(void);
122 int _updwtmpx(const char *, const struct utmpx
*);
123 void updwtmpx(const char *, const struct utmpx
*);
124 struct lastlogx
*getlastlogx(const char *, uid_t
, struct lastlogx
*);
125 int updlastlogx(const char *, uid_t
, struct lastlogx
*);
127 void getutmp(const struct utmpx
*, struct utmp
*);
128 void getutmpx(const struct utmp
*, struct utmpx
*);
129 int utmpxname(const char *);
130 int setutxdb(utx_db_t
, char *);
134 #endif /* _UTMPX_H_ */