]> andersk Git - openssh.git/blame - defines.h
- (djm) Tweak password expiry checking at suggestion of Kevin Steves
[openssh.git] / defines.h
CommitLineData
76a8e733 1#ifndef _DEFINES_H
2#define _DEFINES_H
3
ea1970a3 4/* Necessary headers */
5
a8ed9fd9 6#include <sys/types.h> /* For [u]intxx_t */
cb807f40 7#include <sys/socket.h> /* For SHUT_XXXX */
509b1f88 8#include <sys/param.h> /* For MAXPATHLEN */
ba606eb2 9#include <sys/un.h> /* For SUN_LEN */
509b1f88 10#include <netinet/in_systm.h> /* For typedefs */
a8ed9fd9 11#include <netinet/in.h> /* For IPv6 macros */
18e92801 12#include <netinet/ip.h> /* For IPTOS macros */
5cdfe03f 13#ifdef HAVE_SYS_BITYPES_H
14# include <sys/bitypes.h> /* For u_intXX_t */
15#endif
cb807f40 16#ifdef HAVE_PATHS_H
17# include <paths.h> /* For _PATH_XXX */
18#endif
509b1f88 19#ifdef HAVE_LIMITS_H
20# include <limits.h> /* For PATH_MAX */
21#endif
cb807f40 22#ifdef HAVE_SYS_TIME_H
23# include <sys/time.h> /* For timersub */
24#endif
cb807f40 25#ifdef HAVE_MAILLOCK_H
d94aa2ae 26# include <maillock.h> /* For _PATH_MAILDIR */
cb807f40 27#endif
d94aa2ae 28#ifdef HAVE_SYS_CDEFS_H
29# include <sys/cdefs.h> /* For __P() */
30#endif
d468fc76 31#ifdef HAVE_SYS_SYSMACROS_H
32# include <sys/sysmacros.h> /* For MIN, MAX, etc */
33#endif
729bfe59 34#ifdef HAVE_SYS_STAT_H
35# include <sys/stat.h> /* For S_* constants and macros */
36#endif
37
38#include <unistd.h> /* For STDIN_FILENO, etc */
d468fc76 39
ea1970a3 40/* Constants */
41
cb807f40 42#ifndef SHUT_RDWR
43enum
44{
45 SHUT_RD = 0, /* No more receptions. */
46 SHUT_WR, /* No more transmissions. */
47 SHUT_RDWR /* No more receptions or transmissions. */
48};
49# define SHUT_RD SHUT_RD
50# define SHUT_WR SHUT_WR
51# define SHUT_RDWR SHUT_RDWR
52#endif
53
18e92801 54#ifndef IPTOS_LOWDELAY
55# define IPTOS_LOWDELAY 0x10
56# define IPTOS_THROUGHPUT 0x08
57# define IPTOS_RELIABILITY 0x04
58# define IPTOS_LOWCOST 0x02
59# define IPTOS_MINCOST IPTOS_LOWCOST
60#endif /* IPTOS_LOWDELAY */
61
509b1f88 62#ifndef MAXPATHLEN
63# ifdef PATH_MAX
64# define MAXPATHLEN PATH_MAX
65# else /* PATH_MAX */
66# define MAXPATHLEN 64 /* Should be safe */
67# endif /* PATH_MAX */
68#endif /* MAXPATHLEN */
69
729bfe59 70#ifndef STDIN_FILENO
71# define STDIN_FILENO 0
72#endif
73#ifndef STDOUT_FILENO
74# define STDOUT_FILENO 1
75#endif
76#ifndef STDERR_FILENO
77# define STDERR_FILENO 2
78#endif
79
80#ifndef S_ISREG
81# define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR))
82# define S_ISREG(mode) (((mode) & (_S_IFMT)) == (_S_IFREG))
83#endif /* S_ISREG */
84
85#ifndef S_IXUSR
86# define S_IXUSR 0000100 /* execute/search permission, */
87# define S_IXGRP 0000010 /* execute/search permission, */
88# define S_IXOTH 0000001 /* execute/search permission, */
89# define _S_IWUSR 0000200 /* write permission, */
90# define S_IWUSR _S_IWUSR /* write permission, owner */
91# define S_IWGRP 0000020 /* write permission, group */
92# define S_IWOTH 0000002 /* write permission, other */
93# define S_IRUSR 0000400 /* read permission, owner */
94# define S_IRGRP 0000040 /* read permission, group */
95# define S_IROTH 0000004 /* read permission, other */
96# define S_IRWXU 0000700 /* read, write, execute */
97# define S_IRWXG 0000070 /* read, write, execute */
98# define S_IRWXO 0000007 /* read, write, execute */
99#endif /* S_IXUSR */
100
ea1970a3 101/* Types */
102
cb807f40 103/* If sys/types.h does not supply intXX_t, supply them ourselves */
104/* (or die trying) */
14a9a859 105
106#ifndef HAVE_U_INT
107typedef unsigned int u_int;
108#endif
109
cb807f40 110#ifndef HAVE_INTXX_T
976f7e19 111# if (SIZEOF_CHAR == 1)
112typedef char int8_t;
113# else
114# error "8 bit int type not found."
115# endif
cb807f40 116# if (SIZEOF_SHORT_INT == 2)
ea1970a3 117typedef short int int16_t;
cb807f40 118# else
119# error "16 bit int type not found."
120# endif
121# if (SIZEOF_INT == 4)
ea1970a3 122typedef int int32_t;
cb807f40 123# else
124# error "32 bit int type not found."
125# endif
cb807f40 126#endif
127
128/* If sys/types.h does not supply u_intXX_t, supply them ourselves */
129#ifndef HAVE_U_INTXX_T
130# ifdef HAVE_UINTXX_T
976f7e19 131typedef uint8_t u_int8_t;
ea1970a3 132typedef uint16_t u_int16_t;
133typedef uint32_t u_int32_t;
76a8e733 134# define HAVE_U_INTXX_T 1
cb807f40 135# else
976f7e19 136# if (SIZEOF_CHAR == 1)
137typedef unsigned char u_int8_t;
138# else
139# error "8 bit int type not found."
140# endif
cb807f40 141# if (SIZEOF_SHORT_INT == 2)
ea1970a3 142typedef unsigned short int u_int16_t;
cb807f40 143# else
144# error "16 bit int type not found."
145# endif
146# if (SIZEOF_INT == 4)
ea1970a3 147typedef unsigned int u_int32_t;
cb807f40 148# else
149# error "32 bit int type not found."
150# endif
bd590612 151# endif
152#endif
153
154/* 64-bit types */
155#ifndef HAVE_INT64_T
156# if (SIZEOF_LONG_INT == 8)
157typedef long int int64_t;
158# else
159# if (SIZEOF_LONG_LONG_INT == 8)
160typedef long long int int64_t;
161# define HAVE_INTXX_T 1
cb807f40 162# else
bd590612 163# error "64 bit int type not found."
164# endif
165# endif
166#endif
167#ifndef HAVE_U_INT64_T
168# if (SIZEOF_LONG_INT == 8)
169typedef unsigned long int u_int64_t;
170# else
171# if (SIZEOF_LONG_LONG_INT == 8)
ea1970a3 172typedef unsigned long long int u_int64_t;
bd590612 173# define HAVE_U_INTXX_T 1
174# else
175# error "64 bit int type not found."
cb807f40 176# endif
177# endif
178#endif
179
ea1970a3 180#ifndef HAVE_SOCKLEN_T
181typedef unsigned int socklen_t;
a6ddc88b 182# define HAVE_SOCKLEN_T
ea1970a3 183#endif /* HAVE_SOCKLEN_T */
184
e3a93db0 185#ifndef HAVE_SIZE_T
186typedef unsigned int size_t;
a6ddc88b 187# define HAVE_SIZE_T
e3a93db0 188#endif /* HAVE_SIZE_T */
189
c04f75f1 190#ifndef HAVE_SSIZE_T
191typedef int ssize_t;
192# define HAVE_SSIZE_T
193#endif /* HAVE_SSIZE_T */
194
1c04b088 195#ifndef HAVE_SA_FAMILY_T
196typedef int sa_family_t;
197# define HAVE_SA_FAMILY_T
198#endif /* HAVE_SA_FAMILY_T */
199
729bfe59 200#ifndef HAVE_PID_T
201typedef int pid_t;
202# define HAVE_PID_T
203#endif /* HAVE_PID_T */
204
205#ifndef HAVE_MODE_T
206typedef int mode_t;
207# define HAVE_MODE_T
208#endif /* HAVE_MODE_T */
209
48e671d5 210#if !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE___SS_FAMILY_IN_SS)
211# define ss_family __ss_family
212#endif /* !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE_SA_FAMILY_IN_SS) */
213
ea1970a3 214/* Paths */
215
cb807f40 216#ifndef _PATH_BSHELL
217# define _PATH_BSHELL "/bin/sh"
218#endif
219
220#ifdef USER_PATH
221# ifdef _PATH_STDPATH
222# undef _PATH_STDPATH
223# endif
224# define _PATH_STDPATH USER_PATH
225#endif
226
227#ifndef _PATH_STDPATH
228# define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
229#endif
230
231#ifndef _PATH_DEVNULL
232# define _PATH_DEVNULL "/dev/null"
233#endif
234
c04f75f1 235#ifndef MAIL_DIRECTORY
236# define MAIL_DIRECTORY "/var/spool/mail"
237#endif
238
cb807f40 239#ifndef MAILDIR
240# define MAILDIR MAIL_DIRECTORY
241#endif
242
243#if !defined(_PATH_MAILDIR) && defined(MAILDIR)
244# define _PATH_MAILDIR MAILDIR
245#endif /* !defined(_PATH_MAILDIR) && defined(MAILDIR) */
246
ea1970a3 247#ifndef _PATH_RSH
248# ifdef RSH_PATH
249# define _PATH_RSH RSH_PATH
250# endif /* RSH_PATH */
251#endif /* _PATH_RSH */
252
2e73a022 253#ifndef _PATH_NOLOGIN
254# define _PATH_NOLOGIN "/etc/nologin"
255#endif
256
ea1970a3 257/* Macros */
258
2e73a022 259#if defined(HAVE_LOGIN_GETCAPBOOL) && defined(HAVE_LOGIN_CAP_H)
260# define HAVE_LOGIN_CAP
261#endif
262
cb807f40 263#ifndef MAX
264# define MAX(a,b) (((a)>(b))?(a):(b))
265# define MIN(a,b) (((a)<(b))?(a):(b))
266#endif
267
268#ifndef timersub
269#define timersub(a, b, result) \
270 do { \
271 (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
272 (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
273 if ((result)->tv_usec < 0) { \
274 --(result)->tv_sec; \
275 (result)->tv_usec += 1000000; \
276 } \
277 } while (0)
278#endif
279
cb807f40 280#ifndef __P
281# define __P(x) x
282#endif
283
a8ed9fd9 284#if !defined(IN6_IS_ADDR_V4MAPPED)
285# define IN6_IS_ADDR_V4MAPPED(a) \
84afc958 286 ((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \
287 (((u_int32_t *) (a))[2] == htonl (0xffff)))
a8ed9fd9 288#endif /* !defined(IN6_IS_ADDR_V4MAPPED) */
289
cb807f40 290#if !defined(__GNUC__) || (__GNUC__ < 2)
976f7e19 291# define __attribute__(x)
cb807f40 292#endif /* !defined(__GNUC__) || (__GNUC__ < 2) */
293
ea1970a3 294#if defined(HAVE_SECURITY_PAM_APPL_H) && !defined(DISABLE_PAM)
295# define USE_PAM
296#endif /* defined(HAVE_SECURITY_PAM_APPL_H) && !defined(DISABLE_PAM) */
297
ba606eb2 298#ifndef SUN_LEN
299#define SUN_LEN(su) \
300 (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
301#endif /* SUN_LEN */
302
ea1970a3 303/* Function replacement / compatibility hacks */
304
305/* In older versions of libpam, pam_strerror takes a single argument */
306#ifdef HAVE_OLD_PAM
307# define PAM_STRERROR(a,b) pam_strerror((b))
308#else
309# define PAM_STRERROR(a,b) pam_strerror((a),(b))
310#endif
311
4c8ef3fb 312#if defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO)
313# undef HAVE_GETADDRINFO
314#endif /* defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO) */
315
c04f75f1 316#if !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY)
317# define memmove(s1, s2, n) bcopy((s2), (s1), (n))
318#endif /* !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) */
319
b9f446d1 320#if !defined(HAVE_ATEXIT) && defined(HAVE_ON_EXIT)
321# define atexit(a) on_exit(a)
322#endif /* !defined(HAVE_ATEXIT) && defined(HAVE_ON_EXIT) */
323
3c62e7eb 324#if defined(HAVE_VHANGUP) && !defined(BROKEN_VHANGUP)
325# define USE_VHANGUP
326#endif /* defined(HAVE_VHANGUP) && !defined(BROKEN_VHANGUP) */
327
7f8f5e00 328#ifndef GETPGRP_VOID
329# define getpgrp() getpgrp(0)
330#endif
331
1d7b9b20 332/**
333 ** login recorder definitions
334 **/
335
336/* preprocess */
337
338#ifdef HAVE_UTMP_H
339# ifdef HAVE_TIME_IN_UTMP
340# include <time.h>
341# endif
342# include <utmp.h>
343#endif
344#ifdef HAVE_UTMPX_H
345# ifdef HAVE_TV_IN_UTMPX
346# include <sys/time.h>
347# endif
348# include <utmpx.h>
349#endif
350#ifdef HAVE_LASTLOG_H
351# include <lastlog.h>
352#endif
353#ifdef HAVE_PATHS_H
354# include <paths.h>
355#endif
356
357/* FIXME: put default paths back in */
32eec038 358#ifndef UTMP_FILE
359# ifdef _PATH_UTMP
360# define UTMP_FILE _PATH_UTMP
361# else
362# ifdef CONF_UTMP_FILE
363# define UTMP_FILE CONF_UTMP_FILE
364# endif
365# endif
1d7b9b20 366#endif
32eec038 367#ifndef WTMP_FILE
368# ifdef _PATH_WTMP
369# define WTMP_FILE _PATH_WTMP
370# else
371# ifdef CONF_WTMP_FILE
372# define WTMP_FILE CONF_WTMP_FILE
373# endif
374# endif
1d7b9b20 375#endif
376/* pick up the user's location for lastlog if given */
32eec038 377#ifndef LASTLOG_FILE
378# ifdef _PATH_LASTLOG
379# define LASTLOG_FILE _PATH_LASTLOG
380# else
381# ifdef CONF_LASTLOG_FILE
382# define LASTLOG_FILE CONF_LASTLOG_FILE
383# endif
384# endif
d7c0f3d5 385#endif
1d7b9b20 386
387
388/* The login() library function in libutil is first choice */
389#if defined(HAVE_LOGIN) && !defined(DISABLE_LOGIN)
390# define USE_LOGIN
391
392#else
393/* Simply select your favourite login types. */
394/* Can't do if-else because some systems use several... <sigh> */
395# if defined(UTMPX_FILE) && !defined(DISABLE_UTMPX)
396# define USE_UTMPX
397# endif
398# if defined(UTMP_FILE) && !defined(DISABLE_UTMP)
399# define USE_UTMP
400# endif
401# if defined(WTMPX_FILE) && !defined(DISABLE_WTMPX)
402# define USE_WTMPX
403# endif
404# if defined(WTMP_FILE) && !defined(DISABLE_WTMP)
405# define USE_WTMP
406# endif
407
408#endif
409
410/* I hope that the presence of LASTLOG_FILE is enough to detect this */
411#if defined(LASTLOG_FILE) && !defined(DISABLE_LASTLOG)
412# define USE_LASTLOG
413#endif
414
415/* which type of time to use? (api.c) */
416#ifdef HAVE_SYS_TIME_H
417# define USE_TIMEVAL
418#endif
419
420/** end of login recorder definitions */
421
76a8e733 422#endif /* _DEFINES_H */
This page took 0.136958 seconds and 5 git commands to generate.