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