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>
294 #include <sys/stropts.h>
297 #endif /* USE_LIBDES */
298 extern int gettimeofday (struct timeval
*, void *);
299 extern int gethostname (char *name
, int namelen
);
300 extern int innetgr (const char *, const char *, const char *, const char *);
302 #define SIGNAL_CAST (void (*)(int))
307 #define REPLACE_STRLEN
311 #define REPLACE_GETPASS
312 #define USE_SIGPROCMASK
318 #include <nfs/nfs_clnt.h>
320 #include <netinet/tcp.h>
327 #define SIGNAL_CAST (void(*)(int))
334 #include <netinet/tcp.h>
335 #include <sys/statfs.h>
341 #define SIGNAL_CAST (void (*)())
349 #include <arpa/inet.h>
350 #include <netinet/tcp.h>
351 #include <sys/statvfs.h>
360 #define SIGNAL_CAST (void (*)())
368 #include <bsd/net/soioctl.h>
372 #include <sys/statfs.h>
373 #include <sys/wait.h>
374 #include <sys/termio.h>
375 #define SIGNAL_CAST (void (*)())
377 extern struct group
*getgrnam();
378 extern struct passwd
*getpwnam();
381 #define REPLACE_STRSTR
389 #include <sys/statfs.h>
390 #include <sys/statvfs.h>
395 #define SIGNAL_CAST (void (*)(int))
405 #include <sys/statfs.h>
406 #include <sys/statvfs.h>
408 #include <sys/filio.h>
410 #include <sys/sockio.h>
411 #include <netinet/tcp.h>
416 #define SIGNAL_CAST (void (*)(int))
428 char *mktemp(char *); /* No standard include */
429 #include <netinet/in.h>
430 #include <arpa/inet.h> /* both for inet_ntoa */
431 #define SIGNAL_CAST ( void (*) (int) )
435 #include <netinet/tcp.h>
438 #include <sys/types.h>
439 #include <sys/security.h>
442 #define PASSWORD_LENGTH 16
443 #define NEED_AUTH_PARAMETERS
444 #endif /* OSF1_ENH_SEC */
450 #define SIGNAL_CAST (void (*)())
451 #include <sys/fcntl.h>
452 #include <sys/statfs.h>
460 #define REPLACE_GETPASS
468 #include <netinet/tcp.h>
469 #define SIGNAL_CAST (void (*)())
476 #include <netinet/tcp.h>
477 /* you may not need this */
479 #define SIGNAL_CAST (void (*)())
481 #define REPLACE_INNETGR
487 #include <arpa/inet.h>
489 #include <netinet/tcp.h>
490 #include <netinet/in_systm.h>
491 #include <netinet/ip.h>
492 #define SIGNAL_CAST (void (*)())
500 #define HAVE_GETTIMEOFDAY
501 #define HAVE_PATHCONF
502 #define HAVE_GETGRNAM 1
510 #include <sys/select.h>
512 #include <sys/statfs.h>
515 #include <sys/priv.h>
516 #include <netinet/tcp.h>
521 #define SIGNAL_CAST (void (*)())
522 #define DEFAULT_PRINTING PRINT_AIX
523 /* we undef this because sys/param.h is broken in aix. uggh. */
524 #undef MAXHOSTNAMELEN
533 #include <sys/types.h>
534 #include <sys/termios.h>
535 #include <netinet/tcp.h>
536 #ifdef HPUX_10_TRUSTED
537 #include <hpsecurity.h>
539 #define NEED_AUTH_PARAMETERS
541 #define SIGNAL_CAST (void (*)(__harg))
542 #define SELECT_CAST (int *)
545 #define WAIT3_CAST2 (int *)
549 #define DEFAULT_PRINTING PRINT_HPUX
550 #define SIGCLD_IGNORE
558 #include <sys/types.h>
559 #include <sys/statfs.h>
560 #include <sys/stat.h>
562 #include <sys/socket.h>
565 #define SIGNAL_CAST (void (*)(int))
582 #include <sys/statfs.h>
583 #include <sys/statvfs.h>
586 #include <sys/sockio.h>
587 #include <netinet/tcp.h>
592 #define SIGNAL_CAST (void (*)(int))
596 #define seteuid(uid) setreuid(-1,uid)
599 #define setegid(gid) setregid(-1,gid)
605 #include <sys/types.h>
609 #define bzero(b,len) memset(b,0,len)
623 #define bzero(b,len) memset(b,0,len)
632 #define SIGNAL_CAST (void (*)(int))
633 #define WAIT3_CAST1 (union wait *)
642 #include <sys/statfs.h>
646 #define SIGNAL_CAST (void (*)())
647 #define HAVE_FCNTL_LOCK 0
648 #define HAVE_GETTIMEOFDAY
655 #include <sys/netinet/tcp.h>
656 #include <sys/netinet/in_systm.h>
657 #include <sys/netinet/ip.h>
661 #include <sys/statfs.h>
662 #include <sys/stropts.h>
669 #include <rpcsvc/ypclnt.h>
672 #include <sys/security.h>
673 #include <sys/audit.h>
675 #define crypt bigcrypt
678 #define ftruncate(f,l) syscall(0x0a28,f,l)
680 #define SIGNAL_CAST (void (*)(int))
694 #define NO_INITGROUPS
696 #define HAVE_PATHCONF
702 /* Definitions for RiscIX */
704 #define SIGNAL_CAST (void (*)(int))
705 #include <sys/dirent.h>
706 #include <sys/acct.h>
711 #define HAVE_GETTIMEOFDAY
719 #include <net/errno.h>
723 #include <sys/statfs.h>
725 #include <sys/sioctl.h>
728 #include <netinet/tcp.h>
729 #define FIONREAD FIORDCHK
732 #define SIGNAL_CAST (void (*)(int))
752 #define SIGNAL_CAST (void (*)(int))
753 char *strdup (char *);
766 #define SIGNAL_CAST (void (*)(int))
767 char *strdup (char *);
778 #include <sys/statfs.h>
779 #include <sys/stropts.h>
780 #define NO_GET_BROADCAST
786 #define PF_INET AF_INET
788 #define ftruncate(f,l) chsize(f,l)
792 #include <netinet/tcp.h>
793 #include <arpa/inet.h>
798 #define DONT_REINSTALL_SIG
801 #define SIGNAL_CAST (_SigFunc_Ptr_t)
804 extern char *mktemp(char *);
805 extern int fsync(int);
806 extern int seteuid(uid_t
);
807 extern int setgroups(int, int *);
808 extern int initgroups(char *, int);
809 extern int statfs(char *, struct statfs
*);
810 extern int setegid(gid_t
);
811 extern int getopt(int, char *const *, const char *);
812 extern int chroot(char *);
813 extern int gettimeofday(struct timeval
*, struct timezone
*);
814 extern int gethostname(char *, int);
815 extern char *crypt(char *, char *);
816 extern char *getpass(char *);
821 #define MAXPATHLEN 1024
825 #include <sys/statfs.h>
826 #define SIGNAL_CAST (void (*)(int))
827 #define SIGCLD_IGNORE
828 #define HAVE_FCNTL_LOCK 1
838 #include <sys/fcntl.h>
839 #include <sys/statfs.h>
844 #define ptrdiff_t int
845 #define HAVE_GETGRNAM 0
850 #define NO_INITGROUPS
858 #define REPLACE_MKTIME
859 #define REPLACE_RENAME
860 #define REPLACE_STRSTR
867 #include <sys/statfs.h>
868 #include <sys/select.h>
871 #define SIGNAL_CAST (void (*)())
873 #define NO_INITGROUPS
875 #define HAVE_TIMEZONE
878 #define HAVE_FCNTL_LOCK 1
879 #define DEFAULT_PRINTING PRINT_QNX
887 #include <sys/timeb.h>
893 #include <sys/statfs.h>
896 #define SIGNAL_CAST (void (*)())
897 #define HAVE_FCNTL_LOCK 0
899 #define NO_GET_BROADCAST
902 #define NO_INITGROUPS
907 #define strcasecmp stricmp
908 #define strncasecmp strnicmp
913 #define SIGNAL_CAST (void (*)())
914 #define WAIT3_CAST1 (union wait *)
917 #include <resource.h>
921 #include <sys/statfs.h>
928 #define SIGNAL_CAST (void (*)(int))
931 #include <sys/select.h>
935 #include <sys/statfs.h>
936 #include <sys/bsdioctl.h>
940 #include <arpa/inet.h>
943 #include <netinet/tcp.h>
944 #include <sys/acct.h>
945 #include <sys/fcntl.h>
946 #include <sys/filio.h>
947 #include <sys/sockio.h>
948 #include <netinet/in_systm.h>
949 #include <netinet/ip.h>
950 #include <sys/termios.h>
952 #include <sys/timeb.h>
954 #define SIGNAL_CAST (void (*)(int))
958 #define USE_SIGPROCMASK
962 #define HAVE_FCNTL_LOCK 0
963 #define HAVE_GETTIMEOFDAY
964 #define HAVE_PATHCONF
967 #define NO_FORK_DEBUG
972 /* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */
979 /*******************************************************************
980 end of the platform specific sections
981 ********************************************************************/
983 #if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
984 #include <sys/mman.h>
988 #define NEED_AUTH_PARAMETERS
991 #ifdef REPLACE_GETPASS
992 extern char *getsmbpass(char *);
993 #define getpass(s) getsmbpass(s)
996 #ifdef REPLACE_INNETGR
997 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
1001 #define FD_SETSIZE 255
1008 /* Now for some other grungy stuff */
1010 struct spwd
{ /* fake shadow password structure */
1017 #define bzero(p,s) memset(p,0,s)
1021 #ifndef HAVE_MEMMOVE
1023 #define memmove(d,s,n) MemMove(d,s,n)
1028 #include <sys/dir.h>
1031 /* some unixes have ENOTTY instead of TIOCNOTTY */
1034 #define TIOCNOTTY ENOTTY
1042 /* if undefined then use bsd or sysv printing */
1043 #ifndef DEFAULT_PRINTING
1045 #define DEFAULT_PRINTING PRINT_SYSV
1047 #define DEFAULT_PRINTING PRINT_BSD
1053 #include <afs/stds.h>
1054 #include <afs/kautils.h>
1058 #include <dce/dce_error.h>
1059 #include <dce/sec_login.h>
1071 extern char *sys_errlist
[];
1072 #define strerror(i) sys_errlist[i]
1077 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1080 #ifndef MAXHOSTNAMELEN
1081 #define MAXHOSTNAMELEN 255
1084 #include "version.h"
1086 #include "nameserv.h"
1088 #include "byteorder.h"
1091 #include "charset.h"
1094 #define S_IFREG 0100000
1098 #define S_ISREG(x) ((S_IFREG & x)!=0)
1102 #define S_ISDIR(x) ((S_IFDIR & x)!=0)
1106 #define crypt ufc_crypt
1109 #ifdef REPLACE_STRLEN
1110 #define strlen(s) Strlen(s)
1113 #ifdef REPLACE_STRSTR
1114 #define strstr(s,p) Strstr(s,p)
1117 #ifdef REPLACE_MKTIME
1118 #define mktime(t) Mktime(t)
1122 #define NGROUPS_MAX 128
1126 #define EDQUOT ENOSPC
1129 #ifndef HAVE_GETGRNAM
1130 #define HAVE_GETGRNAM 1
1137 /* default to using ftruncate workaround as this is safer than assuming
1138 it works and getting lots of bug reports */
1139 #ifndef FTRUNCATE_CAN_EXTEND
1140 #define FTRUNCATE_CAN_EXTEND 0
1143 /* maybe this unix doesn't separate RD and WR locks? */
1145 #define F_RDLCK F_WRLCK
1149 #define ENOTSOCK EINVAL
1153 #define SIGCLD SIGCHLD
1160 #ifndef HAVE_FCNTL_LOCK
1161 #define HAVE_FCNTL_LOCK 1
1165 #define WAIT3_CAST2 (struct rusage *)
1169 #define WAIT3_CAST1 (int *)
1173 #define QSORT_CAST (int (*)())
1176 /* this is a rough check to see if this machine has a lstat() call.
1177 it is not guaranteed to work */
1178 #if !(defined(S_ISLNK) || defined(S_IFLNK))
1182 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1189 #define geteuid() getuid()
1190 #define getegid() getgid()
1191 #define seteuid(x) setuid(x)
1192 #define setegid(x) setgid(x)
1196 #if (HAVE_FCNTL_LOCK == 0)
1197 /* since there is no locking available, system includes */
1198 /* for DomainOS 10.4 do not contain any of the following */
1199 /* #define's. So, to satisfy the compiler, add these */
1200 /* #define's, although they arn't really necessary. */
1205 #endif /* HAVE_FCNTL_LOCK == 0 */
1208 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1209 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1213 #define strcpy(dest,src) StrCpy(dest,src)
1217 /* possibly wrap the malloc calls */
1220 /* undo the old malloc def if necessary */
1222 #define xx_old_malloc malloc
1226 #define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
1228 /* undo the old realloc def if necessary */
1230 #define xx_old_realloc realloc
1234 #define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
1236 /* undo the old free def if necessary */
1238 #define xx_old_free free
1242 #define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
1244 /* and the malloc prototypes */
1245 void *malloc_wrapped(int,char *,int);
1246 void *realloc_wrapped(void *,int,char *,int);
1247 void free_wrapped(void *,char *,int);
1253 /* undo the old memcpy def if necessary */
1255 #define xx_old_memcpy memcpy
1259 #define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
1260 void *memcpy_wrapped(void *d
,void *s
,int l
,char *fname
,int line
);