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