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 (*)())
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 #define SIGCLD_IGNORE
574 #include <sys/types.h>
575 #include <sys/statfs.h>
576 #include <sys/stat.h>
578 #include <sys/socket.h>
581 #define SIGNAL_CAST (void (*)(int))
598 #include <sys/statfs.h>
599 #include <sys/statvfs.h>
602 #include <sys/sockio.h>
603 #include <netinet/tcp.h>
608 #define SIGNAL_CAST (void (*)(int))
612 #define seteuid(uid) setreuid(-1,uid)
615 #define setegid(gid) setregid(-1,gid)
621 #include <sys/types.h>
625 #define bzero(b,len) memset(b,0,len)
639 #define bzero(b,len) memset(b,0,len)
648 #define SIGNAL_CAST (void (*)(int))
649 #define WAIT3_CAST1 (union wait *)
658 #include <sys/statfs.h>
662 #define SIGNAL_CAST (void (*)())
663 #define HAVE_FCNTL_LOCK 0
664 #define HAVE_GETTIMEOFDAY
671 #include <sys/netinet/tcp.h>
672 #include <sys/netinet/in_systm.h>
673 #include <sys/netinet/ip.h>
677 #include <sys/statfs.h>
678 #include <sys/stropts.h>
685 #include <rpcsvc/ypclnt.h>
686 #endif /* NETGROUP */
688 #include <sys/security.h>
689 #include <sys/audit.h>
691 #define crypt bigcrypt
692 #endif /* SecureWare */
693 #define SIGNAL_CAST (void (*)(int))
698 #define setuid(u) setreuid(u,-1)
699 #define seteuid(u) setreuid(-1,u)
702 #define ftruncate(f,l) syscall(0x0a28,f,l)
704 #define NO_INITGROUPS
706 #endif /* SCO3_2_2 */
709 #define HAVE_PATHCONF
715 /* Definitions for RiscIX */
717 #define SIGNAL_CAST (void (*)(int))
718 #include <sys/dirent.h>
719 #include <sys/acct.h>
724 #define HAVE_GETTIMEOFDAY
732 #include <net/errno.h>
736 #include <sys/statfs.h>
738 #include <sys/sioctl.h>
741 #include <netinet/tcp.h>
742 #define FIONREAD FIORDCHK
745 #define SIGNAL_CAST (void (*)(int))
765 #define SIGNAL_CAST (void (*)(int))
766 char *strdup (char *);
779 #define SIGNAL_CAST (void (*)(int))
780 char *strdup (char *);
791 #include <sys/statfs.h>
792 #include <sys/stropts.h>
793 #define NO_GET_BROADCAST
799 #define PF_INET AF_INET
801 #define ftruncate(f,l) chsize(f,l)
805 #include <netinet/tcp.h>
806 #include <arpa/inet.h>
811 #define DONT_REINSTALL_SIG
814 #define SIGNAL_CAST (_SigFunc_Ptr_t)
817 extern char *mktemp(char *);
818 extern int fsync(int);
819 extern int seteuid(uid_t);
820 extern int setgroups(int, int *);
821 extern int initgroups(char *, int);
822 extern int statfs(char *, struct statfs *);
823 extern int setegid(gid_t);
824 extern int getopt(int, char *const *, const char *);
825 extern int chroot(char *);
826 extern int gettimeofday(struct timeval *, struct timezone *);
827 extern int gethostname(char *, int);
828 extern char *crypt(char *, char *);
829 extern char *getpass(char *);
834 #define MAXPATHLEN 1024
838 #include <sys/statfs.h>
839 #define SIGNAL_CAST (void (*)(int))
840 #define SIGCLD_IGNORE
841 #define HAVE_FCNTL_LOCK 1
851 #include <sys/fcntl.h>
852 #include <sys/statfs.h>
857 #define ptrdiff_t int
858 #define HAVE_GETGRNAM 0
863 #define NO_INITGROUPS
871 #define REPLACE_MKTIME
872 #define REPLACE_RENAME
873 #define REPLACE_STRSTR
880 #include <sys/statfs.h>
881 #include <sys/select.h>
884 #define SIGNAL_CAST (void (*)())
886 #define NO_INITGROUPS
888 #define HAVE_TIMEZONE
891 #define HAVE_FCNTL_LOCK 1
892 #define DEFAULT_PRINTING PRINT_QNX
900 #include <sys/timeb.h>
906 #include <sys/statfs.h>
909 #define SIGNAL_CAST (void (*)())
910 #define HAVE_FCNTL_LOCK 0
912 #define NO_GET_BROADCAST
915 #define NO_INITGROUPS
920 #define strcasecmp stricmp
921 #define strncasecmp strnicmp
926 #define SIGNAL_CAST (void (*)())
927 #define WAIT3_CAST1 (union wait *)
930 #include <resource.h>
934 #include <sys/statfs.h>
941 #define SIGNAL_CAST (void (*)(int))
944 #include <sys/select.h>
948 #include <sys/statfs.h>
949 #include <sys/bsdioctl.h>
953 #include <arpa/inet.h>
956 #include <netinet/tcp.h>
957 #include <sys/acct.h>
958 #include <sys/fcntl.h>
959 #include <sys/filio.h>
960 #include <sys/sockio.h>
961 #include <netinet/in_systm.h>
962 #include <netinet/ip.h>
963 #include <sys/termios.h>
965 #include <sys/timeb.h>
967 #define SIGNAL_CAST (void (*)(int))
971 #define USE_SIGPROCMASK
975 #define HAVE_FCNTL_LOCK 0
976 #define HAVE_GETTIMEOFDAY
977 #define HAVE_PATHCONF
980 #define NO_FORK_DEBUG
985 /* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */
992 /*******************************************************************
993 end of the platform specific sections
994 ********************************************************************/
996 #if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
997 #include <sys/mman.h>
1001 #define NEED_AUTH_PARAMETERS
1004 #ifdef REPLACE_GETPASS
1005 extern char *getsmbpass(char *);
1006 #define getpass(s) getsmbpass(s)
1009 #ifdef REPLACE_INNETGR
1010 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
1014 #define FD_SETSIZE 255
1021 /* Now for some other grungy stuff */
1023 struct spwd { /* fake shadow password structure */
1030 #define bzero(p,s) memset(p,0,s)
1034 #ifndef HAVE_MEMMOVE
1036 #define memmove(d,s,n) MemMove(d,s,n)
1041 #include <sys/dir.h>
1044 /* some unixes have ENOTTY instead of TIOCNOTTY */
1047 #define TIOCNOTTY ENOTTY
1055 /* if undefined then use bsd or sysv printing */
1056 #ifndef DEFAULT_PRINTING
1058 #define DEFAULT_PRINTING PRINT_SYSV
1060 #define DEFAULT_PRINTING PRINT_BSD
1066 #include <afs/stds.h>
1067 #include <afs/kautils.h>
1071 #include <dce/dce_error.h>
1072 #include <dce/sec_login.h>
1088 extern char *sys_errlist[];
1089 #define strerror(i) sys_errlist[i]
1094 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1097 #ifndef MAXHOSTNAMELEN
1098 #define MAXHOSTNAMELEN 255
1101 #include "version.h"
1103 #include "nameserv.h"
1105 #include "byteorder.h"
1108 #include "charset.h"
1111 #define S_IFREG 0100000
1115 #define S_ISREG(x) ((S_IFREG & x)!=0)
1119 #define S_ISDIR(x) ((S_IFDIR & x)!=0)
1122 #if !defined(S_ISLNK) && defined(S_IFLNK)
1123 #define S_ISLNK(x) ((S_IFLNK & x)!=0)
1127 #define crypt ufc_crypt
1130 #ifdef REPLACE_STRLEN
1131 #define strlen(s) Strlen(s)
1134 #ifdef REPLACE_STRSTR
1135 #define strstr(s,p) Strstr(s,p)
1138 #ifdef REPLACE_MKTIME
1139 #define mktime(t) Mktime(t)
1143 #define NGROUPS_MAX 128
1147 #define EDQUOT ENOSPC
1150 #ifndef HAVE_GETGRNAM
1151 #define HAVE_GETGRNAM 1
1158 /* default to using ftruncate workaround as this is safer than assuming
1159 it works and getting lots of bug reports */
1160 #ifndef FTRUNCATE_CAN_EXTEND
1161 #define FTRUNCATE_CAN_EXTEND 0
1164 /* maybe this unix doesn't separate RD and WR locks? */
1166 #define F_RDLCK F_WRLCK
1170 #define ENOTSOCK EINVAL
1174 #define SIGCLD SIGCHLD
1181 #ifndef HAVE_FCNTL_LOCK
1182 #define HAVE_FCNTL_LOCK 1
1186 #define WAIT3_CAST2 (struct rusage *)
1190 #define WAIT3_CAST1 (int *)
1194 #define QSORT_CAST (int (*)())
1197 /* this is a rough check to see if this machine has a lstat() call.
1198 it is not guaranteed to work */
1199 #if !(defined(S_ISLNK) || defined(S_IFLNK))
1203 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1210 #define geteuid() getuid()
1211 #define getegid() getgid()
1212 #define seteuid(x) setuid(x)
1213 #define setegid(x) setgid(x)
1217 #if (HAVE_FCNTL_LOCK == 0)
1218 /* since there is no locking available, system includes */
1219 /* for DomainOS 10.4 do not contain any of the following */
1220 /* #define's. So, to satisfy the compiler, add these */
1221 /* #define's, although they arn't really necessary. */
1226 #endif /* HAVE_FCNTL_LOCK == 0 */
1229 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1230 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1234 #define strcpy(dest,src) StrCpy(dest,src)
1238 /* possibly wrap the malloc calls */
1241 /* undo the old malloc def if necessary */
1243 #define xx_old_malloc malloc
1247 #define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
1249 /* undo the old realloc def if necessary */
1251 #define xx_old_realloc realloc
1255 #define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
1257 /* undo the old free def if necessary */
1259 #define xx_old_free free
1263 #define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
1265 /* and the malloc prototypes */
1266 void *malloc_wrapped(int,char *,int);
1267 void *realloc_wrapped(void *,int,char *,int);
1268 void free_wrapped(void *,char *,int);
1274 /* undo the old memcpy def if necessary */
1276 #define xx_old_memcpy memcpy
1280 #define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
1281 void *memcpy_wrapped(void *d,void *s,int l,char *fname,int line);