4 Unix SMB/Netbios implementation.
6 Machine customisation and include handling
7 Copyright (C) Andrew Tridgell 1994-1998
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
100 #define REPLACE_MKTIME
114 #if (defined(SHADOW_PWD)||defined(OSF1_ENH_SEC)||defined(SecureWare)||defined(PWDAUTH))
115 #define PASSWORD_LENGTH 16
118 /* here is the general includes section - with some ifdefs generated
119 by the previous section
124 #include <posix/stdlib.h>
133 #include <sys/types.h>
136 #include <sys/statfs.h>
137 #include <sys/stream.h>
138 #include <netinet/types.h>
139 #include <netinet/ether.h>
140 #include <netinet/ip_if.h>
143 #include <sys/socket.h>
147 #include <sys/ioctl.h>
150 #include <posix/utime.h>
151 #include <bsd/sys/time.h>
152 #include <bsd/netinet/in.h>
154 #include <sys/time.h>
155 #include <netinet/in.h>
160 #include <sys/file.h>
161 #include <sys/stat.h>
162 #include <sys/param.h>
165 #include <sys/resource.h>
168 #include <sys/mount.h>
179 #include <sys/wait.h>
181 #include <sys/stream.h>
185 #include <bsd/net/if.h>
188 #include <net/route.h>
189 #include <sys/mbuf.h>
195 #if defined(GETPWANAM)
196 #include <sys/types.h>
197 #include <sys/label.h>
198 #include <sys/audit.h>
202 #if defined(SHADOW_PWD) && !defined(NETBSD) && !defined(FreeBSD) && !defined(CONVEX) && !defined(__OpenBSD__)
215 /***************************************************************************
216 Here come some platform specific sections
217 ***************************************************************************/
221 #include <arpa/inet.h>
225 #include <netinet/in.h>
227 #define _LINUX_C_LIB_VERSION_MAJOR 6
229 #include <rpcsvc/ypclnt.h>
231 #include <netinet/tcp.h>
232 #include <netinet/ip.h>
235 #define QSORT_CAST (int (*)(const void *, const void *))
236 #endif /* QSORT_CAST */
237 #define SIGNAL_CAST (__sighandler_t)
242 #define HAVE_VSNPRINTF
243 #define USE_SIGPROCMASK
247 /* SETFS disabled until we can check on some bug reports */
248 #if _LINUX_C_LIB_VERSION_MAJOR >= 5
253 #if _LINUX_C_LIB_VERSION_MAJOR < 5
255 #define crypt pw_encrypt
262 #define SIGNAL_CAST (void (*)(int))
263 #include <netinet/tcp.h>
265 #include <sys/acct.h>
270 #include <sys/wait.h>
272 /* #include <termios.h> */
276 #define mktime timelocal
277 typedef unsigned short mode_t;
282 #ifndef REPLACE_GETPASS
283 #define REPLACE_GETPASS
288 #ifndef USE_SIGPROCMASK
289 #define USE_SIGPROCMASK
295 /* SunOS doesn't have POSIX atexit */
296 #define atexit on_exit
299 #define QSORT_CAST (int (*)(const void *, const void *))
300 #endif /* QSORT_CAST */
307 #include <sys/acct.h>
308 #include <sys/statfs.h>
309 #include <sys/statvfs.h>
310 #include <sys/filio.h>
311 #include <sys/sockio.h>
312 #include <netinet/in_systm.h>
313 #include <netinet/tcp.h>
314 #include <netinet/ip.h>
316 #include <arpa/inet.h>
317 #include <rpcsvc/ypclnt.h>
319 #include <sys/stropts.h>
320 #if !defined(USE_LIBDES) && !defined(KRB4_AUTH)
322 #endif /* !USE_LIBDES && !KRB4_AUTH */
323 extern int gettimeofday (struct timeval *, void *);
324 extern int gethostname (char *name, int namelen);
325 extern int innetgr (const char *, const char *, const char *, const char *);
327 #define SIGNAL_CAST (void (*)(int))
332 #define REPLACE_STRLEN
338 #ifndef REPLACE_GETPASS
339 #define REPLACE_GETPASS
340 #endif /* REPLACE_GETPASS */
341 #define USE_SIGPROCMASK
343 #define QSORT_CAST (int (*)(const void *, const void *))
344 #endif /* QSORT_CAST */
350 #include <nfs/nfs_clnt.h>
352 #include <netinet/tcp.h>
359 #define SIGNAL_CAST (void(*)(int))
366 #include <netinet/tcp.h>
367 #include <sys/statfs.h>
373 #define SIGNAL_CAST (void (*)())
381 #if defined(SGI5) || defined(SGI6)
382 #include <arpa/inet.h>
383 #include <netinet/tcp.h>
384 #include <netinet/in_systm.h>
385 #include <netinet/ip.h>
386 #include <sys/statvfs.h>
395 #define SIGNAL_CAST (void (*)())
401 #define QSORT_CAST (int (*)(const void *, const void *))
402 #endif /* QSORT_CAST */
407 #include <bsd/net/soioctl.h>
411 #include <sys/statfs.h>
412 #include <sys/wait.h>
413 #include <sys/termio.h>
414 #define SIGNAL_CAST (void (*)())
416 extern struct group *getgrnam();
417 extern struct passwd *getpwnam();
420 #define REPLACE_STRSTR
428 #include <sys/statfs.h>
429 #include <sys/statvfs.h>
434 #define SIGNAL_CAST (void (*)(int))
444 #include <sys/statfs.h>
445 #include <sys/statvfs.h>
447 #include <sys/filio.h>
449 #include <sys/sockio.h>
450 #include <netinet/tcp.h>
455 #define SIGNAL_CAST (void (*)(int))
469 char *mktemp(char *); /* No standard include */
470 #include <netinet/in.h>
471 #include <arpa/inet.h> /* both for inet_ntoa */
472 #define SIGNAL_CAST ( void (*) (int) )
476 #include <netinet/tcp.h>
479 #include <sys/types.h>
480 #include <sys/security.h>
483 #define PASSWORD_LENGTH 16
484 #define NEED_AUTH_PARAMETERS
485 #endif /* OSF1_ENH_SEC */
493 #define SIGNAL_CAST (void (*)())
494 #include <sys/fcntl.h>
495 #include <sys/statfs.h>
503 #ifndef REPLACE_GETPASS
504 #define REPLACE_GETPASS
505 #endif /* REPLACE_GETPASS */
513 #include <netinet/tcp.h>
514 #define SIGNAL_CAST (void (*)())
516 #define QSORT_CAST (int (*)(const void *, const void *))
523 #ifdef ALLOW_CHANGE_PASSWORD
525 #endif /* ALLOW_CHANGE_PASSWORD */
526 #else /* NetBSD1_3 */
528 #endif /* NetBSD1_3 */
529 #include <netinet/tcp.h>
530 #include <netinet/in_systm.h>
531 #include <netinet/ip.h>
532 /* you may not need this */
534 #define SIGNAL_CAST (void (*)())
536 #define REPLACE_INNETGR
541 #include <arpa/inet.h>
543 #include <netinet/tcp.h>
544 #include <netinet/in_systm.h>
545 #include <netinet/ip.h>
553 #define SIGNAL_CAST (void (*)(int))
560 #define HAVE_GETTIMEOFDAY
561 #define HAVE_PATHCONF
562 #define HAVE_GETGRNAM 1
563 #define HAVE_VSNPRINTF
564 #define QSORT_CAST (int (*)(const void *, const void *))
567 #define O_SYNC O_FSYNC
568 #else /* defined(O_FSYNC) */
570 #endif /* defined(O_FSYNC) */
571 #endif /* !defined(O_SYNC) */
576 #include <netinet/tcp.h>
578 #define SIGNAL_CAST (void (*)())
580 #define REPLACE_INNETGR
582 #define HAVE_PATHCONF
583 #define HAVE_GETGRNAM 1
584 #define HAVE_GETTIMEOFDAY
593 #include <sys/select.h>
595 #include <sys/statfs.h>
598 #include <sys/priv.h>
599 /* According to AIX 4.1 man pages, inet_ntoa needs the following headers */
600 #include <sys/socket.h>
601 #include <netinet/in.h>
602 #include <arpa/inet.h>
603 #include <netinet/tcp.h>
606 #define HAVE_GETGRNAM 1
610 #define SIGNAL_CAST (void (*)())
611 #define DEFAULT_PRINTING PRINT_AIX
612 /* we undef this because sys/param.h is broken in aix. uggh. */
613 #undef MAXHOSTNAMELEN
622 #include <sys/types.h>
623 #include <sys/termios.h>
624 #include <netinet/tcp.h>
625 #include <arpa/inet.h> /* needed for inet_ntoa proto */
626 #ifdef HPUX_10_TRUSTED
627 #include <hpsecurity.h>
629 #define NEED_AUTH_PARAMETERS
631 #define SIGNAL_CAST (void (*)(__harg))
635 /* This is only needed for HPUX 9.x */
636 #define SELECT_CAST (int *)
640 #define WAIT3_CAST2 (int *)
646 #define DEFAULT_PRINTING PRINT_HPUX
647 /* Ken Weiss <krweiss@ucdavis.edu> tells us that SIGCLD_IGNORE is
649 /* #define SIGCLD_IGNORE */
650 #define USE_SIGPROCMASK /* Needed to stop zombie processes on HPUX 9.x and 10.x.*/
658 #include <sys/types.h>
659 #include <sys/statfs.h>
660 #include <sys/stat.h>
662 #include <sys/socket.h>
665 #define SIGNAL_CAST (void (*)(int))
682 #include <sys/statfs.h>
683 #include <sys/statvfs.h>
686 #include <sys/sockio.h>
687 #include <netinet/tcp.h>
692 #define SIGNAL_CAST (void (*)(int))
696 #define seteuid(uid) setreuid(-1,uid)
699 #define setegid(gid) setregid(-1,gid)
705 #include <sys/types.h>
709 #define bzero(b,len) memset(b,0,len)
731 #define SIGNAL_CAST (void (*)(int))
732 #define WAIT3_CAST1 (union wait *)
734 #define O_NONBLOCK O_NDELAY
742 #include <sys/statfs.h>
746 #define SIGNAL_CAST (void (*)())
747 #define HAVE_FCNTL_LOCK 0
748 #define HAVE_GETTIMEOFDAY
755 #include <sys/netinet/tcp.h>
756 #include <sys/netinet/in_systm.h>
757 #include <sys/netinet/ip.h>
762 #include <sys/statfs.h>
763 #include <sys/stropts.h>
770 #include <rpcsvc/ypclnt.h>
771 #endif /* NETGROUP */
773 #include <sys/security.h>
774 #include <sys/audit.h>
776 #define crypt bigcrypt
777 #endif /* SecureWare */
778 #define SIGNAL_CAST (void (*)(int))
783 #define setuid(u) setreuid(u,-1)
784 #define seteuid(u) setreuid(-1,u)
787 #define ftruncate(f,l) syscall(0x0a28,f,l)
789 #define NO_INITGROUPS
791 #endif /* SCO3_2_2 */
794 #define HAVE_PATHCONF
800 /* Definitions for RiscIX */
802 #define SIGNAL_CAST (void (*)(int))
803 #include <sys/dirent.h>
804 #include <sys/acct.h>
809 #define HAVE_GETTIMEOFDAY
817 #include <net/errno.h>
821 #include <sys/statfs.h>
823 #include <sys/sioctl.h>
826 #include <netinet/tcp.h>
827 #define FIONREAD FIORDCHK
830 #define SIGNAL_CAST (void (*)(int))
850 #define SIGNAL_CAST (void (*)(int))
851 char *strdup (char *);
864 #define SIGNAL_CAST (void (*)(int))
865 char *strdup (char *);
876 #include <sys/statfs.h>
877 #include <sys/stropts.h>
878 #define NO_GET_BROADCAST
884 #define PF_INET AF_INET
886 #define ftruncate(f,l) chsize(f,l)
890 #include <netinet/tcp.h>
891 #include <arpa/inet.h>
896 #define DONT_REINSTALL_SIG
899 #define SIGNAL_CAST (_SigFunc_Ptr_t)
902 extern char *mktemp(char *);
903 extern int fsync(int);
904 extern int seteuid(uid_t);
905 extern int setgroups(int, int *);
906 extern int initgroups(char *, int);
907 extern int statfs(char *, struct statfs *);
908 extern int setegid(gid_t);
909 extern int getopt(int, char *const *, const char *);
910 extern int chroot(char *);
911 extern int gettimeofday(struct timeval *, struct timezone *);
912 extern int gethostname(char *, int);
913 extern char *crypt(char *, char *);
914 extern char *getpass(char *);
919 #define MAXPATHLEN 1024
923 #include <sys/statfs.h>
924 #define SIGNAL_CAST (void (*)(int))
925 #define SIGCLD_IGNORE
926 #define HAVE_FCNTL_LOCK 1
936 #include <sys/fcntl.h>
937 #include <sys/statfs.h>
942 #define ptrdiff_t int
943 #define HAVE_GETGRNAM 0
948 #define NO_INITGROUPS
956 #define REPLACE_MKTIME
957 #define REPLACE_RENAME
958 #define REPLACE_STRSTR
964 #include <arpa/inet.h>
966 #include <sys/statfs.h>
967 /* Override QNX size of 32 to be 255 */
968 #define FD_SETSIZE 255
969 #include <sys/select.h>
972 #define SIGNAL_CAST (void (*)())
974 #define NO_INITGROUPS
976 #define HAVE_TIMEZONE
979 #define HAVE_FCNTL_LOCK 1
980 #define DEFAULT_PRINTING PRINT_QNX
988 #include <sys/timeb.h>
994 #include <sys/statfs.h>
997 #define SIGNAL_CAST (void (*)())
998 #define HAVE_FCNTL_LOCK 0
1000 #define NO_GET_BROADCAST
1002 #define NO_SETGROUPS
1003 #define NO_INITGROUPS
1008 #define strcasecmp stricmp
1009 #define strncasecmp strnicmp
1014 #define SIGNAL_CAST (void (*)())
1015 #define WAIT3_CAST1 (union wait *)
1018 #include <resource.h>
1022 #include <sys/statfs.h>
1029 #define SIGNAL_CAST (void (*)(int))
1031 #include <sys/dir.h>
1032 #include <sys/select.h>
1036 #include <sys/statfs.h>
1037 #include <sys/bsdioctl.h>
1041 #include <arpa/inet.h>
1044 #include <netinet/tcp.h>
1045 #include <sys/acct.h>
1046 #include <sys/fcntl.h>
1047 #include <sys/filio.h>
1048 #include <sys/sockio.h>
1049 #include <netinet/in_systm.h>
1050 #include <netinet/ip.h>
1051 #include <sys/termios.h>
1053 #include <sys/timeb.h>
1055 #define SIGNAL_CAST (void (*)(int))
1058 #define HAVE_MEMMOVE
1059 #define USE_SIGPROCMASK
1063 #define HAVE_FCNTL_LOCK 0
1064 #define HAVE_GETTIMEOFDAY
1065 #define HAVE_PATHCONF
1067 #define HAVE_NO_PROC
1068 #define NO_FORK_DEBUG
1070 #define HAVE_VFORK 1
1073 /* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */
1080 /*******************************************************************
1081 end of the platform specific sections
1082 ********************************************************************/
1084 #if (!defined(USE_LDAP_DB) && !defined(USE_NISPLUS_DB))
1085 #define USE_SMBPASS_DB
1088 #if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
1089 #include <sys/mman.h>
1093 #define NEED_AUTH_PARAMETERS
1096 #ifdef REPLACE_GETPASS
1097 extern char *getsmbpass(char *);
1098 #define getpass(s) getsmbpass(s)
1101 #ifdef REPLACE_INNETGR
1102 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
1106 #define FD_SETSIZE 255
1113 /* Now for some other grungy stuff */
1114 #if defined(NO_GETSPNAM) && !defined(QNX)
1115 struct spwd { /* fake shadow password structure */
1122 #define bzero(p,s) memset(p,0,s)
1126 #ifndef HAVE_MEMMOVE
1128 #define memmove(d,s,n) MemMove(d,s,n)
1133 #include <sys/dir.h>
1136 /* some unixes have ENOTTY instead of TIOCNOTTY */
1139 #define TIOCNOTTY ENOTTY
1147 /* if undefined then use bsd or sysv printing */
1148 #ifndef DEFAULT_PRINTING
1150 #define DEFAULT_PRINTING PRINT_SYSV
1152 #define DEFAULT_PRINTING PRINT_BSD
1156 /* This defines the name of the printcap file. It is MOST UNLIKELY that
1157 this will change BUT! Specifying a file with the format of a printcap
1158 file but containing only a subset of the printers actually in your real
1159 printcap file is a quick-n-dirty way to allow dynamic access to a subset
1160 of available printers.
1162 #ifndef PRINTCAP_NAME
1164 #define PRINTCAP_NAME "/etc/qconfig"
1166 #define PRINTCAP_NAME "lpstat"
1168 #define PRINTCAP_NAME "/etc/printcap"
1174 #include <sys/ipc.h>
1175 #include <sys/sem.h>
1176 #include <sys/shm.h>
1180 struct semid_ds *buf;
1181 unsigned short *array;
1184 #if defined(HPUX) && defined(HPUX10)
1188 #endif /* HPUX && HPUX10 */
1192 #include <afs/stds.h>
1193 #include <afs/kautils.h>
1197 #include <dce/dce_error.h>
1198 #include <dce/sec_login.h>
1218 extern char *sys_errlist[];
1219 #define strerror(i) sys_errlist[i]
1224 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1227 #ifndef MAXHOSTNAMELEN
1228 #define MAXHOSTNAMELEN 255
1231 /* Lists, trees, caching, datbase... */
1232 #include "ubi_sLinkList.h"
1233 #include "ubi_dLinkList.h"
1234 #ifndef UBI_BINTREE_H
1235 #include "ubi_Cache.h"
1236 #endif /* UBI_BINTREE_H */
1238 #include "version.h"
1240 #include "nameserv.h"
1242 #include "byteorder.h"
1245 #include "charset.h"
1247 #ifndef MAXCODEPAGELINES
1248 #define MAXCODEPAGELINES 256
1251 /***** automatically generated prototypes *****/
1257 #define S_IFREG 0100000
1261 #define S_ISREG(x) ((S_IFREG & (x))!=0)
1265 #define S_ISDIR(x) ((S_IFDIR & (x))!=0)
1268 #if !defined(S_ISLNK) && defined(S_IFLNK)
1269 #define S_ISLNK(x) ((S_IFLNK & (x))!=0)
1273 #define crypt ufc_crypt
1276 #ifdef REPLACE_STRLEN
1277 #define strlen(s) Strlen(s)
1280 #ifdef REPLACE_STRSTR
1281 #define strstr(s,p) Strstr(s,p)
1284 #ifdef REPLACE_MKTIME
1285 #define mktime(t) Mktime(t)
1289 #define NGROUPS_MAX 128
1293 #define EDQUOT ENOSPC
1296 #ifndef HAVE_GETGRNAM
1297 #define HAVE_GETGRNAM 1
1304 /* default to using ftruncate workaround as this is safer than assuming
1305 it works and getting lots of bug reports */
1306 #ifndef FTRUNCATE_CAN_EXTEND
1307 #define FTRUNCATE_CAN_EXTEND 0
1310 /* maybe this unix doesn't separate RD and WR locks? */
1312 #define F_RDLCK F_WRLCK
1316 #define ENOTSOCK EINVAL
1320 #define SIGCLD SIGCHLD
1327 #ifndef HAVE_FCNTL_LOCK
1328 #define HAVE_FCNTL_LOCK 1
1332 #define WAIT3_CAST2 (struct rusage *)
1336 #define WAIT3_CAST1 (int *)
1340 #define QSORT_CAST (int (*)())
1343 #ifndef INADDR_LOOPBACK
1344 #define INADDR_LOOPBACK 0x7f000001
1345 #endif /* INADDR_LOOPBACK */
1347 /* this is a rough check to see if this machine has a lstat() call.
1348 it is not guaranteed to work */
1349 #if !defined(S_ISLNK)
1353 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1360 #define geteuid() getuid()
1361 #define getegid() getgid()
1362 #define seteuid(x) setuid(x)
1363 #define setegid(x) setgid(x)
1367 #if (HAVE_FCNTL_LOCK == 0)
1368 /* since there is no locking available, system includes */
1369 /* for DomainOS 10.4 do not contain any of the following */
1370 /* #define's. So, to satisfy the compiler, add these */
1371 /* #define's, although they arn't really necessary. */
1376 #endif /* HAVE_FCNTL_LOCK == 0 */
1379 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1380 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1386 #define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
1391 #define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
1395 #endif /* sprintf */
1396 #define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
1398 #define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
1399 #define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
1400 #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
1401 #define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
1404 #include "mem_man/mem_man.h"
1405 #endif /* MEM_MAN */
1407 #endif /* _INCLUDES_H */