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>
221 #define _LINUX_C_LIB_VERSION_MAJOR 6
223 #include <rpcsvc/ypclnt.h>
225 #include <netinet/tcp.h>
226 #include <netinet/ip.h>
228 #define SIGNAL_CAST (__sighandler_t)
233 #define USE_SIGPROCMASK
236 /* SETFS disabled until we can check on some bug reports */
237 #if _LINUX_C_LIB_VERSION_MAJOR >= 5
242 #if _LINUX_C_LIB_VERSION_MAJOR < 5
244 #define crypt pw_encrypt
251 #define SIGNAL_CAST (void (*)(int))
252 #include <netinet/tcp.h>
254 #include <sys/acct.h>
258 #include <sys/wait.h>
260 /* #include <termios.h> */
264 #define mktime timelocal
265 typedef unsigned short mode_t;
270 #ifndef REPLACE_GETPASS
271 #define REPLACE_GETPASS
276 #ifndef USE_SIGPROCMASK
277 #define USE_SIGPROCMASK
282 /* SunOS doesn't have POSIX atexit */
283 #define atexit on_exit
290 #include <sys/acct.h>
291 #include <sys/statfs.h>
292 #include <sys/statvfs.h>
293 #include <sys/filio.h>
294 #include <sys/sockio.h>
295 #include <netinet/in_systm.h>
296 #include <netinet/tcp.h>
297 #include <netinet/ip.h>
299 #include <arpa/inet.h>
300 #include <rpcsvc/ypclnt.h>
302 #include <sys/stropts.h>
305 #endif /* USE_LIBDES */
306 extern int gettimeofday (struct timeval *, void *);
307 extern int gethostname (char *name, int namelen);
308 extern int innetgr (const char *, const char *, const char *, const char *);
310 #define SIGNAL_CAST (void (*)(int))
315 #define REPLACE_STRLEN
319 #ifndef REPLACE_GETPASS
320 #define REPLACE_GETPASS
321 #endif /* REPLACE_GETPASS */
322 #define USE_SIGPROCMASK
328 #include <nfs/nfs_clnt.h>
330 #include <netinet/tcp.h>
337 #define SIGNAL_CAST (void(*)(int))
344 #include <netinet/tcp.h>
345 #include <sys/statfs.h>
351 #define SIGNAL_CAST (void (*)())
358 #if defined(SGI5) || defined(SGI6)
359 #include <arpa/inet.h>
360 #include <netinet/tcp.h>
361 #include <netinet/in_systm.h>
362 #include <netinet/ip.h>
363 #include <sys/statvfs.h>
372 #define SIGNAL_CAST (void (*)())
380 #include <bsd/net/soioctl.h>
384 #include <sys/statfs.h>
385 #include <sys/wait.h>
386 #include <sys/termio.h>
387 #define SIGNAL_CAST (void (*)())
389 extern struct group *getgrnam();
390 extern struct passwd *getpwnam();
393 #define REPLACE_STRSTR
401 #include <sys/statfs.h>
402 #include <sys/statvfs.h>
407 #define SIGNAL_CAST (void (*)(int))
417 #include <sys/statfs.h>
418 #include <sys/statvfs.h>
420 #include <sys/filio.h>
422 #include <sys/sockio.h>
423 #include <netinet/tcp.h>
428 #define SIGNAL_CAST (void (*)(int))
440 char *mktemp(char *); /* No standard include */
441 #include <netinet/in.h>
442 #include <arpa/inet.h> /* both for inet_ntoa */
443 #define SIGNAL_CAST ( void (*) (int) )
447 #include <netinet/tcp.h>
450 #include <sys/types.h>
451 #include <sys/security.h>
454 #define PASSWORD_LENGTH 16
455 #define NEED_AUTH_PARAMETERS
456 #endif /* OSF1_ENH_SEC */
462 #define SIGNAL_CAST (void (*)())
463 #include <sys/fcntl.h>
464 #include <sys/statfs.h>
472 #ifndef REPLACE_GETPASS
473 #define REPLACE_GETPASS
474 #endif /* REPLACE_GETPASS */
482 #include <netinet/tcp.h>
483 #define SIGNAL_CAST (void (*)())
490 #include <netinet/tcp.h>
491 /* you may not need this */
493 #define SIGNAL_CAST (void (*)())
495 #define REPLACE_INNETGR
501 #include <arpa/inet.h>
503 #include <netinet/tcp.h>
504 #include <netinet/in_systm.h>
505 #include <netinet/ip.h>
506 #define SIGNAL_CAST (void (*)())
514 #define HAVE_GETTIMEOFDAY
515 #define HAVE_PATHCONF
516 #define HAVE_GETGRNAM 1
524 #include <sys/select.h>
526 #include <sys/statfs.h>
529 #include <sys/priv.h>
530 #include <netinet/tcp.h>
535 #define SIGNAL_CAST (void (*)())
536 #define DEFAULT_PRINTING PRINT_AIX
537 /* we undef this because sys/param.h is broken in aix. uggh. */
538 #undef MAXHOSTNAMELEN
547 #include <sys/types.h>
548 #include <sys/termios.h>
549 #include <netinet/tcp.h>
550 #ifdef HPUX_10_TRUSTED
551 #include <hpsecurity.h>
553 #define NEED_AUTH_PARAMETERS
555 #define SIGNAL_CAST (void (*)(__harg))
556 #ifndef HPUX10 /* This is only needed for HPUX 9.x */
557 #define SELECT_CAST (int *)
561 #define WAIT3_CAST2 (int *)
565 #define DEFAULT_PRINTING PRINT_HPUX
566 /* Ken Weiss <krweiss@ucdavis.edu> tells us that SIGCLD_IGNORE is
568 /* #define SIGCLD_IGNORE */
576 #include <sys/types.h>
577 #include <sys/statfs.h>
578 #include <sys/stat.h>
580 #include <sys/socket.h>
583 #define SIGNAL_CAST (void (*)(int))
600 #include <sys/statfs.h>
601 #include <sys/statvfs.h>
604 #include <sys/sockio.h>
605 #include <netinet/tcp.h>
610 #define SIGNAL_CAST (void (*)(int))
614 #define seteuid(uid) setreuid(-1,uid)
617 #define setegid(gid) setregid(-1,gid)
623 #include <sys/types.h>
627 #define bzero(b,len) memset(b,0,len)
641 #define bzero(b,len) memset(b,0,len)
650 #define SIGNAL_CAST (void (*)(int))
651 #define WAIT3_CAST1 (union wait *)
660 #include <sys/statfs.h>
664 #define SIGNAL_CAST (void (*)())
665 #define HAVE_FCNTL_LOCK 0
666 #define HAVE_GETTIMEOFDAY
673 #include <sys/netinet/tcp.h>
674 #include <sys/netinet/in_systm.h>
675 #include <sys/netinet/ip.h>
679 #include <sys/statfs.h>
680 #include <sys/stropts.h>
687 #include <rpcsvc/ypclnt.h>
688 #endif /* NETGROUP */
690 #include <sys/security.h>
691 #include <sys/audit.h>
693 #define crypt bigcrypt
694 #endif /* SecureWare */
695 #define SIGNAL_CAST (void (*)(int))
700 #define setuid(u) setreuid(u,-1)
701 #define seteuid(u) setreuid(-1,u)
704 #define ftruncate(f,l) syscall(0x0a28,f,l)
706 #define NO_INITGROUPS
708 #endif /* SCO3_2_2 */
711 #define HAVE_PATHCONF
717 /* Definitions for RiscIX */
719 #define SIGNAL_CAST (void (*)(int))
720 #include <sys/dirent.h>
721 #include <sys/acct.h>
726 #define HAVE_GETTIMEOFDAY
734 #include <net/errno.h>
738 #include <sys/statfs.h>
740 #include <sys/sioctl.h>
743 #include <netinet/tcp.h>
744 #define FIONREAD FIORDCHK
747 #define SIGNAL_CAST (void (*)(int))
767 #define SIGNAL_CAST (void (*)(int))
768 char *strdup (char *);
781 #define SIGNAL_CAST (void (*)(int))
782 char *strdup (char *);
793 #include <sys/statfs.h>
794 #include <sys/stropts.h>
795 #define NO_GET_BROADCAST
801 #define PF_INET AF_INET
803 #define ftruncate(f,l) chsize(f,l)
807 #include <netinet/tcp.h>
808 #include <arpa/inet.h>
813 #define DONT_REINSTALL_SIG
816 #define SIGNAL_CAST (_SigFunc_Ptr_t)
819 extern char *mktemp(char *);
820 extern int fsync(int);
821 extern int seteuid(uid_t);
822 extern int setgroups(int, int *);
823 extern int initgroups(char *, int);
824 extern int statfs(char *, struct statfs *);
825 extern int setegid(gid_t);
826 extern int getopt(int, char *const *, const char *);
827 extern int chroot(char *);
828 extern int gettimeofday(struct timeval *, struct timezone *);
829 extern int gethostname(char *, int);
830 extern char *crypt(char *, char *);
831 extern char *getpass(char *);
836 #define MAXPATHLEN 1024
840 #include <sys/statfs.h>
841 #define SIGNAL_CAST (void (*)(int))
842 #define SIGCLD_IGNORE
843 #define HAVE_FCNTL_LOCK 1
853 #include <sys/fcntl.h>
854 #include <sys/statfs.h>
859 #define ptrdiff_t int
860 #define HAVE_GETGRNAM 0
865 #define NO_INITGROUPS
873 #define REPLACE_MKTIME
874 #define REPLACE_RENAME
875 #define REPLACE_STRSTR
882 #include <sys/statfs.h>
883 #include <sys/select.h>
886 #define SIGNAL_CAST (void (*)())
888 #define NO_INITGROUPS
890 #define HAVE_TIMEZONE
893 #define HAVE_FCNTL_LOCK 1
894 #define DEFAULT_PRINTING PRINT_QNX
902 #include <sys/timeb.h>
908 #include <sys/statfs.h>
911 #define SIGNAL_CAST (void (*)())
912 #define HAVE_FCNTL_LOCK 0
914 #define NO_GET_BROADCAST
917 #define NO_INITGROUPS
922 #define strcasecmp stricmp
923 #define strncasecmp strnicmp
928 #define SIGNAL_CAST (void (*)())
929 #define WAIT3_CAST1 (union wait *)
932 #include <resource.h>
936 #include <sys/statfs.h>
943 #define SIGNAL_CAST (void (*)(int))
946 #include <sys/select.h>
950 #include <sys/statfs.h>
951 #include <sys/bsdioctl.h>
955 #include <arpa/inet.h>
958 #include <netinet/tcp.h>
959 #include <sys/acct.h>
960 #include <sys/fcntl.h>
961 #include <sys/filio.h>
962 #include <sys/sockio.h>
963 #include <netinet/in_systm.h>
964 #include <netinet/ip.h>
965 #include <sys/termios.h>
967 #include <sys/timeb.h>
969 #define SIGNAL_CAST (void (*)(int))
973 #define USE_SIGPROCMASK
977 #define HAVE_FCNTL_LOCK 0
978 #define HAVE_GETTIMEOFDAY
979 #define HAVE_PATHCONF
982 #define NO_FORK_DEBUG
987 /* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */
994 /*******************************************************************
995 end of the platform specific sections
996 ********************************************************************/
998 #if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
999 #include <sys/mman.h>
1003 #define NEED_AUTH_PARAMETERS
1006 #ifdef REPLACE_GETPASS
1007 extern char *getsmbpass(char *);
1008 #define getpass(s) getsmbpass(s)
1011 #ifdef REPLACE_INNETGR
1012 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
1016 #define FD_SETSIZE 255
1023 /* Now for some other grungy stuff */
1025 struct spwd { /* fake shadow password structure */
1032 #define bzero(p,s) memset(p,0,s)
1036 #ifndef HAVE_MEMMOVE
1038 #define memmove(d,s,n) MemMove(d,s,n)
1043 #include <sys/dir.h>
1046 /* some unixes have ENOTTY instead of TIOCNOTTY */
1049 #define TIOCNOTTY ENOTTY
1057 /* if undefined then use bsd or sysv printing */
1058 #ifndef DEFAULT_PRINTING
1060 #define DEFAULT_PRINTING PRINT_SYSV
1062 #define DEFAULT_PRINTING PRINT_BSD
1068 #include <afs/stds.h>
1069 #include <afs/kautils.h>
1073 #include <dce/dce_error.h>
1074 #include <dce/sec_login.h>
1090 extern char *sys_errlist[];
1091 #define strerror(i) sys_errlist[i]
1096 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1099 #ifndef MAXHOSTNAMELEN
1100 #define MAXHOSTNAMELEN 255
1103 #include "version.h"
1105 #include "nameserv.h"
1107 #include "byteorder.h"
1110 #include "charset.h"
1113 #define S_IFREG 0100000
1117 #define S_ISREG(x) ((S_IFREG & x)!=0)
1121 #define S_ISDIR(x) ((S_IFDIR & x)!=0)
1124 #if !defined(S_ISLNK) && defined(S_IFLNK)
1125 #define S_ISLNK(x) ((S_IFLNK & x)!=0)
1129 #define crypt ufc_crypt
1132 #ifdef REPLACE_STRLEN
1133 #define strlen(s) Strlen(s)
1136 #ifdef REPLACE_STRSTR
1137 #define strstr(s,p) Strstr(s,p)
1140 #ifdef REPLACE_MKTIME
1141 #define mktime(t) Mktime(t)
1145 #define NGROUPS_MAX 128
1149 #define EDQUOT ENOSPC
1152 #ifndef HAVE_GETGRNAM
1153 #define HAVE_GETGRNAM 1
1160 /* default to using ftruncate workaround as this is safer than assuming
1161 it works and getting lots of bug reports */
1162 #ifndef FTRUNCATE_CAN_EXTEND
1163 #define FTRUNCATE_CAN_EXTEND 0
1166 /* maybe this unix doesn't separate RD and WR locks? */
1168 #define F_RDLCK F_WRLCK
1172 #define ENOTSOCK EINVAL
1176 #define SIGCLD SIGCHLD
1183 #ifndef HAVE_FCNTL_LOCK
1184 #define HAVE_FCNTL_LOCK 1
1188 #define WAIT3_CAST2 (struct rusage *)
1192 #define WAIT3_CAST1 (int *)
1196 #define QSORT_CAST (int (*)())
1199 #ifndef INADDR_LOOPBACK
1200 #define INADDR_LOOPBACK 0x7f000001
1201 #endif /* INADDR_LOOPBACK */
1203 /* this is a rough check to see if this machine has a lstat() call.
1204 it is not guaranteed to work */
1205 #if !(defined(S_ISLNK) || defined(S_IFLNK))
1209 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1216 #define geteuid() getuid()
1217 #define getegid() getgid()
1218 #define seteuid(x) setuid(x)
1219 #define setegid(x) setgid(x)
1223 #if (HAVE_FCNTL_LOCK == 0)
1224 /* since there is no locking available, system includes */
1225 /* for DomainOS 10.4 do not contain any of the following */
1226 /* #define's. So, to satisfy the compiler, add these */
1227 /* #define's, although they arn't really necessary. */
1232 #endif /* HAVE_FCNTL_LOCK == 0 */
1235 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1236 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1240 #define strcpy(dest,src) StrCpy(dest,src)
1244 /* possibly wrap the malloc calls */
1247 /* undo the old malloc def if necessary */
1249 #define xx_old_malloc malloc
1253 #define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
1255 /* undo the old realloc def if necessary */
1257 #define xx_old_realloc realloc
1261 #define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
1263 /* undo the old free def if necessary */
1265 #define xx_old_free free
1269 #define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
1271 /* and the malloc prototypes */
1272 void *malloc_wrapped(int,char *,int);
1273 void *realloc_wrapped(void *,int,char *,int);
1274 void free_wrapped(void *,char *,int);
1280 /* undo the old memcpy def if necessary */
1282 #define xx_old_memcpy memcpy
1286 #define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
1287 void *memcpy_wrapped(void *d,void *s,int l,char *fname,int line);