All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sysutmp.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15  */
16 #ifndef _FR_SYSUTMP_H
17 #define _FR_SYSUTMP_H
18 /**
19  * $Id: 3ffde24700b17a947be26a6635d4cb45dee36c19 $
20  *
21  * @file include/sysutmp.h
22  * @brief Compatibility stuff for the different UTMP systems.
23  *
24  * @copyright 2015 The FreeRADIUS server project
25  */
26 RCSIDH(sysutmp_h, "$Id: 3ffde24700b17a947be26a6635d4cb45dee36c19 $")
27 
28 /*
29  * If we have BOTH utmp.h and utmpx.h, then
30  * we prefer to use utmp.h, but only on systems other than Solaris.
31  */
32 #if !defined(__sun) && !defined(sgi) && !defined(hpux)
33 # ifdef HAVE_UTMP_H
34 # undef HAVE_UTMPX_H
35 # endif
36 #endif
37 
38 #if defined(HAVE_UTMP_H) || defined(HAVE_UTMPX_H)
39 
40 /* UTMP stuff. Uses utmpx on svr4 */
41 #ifdef HAVE_UTMPX_H
42 # include <utmpx.h>
43 # include <sys/fcntl.h>
44 # define utmp utmpx
45 # define UT_NAMESIZE 32
46 # define UT_LINESIZE 32
47 # define UT_HOSTSIZE 257
48 #if defined(hpux) || defined(__FreeBSD__)
49 # define ut_name ut_user
50 #endif
51 #else
52 # include <utmp.h>
53 #endif
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 #ifdef __osf__
60 # define UT_NAMESIZE 32
61 # define UT_LINESIZE 32
62 # define UT_HOSTSIZE 64
63 #endif
64 
65 #if (defined(__FreeBSD__) && !defined(HAVE_UTMPX_H)) || defined(__NetBSD__) || defined(bsdi) || defined(__OpenBSD__) || defined(__APPLE__)
66 # ifndef UTMP_FILE
67 # define UTMP_FILE "/var/run/utmp"
68 # endif
69 # define ut_user ut_name
70 #endif
71 
72 /*
73  * Generate definitions for systems which are too broken to
74  * do it themselves.
75  *
76  * Hmm... this means that we can probably get rid of a lot of
77  * the static defines above, as the following lines will generate
78  * the proper defines for any system.
79  */
80 #ifndef UT_LINESIZE
81 #define UT_LINESIZE sizeof(((struct utmp *) NULL)->ut_line)
82 #endif
83 
84 #ifndef UT_NAMESIZE
85 #define UT_NAMESIZE sizeof(((struct utmp *) NULL)->ut_user)
86 #endif
87 
88 #ifndef UT_HOSTSIZE
89 #define UT_HOSTSIZE sizeof(((struct utmp *) NULL)->ut_host)
90 #endif
91 
92 #else /* HAVE_UTMP_H */
93 
94 /*
95  * No <utmp.h> file - define stuff ourselves (minimally).
96  */
97 #define UT_LINESIZE 16
98 #define UT_NAMESIZE 16
99 #define UT_HOSTSIZE 16
100 
101 #define USER_PROCESS 7
102 #define DEAD_PROCESS 8
103 
104 #define UTMP_FILE "/var/run/utmp"
105 #define ut_name ut_user
106 
107 struct utmp {
108  short ut_type;
109  int ut_pid;
111  char ut_id[4];
112  long ut_time;
115  long ut_addr;
116 };
117 
118 #endif /* HAVE_UTMP_H */
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 #endif /* _FR_SYSUTMP_H */
long ut_time
Definition: sysutmp.h:112
#define RCSIDH(h, id)
Definition: build.h:136
long ut_addr
Definition: sysutmp.h:115
Definition: sysutmp.h:107
char ut_user[UT_NAMESIZE]
Definition: sysutmp.h:113
#define UT_HOSTSIZE
Definition: sysutmp.h:99
#define UT_LINESIZE
Definition: sysutmp.h:97
#define UT_NAMESIZE
Definition: sysutmp.h:98
char ut_host[UT_HOSTSIZE]
Definition: sysutmp.h:114
short ut_type
Definition: sysutmp.h:108
char ut_id[4]
Definition: sysutmp.h:111
char ut_line[UT_LINESIZE]
Definition: sysutmp.h:110
int ut_pid
Definition: sysutmp.h:109