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 /* Copyright (c) 1988 AT&T */ 237c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* 27*ba3594baSGarrett D'Amore * Copyright 2014 Garrett D'Amore <garrett@damore.org> 28*ba3594baSGarrett D'Amore * 297c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 307c478bd9Sstevel@tonic-gate * Use is subject to license terms. 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifndef _UTMP_H 357c478bd9Sstevel@tonic-gate #define _UTMP_H 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate /* 387c478bd9Sstevel@tonic-gate * Note: The getutent(3c) family of interfaces are obsolete. 397c478bd9Sstevel@tonic-gate * The getutxent(3c) family provide a superset of this functionality 407c478bd9Sstevel@tonic-gate * and should be used in place of getutent(3c). 417c478bd9Sstevel@tonic-gate */ 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #include <sys/types.h> 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate #ifdef __cplusplus 467c478bd9Sstevel@tonic-gate extern "C" { 477c478bd9Sstevel@tonic-gate #endif 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 507c478bd9Sstevel@tonic-gate #define UTMP_FILE "/var/adm/utmp" 517c478bd9Sstevel@tonic-gate #define WTMP_FILE "/var/adm/wtmp" 527c478bd9Sstevel@tonic-gate #endif 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate #define ut_name ut_user 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 577c478bd9Sstevel@tonic-gate struct exit_status { 587c478bd9Sstevel@tonic-gate short e_termination; /* Process termination status */ 597c478bd9Sstevel@tonic-gate short e_exit; /* Process exit status */ 607c478bd9Sstevel@tonic-gate }; 617c478bd9Sstevel@tonic-gate #else 627c478bd9Sstevel@tonic-gate struct ut_exit_status { 637c478bd9Sstevel@tonic-gate short ut_e_termination; /* Process termination status */ 647c478bd9Sstevel@tonic-gate short ut_e_exit; /* Process exit status */ 657c478bd9Sstevel@tonic-gate }; 667c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate /* 717c478bd9Sstevel@tonic-gate * This data structure describes the utmp entries returned by 727c478bd9Sstevel@tonic-gate * the getutent(3c) family of APIs. It does not (necessarily) 737c478bd9Sstevel@tonic-gate * correspond to the contents of the utmp or wtmp files. 747c478bd9Sstevel@tonic-gate * 757c478bd9Sstevel@tonic-gate * Applications should only interact with this subsystem via 767c478bd9Sstevel@tonic-gate * the getutxent(3c) family of APIs, as the getutent(3c) family 777c478bd9Sstevel@tonic-gate * are obsolete. 787c478bd9Sstevel@tonic-gate */ 797c478bd9Sstevel@tonic-gate struct utmp { 807c478bd9Sstevel@tonic-gate char ut_user[8]; /* User login name */ 817c478bd9Sstevel@tonic-gate char ut_id[4]; /* /etc/inittab id(usually line #) */ 827c478bd9Sstevel@tonic-gate char ut_line[12]; /* device name (console, lnxx) */ 837c478bd9Sstevel@tonic-gate short ut_pid; /* short for compat. - process id */ 847c478bd9Sstevel@tonic-gate short ut_type; /* type of entry */ 857c478bd9Sstevel@tonic-gate struct exit_status ut_exit; /* The exit status of a process */ 867c478bd9Sstevel@tonic-gate /* marked as DEAD_PROCESS. */ 877c478bd9Sstevel@tonic-gate time_t ut_time; /* time entry was made */ 887c478bd9Sstevel@tonic-gate }; 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate #include <sys/types32.h> 917c478bd9Sstevel@tonic-gate #include <inttypes.h> 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate /* 947c478bd9Sstevel@tonic-gate * This data structure describes the utmp *file* contents using 957c478bd9Sstevel@tonic-gate * fixed-width data types. It should only be used by the implementation. 967c478bd9Sstevel@tonic-gate * 977c478bd9Sstevel@tonic-gate * Applications should use the getutxent(3c) family of routines to interact 987c478bd9Sstevel@tonic-gate * with this database. 997c478bd9Sstevel@tonic-gate */ 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate struct futmp { 1027c478bd9Sstevel@tonic-gate char ut_user[8]; /* User login name */ 1037c478bd9Sstevel@tonic-gate char ut_id[4]; /* /etc/inittab id */ 1047c478bd9Sstevel@tonic-gate char ut_line[12]; /* device name (console, lnxx) */ 1057c478bd9Sstevel@tonic-gate int16_t ut_pid; /* process id */ 1067c478bd9Sstevel@tonic-gate int16_t ut_type; /* type of entry */ 1077c478bd9Sstevel@tonic-gate struct { 1087c478bd9Sstevel@tonic-gate int16_t e_termination; /* Process termination status */ 1097c478bd9Sstevel@tonic-gate int16_t e_exit; /* Process exit status */ 1107c478bd9Sstevel@tonic-gate } ut_exit; /* The exit status of a process */ 1117c478bd9Sstevel@tonic-gate time32_t ut_time; /* time entry was made */ 1127c478bd9Sstevel@tonic-gate }; 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate /* Definitions for ut_type */ 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate #define EMPTY 0 1197c478bd9Sstevel@tonic-gate #define RUN_LVL 1 1207c478bd9Sstevel@tonic-gate #define BOOT_TIME 2 1217c478bd9Sstevel@tonic-gate #define OLD_TIME 3 1227c478bd9Sstevel@tonic-gate #define NEW_TIME 4 1237c478bd9Sstevel@tonic-gate #define INIT_PROCESS 5 /* Process spawned by "init" */ 1247c478bd9Sstevel@tonic-gate #define LOGIN_PROCESS 6 /* A "getty" process waiting for login */ 1257c478bd9Sstevel@tonic-gate #define USER_PROCESS 7 /* A user process */ 1267c478bd9Sstevel@tonic-gate #define DEAD_PROCESS 8 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate #define ACCOUNTING 9 1317c478bd9Sstevel@tonic-gate #define DOWN_TIME 10 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate #define UTMAXTYPE DOWN_TIME /* Largest legal value of ut_type */ 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate /* Special strings or formats used in the "ut_line" field when */ 1367c478bd9Sstevel@tonic-gate /* accounting for something other than a process. */ 1377c478bd9Sstevel@tonic-gate /* No string for the ut_line field can be more than 11 chars + */ 1387c478bd9Sstevel@tonic-gate /* a NULL in length. */ 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate #define RUNLVL_MSG "run-level %c" 1417c478bd9Sstevel@tonic-gate #define BOOT_MSG "system boot" 1427c478bd9Sstevel@tonic-gate #define OTIME_MSG "old time" 1437c478bd9Sstevel@tonic-gate #define NTIME_MSG "new time" 1447c478bd9Sstevel@tonic-gate #define PSRADM_MSG "%03d %s" /* processor on or off */ 1457c478bd9Sstevel@tonic-gate #define DOWN_MSG "system down" 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate /* Define and macro for determing if a normal user wrote the entry */ 1487c478bd9Sstevel@tonic-gate /* and marking the utmpx entry as a normal user */ 1497c478bd9Sstevel@tonic-gate #define NONROOT_USR 2 1507c478bd9Sstevel@tonic-gate #define nonuser(ut) ((ut).ut_exit.e_exit == NONROOT_USR ? 1 : 0) 1517c478bd9Sstevel@tonic-gate #define setuser(ut) ((ut).ut_exit.e_exit = NONROOT_USR) 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate extern void endutent(void); 1557c478bd9Sstevel@tonic-gate extern struct utmp *getutent(void); 1567c478bd9Sstevel@tonic-gate extern struct utmp *getutid(const struct utmp *); 1577c478bd9Sstevel@tonic-gate extern struct utmp *getutline(const struct utmp *); 1587c478bd9Sstevel@tonic-gate extern struct utmp *pututline(const struct utmp *); 1597c478bd9Sstevel@tonic-gate extern void setutent(void); 1607c478bd9Sstevel@tonic-gate extern int utmpname(const char *); 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1657c478bd9Sstevel@tonic-gate } 1667c478bd9Sstevel@tonic-gate #endif 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate #endif /* _UTMP_H */ 169