xref: /titanic_53/usr/src/head/utmpx.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 1997 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983,1984,1985,1986,1987,1988,1989 AT&T	*/
28*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate /*
31*7c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley 4.3 BSD
32*7c478bd9Sstevel@tonic-gate  * under license from the Regents of the University of California.
33*7c478bd9Sstevel@tonic-gate  */
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate #ifndef _UTMPX_H
36*7c478bd9Sstevel@tonic-gate #define	_UTMPX_H
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
41*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
42*7c478bd9Sstevel@tonic-gate #include <sys/time.h>
43*7c478bd9Sstevel@tonic-gate #include <utmp.h>
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
46*7c478bd9Sstevel@tonic-gate extern "C" {
47*7c478bd9Sstevel@tonic-gate #endif
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate #define	_UTMPX_FILE	"/var/adm/utmpx"
50*7c478bd9Sstevel@tonic-gate #define	_WTMPX_FILE	"/var/adm/wtmpx"
51*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
52*7c478bd9Sstevel@tonic-gate #define	UTMPX_FILE	_UTMPX_FILE
53*7c478bd9Sstevel@tonic-gate #define	WTMPX_FILE	_WTMPX_FILE
54*7c478bd9Sstevel@tonic-gate #endif
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate #define	ut_name	ut_user
57*7c478bd9Sstevel@tonic-gate #define	ut_xtime ut_tv.tv_sec
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate /*
60*7c478bd9Sstevel@tonic-gate  * This data structure describes the utmpx entries returned by
61*7c478bd9Sstevel@tonic-gate  * the getutxent(3c) family of APIs.  It does not (necessarily)
62*7c478bd9Sstevel@tonic-gate  * correspond to the contents of the utmpx or wtmpx files.
63*7c478bd9Sstevel@tonic-gate  *
64*7c478bd9Sstevel@tonic-gate  * Applications should only interact with this subsystem via
65*7c478bd9Sstevel@tonic-gate  * the getutxent(3c) family of APIs.
66*7c478bd9Sstevel@tonic-gate  */
67*7c478bd9Sstevel@tonic-gate struct utmpx {
68*7c478bd9Sstevel@tonic-gate 	char	ut_user[32];		/* user login name */
69*7c478bd9Sstevel@tonic-gate 	char	ut_id[4];		/* inittab id */
70*7c478bd9Sstevel@tonic-gate 	char	ut_line[32];		/* device name (console, lnxx) */
71*7c478bd9Sstevel@tonic-gate 	pid_t	ut_pid;			/* process id */
72*7c478bd9Sstevel@tonic-gate 	short	ut_type;		/* type of entry */
73*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
74*7c478bd9Sstevel@tonic-gate 	struct exit_status ut_exit;	/* process termination/exit status */
75*7c478bd9Sstevel@tonic-gate #else
76*7c478bd9Sstevel@tonic-gate 	struct ut_exit_status ut_exit;	/* process termination/exit status */
77*7c478bd9Sstevel@tonic-gate #endif
78*7c478bd9Sstevel@tonic-gate 	struct timeval ut_tv;		/* time entry was made */
79*7c478bd9Sstevel@tonic-gate 	int	ut_session;		/* session ID, used for windowing */
80*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
81*7c478bd9Sstevel@tonic-gate 	int	pad[5];			/* reserved for future use */
82*7c478bd9Sstevel@tonic-gate #else
83*7c478bd9Sstevel@tonic-gate 	int	__pad[5];		/* reserved for future use */
84*7c478bd9Sstevel@tonic-gate #endif
85*7c478bd9Sstevel@tonic-gate 	short	ut_syslen;		/* significant length of ut_host */
86*7c478bd9Sstevel@tonic-gate 					/*   including terminating null */
87*7c478bd9Sstevel@tonic-gate 	char	ut_host[257];		/* remote host name */
88*7c478bd9Sstevel@tonic-gate };
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate #include <sys/types32.h>
93*7c478bd9Sstevel@tonic-gate #include <inttypes.h>
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate /*
96*7c478bd9Sstevel@tonic-gate  * This data structure describes the utmp *file* contents using
97*7c478bd9Sstevel@tonic-gate  * fixed-width data types.  It should only be used by the implementation.
98*7c478bd9Sstevel@tonic-gate  *
99*7c478bd9Sstevel@tonic-gate  * Applications should use the getutxent(3c) family of routines to interact
100*7c478bd9Sstevel@tonic-gate  * with this database.
101*7c478bd9Sstevel@tonic-gate  */
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate struct futmpx {
104*7c478bd9Sstevel@tonic-gate 	char	ut_user[32];		/* user login name */
105*7c478bd9Sstevel@tonic-gate 	char	ut_id[4];		/* inittab id */
106*7c478bd9Sstevel@tonic-gate 	char	ut_line[32];		/* device name (console, lnxx) */
107*7c478bd9Sstevel@tonic-gate 	pid32_t	ut_pid;			/* process id */
108*7c478bd9Sstevel@tonic-gate 	int16_t ut_type;		/* type of entry */
109*7c478bd9Sstevel@tonic-gate 	struct {
110*7c478bd9Sstevel@tonic-gate 		int16_t	e_termination;	/* process termination status */
111*7c478bd9Sstevel@tonic-gate 		int16_t	e_exit;		/* process exit status */
112*7c478bd9Sstevel@tonic-gate 	} ut_exit;			/* exit status of a process */
113*7c478bd9Sstevel@tonic-gate 	struct timeval32 ut_tv;		/* time entry was made */
114*7c478bd9Sstevel@tonic-gate 	int32_t	ut_session;		/* session ID, user for windowing */
115*7c478bd9Sstevel@tonic-gate 	int32_t	pad[5];			/* reserved for future use */
116*7c478bd9Sstevel@tonic-gate 	int16_t ut_syslen;		/* significant length of ut_host */
117*7c478bd9Sstevel@tonic-gate 	char	ut_host[257];		/* remote host name */
118*7c478bd9Sstevel@tonic-gate };
119*7c478bd9Sstevel@tonic-gate 
120*7c478bd9Sstevel@tonic-gate #define	MOD_WIN		10
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate /*	Define and macro for determing if a normal user wrote the entry */
123*7c478bd9Sstevel@tonic-gate /*	and marking the utmpx entry as a normal user */
124*7c478bd9Sstevel@tonic-gate #define	NONROOT_USRX	2
125*7c478bd9Sstevel@tonic-gate #define	nonuserx(utx)	((utx).ut_exit.e_exit == NONROOT_USRX ? 1 : 0)
126*7c478bd9Sstevel@tonic-gate #define	setuserx(utx)	((utx).ut_exit.e_exit = NONROOT_USRX)
127*7c478bd9Sstevel@tonic-gate 
128*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
129*7c478bd9Sstevel@tonic-gate 
130*7c478bd9Sstevel@tonic-gate #if defined(__STDC__)
131*7c478bd9Sstevel@tonic-gate 
132*7c478bd9Sstevel@tonic-gate extern void endutxent(void);
133*7c478bd9Sstevel@tonic-gate extern struct utmpx *getutxent(void);
134*7c478bd9Sstevel@tonic-gate extern struct utmpx *getutxid(const struct utmpx *);
135*7c478bd9Sstevel@tonic-gate extern struct utmpx *getutxline(const struct utmpx *);
136*7c478bd9Sstevel@tonic-gate extern struct utmpx *pututxline(const struct utmpx *);
137*7c478bd9Sstevel@tonic-gate extern void setutxent(void);
138*7c478bd9Sstevel@tonic-gate 
139*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
140*7c478bd9Sstevel@tonic-gate extern int utmpxname(const char *);
141*7c478bd9Sstevel@tonic-gate extern struct utmpx *makeutx(const struct utmpx *);
142*7c478bd9Sstevel@tonic-gate extern struct utmpx *modutx(const struct utmpx *);
143*7c478bd9Sstevel@tonic-gate extern void getutmp(const struct utmpx *, struct utmp *);
144*7c478bd9Sstevel@tonic-gate extern void getutmpx(const struct utmp *, struct utmpx *);
145*7c478bd9Sstevel@tonic-gate extern void updwtmp(const char *, struct utmp *);
146*7c478bd9Sstevel@tonic-gate extern void updwtmpx(const char *, struct utmpx *);
147*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
148*7c478bd9Sstevel@tonic-gate 
149*7c478bd9Sstevel@tonic-gate #else /* __STDC__ */
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate extern void endutxent();
152*7c478bd9Sstevel@tonic-gate extern struct utmpx *getutxent();
153*7c478bd9Sstevel@tonic-gate extern struct utmpx *getutxid();
154*7c478bd9Sstevel@tonic-gate extern struct utmpx *getutxline();
155*7c478bd9Sstevel@tonic-gate extern struct utmpx *pututxline();
156*7c478bd9Sstevel@tonic-gate extern void setutxent();
157*7c478bd9Sstevel@tonic-gate 
158*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
159*7c478bd9Sstevel@tonic-gate extern int utmpxname();
160*7c478bd9Sstevel@tonic-gate extern struct utmpx *makeutx();
161*7c478bd9Sstevel@tonic-gate extern struct utmpx *modutx();
162*7c478bd9Sstevel@tonic-gate extern void getutmp();
163*7c478bd9Sstevel@tonic-gate extern void getutmpx();
164*7c478bd9Sstevel@tonic-gate extern void updwtmp();
165*7c478bd9Sstevel@tonic-gate extern void updwtmpx();
166*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate #endif /* __STDC__ */
169*7c478bd9Sstevel@tonic-gate 
170*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
171*7c478bd9Sstevel@tonic-gate }
172*7c478bd9Sstevel@tonic-gate #endif
173*7c478bd9Sstevel@tonic-gate 
174*7c478bd9Sstevel@tonic-gate #endif	/* _UTMPX_H */
175