4 Unix SMB/Netbios implementation.
6 Machine customisation and include handling
7 Copyright (C) Andrew Tridgell 1994-1995
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>
295 extern int gettimeofday (struct timeval *, void *);
296 extern int gethostname (char *name, int namelen);
297 extern int innetgr (const char *, const char *, const char *, const char *);
299 #define SIGNAL_CAST (void (*)(int))
304 #define REPLACE_STRLEN
308 #define REPLACE_GETPASS
309 #define USE_SIGPROCMASK
315 #include <nfs/nfs_clnt.h>
317 #include <netinet/tcp.h>
324 #define SIGNAL_CAST (void(*)(int))
331 #include <netinet/tcp.h>
332 #include <sys/statfs.h>
338 #define SIGNAL_CAST (void (*)())
345 #include <netinet/tcp.h>
346 #include <sys/statvfs.h>
355 #define SIGNAL_CAST (void (*)())
362 #include <bsd/net/soioctl.h>
366 #include <sys/statfs.h>
367 #include <sys/wait.h>
368 #include <sys/termio.h>
369 #define SIGNAL_CAST (void (*)())
371 extern struct group *getgrnam();
372 extern struct passwd *getpwnam();
375 #define REPLACE_STRSTR
383 #include <sys/statfs.h>
384 #include <sys/statvfs.h>
389 #define SIGNAL_CAST (void (*)(int))
399 #include <sys/statfs.h>
400 #include <sys/statvfs.h>
402 #include <sys/filio.h>
404 #include <sys/sockio.h>
405 #include <netinet/tcp.h>
410 #define SIGNAL_CAST (void (*)(int))
422 char *mktemp(char *); /* No standard include */
423 #include <netinet/in.h>
424 #include <arpa/inet.h> /* both for inet_ntoa */
425 #define SIGNAL_CAST ( void (*) (int) )
428 #include <netinet/tcp.h>
431 #include <sys/types.h>
432 #include <sys/security.h>
435 #define PASSWORD_LENGTH 16
436 #define NEED_AUTH_PARAMETERS
437 #endif /* OSF1_ENH_SEC */
443 #define SIGNAL_CAST (void (*)())
444 #include <sys/fcntl.h>
445 #include <sys/statfs.h>
453 #define REPLACE_GETPASS
461 #include <netinet/tcp.h>
462 #define SIGNAL_CAST (void (*)())
469 #include <netinet/tcp.h>
470 /* you may not need this */
472 #define SIGNAL_CAST (void (*)())
474 #define REPLACE_INNETGR
481 #include <netinet/tcp.h>
482 #include <netinet/in_systm.h>
483 #include <netinet/ip.h>
484 #define SIGNAL_CAST (void (*)())
492 #define HAVE_GETTIMEOFDAY
493 #define HAVE_PATHCONF
494 #define HAVE_GETGRNAM 1
502 #include <sys/select.h>
504 #include <sys/statfs.h>
507 #include <sys/priv.h>
508 #include <netinet/tcp.h>
513 #define SIGNAL_CAST (void (*)())
514 #define DEFAULT_PRINTING PRINT_AIX
515 /* we undef this because sys/param.h is broken in aix. uggh. */
516 #undef MAXHOSTNAMELEN
525 #include <sys/types.h>
526 #include <sys/termios.h>
527 #include <netinet/tcp.h>
528 #ifdef HPUX_10_TRUSTED
529 #include <hpsecurity.h>
531 #define NEED_AUTH_PARAMETERS
533 #define SIGNAL_CAST (void (*)(__harg))
534 #define SELECT_CAST (int *)
537 #define WAIT3_CAST2 (int *)
541 #define DEFAULT_PRINTING PRINT_HPUX
542 #define SIGCLD_IGNORE
550 #include <sys/types.h>
551 #include <sys/statfs.h>
552 #include <sys/stat.h>
554 #include <sys/socket.h>
557 #define SIGNAL_CAST (void (*)(int))
574 #include <sys/statfs.h>
575 #include <sys/statvfs.h>
578 #include <sys/sockio.h>
579 #include <netinet/tcp.h>
584 #define SIGNAL_CAST (void (*)(int))
588 #define seteuid(uid) setreuid(-1,uid)
591 #define setegid(gid) setregid(-1,gid)
597 #include <sys/types.h>
601 #define bzero(b,len) memset(b,0,len)
615 #define bzero(b,len) memset(b,0,len)
624 #define SIGNAL_CAST (void (*)(int))
625 #define WAIT3_CAST1 (union wait *)
634 #include <sys/statfs.h>
638 #define SIGNAL_CAST (void (*)())
639 #define HAVE_FCNTL_LOCK 0
640 #define HAVE_GETTIMEOFDAY
647 #include <sys/netinet/tcp.h>
648 #include <sys/netinet/in_systm.h>
649 #include <sys/netinet/ip.h>
653 #include <sys/statfs.h>
654 #include <sys/stropts.h>
661 #include <rpcsvc/ypclnt.h>
664 #include <sys/security.h>
665 #include <sys/audit.h>
667 #define crypt bigcrypt
670 #define ftruncate(f,l) syscall(0x0a28,f,l)
672 #define SIGNAL_CAST (void (*)(int))
686 #define NO_INITGROUPS
688 #define HAVE_PATHCONF
694 /* Definitions for RiscIX */
696 #define SIGNAL_CAST (void (*)(int))
697 #include <sys/dirent.h>
698 #include <sys/acct.h>
703 #define HAVE_GETTIMEOFDAY
711 #include <net/errno.h>
715 #include <sys/statfs.h>
717 #include <sys/sioctl.h>
720 #include <netinet/tcp.h>
721 #define FIONREAD FIORDCHK
724 #define SIGNAL_CAST (void (*)(int))
744 #define SIGNAL_CAST (void (*)(int))
745 char *strdup (char *);
758 #define SIGNAL_CAST (void (*)(int))
759 char *strdup (char *);
770 #include <sys/statfs.h>
771 #include <sys/stropts.h>
772 #define NO_GET_BROADCAST
778 #define PF_INET AF_INET
780 #define ftruncate(f,l) chsize(f,l)
784 #include <netinet/tcp.h>
785 #include <arpa/inet.h>
790 #define DONT_REINSTALL_SIG
793 #define SIGNAL_CAST (_SigFunc_Ptr_t)
796 extern char *mktemp(char *);
797 extern int fsync(int);
798 extern int seteuid(uid_t);
799 extern int setgroups(int, int *);
800 extern int initgroups(char *, int);
801 extern int statfs(char *, struct statfs *);
802 extern int setegid(gid_t);
803 extern int getopt(int, char *const *, const char *);
804 extern int chroot(char *);
805 extern int gettimeofday(struct timeval *, struct timezone *);
806 extern int gethostname(char *, int);
807 extern char *crypt(char *, char *);
808 extern char *getpass(char *);
813 #define MAXPATHLEN 1024
817 #include <sys/statfs.h>
818 #define SIGNAL_CAST (void (*)(int))
819 #define SIGCLD_IGNORE
820 #define HAVE_FCNTL_LOCK 1
830 #include <sys/fcntl.h>
831 #include <sys/statfs.h>
836 #define ptrdiff_t int
837 #define HAVE_GETGRNAM 0
842 #define NO_INITGROUPS
850 #define REPLACE_MKTIME
851 #define REPLACE_RENAME
852 #define REPLACE_STRSTR
859 #include <sys/statfs.h>
860 #include <sys/select.h>
863 #define SIGNAL_CAST (void (*)())
865 #define NO_INITGROUPS
867 #define HAVE_TIMEZONE
870 #define HAVE_FCNTL_LOCK 1
871 #define DEFAULT_PRINTING PRINT_QNX
879 #include <sys/timeb.h>
885 #include <sys/statfs.h>
888 #define SIGNAL_CAST (void (*)())
889 #define HAVE_FCNTL_LOCK 0
891 #define NO_GET_BROADCAST
894 #define NO_INITGROUPS
899 #define strcasecmp stricmp
900 #define strncasecmp strnicmp
905 #define SIGNAL_CAST (void (*)())
906 #define WAIT3_CAST1 (union wait *)
909 #include <resource.h>
913 #include <sys/statfs.h>
920 #define SIGNAL_CAST (void (*)(int))
923 #include <sys/select.h>
927 #include <sys/statfs.h>
928 #include <sys/bsdioctl.h>
932 #include <arpa/inet.h>
935 #include <netinet/tcp.h>
936 #include <sys/acct.h>
937 #include <sys/fcntl.h>
938 #include <sys/filio.h>
939 #include <sys/sockio.h>
940 #include <netinet/in_systm.h>
941 #include <netinet/ip.h>
942 #include <sys/termios.h>
944 #include <sys/timeb.h>
946 #define SIGNAL_CAST (void (*)(int))
950 #define USE_SIGPROCMASK
954 #define HAVE_FCNTL_LOCK 0
955 #define HAVE_GETTIMEOFDAY
956 #define HAVE_PATHCONF
959 #define NO_FORK_DEBUG
965 /*******************************************************************
966 end of the platform specific sections
967 ********************************************************************/
969 #if defined(USE_MMAP) || FAST_SHARE_MODES
970 #include <sys/mman.h>
974 #define NEED_AUTH_PARAMETERS
977 #ifdef REPLACE_GETPASS
978 extern char *getsmbpass(char *);
979 #define getpass(s) getsmbpass(s)
982 #ifdef REPLACE_INNETGR
983 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
987 #define FD_SETSIZE 255
994 /* Now for some other grungy stuff */
996 struct spwd { /* fake shadow password structure */
1003 #define bzero(p,s) memset(p,0,s)
1007 #ifndef HAVE_MEMMOVE
1009 #define memmove(d,s,n) MemMove(d,s,n)
1014 #include <sys/dir.h>
1017 /* some unixes have ENOTTY instead of TIOCNOTTY */
1020 #define TIOCNOTTY ENOTTY
1028 /* if undefined then use bsd or sysv printing */
1029 #ifndef DEFAULT_PRINTING
1031 #define DEFAULT_PRINTING PRINT_SYSV
1033 #define DEFAULT_PRINTING PRINT_BSD
1039 #include <afs/stds.h>
1040 #include <afs/kautils.h>
1044 #include <dce/dce_error.h>
1045 #include <dce/sec_login.h>
1057 extern char *sys_errlist[];
1058 #define strerror(i) sys_errlist[i]
1063 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1066 #ifndef MAXHOSTNAMELEN
1067 #define MAXHOSTNAMELEN 255
1070 #include "version.h"
1072 #include "nameserv.h"
1074 #include "byteorder.h"
1077 #include "charset.h"
1080 #define S_IFREG 0100000
1084 #define S_ISREG(x) ((S_IFREG & x)!=0)
1088 #define S_ISDIR(x) ((S_IFDIR & x)!=0)
1092 #define crypt ufc_crypt
1095 #ifdef REPLACE_STRLEN
1096 #define strlen(s) Strlen(s)
1099 #ifdef REPLACE_STRSTR
1100 #define strstr(s,p) Strstr(s,p)
1103 #ifdef REPLACE_MKTIME
1104 #define mktime(t) Mktime(t)
1108 #define NGROUPS_MAX 128
1112 #define EDQUOT ENOSPC
1115 #ifndef HAVE_GETGRNAM
1116 #define HAVE_GETGRNAM 1
1123 /* default to using ftruncate workaround as this is safer than assuming
1124 it works and getting lots of bug reports */
1125 #ifndef FTRUNCATE_CAN_EXTEND
1126 #define FTRUNCATE_CAN_EXTEND 0
1129 /* maybe this unix doesn't separate RD and WR locks? */
1131 #define F_RDLCK F_WRLCK
1135 #define ENOTSOCK EINVAL
1139 #define SIGCLD SIGCHLD
1146 #ifndef HAVE_FCNTL_LOCK
1147 #define HAVE_FCNTL_LOCK 1
1151 #define WAIT3_CAST2 (struct rusage *)
1155 #define WAIT3_CAST1 (int *)
1159 #define QSORT_CAST (int (*)())
1162 /* this is a rough check to see if this machine has a lstat() call.
1163 it is not guaranteed to work */
1164 #if !(defined(S_ISLNK) || defined(S_IFLNK))
1168 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1175 #define geteuid() getuid()
1176 #define getegid() getgid()
1177 #define seteuid(x) setuid(x)
1178 #define setegid(x) setgid(x)
1182 #if (HAVE_FCNTL_LOCK == 0)
1183 /* since there is no locking available, system includes */
1184 /* for DomainOS 10.4 do not contain any of the following */
1185 /* #define's. So, to satisfy the compiler, add these */
1186 /* #define's, although they arn't really necessary. */
1191 #endif /* HAVE_FCNTL_LOCK == 0 */
1194 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1195 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1199 #define strcpy(dest,src) StrCpy(dest,src)
1203 /* possibly wrap the malloc calls */
1206 /* undo the old malloc def if necessary */
1208 #define xx_old_malloc malloc
1212 #define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
1214 /* undo the old realloc def if necessary */
1216 #define xx_old_realloc realloc
1220 #define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
1222 /* undo the old free def if necessary */
1224 #define xx_old_free free
1228 #define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
1230 /* and the malloc prototypes */
1231 void *malloc_wrapped(int,char *,int);
1232 void *realloc_wrapped(void *,int,char *,int);
1233 void free_wrapped(void *,char *,int);
1239 /* undo the old memcpy def if necessary */
1241 #define xx_old_memcpy memcpy
1245 #define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
1246 void *memcpy_wrapped(void *d,void *s,int l,char *fname,int line);