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