4 Unix SMB/Netbios implementation.
6 Machine customisation and include handling
7 Copyright (C) Andrew Tridgell 1994-1997
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 This file does all the #includes's. This makes it easier to
25 port to a new unix. Hopefully a port will only have to edit the Makefile
26 and add a section for the new unix below.
30 /* the first OS dependent section is to setup what includes will be used.
31 the main OS dependent section comes later on
98 #define REPLACE_MKTIME
112 #if (defined(SHADOW_PWD)||defined(OSF1_ENH_SEC)||defined(SecureWare)||defined(PWDAUTH))
113 #define PASSWORD_LENGTH 16
116 /* here is the general includes section - with some ifdefs generated
117 by the previous section
122 #include <posix/stdlib.h>
131 #include <sys/types.h>
134 #include <sys/statfs.h>
135 #include <sys/stream.h>
136 #include <netinet/types.h>
137 #include <netinet/ether.h>
138 #include <netinet/ip_if.h>
141 #include <sys/socket.h>
145 #include <sys/ioctl.h>
148 #include <posix/utime.h>
149 #include <bsd/sys/time.h>
150 #include <bsd/netinet/in.h>
152 #include <sys/time.h>
153 #include <netinet/in.h>
158 #include <sys/file.h>
159 #include <sys/stat.h>
160 #include <sys/param.h>
163 #include <sys/resource.h>
166 #include <sys/mount.h>
177 #include <sys/wait.h>
179 #include <sys/stream.h>
183 #include <bsd/net/if.h>
189 #if defined(GETPWANAM)
190 #include <sys/types.h>
191 #include <sys/label.h>
192 #include <sys/audit.h>
196 #if defined(SHADOW_PWD) && !defined(NETBSD) && !defined(FreeBSD) && !defined(CONVEX)
206 /***************************************************************************
207 Here come some platform specific sections
208 ***************************************************************************/
212 #include <arpa/inet.h>
216 #include <netinet/in.h>
217 #ifndef NO_ASMSIGNALH
218 #include <asm/signal.h>
220 #define SIGNAL_CAST (__sighandler_t)
225 #define USE_SIGPROCMASK
228 /* SETFS disabled until we can check on some bug reports */
229 #if _LINUX_C_LIB_VERSION_MAJOR >= 5
234 #if _LINUX_C_LIB_VERSION_MAJOR < 5
236 #define crypt pw_encrypt
243 #define SIGNAL_CAST (void (*)(int))
244 #include <netinet/tcp.h>
246 #include <sys/acct.h>
250 #include <sys/wait.h>
252 /* #include <termios.h> */
256 #define mktime timelocal
257 typedef unsigned short mode_t;
262 #ifndef REPLACE_GETPASS
263 #define REPLACE_GETPASS
268 #ifndef USE_SIGPROCMASK
269 #define USE_SIGPROCMASK
274 /* SunOS doesn't have POSIX atexit */
275 #define atexit on_exit
282 #include <sys/acct.h>
283 #include <sys/statfs.h>
284 #include <sys/statvfs.h>
285 #include <sys/filio.h>
286 #include <sys/sockio.h>
287 #include <netinet/in_systm.h>
288 #include <netinet/tcp.h>
289 #include <netinet/ip.h>
291 #include <arpa/inet.h>
292 #include <rpcsvc/ypclnt.h>
296 #endif /* USE_LIBDES */
297 extern int gettimeofday (struct timeval *, void *);
298 extern int gethostname (char *name, int namelen);
299 extern int innetgr (const char *, const char *, const char *, const char *);
301 #define SIGNAL_CAST (void (*)(int))
306 #define REPLACE_STRLEN
310 #define REPLACE_GETPASS
311 #define USE_SIGPROCMASK
317 #include <nfs/nfs_clnt.h>
319 #include <netinet/tcp.h>
326 #define SIGNAL_CAST (void(*)(int))
333 #include <netinet/tcp.h>
334 #include <sys/statfs.h>
340 #define SIGNAL_CAST (void (*)())
347 #include <arpa/inet.h>
348 #include <netinet/tcp.h>
349 #include <sys/statvfs.h>
358 #define SIGNAL_CAST (void (*)())
365 #include <bsd/net/soioctl.h>
369 #include <sys/statfs.h>
370 #include <sys/wait.h>
371 #include <sys/termio.h>
372 #define SIGNAL_CAST (void (*)())
374 extern struct group *getgrnam();
375 extern struct passwd *getpwnam();
378 #define REPLACE_STRSTR
386 #include <sys/statfs.h>
387 #include <sys/statvfs.h>
392 #define SIGNAL_CAST (void (*)(int))
402 #include <sys/statfs.h>
403 #include <sys/statvfs.h>
405 #include <sys/filio.h>
407 #include <sys/sockio.h>
408 #include <netinet/tcp.h>
413 #define SIGNAL_CAST (void (*)(int))
425 char *mktemp(char *); /* No standard include */
426 #include <netinet/in.h>
427 #include <arpa/inet.h> /* both for inet_ntoa */
428 #define SIGNAL_CAST ( void (*) (int) )
432 #include <netinet/tcp.h>
435 #include <sys/types.h>
436 #include <sys/security.h>
439 #define PASSWORD_LENGTH 16
440 #define NEED_AUTH_PARAMETERS
441 #endif /* OSF1_ENH_SEC */
447 #define SIGNAL_CAST (void (*)())
448 #include <sys/fcntl.h>
449 #include <sys/statfs.h>
457 #define REPLACE_GETPASS
465 #include <netinet/tcp.h>
466 #define SIGNAL_CAST (void (*)())
473 #include <netinet/tcp.h>
474 /* you may not need this */
476 #define SIGNAL_CAST (void (*)())
478 #define REPLACE_INNETGR
485 #include <netinet/tcp.h>
486 #include <netinet/in_systm.h>
487 #include <netinet/ip.h>
488 #define SIGNAL_CAST (void (*)())
496 #define HAVE_GETTIMEOFDAY
497 #define HAVE_PATHCONF
498 #define HAVE_GETGRNAM 1
506 #include <sys/select.h>
508 #include <sys/statfs.h>
511 #include <sys/priv.h>
512 #include <netinet/tcp.h>
517 #define SIGNAL_CAST (void (*)())
518 #define DEFAULT_PRINTING PRINT_AIX
519 /* we undef this because sys/param.h is broken in aix. uggh. */
520 #undef MAXHOSTNAMELEN
529 #include <sys/types.h>
530 #include <sys/termios.h>
531 #include <netinet/tcp.h>
532 #ifdef HPUX_10_TRUSTED
533 #include <hpsecurity.h>
535 #define NEED_AUTH_PARAMETERS
537 #define SIGNAL_CAST (void (*)(__harg))
538 #define SELECT_CAST (int *)
541 #define WAIT3_CAST2 (int *)
545 #define DEFAULT_PRINTING PRINT_HPUX
546 #define SIGCLD_IGNORE
554 #include <sys/types.h>
555 #include <sys/statfs.h>
556 #include <sys/stat.h>
558 #include <sys/socket.h>
561 #define SIGNAL_CAST (void (*)(int))
578 #include <sys/statfs.h>
579 #include <sys/statvfs.h>
582 #include <sys/sockio.h>
583 #include <netinet/tcp.h>
588 #define SIGNAL_CAST (void (*)(int))
592 #define seteuid(uid) setreuid(-1,uid)
595 #define setegid(gid) setregid(-1,gid)
601 #include <sys/types.h>
605 #define bzero(b,len) memset(b,0,len)
619 #define bzero(b,len) memset(b,0,len)
628 #define SIGNAL_CAST (void (*)(int))
629 #define WAIT3_CAST1 (union wait *)
638 #include <sys/statfs.h>
642 #define SIGNAL_CAST (void (*)())
643 #define HAVE_FCNTL_LOCK 0
644 #define HAVE_GETTIMEOFDAY
651 #include <sys/netinet/tcp.h>
652 #include <sys/netinet/in_systm.h>
653 #include <sys/netinet/ip.h>
657 #include <sys/statfs.h>
658 #include <sys/stropts.h>
665 #include <rpcsvc/ypclnt.h>
668 #include <sys/security.h>
669 #include <sys/audit.h>
671 #define crypt bigcrypt
674 #define ftruncate(f,l) syscall(0x0a28,f,l)
676 #define SIGNAL_CAST (void (*)(int))
690 #define NO_INITGROUPS
692 #define HAVE_PATHCONF
698 /* Definitions for RiscIX */
700 #define SIGNAL_CAST (void (*)(int))
701 #include <sys/dirent.h>
702 #include <sys/acct.h>
707 #define HAVE_GETTIMEOFDAY
715 #include <net/errno.h>
719 #include <sys/statfs.h>
721 #include <sys/sioctl.h>
724 #include <netinet/tcp.h>
725 #define FIONREAD FIORDCHK
728 #define SIGNAL_CAST (void (*)(int))
748 #define SIGNAL_CAST (void (*)(int))
749 char *strdup (char *);
762 #define SIGNAL_CAST (void (*)(int))
763 char *strdup (char *);
774 #include <sys/statfs.h>
775 #include <sys/stropts.h>
776 #define NO_GET_BROADCAST
782 #define PF_INET AF_INET
784 #define ftruncate(f,l) chsize(f,l)
788 #include <netinet/tcp.h>
789 #include <arpa/inet.h>
794 #define DONT_REINSTALL_SIG
797 #define SIGNAL_CAST (_SigFunc_Ptr_t)
800 extern char *mktemp(char *);
801 extern int fsync(int);
802 extern int seteuid(uid_t);
803 extern int setgroups(int, int *);
804 extern int initgroups(char *, int);
805 extern int statfs(char *, struct statfs *);
806 extern int setegid(gid_t);
807 extern int getopt(int, char *const *, const char *);
808 extern int chroot(char *);
809 extern int gettimeofday(struct timeval *, struct timezone *);
810 extern int gethostname(char *, int);
811 extern char *crypt(char *, char *);
812 extern char *getpass(char *);
817 #define MAXPATHLEN 1024
821 #include <sys/statfs.h>
822 #define SIGNAL_CAST (void (*)(int))
823 #define SIGCLD_IGNORE
824 #define HAVE_FCNTL_LOCK 1
834 #include <sys/fcntl.h>
835 #include <sys/statfs.h>
840 #define ptrdiff_t int
841 #define HAVE_GETGRNAM 0
846 #define NO_INITGROUPS
854 #define REPLACE_MKTIME
855 #define REPLACE_RENAME
856 #define REPLACE_STRSTR
863 #include <sys/statfs.h>
864 #include <sys/select.h>
867 #define SIGNAL_CAST (void (*)())
869 #define NO_INITGROUPS
871 #define HAVE_TIMEZONE
874 #define HAVE_FCNTL_LOCK 1
875 #define DEFAULT_PRINTING PRINT_QNX
883 #include <sys/timeb.h>
889 #include <sys/statfs.h>
892 #define SIGNAL_CAST (void (*)())
893 #define HAVE_FCNTL_LOCK 0
895 #define NO_GET_BROADCAST
898 #define NO_INITGROUPS
903 #define strcasecmp stricmp
904 #define strncasecmp strnicmp
909 #define SIGNAL_CAST (void (*)())
910 #define WAIT3_CAST1 (union wait *)
913 #include <resource.h>
917 #include <sys/statfs.h>
924 #define SIGNAL_CAST (void (*)(int))
927 #include <sys/select.h>
931 #include <sys/statfs.h>
932 #include <sys/bsdioctl.h>
936 #include <arpa/inet.h>
939 #include <netinet/tcp.h>
940 #include <sys/acct.h>
941 #include <sys/fcntl.h>
942 #include <sys/filio.h>
943 #include <sys/sockio.h>
944 #include <netinet/in_systm.h>
945 #include <netinet/ip.h>
946 #include <sys/termios.h>
948 #include <sys/timeb.h>
950 #define SIGNAL_CAST (void (*)(int))
954 #define USE_SIGPROCMASK
958 #define HAVE_FCNTL_LOCK 0
959 #define HAVE_GETTIMEOFDAY
960 #define HAVE_PATHCONF
963 #define NO_FORK_DEBUG
969 /*******************************************************************
970 end of the platform specific sections
971 ********************************************************************/
973 #if defined(USE_MMAP) || FAST_SHARE_MODES
974 #include <sys/mman.h>
978 #define NEED_AUTH_PARAMETERS
981 #ifdef REPLACE_GETPASS
982 extern char *getsmbpass(char *);
983 #define getpass(s) getsmbpass(s)
986 #ifdef REPLACE_INNETGR
987 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
991 #define FD_SETSIZE 255
998 /* Now for some other grungy stuff */
1000 struct spwd { /* fake shadow password structure */
1007 #define bzero(p,s) memset(p,0,s)
1011 #ifndef HAVE_MEMMOVE
1013 #define memmove(d,s,n) MemMove(d,s,n)
1018 #include <sys/dir.h>
1021 /* some unixes have ENOTTY instead of TIOCNOTTY */
1024 #define TIOCNOTTY ENOTTY
1032 /* if undefined then use bsd or sysv printing */
1033 #ifndef DEFAULT_PRINTING
1035 #define DEFAULT_PRINTING PRINT_SYSV
1037 #define DEFAULT_PRINTING PRINT_BSD
1043 #include <afs/stds.h>
1044 #include <afs/kautils.h>
1048 #include <dce/dce_error.h>
1049 #include <dce/sec_login.h>
1061 extern char *sys_errlist[];
1062 #define strerror(i) sys_errlist[i]
1067 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1070 #ifndef MAXHOSTNAMELEN
1071 #define MAXHOSTNAMELEN 255
1074 #include "version.h"
1076 #include "nameserv.h"
1078 #include "byteorder.h"
1081 #include "charset.h"
1084 #define S_IFREG 0100000
1088 #define S_ISREG(x) ((S_IFREG & x)!=0)
1092 #define S_ISDIR(x) ((S_IFDIR & x)!=0)
1096 #define crypt ufc_crypt
1099 #ifdef REPLACE_STRLEN
1100 #define strlen(s) Strlen(s)
1103 #ifdef REPLACE_STRSTR
1104 #define strstr(s,p) Strstr(s,p)
1107 #ifdef REPLACE_MKTIME
1108 #define mktime(t) Mktime(t)
1112 #define NGROUPS_MAX 128
1116 #define EDQUOT ENOSPC
1119 #ifndef HAVE_GETGRNAM
1120 #define HAVE_GETGRNAM 1
1127 /* default to using ftruncate workaround as this is safer than assuming
1128 it works and getting lots of bug reports */
1129 #ifndef FTRUNCATE_CAN_EXTEND
1130 #define FTRUNCATE_CAN_EXTEND 0
1133 /* maybe this unix doesn't separate RD and WR locks? */
1135 #define F_RDLCK F_WRLCK
1139 #define ENOTSOCK EINVAL
1143 #define SIGCLD SIGCHLD
1150 #ifndef HAVE_FCNTL_LOCK
1151 #define HAVE_FCNTL_LOCK 1
1155 #define WAIT3_CAST2 (struct rusage *)
1159 #define WAIT3_CAST1 (int *)
1163 #define QSORT_CAST (int (*)())
1166 /* this is a rough check to see if this machine has a lstat() call.
1167 it is not guaranteed to work */
1168 #if !(defined(S_ISLNK) || defined(S_IFLNK))
1172 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1179 #define geteuid() getuid()
1180 #define getegid() getgid()
1181 #define seteuid(x) setuid(x)
1182 #define setegid(x) setgid(x)
1186 #if (HAVE_FCNTL_LOCK == 0)
1187 /* since there is no locking available, system includes */
1188 /* for DomainOS 10.4 do not contain any of the following */
1189 /* #define's. So, to satisfy the compiler, add these */
1190 /* #define's, although they arn't really necessary. */
1195 #endif /* HAVE_FCNTL_LOCK == 0 */
1198 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1199 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1203 #define strcpy(dest,src) StrCpy(dest,src)
1207 /* possibly wrap the malloc calls */
1210 /* undo the old malloc def if necessary */
1212 #define xx_old_malloc malloc
1216 #define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
1218 /* undo the old realloc def if necessary */
1220 #define xx_old_realloc realloc
1224 #define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
1226 /* undo the old free def if necessary */
1228 #define xx_old_free free
1232 #define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
1234 /* and the malloc prototypes */
1235 void *malloc_wrapped(int,char *,int);
1236 void *realloc_wrapped(void *,int,char *,int);
1237 void free_wrapped(void *,char *,int);
1243 /* undo the old memcpy def if necessary */
1245 #define xx_old_memcpy memcpy
1249 #define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
1250 void *memcpy_wrapped(void *d,void *s,int l,char *fname,int line);