1 /* Necessary headers */
3 #include <sys/types.h> /* For u_intXX_t */
4 #include <sys/socket.h> /* For SHUT_XXXX */
7 # include <paths.h> /* For _PATH_XXX */
11 # include <utmp.h> /* For _PATH_XXX */
14 #if defined(HAVE_UTMPX_H) && defined(USE_UTMPX)
15 # include <utmpx.h> /* For _PATH_XXX */
18 #ifdef HAVE_SYS_TIME_H
19 # include <sys/time.h> /* For timersub */
22 #ifdef HAVE_MAILLOCK_H
23 # include <maillock.h> /* For _PATH_MAILDIR */
26 #ifdef HAVE_SYS_CDEFS_H
27 # include <sys/cdefs.h> /* For __P() */
35 SHUT_RD = 0, /* No more receptions. */
36 SHUT_WR, /* No more transmissions. */
37 SHUT_RDWR /* No more receptions or transmissions. */
39 # define SHUT_RD SHUT_RD
40 # define SHUT_WR SHUT_WR
41 # define SHUT_RDWR SHUT_RDWR
46 /* If sys/types.h does not supply intXX_t, supply them ourselves */
49 # if (SIZEOF_SHORT_INT == 2)
50 typedef short int int16_t;
52 # error "16 bit int type not found."
54 # if (SIZEOF_INT == 4)
57 # error "32 bit int type not found."
59 # if (SIZEOF_LONG_INT == 8)
60 typedef long int int64_t;
62 # if (SIZEOF_LONG_LONG_INT == 8)
63 typedef long long int int64_t;
65 # error "64 bit int type not found."
70 /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
71 #ifndef HAVE_U_INTXX_T
73 typedef uint16_t u_int16_t;
74 typedef uint32_t u_int32_t;
75 typedef uint64_t u_int64_t;
77 # if (SIZEOF_SHORT_INT == 2)
78 typedef unsigned short int u_int16_t;
80 # error "16 bit int type not found."
82 # if (SIZEOF_INT == 4)
83 typedef unsigned int u_int32_t;
85 # error "32 bit int type not found."
87 # if (SIZEOF_LONG_INT == 8)
88 typedef unsigned long int u_int64_t;
90 # if (SIZEOF_LONG_LONG_INT == 8)
91 typedef unsigned long long int u_int64_t;
93 # error "64 bit int type not found."
99 /* If quad_t is not supplied, then supply it now. We can rely on int64_t */
100 /* being defined by the above */
102 typedef int64_t quad_t;
105 #ifndef HAVE_SOCKLEN_T
106 typedef unsigned int socklen_t;
107 #endif /* HAVE_SOCKLEN_T */
111 /* If _PATH_LASTLOG is not defined by system headers, set it to the */
112 /* lastlog file detected by autoconf */
113 #ifndef _PATH_LASTLOG
114 # ifdef LASTLOG_LOCATION
115 # define _PATH_LASTLOG LASTLOG_LOCATION
121 # define _PATH_UTMP UTMP_FILE
123 # define _PATH_UTMP "/var/adm/utmp"
129 # define _PATH_WTMP WTMP_FILE
131 # define _PATH_WTMP "/var/adm/wtmp"
135 #if defined(HAVE_UTMPX_H) && defined(USE_UTMPX)
138 # define _PATH_UTMPX UTMPX_FILE
140 # define _PATH_UTMPX "/var/adm/utmpx"
145 # define _PATH_WTMPX WTMPX_FILE
147 # define _PATH_WTMPX "/var/adm/wtmp"
153 # define _PATH_BSHELL "/bin/sh"
157 # ifdef _PATH_STDPATH
158 # undef _PATH_STDPATH
160 # define _PATH_STDPATH USER_PATH
163 #ifndef _PATH_STDPATH
164 # define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
167 #ifndef _PATH_DEVNULL
168 # define _PATH_DEVNULL "/dev/null"
172 # define MAILDIR MAIL_DIRECTORY
175 #if !defined(_PATH_MAILDIR) && defined(MAILDIR)
176 # define _PATH_MAILDIR MAILDIR
177 #endif /* !defined(_PATH_MAILDIR) && defined(MAILDIR) */
181 # define _PATH_RSH RSH_PATH
182 # endif /* RSH_PATH */
183 #endif /* _PATH_RSH */
188 # define MAX(a,b) (((a)>(b))?(a):(b))
189 # define MIN(a,b) (((a)<(b))?(a):(b))
193 #define timersub(a, b, result) \
195 (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
196 (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
197 if ((result)->tv_usec < 0) { \
198 --(result)->tv_sec; \
199 (result)->tv_usec += 1000000; \
208 #if !defined(__GNUC__) || (__GNUC__ < 2)
209 # define __attribute__(x)
210 #endif /* !defined(__GNUC__) || (__GNUC__ < 2) */
212 #if defined(HAVE_SECURITY_PAM_APPL_H) && !defined(DISABLE_PAM)
214 #endif /* defined(HAVE_SECURITY_PAM_APPL_H) && !defined(DISABLE_PAM) */
216 /* Function replacement / compatibility hacks */
218 /* In older versions of libpam, pam_strerror takes a single argument */
220 # define PAM_STRERROR(a,b) pam_strerror((b))
222 # define PAM_STRERROR(a,b) pam_strerror((a),(b))
225 #if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID)
226 # define seteuid(a) setreuid(-1,a)
227 #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */
230 # define innetgr(a,b,c,d) (0)
231 #endif /* HAVE_INNETGR */