xref: /illumos-gate/usr/src/head/utmpx.h (revision b4203d75)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*ba3594baSGarrett D'Amore  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24*ba3594baSGarrett D'Amore  *
257c478bd9Sstevel@tonic-gate  * Copyright 1997 Sun Microsystems, Inc.  All rights reserved.
267c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
277c478bd9Sstevel@tonic-gate  */
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983,1984,1985,1986,1987,1988,1989 AT&T	*/
307c478bd9Sstevel@tonic-gate /*	  All Rights Reserved	*/
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate /*
337c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley 4.3 BSD
347c478bd9Sstevel@tonic-gate  * under license from the Regents of the University of California.
357c478bd9Sstevel@tonic-gate  */
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifndef _UTMPX_H
387c478bd9Sstevel@tonic-gate #define	_UTMPX_H
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
417c478bd9Sstevel@tonic-gate #include <sys/types.h>
427c478bd9Sstevel@tonic-gate #include <sys/time.h>
437c478bd9Sstevel@tonic-gate #include <utmp.h>
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
467c478bd9Sstevel@tonic-gate extern "C" {
477c478bd9Sstevel@tonic-gate #endif
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate #define	_UTMPX_FILE	"/var/adm/utmpx"
507c478bd9Sstevel@tonic-gate #define	_WTMPX_FILE	"/var/adm/wtmpx"
517c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
527c478bd9Sstevel@tonic-gate #define	UTMPX_FILE	_UTMPX_FILE
537c478bd9Sstevel@tonic-gate #define	WTMPX_FILE	_WTMPX_FILE
547c478bd9Sstevel@tonic-gate #endif
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate #define	ut_name	ut_user
577c478bd9Sstevel@tonic-gate #define	ut_xtime ut_tv.tv_sec
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate /*
607c478bd9Sstevel@tonic-gate  * This data structure describes the utmpx entries returned by
617c478bd9Sstevel@tonic-gate  * the getutxent(3c) family of APIs.  It does not (necessarily)
627c478bd9Sstevel@tonic-gate  * correspond to the contents of the utmpx or wtmpx files.
637c478bd9Sstevel@tonic-gate  *
647c478bd9Sstevel@tonic-gate  * Applications should only interact with this subsystem via
657c478bd9Sstevel@tonic-gate  * the getutxent(3c) family of APIs.
667c478bd9Sstevel@tonic-gate  */
677c478bd9Sstevel@tonic-gate struct utmpx {
687c478bd9Sstevel@tonic-gate 	char	ut_user[32];		/* user login name */
697c478bd9Sstevel@tonic-gate 	char	ut_id[4];		/* inittab id */
707c478bd9Sstevel@tonic-gate 	char	ut_line[32];		/* device name (console, lnxx) */
717c478bd9Sstevel@tonic-gate 	pid_t	ut_pid;			/* process id */
727c478bd9Sstevel@tonic-gate 	short	ut_type;		/* type of entry */
737c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
747c478bd9Sstevel@tonic-gate 	struct exit_status ut_exit;	/* process termination/exit status */
757c478bd9Sstevel@tonic-gate #else
767c478bd9Sstevel@tonic-gate 	struct ut_exit_status ut_exit;	/* process termination/exit status */
777c478bd9Sstevel@tonic-gate #endif
787c478bd9Sstevel@tonic-gate 	struct timeval ut_tv;		/* time entry was made */
797c478bd9Sstevel@tonic-gate 	int	ut_session;		/* session ID, used for windowing */
807c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
817c478bd9Sstevel@tonic-gate 	int	pad[5];			/* reserved for future use */
827c478bd9Sstevel@tonic-gate #else
837c478bd9Sstevel@tonic-gate 	int	__pad[5];		/* reserved for future use */
847c478bd9Sstevel@tonic-gate #endif
857c478bd9Sstevel@tonic-gate 	short	ut_syslen;		/* significant length of ut_host */
867c478bd9Sstevel@tonic-gate 					/*   including terminating null */
877c478bd9Sstevel@tonic-gate 	char	ut_host[257];		/* remote host name */
887c478bd9Sstevel@tonic-gate };
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate #include <sys/types32.h>
937c478bd9Sstevel@tonic-gate #include <inttypes.h>
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate /*
967c478bd9Sstevel@tonic-gate  * This data structure describes the utmp *file* contents using
977c478bd9Sstevel@tonic-gate  * fixed-width data types.  It should only be used by the implementation.
987c478bd9Sstevel@tonic-gate  *
997c478bd9Sstevel@tonic-gate  * Applications should use the getutxent(3c) family of routines to interact
1007c478bd9Sstevel@tonic-gate  * with this database.
1017c478bd9Sstevel@tonic-gate  */
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate struct futmpx {
1047c478bd9Sstevel@tonic-gate 	char	ut_user[32];		/* user login name */
1057c478bd9Sstevel@tonic-gate 	char	ut_id[4];		/* inittab id */
1067c478bd9Sstevel@tonic-gate 	char	ut_line[32];		/* device name (console, lnxx) */
1077c478bd9Sstevel@tonic-gate 	pid32_t	ut_pid;			/* process id */
1087c478bd9Sstevel@tonic-gate 	int16_t ut_type;		/* type of entry */
1097c478bd9Sstevel@tonic-gate 	struct {
1107c478bd9Sstevel@tonic-gate 		int16_t	e_termination;	/* process termination status */
1117c478bd9Sstevel@tonic-gate 		int16_t	e_exit;		/* process exit status */
1127c478bd9Sstevel@tonic-gate 	} ut_exit;			/* exit status of a process */
1137c478bd9Sstevel@tonic-gate 	struct timeval32 ut_tv;		/* time entry was made */
1147c478bd9Sstevel@tonic-gate 	int32_t	ut_session;		/* session ID, user for windowing */
1157c478bd9Sstevel@tonic-gate 	int32_t	pad[5];			/* reserved for future use */
1167c478bd9Sstevel@tonic-gate 	int16_t ut_syslen;		/* significant length of ut_host */
1177c478bd9Sstevel@tonic-gate 	char	ut_host[257];		/* remote host name */
1187c478bd9Sstevel@tonic-gate };
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate #define	MOD_WIN		10
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate /*	Define and macro for determing if a normal user wrote the entry */
1237c478bd9Sstevel@tonic-gate /*	and marking the utmpx entry as a normal user */
1247c478bd9Sstevel@tonic-gate #define	NONROOT_USRX	2
1257c478bd9Sstevel@tonic-gate #define	nonuserx(utx)	((utx).ut_exit.e_exit == NONROOT_USRX ? 1 : 0)
1267c478bd9Sstevel@tonic-gate #define	setuserx(utx)	((utx).ut_exit.e_exit = NONROOT_USRX)
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate extern void endutxent(void);
1317c478bd9Sstevel@tonic-gate extern struct utmpx *getutxent(void);
1327c478bd9Sstevel@tonic-gate extern struct utmpx *getutxid(const struct utmpx *);
1337c478bd9Sstevel@tonic-gate extern struct utmpx *getutxline(const struct utmpx *);
1347c478bd9Sstevel@tonic-gate extern struct utmpx *pututxline(const struct utmpx *);
1357c478bd9Sstevel@tonic-gate extern void setutxent(void);
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
1387c478bd9Sstevel@tonic-gate extern int utmpxname(const char *);
1397c478bd9Sstevel@tonic-gate extern struct utmpx *makeutx(const struct utmpx *);
1407c478bd9Sstevel@tonic-gate extern struct utmpx *modutx(const struct utmpx *);
1417c478bd9Sstevel@tonic-gate extern void getutmp(const struct utmpx *, struct utmp *);
1427c478bd9Sstevel@tonic-gate extern void getutmpx(const struct utmp *, struct utmpx *);
1437c478bd9Sstevel@tonic-gate extern void updwtmp(const char *, struct utmp *);
1447c478bd9Sstevel@tonic-gate extern void updwtmpx(const char *, struct utmpx *);
1457c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1487c478bd9Sstevel@tonic-gate }
1497c478bd9Sstevel@tonic-gate #endif
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate #endif	/* _UTMPX_H */
152