Merge branch 'vendor/AWK'
[dragonfly.git] / crypto / openssh / defines.h
1 /*
2  * Copyright (c) 1999-2003 Damien Miller.  All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  */
24
25 #ifndef _DEFINES_H
26 #define _DEFINES_H
27
28 /* $Id: defines.h,v 1.164 2011/01/17 10:15:31 dtucker Exp $ */
29
30
31 /* Constants */
32
33 #if defined(HAVE_DECL_SHUT_RD) && HAVE_DECL_SHUT_RD == 0
34 enum
35 {
36   SHUT_RD = 0,          /* No more receptions.  */
37   SHUT_WR,                      /* No more transmissions.  */
38   SHUT_RDWR                     /* No more receptions or transmissions.  */
39 };
40 # define SHUT_RD   SHUT_RD
41 # define SHUT_WR   SHUT_WR
42 # define SHUT_RDWR SHUT_RDWR
43 #endif
44
45 /*
46  * Definitions for IP type of service (ip_tos)
47  */
48 #ifndef IPTOS_LOWDELAY
49 # define IPTOS_LOWDELAY          0x10
50 # define IPTOS_THROUGHPUT        0x08
51 # define IPTOS_RELIABILITY       0x04
52 # define IPTOS_LOWCOST           0x02
53 # define IPTOS_MINCOST           IPTOS_LOWCOST
54 #endif /* IPTOS_LOWDELAY */
55
56 /*
57  * Definitions for DiffServ Codepoints as per RFC2474
58  */
59 #ifndef IPTOS_DSCP_AF11
60 # define        IPTOS_DSCP_AF11         0x28
61 # define        IPTOS_DSCP_AF12         0x30
62 # define        IPTOS_DSCP_AF13         0x38
63 # define        IPTOS_DSCP_AF21         0x48
64 # define        IPTOS_DSCP_AF22         0x50
65 # define        IPTOS_DSCP_AF23         0x58
66 # define        IPTOS_DSCP_AF31         0x68
67 # define        IPTOS_DSCP_AF32         0x70
68 # define        IPTOS_DSCP_AF33         0x78
69 # define        IPTOS_DSCP_AF41         0x88
70 # define        IPTOS_DSCP_AF42         0x90
71 # define        IPTOS_DSCP_AF43         0x98
72 # define        IPTOS_DSCP_EF           0xb8
73 #endif /* IPTOS_DSCP_AF11 */
74 #ifndef IPTOS_DSCP_CS0
75 # define        IPTOS_DSCP_CS0          0x00
76 # define        IPTOS_DSCP_CS1          0x20
77 # define        IPTOS_DSCP_CS2          0x40
78 # define        IPTOS_DSCP_CS3          0x60
79 # define        IPTOS_DSCP_CS4          0x80
80 # define        IPTOS_DSCP_CS5          0xa0
81 # define        IPTOS_DSCP_CS6          0xc0
82 # define        IPTOS_DSCP_CS7          0xe0
83 #endif /* IPTOS_DSCP_CS0 */
84 #ifndef IPTOS_DSCP_EF
85 # define        IPTOS_DSCP_EF           0xb8
86 #endif /* IPTOS_DSCP_EF */
87
88 #ifndef MAXPATHLEN
89 # ifdef PATH_MAX
90 #  define MAXPATHLEN PATH_MAX
91 # else /* PATH_MAX */
92 #  define MAXPATHLEN 64
93 /* realpath uses a fixed buffer of size MAXPATHLEN, so force use of ours */
94 #  ifndef BROKEN_REALPATH
95 #   define BROKEN_REALPATH 1
96 #  endif /* BROKEN_REALPATH */
97 # endif /* PATH_MAX */
98 #endif /* MAXPATHLEN */
99
100 #ifndef PATH_MAX
101 # ifdef _POSIX_PATH_MAX
102 # define PATH_MAX _POSIX_PATH_MAX
103 # endif
104 #endif
105
106 #if defined(HAVE_DECL_MAXSYMLINKS) && HAVE_DECL_MAXSYMLINKS == 0
107 # define MAXSYMLINKS 5
108 #endif
109
110 #ifndef STDIN_FILENO
111 # define STDIN_FILENO    0
112 #endif
113 #ifndef STDOUT_FILENO
114 # define STDOUT_FILENO   1
115 #endif
116 #ifndef STDERR_FILENO
117 # define STDERR_FILENO   2
118 #endif
119
120 #ifndef NGROUPS_MAX     /* Disable groupaccess if NGROUP_MAX is not set */
121 #ifdef NGROUPS
122 #define NGROUPS_MAX NGROUPS
123 #else
124 #define NGROUPS_MAX 0
125 #endif
126 #endif
127
128 #if defined(HAVE_DECL_O_NONBLOCK) && HAVE_DECL_O_NONBLOCK == 0
129 # define O_NONBLOCK      00004  /* Non Blocking Open */
130 #endif
131
132 #ifndef S_ISDIR
133 # define S_ISDIR(mode)  (((mode) & (_S_IFMT)) == (_S_IFDIR))
134 #endif /* S_ISDIR */
135
136 #ifndef S_ISREG
137 # define S_ISREG(mode)  (((mode) & (_S_IFMT)) == (_S_IFREG))
138 #endif /* S_ISREG */
139
140 #ifndef S_ISLNK
141 # define S_ISLNK(mode)  (((mode) & S_IFMT) == S_IFLNK)
142 #endif /* S_ISLNK */
143
144 #ifndef S_IXUSR
145 # define S_IXUSR                        0000100 /* execute/search permission, */
146 # define S_IXGRP                        0000010 /* execute/search permission, */
147 # define S_IXOTH                        0000001 /* execute/search permission, */
148 # define _S_IWUSR                       0000200 /* write permission, */
149 # define S_IWUSR                        _S_IWUSR        /* write permission, owner */
150 # define S_IWGRP                        0000020 /* write permission, group */
151 # define S_IWOTH                        0000002 /* write permission, other */
152 # define S_IRUSR                        0000400 /* read permission, owner */
153 # define S_IRGRP                        0000040 /* read permission, group */
154 # define S_IROTH                        0000004 /* read permission, other */
155 # define S_IRWXU                        0000700 /* read, write, execute */
156 # define S_IRWXG                        0000070 /* read, write, execute */
157 # define S_IRWXO                        0000007 /* read, write, execute */
158 #endif /* S_IXUSR */
159
160 #if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)
161 #define MAP_ANON MAP_ANONYMOUS
162 #endif
163
164 #ifndef MAP_FAILED
165 # define MAP_FAILED ((void *)-1)
166 #endif
167
168 /* *-*-nto-qnx doesn't define this constant in the system headers */
169 #ifdef MISSING_NFDBITS
170 # define        NFDBITS (8 * sizeof(unsigned long))
171 #endif
172
173 /*
174 SCO Open Server 3 has INADDR_LOOPBACK defined in rpc/rpc.h but
175 including rpc/rpc.h breaks Solaris 6
176 */
177 #ifndef INADDR_LOOPBACK
178 #define INADDR_LOOPBACK ((u_long)0x7f000001)
179 #endif
180
181 /* Types */
182
183 /* If sys/types.h does not supply intXX_t, supply them ourselves */
184 /* (or die trying) */
185
186 #ifndef HAVE_U_INT
187 typedef unsigned int u_int;
188 #endif
189
190 #ifndef HAVE_INTXX_T
191 # if (SIZEOF_CHAR == 1)
192 typedef char int8_t;
193 # else
194 #  error "8 bit int type not found."
195 # endif
196 # if (SIZEOF_SHORT_INT == 2)
197 typedef short int int16_t;
198 # else
199 #  ifdef _UNICOS
200 #   if (SIZEOF_SHORT_INT == 4)
201 typedef short int16_t;
202 #   else
203 typedef long  int16_t;
204 #   endif
205 #  else
206 #   error "16 bit int type not found."
207 #  endif /* _UNICOS */
208 # endif
209 # if (SIZEOF_INT == 4)
210 typedef int int32_t;
211 # else
212 #  ifdef _UNICOS
213 typedef long  int32_t;
214 #  else
215 #   error "32 bit int type not found."
216 #  endif /* _UNICOS */
217 # endif
218 #endif
219
220 /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
221 #ifndef HAVE_U_INTXX_T
222 # ifdef HAVE_UINTXX_T
223 typedef uint8_t u_int8_t;
224 typedef uint16_t u_int16_t;
225 typedef uint32_t u_int32_t;
226 # define HAVE_U_INTXX_T 1
227 # else
228 #  if (SIZEOF_CHAR == 1)
229 typedef unsigned char u_int8_t;
230 #  else
231 #   error "8 bit int type not found."
232 #  endif
233 #  if (SIZEOF_SHORT_INT == 2)
234 typedef unsigned short int u_int16_t;
235 #  else
236 #   ifdef _UNICOS
237 #    if (SIZEOF_SHORT_INT == 4)
238 typedef unsigned short u_int16_t;
239 #    else
240 typedef unsigned long  u_int16_t;
241 #    endif
242 #   else
243 #    error "16 bit int type not found."
244 #   endif
245 #  endif
246 #  if (SIZEOF_INT == 4)
247 typedef unsigned int u_int32_t;
248 #  else
249 #   ifdef _UNICOS
250 typedef unsigned long  u_int32_t;
251 #   else
252 #    error "32 bit int type not found."
253 #   endif
254 #  endif
255 # endif
256 #define __BIT_TYPES_DEFINED__
257 #endif
258
259 /* 64-bit types */
260 #ifndef HAVE_INT64_T
261 # if (SIZEOF_LONG_INT == 8)
262 typedef long int int64_t;
263 # else
264 #  if (SIZEOF_LONG_LONG_INT == 8)
265 typedef long long int int64_t;
266 #  endif
267 # endif
268 #endif
269 #ifndef HAVE_U_INT64_T
270 # if (SIZEOF_LONG_INT == 8)
271 typedef unsigned long int u_int64_t;
272 # else
273 #  if (SIZEOF_LONG_LONG_INT == 8)
274 typedef unsigned long long int u_int64_t;
275 #  endif
276 # endif
277 #endif
278
279 #ifndef HAVE_U_CHAR
280 typedef unsigned char u_char;
281 # define HAVE_U_CHAR
282 #endif /* HAVE_U_CHAR */
283
284 #ifndef SIZE_T_MAX
285 #define SIZE_T_MAX ULONG_MAX
286 #endif /* SIZE_T_MAX */
287
288 #ifndef HAVE_SIZE_T
289 typedef unsigned int size_t;
290 # define HAVE_SIZE_T
291 # define SIZE_T_MAX UINT_MAX
292 #endif /* HAVE_SIZE_T */
293
294 #ifndef SIZE_MAX
295 #define SIZE_MAX SIZE_T_MAX
296 #endif
297
298 #ifndef HAVE_SSIZE_T
299 typedef int ssize_t;
300 # define HAVE_SSIZE_T
301 #endif /* HAVE_SSIZE_T */
302
303 #ifndef HAVE_CLOCK_T
304 typedef long clock_t;
305 # define HAVE_CLOCK_T
306 #endif /* HAVE_CLOCK_T */
307
308 #ifndef HAVE_SA_FAMILY_T
309 typedef int sa_family_t;
310 # define HAVE_SA_FAMILY_T
311 #endif /* HAVE_SA_FAMILY_T */
312
313 #ifndef HAVE_PID_T
314 typedef int pid_t;
315 # define HAVE_PID_T
316 #endif /* HAVE_PID_T */
317
318 #ifndef HAVE_SIG_ATOMIC_T
319 typedef int sig_atomic_t;
320 # define HAVE_SIG_ATOMIC_T
321 #endif /* HAVE_SIG_ATOMIC_T */
322
323 #ifndef HAVE_MODE_T
324 typedef int mode_t;
325 # define HAVE_MODE_T
326 #endif /* HAVE_MODE_T */
327
328 #if !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE___SS_FAMILY_IN_SS)
329 # define ss_family __ss_family
330 #endif /* !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE_SA_FAMILY_IN_SS) */
331
332 #ifndef HAVE_SYS_UN_H
333 struct  sockaddr_un {
334         short   sun_family;             /* AF_UNIX */
335         char    sun_path[108];          /* path name (gag) */
336 };
337 #endif /* HAVE_SYS_UN_H */
338
339 #ifndef HAVE_IN_ADDR_T
340 typedef u_int32_t       in_addr_t;
341 #endif
342 #ifndef HAVE_IN_PORT_T
343 typedef u_int16_t       in_port_t;
344 #endif
345
346 #if defined(BROKEN_SYS_TERMIO_H) && !defined(_STRUCT_WINSIZE)
347 #define _STRUCT_WINSIZE
348 struct winsize {
349       unsigned short ws_row;          /* rows, in characters */
350       unsigned short ws_col;          /* columns, in character */
351       unsigned short ws_xpixel;       /* horizontal size, pixels */
352       unsigned short ws_ypixel;       /* vertical size, pixels */
353 };
354 #endif
355
356 /* *-*-nto-qnx does not define this type in the system headers */
357 #ifdef MISSING_FD_MASK
358  typedef unsigned long int      fd_mask;
359 #endif
360
361 /* Paths */
362
363 #ifndef _PATH_BSHELL
364 # define _PATH_BSHELL "/bin/sh"
365 #endif
366
367 #ifdef USER_PATH
368 # ifdef _PATH_STDPATH
369 #  undef _PATH_STDPATH
370 # endif
371 # define _PATH_STDPATH USER_PATH
372 #endif
373
374 #ifndef _PATH_STDPATH
375 # define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
376 #endif
377
378 #ifndef SUPERUSER_PATH
379 # define SUPERUSER_PATH _PATH_STDPATH
380 #endif
381
382 #ifndef _PATH_DEVNULL
383 # define _PATH_DEVNULL "/dev/null"
384 #endif
385
386 #ifndef MAIL_DIRECTORY
387 # define MAIL_DIRECTORY "/var/spool/mail"
388 #endif
389
390 #ifndef MAILDIR
391 # define MAILDIR MAIL_DIRECTORY
392 #endif
393
394 #if !defined(_PATH_MAILDIR) && defined(MAILDIR)
395 # define _PATH_MAILDIR MAILDIR
396 #endif /* !defined(_PATH_MAILDIR) && defined(MAILDIR) */
397
398 #ifndef _PATH_NOLOGIN
399 # define _PATH_NOLOGIN "/etc/nologin"
400 #endif
401
402 /* Define this to be the path of the xauth program. */
403 #ifdef XAUTH_PATH
404 #define _PATH_XAUTH XAUTH_PATH
405 #endif /* XAUTH_PATH */
406
407 /* derived from XF4/xc/lib/dps/Xlibnet.h */
408 #ifndef X_UNIX_PATH
409 #  ifdef __hpux
410 #    define X_UNIX_PATH "/var/spool/sockets/X11/%u"
411 #  else
412 #    define X_UNIX_PATH "/tmp/.X11-unix/X%u"
413 #  endif
414 #endif /* X_UNIX_PATH */
415 #define _PATH_UNIX_X X_UNIX_PATH
416
417 #ifndef _PATH_TTY
418 # define _PATH_TTY "/dev/tty"
419 #endif
420
421 /* Macros */
422
423 #if defined(HAVE_LOGIN_GETCAPBOOL) && defined(HAVE_LOGIN_CAP_H)
424 # define HAVE_LOGIN_CAP
425 #endif
426
427 #ifndef MAX
428 # define MAX(a,b) (((a)>(b))?(a):(b))
429 # define MIN(a,b) (((a)<(b))?(a):(b))
430 #endif
431
432 #ifndef roundup
433 # define roundup(x, y)   ((((x)+((y)-1))/(y))*(y))
434 #endif
435
436 #ifndef timersub
437 #define timersub(a, b, result)                                  \
438    do {                                                         \
439       (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;             \
440       (result)->tv_usec = (a)->tv_usec - (b)->tv_usec;          \
441       if ((result)->tv_usec < 0) {                              \
442          --(result)->tv_sec;                                    \
443          (result)->tv_usec += 1000000;                          \
444       }                                                         \
445    } while (0)
446 #endif
447
448 #ifndef TIMEVAL_TO_TIMESPEC
449 #define TIMEVAL_TO_TIMESPEC(tv, ts) {                                   \
450         (ts)->tv_sec = (tv)->tv_sec;                                    \
451         (ts)->tv_nsec = (tv)->tv_usec * 1000;                           \
452 }
453 #endif
454
455 #ifndef TIMESPEC_TO_TIMEVAL
456 #define TIMESPEC_TO_TIMEVAL(tv, ts) {                                   \
457         (tv)->tv_sec = (ts)->tv_sec;                                    \
458         (tv)->tv_usec = (ts)->tv_nsec / 1000;                           \
459 }
460 #endif
461
462 #ifndef __P
463 # define __P(x) x
464 #endif
465
466 #if !defined(IN6_IS_ADDR_V4MAPPED)
467 # define IN6_IS_ADDR_V4MAPPED(a) \
468         ((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \
469          (((u_int32_t *) (a))[2] == htonl (0xffff)))
470 #endif /* !defined(IN6_IS_ADDR_V4MAPPED) */
471
472 #if !defined(__GNUC__) || (__GNUC__ < 2)
473 # define __attribute__(x)
474 #endif /* !defined(__GNUC__) || (__GNUC__ < 2) */
475
476 #if !defined(HAVE_ATTRIBUTE__SENTINEL__) && !defined(__sentinel__)
477 # define __sentinel__
478 #endif
479
480 #if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__bounded__)
481 # define __bounded__(x, y, z)
482 #endif
483
484 #if !defined(HAVE_ATTRIBUTE__NONNULL__) && !defined(__nonnull__)
485 # define __nonnull__(x)
486 #endif
487
488 /* *-*-nto-qnx doesn't define this macro in the system headers */
489 #ifdef MISSING_HOWMANY
490 # define howmany(x,y)   (((x)+((y)-1))/(y))
491 #endif
492
493 #ifndef OSSH_ALIGNBYTES
494 #define OSSH_ALIGNBYTES (sizeof(int) - 1)
495 #endif
496 #ifndef __CMSG_ALIGN
497 #define __CMSG_ALIGN(p) (((u_int)(p) + OSSH_ALIGNBYTES) &~ OSSH_ALIGNBYTES)
498 #endif
499
500 /* Length of the contents of a control message of length len */
501 #ifndef CMSG_LEN
502 #define CMSG_LEN(len)   (__CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
503 #endif
504
505 /* Length of the space taken up by a padded control message of length len */
506 #ifndef CMSG_SPACE
507 #define CMSG_SPACE(len) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + __CMSG_ALIGN(len))
508 #endif
509
510 /* given pointer to struct cmsghdr, return pointer to data */
511 #ifndef CMSG_DATA
512 #define CMSG_DATA(cmsg) ((u_char *)(cmsg) + __CMSG_ALIGN(sizeof(struct cmsghdr)))
513 #endif /* CMSG_DATA */
514
515 /*
516  * RFC 2292 requires to check msg_controllen, in case that the kernel returns
517  * an empty list for some reasons.
518  */
519 #ifndef CMSG_FIRSTHDR
520 #define CMSG_FIRSTHDR(mhdr) \
521         ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
522          (struct cmsghdr *)(mhdr)->msg_control : \
523          (struct cmsghdr *)NULL)
524 #endif /* CMSG_FIRSTHDR */
525
526 #if defined(HAVE_DECL_OFFSETOF) && HAVE_DECL_OFFSETOF == 0
527 # define offsetof(type, member) ((size_t) &((type *)0)->member)
528 #endif
529
530 /* Set up BSD-style BYTE_ORDER definition if it isn't there already */
531 /* XXX: doesn't try to cope with strange byte orders (PDP_ENDIAN) */
532 #ifndef BYTE_ORDER
533 # ifndef LITTLE_ENDIAN
534 #  define LITTLE_ENDIAN  1234
535 # endif /* LITTLE_ENDIAN */
536 # ifndef BIG_ENDIAN
537 #  define BIG_ENDIAN     4321
538 # endif /* BIG_ENDIAN */
539 # ifdef WORDS_BIGENDIAN
540 #  define BYTE_ORDER BIG_ENDIAN
541 # else /* WORDS_BIGENDIAN */
542 #  define BYTE_ORDER LITTLE_ENDIAN
543 # endif /* WORDS_BIGENDIAN */
544 #endif /* BYTE_ORDER */
545
546 /* Function replacement / compatibility hacks */
547
548 #if !defined(HAVE_GETADDRINFO) && (defined(HAVE_OGETADDRINFO) || defined(HAVE_NGETADDRINFO))
549 # define HAVE_GETADDRINFO
550 #endif
551
552 #ifndef HAVE_GETOPT_OPTRESET
553 # undef getopt
554 # undef opterr
555 # undef optind
556 # undef optopt
557 # undef optreset
558 # undef optarg
559 # define getopt(ac, av, o)  BSDgetopt(ac, av, o)
560 # define opterr             BSDopterr
561 # define optind             BSDoptind
562 # define optopt             BSDoptopt
563 # define optreset           BSDoptreset
564 # define optarg             BSDoptarg
565 #endif
566
567 #if defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO)
568 # undef HAVE_GETADDRINFO
569 #endif
570 #if defined(BROKEN_GETADDRINFO) && defined(HAVE_FREEADDRINFO)
571 # undef HAVE_FREEADDRINFO
572 #endif
573 #if defined(BROKEN_GETADDRINFO) && defined(HAVE_GAI_STRERROR)
574 # undef HAVE_GAI_STRERROR
575 #endif
576
577 #if defined(BROKEN_UPDWTMPX) && defined(HAVE_UPDWTMPX)
578 # undef HAVE_UPDWTMPX
579 #endif
580
581 #if defined(BROKEN_SHADOW_EXPIRE) && defined(HAS_SHADOW_EXPIRE)
582 # undef HAS_SHADOW_EXPIRE
583 #endif
584
585 #if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT) && \
586     defined(SYSLOG_R_SAFE_IN_SIGHAND)
587 # define DO_LOG_SAFE_IN_SIGHAND
588 #endif
589
590 #if !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY)
591 # define memmove(s1, s2, n) bcopy((s2), (s1), (n))
592 #endif /* !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) */
593
594 #if defined(HAVE_VHANGUP) && !defined(HAVE_DEV_PTMX)
595 #  define USE_VHANGUP
596 #endif /* defined(HAVE_VHANGUP) && !defined(HAVE_DEV_PTMX) */
597
598 #ifndef GETPGRP_VOID
599 # include <unistd.h>
600 # define getpgrp() getpgrp(0)
601 #endif
602
603 #ifdef USE_BSM_AUDIT
604 # define SSH_AUDIT_EVENTS
605 # define CUSTOM_SSH_AUDIT_EVENTS
606 #endif
607
608 #ifdef USE_LINUX_AUDIT
609 # define SSH_AUDIT_EVENTS
610 # define CUSTOM_SSH_AUDIT_EVENTS
611 #endif
612
613 #if !defined(HAVE___func__) && defined(HAVE___FUNCTION__)
614 #  define __func__ __FUNCTION__
615 #elif !defined(HAVE___func__)
616 #  define __func__ ""
617 #endif
618
619 #if defined(KRB5) && !defined(HEIMDAL)
620 #  define krb5_get_err_text(context,code) error_message(code)
621 #endif
622
623 #if defined(SKEYCHALLENGE_4ARG)
624 # define _compat_skeychallenge(a,b,c,d) skeychallenge(a,b,c,d)
625 #else
626 # define _compat_skeychallenge(a,b,c,d) skeychallenge(a,b,c)
627 #endif
628
629 /* Maximum number of file descriptors available */
630 #ifdef HAVE_SYSCONF
631 # define SSH_SYSFDMAX sysconf(_SC_OPEN_MAX)
632 #else
633 # define SSH_SYSFDMAX 10000
634 #endif
635
636 #ifdef FSID_HAS_VAL
637 /* encode f_fsid into a 64 bit value  */
638 #define FSID_TO_ULONG(f) \
639         ((((u_int64_t)(f).val[0] & 0xffffffffUL) << 32) | \
640             ((f).val[1] & 0xffffffffUL))
641 #elif defined(FSID_HAS___VAL)
642 #define FSID_TO_ULONG(f) \
643         ((((u_int64_t)(f).__val[0] & 0xffffffffUL) << 32) | \
644             ((f).__val[1] & 0xffffffffUL))
645 #else
646 # define FSID_TO_ULONG(f) ((f))
647 #endif
648
649 #if defined(__Lynx__)
650  /*
651   * LynxOS defines these in param.h which we do not want to include since
652   * it will also pull in a bunch of kernel definitions.
653   */
654 # define ALIGNBYTES (sizeof(int) - 1)
655 # define ALIGN(p) (((unsigned)p + ALIGNBYTES) & ~ALIGNBYTES)
656   /* Missing prototypes on LynxOS */
657   int snprintf (char *, size_t, const char *, ...);
658   int mkstemp (char *);
659   char *crypt (const char *, const char *);
660   int seteuid (uid_t);
661   int setegid (gid_t);
662   char *mkdtemp (char *);
663   int rresvport_af (int *, sa_family_t);
664   int innetgr (const char *, const char *, const char *, const char *);
665 #endif
666
667 /*
668  * Define this to use pipes instead of socketpairs for communicating with the
669  * client program.  Socketpairs do not seem to work on all systems.
670  *
671  * configure.ac sets this for a few OS's which are known to have problems
672  * but you may need to set it yourself
673  */
674 /* #define USE_PIPES 1 */
675
676 /**
677  ** login recorder definitions
678  **/
679
680 /* FIXME: put default paths back in */
681 #ifndef UTMP_FILE
682 #  ifdef _PATH_UTMP
683 #    define UTMP_FILE _PATH_UTMP
684 #  else
685 #    ifdef CONF_UTMP_FILE
686 #      define UTMP_FILE CONF_UTMP_FILE
687 #    endif
688 #  endif
689 #endif
690 #ifndef WTMP_FILE
691 #  ifdef _PATH_WTMP
692 #    define WTMP_FILE _PATH_WTMP
693 #  else
694 #    ifdef CONF_WTMP_FILE
695 #      define WTMP_FILE CONF_WTMP_FILE
696 #    endif
697 #  endif
698 #endif
699 /* pick up the user's location for lastlog if given */
700 #ifndef LASTLOG_FILE
701 #  ifdef _PATH_LASTLOG
702 #    define LASTLOG_FILE _PATH_LASTLOG
703 #  else
704 #    ifdef CONF_LASTLOG_FILE
705 #      define LASTLOG_FILE CONF_LASTLOG_FILE
706 #    endif
707 #  endif
708 #endif
709
710 #if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW)
711 # define USE_SHADOW
712 #endif
713
714 /* The login() library function in libutil is first choice */
715 #if defined(HAVE_LOGIN) && !defined(DISABLE_LOGIN)
716 #  define USE_LOGIN
717
718 #else
719 /* Simply select your favourite login types. */
720 /* Can't do if-else because some systems use several... <sigh> */
721 #  if !defined(DISABLE_UTMPX)
722 #    define USE_UTMPX
723 #  endif
724 #  if defined(UTMP_FILE) && !defined(DISABLE_UTMP)
725 #    define USE_UTMP
726 #  endif
727 #  if defined(WTMPX_FILE) && !defined(DISABLE_WTMPX)
728 #    define USE_WTMPX
729 #  endif
730 #  if defined(WTMP_FILE) && !defined(DISABLE_WTMP)
731 #    define USE_WTMP
732 #  endif
733
734 #endif
735
736 #ifndef UT_LINESIZE
737 # define UT_LINESIZE 8
738 #endif
739
740 /* I hope that the presence of LASTLOG_FILE is enough to detect this */
741 #if defined(LASTLOG_FILE) && !defined(DISABLE_LASTLOG)
742 #  define USE_LASTLOG
743 #endif
744
745 #ifdef HAVE_OSF_SIA
746 # ifdef USE_SHADOW
747 #  undef USE_SHADOW
748 # endif
749 # define CUSTOM_SYS_AUTH_PASSWD 1
750 #endif
751
752 #if defined(HAVE_LIBIAF) && defined(HAVE_SET_ID) && !defined(HAVE_SECUREWARE)
753 # define CUSTOM_SYS_AUTH_PASSWD 1
754 #endif
755 #if defined(HAVE_LIBIAF) && defined(HAVE_SET_ID) && !defined(BROKEN_LIBIAF)
756 # define USE_LIBIAF
757 #endif
758
759 /* HP-UX 11.11 */
760 #ifdef BTMP_FILE
761 # define _PATH_BTMP BTMP_FILE
762 #endif
763
764 #if defined(USE_BTMP) && defined(_PATH_BTMP)
765 # define CUSTOM_FAILED_LOGIN
766 #endif
767
768 /** end of login recorder definitions */
769
770 #ifdef BROKEN_GETGROUPS
771 # define getgroups(a,b) ((a)==0 && (b)==NULL ? NGROUPS_MAX : getgroups((a),(b)))
772 #endif
773
774 #if defined(HAVE_MMAP) && defined(BROKEN_MMAP)
775 # undef HAVE_MMAP
776 #endif
777
778 #ifndef IOV_MAX
779 # if defined(_XOPEN_IOV_MAX)
780 #  define       IOV_MAX         _XOPEN_IOV_MAX
781 # elif defined(DEF_IOV_MAX)
782 #  define       IOV_MAX         DEF_IOV_MAX
783 # else
784 #  define       IOV_MAX         16
785 # endif
786 #endif
787
788 #ifndef EWOULDBLOCK
789 # define EWOULDBLOCK EAGAIN
790 #endif
791
792 #ifndef INET6_ADDRSTRLEN        /* for non IPv6 machines */
793 #define INET6_ADDRSTRLEN 46
794 #endif
795
796 #ifndef SSH_IOBUFSZ
797 # define SSH_IOBUFSZ 8192
798 #endif
799
800 #ifndef _NSIG
801 # ifdef NSIG
802 #  define _NSIG NSIG
803 # else
804 #  define _NSIG 128
805 # endif
806 #endif
807
808 #endif /* _DEFINES_H */