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
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>
186 #include <net/route.h>
187 #include <sys/mbuf.h>
193 #if defined(GETPWANAM)
194 #include <sys/types.h>
195 #include <sys/label.h>
196 #include <sys/audit.h>
200 #if defined(SHADOW_PWD) && !defined(NETBSD) && !defined(FreeBSD) && !defined(CONVEX) && !defined(__OpenBSD__)
213 /***************************************************************************
214 Here come some platform specific sections
215 ***************************************************************************/
219 #include <arpa/inet.h>
223 #include <netinet/in.h>
225 #define _LINUX_C_LIB_VERSION_MAJOR 6
227 #include <rpcsvc/ypclnt.h>
229 #include <netinet/tcp.h>
230 #include <netinet/ip.h>
233 #define QSORT_CAST (int (*)(const void *, const void *))
234 #endif /* QSORT_CAST */
235 #define SIGNAL_CAST (__sighandler_t)
240 #define HAVE_VSNPRINTF
241 #define USE_SIGPROCMASK
245 /* SETFS disabled until we can check on some bug reports */
246 #if _LINUX_C_LIB_VERSION_MAJOR >= 5
251 #if _LINUX_C_LIB_VERSION_MAJOR < 5
253 #define crypt pw_encrypt
260 #define SIGNAL_CAST (void (*)(int))
261 #include <netinet/tcp.h>
263 #include <sys/acct.h>
268 #include <sys/wait.h>
270 /* #include <termios.h> */
274 #define mktime timelocal
275 typedef unsigned short mode_t;
280 #ifndef REPLACE_GETPASS
281 #define REPLACE_GETPASS
286 #ifndef USE_SIGPROCMASK
287 #define USE_SIGPROCMASK
293 /* SunOS doesn't have POSIX atexit */
294 #define atexit on_exit
297 #define QSORT_CAST (int (*)(const void *, const void *))
298 #endif /* QSORT_CAST */
305 #include <sys/acct.h>
306 #include <sys/statfs.h>
307 #include <sys/statvfs.h>
308 #include <sys/filio.h>
309 #include <sys/sockio.h>
310 #include <netinet/in_systm.h>
311 #include <netinet/tcp.h>
312 #include <netinet/ip.h>
314 #include <arpa/inet.h>
315 #include <rpcsvc/ypclnt.h>
317 #include <sys/stropts.h>
318 #if !defined(USE_LIBDES) && !defined(KRB4_AUTH)
320 #endif /* !USE_LIBDES && !KRB4_AUTH */
321 extern int gettimeofday (struct timeval *, void *);
322 extern int gethostname (char *name, int namelen);
323 extern int innetgr (const char *, const char *, const char *, const char *);
325 #define SIGNAL_CAST (void (*)(int))
330 #define REPLACE_STRLEN
336 #ifndef REPLACE_GETPASS
337 #define REPLACE_GETPASS
338 #endif /* REPLACE_GETPASS */
339 #define USE_SIGPROCMASK
341 #define QSORT_CAST (int (*)(const void *, const void *))
342 #endif /* QSORT_CAST */
348 #include <nfs/nfs_clnt.h>
350 #include <netinet/tcp.h>
357 #define SIGNAL_CAST (void(*)(int))
364 #include <netinet/tcp.h>
365 #include <sys/statfs.h>
371 #define SIGNAL_CAST (void (*)())
379 #if defined(SGI5) || defined(SGI6)
380 #include <arpa/inet.h>
381 #include <netinet/tcp.h>
382 #include <netinet/in_systm.h>
383 #include <netinet/ip.h>
384 #include <sys/statvfs.h>
393 #define SIGNAL_CAST (void (*)())
399 #define QSORT_CAST (int (*)(const void *, const void *))
400 #endif /* QSORT_CAST */
405 #include <bsd/net/soioctl.h>
409 #include <sys/statfs.h>
410 #include <sys/wait.h>
411 #include <sys/termio.h>
412 #define SIGNAL_CAST (void (*)())
414 extern struct group *getgrnam();
415 extern struct passwd *getpwnam();
418 #define REPLACE_STRSTR
426 #include <sys/statfs.h>
427 #include <sys/statvfs.h>
432 #define SIGNAL_CAST (void (*)(int))
442 #include <sys/statfs.h>
443 #include <sys/statvfs.h>
445 #include <sys/filio.h>
447 #include <sys/sockio.h>
448 #include <netinet/tcp.h>
453 #define SIGNAL_CAST (void (*)(int))
467 char *mktemp(char *); /* No standard include */
468 #include <netinet/in.h>
469 #include <arpa/inet.h> /* both for inet_ntoa */
470 #define SIGNAL_CAST ( void (*) (int) )
474 #include <netinet/tcp.h>
477 #include <sys/types.h>
478 #include <sys/security.h>
481 #define PASSWORD_LENGTH 16
482 #define NEED_AUTH_PARAMETERS
483 #endif /* OSF1_ENH_SEC */
491 #define SIGNAL_CAST (void (*)())
492 #include <sys/fcntl.h>
493 #include <sys/statfs.h>
501 #ifndef REPLACE_GETPASS
502 #define REPLACE_GETPASS
503 #endif /* REPLACE_GETPASS */
511 #include <netinet/tcp.h>
512 #define SIGNAL_CAST (void (*)())
514 #define QSORT_CAST (int (*)(const void *, const void *))
521 #ifdef ALLOW_CHANGE_PASSWORD
523 #endif /* ALLOW_CHANGE_PASSWORD */
524 #else /* NetBSD1_3 */
526 #endif /* NetBSD1_3 */
527 #include <netinet/tcp.h>
528 #include <netinet/in_systm.h>
529 #include <netinet/ip.h>
530 /* you may not need this */
532 #define SIGNAL_CAST (void (*)())
534 #define REPLACE_INNETGR
539 #include <arpa/inet.h>
541 #include <netinet/tcp.h>
542 #include <netinet/in_systm.h>
543 #include <netinet/ip.h>
551 #define SIGNAL_CAST (void (*)(int))
558 #define HAVE_GETTIMEOFDAY
559 #define HAVE_PATHCONF
560 #define HAVE_GETGRNAM 1
561 #define HAVE_VSNPRINTF
562 #define QSORT_CAST (int (*)(const void *, const void *))
565 #define O_SYNC O_FSYNC
566 #else /* defined(O_FSYNC) */
568 #endif /* defined(O_FSYNC) */
569 #endif /* !defined(O_SYNC) */
574 #include <netinet/tcp.h>
576 #define SIGNAL_CAST (void (*)())
578 #define REPLACE_INNETGR
580 #define HAVE_PATHCONF
581 #define HAVE_GETGRNAM 1
582 #define HAVE_GETTIMEOFDAY
591 #include <sys/select.h>
593 #include <sys/statfs.h>
596 #include <sys/priv.h>
597 /* According to AIX 4.1 man pages, inet_ntoa needs the following headers */
598 #include <sys/socket.h>
599 #include <netinet/in.h>
600 #include <arpa/inet.h>
601 #include <netinet/tcp.h>
604 #define HAVE_GETGRNAM 1
608 #define SIGNAL_CAST (void (*)())
609 #define DEFAULT_PRINTING PRINT_AIX
610 /* we undef this because sys/param.h is broken in aix. uggh. */
611 #undef MAXHOSTNAMELEN
620 #include <sys/types.h>
621 #include <sys/termios.h>
622 #include <netinet/tcp.h>
623 #include <arpa/inet.h> /* needed for inet_ntoa proto */
624 #ifdef HPUX_10_TRUSTED
625 #include <hpsecurity.h>
627 #define NEED_AUTH_PARAMETERS
629 #define SIGNAL_CAST (void (*)(__harg))
633 /* This is only needed for HPUX 9.x */
634 #define SELECT_CAST (int *)
638 #define WAIT3_CAST2 (int *)
644 #define DEFAULT_PRINTING PRINT_HPUX
645 /* Ken Weiss <krweiss@ucdavis.edu> tells us that SIGCLD_IGNORE is
647 /* #define SIGCLD_IGNORE */
648 #define USE_SIGPROCMASK /* Needed to stop zombie processes on HPUX 9.x and 10.x.*/
656 #include <sys/types.h>
657 #include <sys/statfs.h>
658 #include <sys/stat.h>
660 #include <sys/socket.h>
663 #define SIGNAL_CAST (void (*)(int))
680 #include <sys/statfs.h>
681 #include <sys/statvfs.h>
684 #include <sys/sockio.h>
685 #include <netinet/tcp.h>
690 #define SIGNAL_CAST (void (*)(int))
694 #define seteuid(uid) setreuid(-1,uid)
697 #define setegid(gid) setregid(-1,gid)
703 #include <sys/types.h>
707 #define bzero(b,len) memset(b,0,len)
729 #define SIGNAL_CAST (void (*)(int))
730 #define WAIT3_CAST1 (union wait *)
732 #define O_NONBLOCK O_NDELAY
740 #include <sys/statfs.h>
744 #define SIGNAL_CAST (void (*)())
745 #define HAVE_FCNTL_LOCK 0
746 #define HAVE_GETTIMEOFDAY
753 #include <sys/netinet/tcp.h>
754 #include <sys/netinet/in_systm.h>
755 #include <sys/netinet/ip.h>
760 #include <sys/statfs.h>
761 #include <sys/stropts.h>
768 #include <rpcsvc/ypclnt.h>
769 #endif /* NETGROUP */
771 #include <sys/security.h>
772 #include <sys/audit.h>
774 #define crypt bigcrypt
775 #endif /* SecureWare */
776 #define SIGNAL_CAST (void (*)(int))
781 #define setuid(u) setreuid(u,-1)
782 #define seteuid(u) setreuid(-1,u)
785 #define ftruncate(f,l) syscall(0x0a28,f,l)
787 #define NO_INITGROUPS
789 #endif /* SCO3_2_2 */
792 #define HAVE_PATHCONF
798 /* Definitions for RiscIX */
800 #define SIGNAL_CAST (void (*)(int))
801 #include <sys/dirent.h>
802 #include <sys/acct.h>
807 #define HAVE_GETTIMEOFDAY
815 #include <net/errno.h>
819 #include <sys/statfs.h>
821 #include <sys/sioctl.h>
824 #include <netinet/tcp.h>
825 #define FIONREAD FIORDCHK
828 #define SIGNAL_CAST (void (*)(int))
848 #define SIGNAL_CAST (void (*)(int))
849 char *strdup (char *);
862 #define SIGNAL_CAST (void (*)(int))
863 char *strdup (char *);
874 #include <sys/statfs.h>
875 #include <sys/stropts.h>
876 #define NO_GET_BROADCAST
882 #define PF_INET AF_INET
884 #define ftruncate(f,l) chsize(f,l)
888 #include <netinet/tcp.h>
889 #include <arpa/inet.h>
894 #define DONT_REINSTALL_SIG
897 #define SIGNAL_CAST (_SigFunc_Ptr_t)
900 extern char *mktemp(char *);
901 extern int fsync(int);
902 extern int seteuid(uid_t);
903 extern int setgroups(int, int *);
904 extern int initgroups(char *, int);
905 extern int statfs(char *, struct statfs *);
906 extern int setegid(gid_t);
907 extern int getopt(int, char *const *, const char *);
908 extern int chroot(char *);
909 extern int gettimeofday(struct timeval *, struct timezone *);
910 extern int gethostname(char *, int);
911 extern char *crypt(char *, char *);
912 extern char *getpass(char *);
917 #define MAXPATHLEN 1024
921 #include <sys/statfs.h>
922 #define SIGNAL_CAST (void (*)(int))
923 #define SIGCLD_IGNORE
924 #define HAVE_FCNTL_LOCK 1
934 #include <sys/fcntl.h>
935 #include <sys/statfs.h>
940 #define ptrdiff_t int
941 #define HAVE_GETGRNAM 0
946 #define NO_INITGROUPS
954 #define REPLACE_MKTIME
955 #define REPLACE_RENAME
956 #define REPLACE_STRSTR
963 #include <sys/statfs.h>
964 #include <sys/select.h>
967 #define SIGNAL_CAST (void (*)())
969 #define NO_INITGROUPS
971 #define HAVE_TIMEZONE
974 #define HAVE_FCNTL_LOCK 1
975 #define DEFAULT_PRINTING PRINT_QNX
983 #include <sys/timeb.h>
989 #include <sys/statfs.h>
992 #define SIGNAL_CAST (void (*)())
993 #define HAVE_FCNTL_LOCK 0
995 #define NO_GET_BROADCAST
998 #define NO_INITGROUPS
1003 #define strcasecmp stricmp
1004 #define strncasecmp strnicmp
1009 #define SIGNAL_CAST (void (*)())
1010 #define WAIT3_CAST1 (union wait *)
1013 #include <resource.h>
1017 #include <sys/statfs.h>
1024 #define SIGNAL_CAST (void (*)(int))
1026 #include <sys/dir.h>
1027 #include <sys/select.h>
1031 #include <sys/statfs.h>
1032 #include <sys/bsdioctl.h>
1036 #include <arpa/inet.h>
1039 #include <netinet/tcp.h>
1040 #include <sys/acct.h>
1041 #include <sys/fcntl.h>
1042 #include <sys/filio.h>
1043 #include <sys/sockio.h>
1044 #include <netinet/in_systm.h>
1045 #include <netinet/ip.h>
1046 #include <sys/termios.h>
1048 #include <sys/timeb.h>
1050 #define SIGNAL_CAST (void (*)(int))
1053 #define HAVE_MEMMOVE
1054 #define USE_SIGPROCMASK
1058 #define HAVE_FCNTL_LOCK 0
1059 #define HAVE_GETTIMEOFDAY
1060 #define HAVE_PATHCONF
1062 #define HAVE_NO_PROC
1063 #define NO_FORK_DEBUG
1065 #define HAVE_VFORK 1
1068 /* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */
1075 /*******************************************************************
1076 end of the platform specific sections
1077 ********************************************************************/
1079 #if (!defined(USE_LDAP_DB) && !defined(USE_NISPLUS_DB))
1080 #define USE_SMBPASS_DB
1083 #if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
1084 #include <sys/mman.h>
1088 #define NEED_AUTH_PARAMETERS
1091 #ifdef REPLACE_GETPASS
1092 extern char *getsmbpass(char *);
1093 #define getpass(s) getsmbpass(s)
1096 #ifdef REPLACE_INNETGR
1097 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
1101 #define FD_SETSIZE 255
1108 /* Now for some other grungy stuff */
1110 struct spwd { /* fake shadow password structure */
1117 #define bzero(p,s) memset(p,0,s)
1121 #ifndef HAVE_MEMMOVE
1123 #define memmove(d,s,n) MemMove(d,s,n)
1128 #include <sys/dir.h>
1131 /* some unixes have ENOTTY instead of TIOCNOTTY */
1134 #define TIOCNOTTY ENOTTY
1142 /* if undefined then use bsd or sysv printing */
1143 #ifndef DEFAULT_PRINTING
1145 #define DEFAULT_PRINTING PRINT_SYSV
1147 #define DEFAULT_PRINTING PRINT_BSD
1151 /* This defines the name of the printcap file. It is MOST UNLIKELY that
1152 this will change BUT! Specifying a file with the format of a printcap
1153 file but containing only a subset of the printers actually in your real
1154 printcap file is a quick-n-dirty way to allow dynamic access to a subset
1155 of available printers.
1157 #ifndef PRINTCAP_NAME
1159 #define PRINTCAP_NAME "/etc/qconfig"
1161 #define PRINTCAP_NAME "lpstat"
1163 #define PRINTCAP_NAME "/etc/printcap"
1169 #include <sys/ipc.h>
1170 #include <sys/sem.h>
1171 #include <sys/shm.h>
1175 struct semid_ds *buf;
1176 unsigned short *array;
1179 #if defined(HPUX) && defined(HPUX10)
1183 #endif /* HPUX && HPUX10 */
1187 #include <afs/stds.h>
1188 #include <afs/kautils.h>
1192 #include <dce/dce_error.h>
1193 #include <dce/sec_login.h>
1213 extern char *sys_errlist[];
1214 #define strerror(i) sys_errlist[i]
1219 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1222 #ifndef MAXHOSTNAMELEN
1223 #define MAXHOSTNAMELEN 255
1226 /* Lists, trees, caching, datbase... */
1227 #include "ubi_sLinkList.h"
1228 #include "ubi_dLinkList.h"
1229 #ifndef UBI_BINTREE_H
1230 #include "ubi_Cache.h"
1231 #endif /* UBI_BINTREE_H */
1233 #include "version.h"
1235 #include "nameserv.h"
1237 #include "byteorder.h"
1240 #include "charset.h"
1242 #ifndef MAXCODEPAGELINES
1243 #define MAXCODEPAGELINES 256
1246 /***** automatically generated prototypes *****/
1252 #define S_IFREG 0100000
1256 #define S_ISREG(x) ((S_IFREG & (x))!=0)
1260 #define S_ISDIR(x) ((S_IFDIR & (x))!=0)
1263 #if !defined(S_ISLNK) && defined(S_IFLNK)
1264 #define S_ISLNK(x) ((S_IFLNK & (x))!=0)
1268 #define crypt ufc_crypt
1271 #ifdef REPLACE_STRLEN
1272 #define strlen(s) Strlen(s)
1275 #ifdef REPLACE_STRSTR
1276 #define strstr(s,p) Strstr(s,p)
1279 #ifdef REPLACE_MKTIME
1280 #define mktime(t) Mktime(t)
1284 #define NGROUPS_MAX 128
1288 #define EDQUOT ENOSPC
1291 #ifndef HAVE_GETGRNAM
1292 #define HAVE_GETGRNAM 1
1299 /* default to using ftruncate workaround as this is safer than assuming
1300 it works and getting lots of bug reports */
1301 #ifndef FTRUNCATE_CAN_EXTEND
1302 #define FTRUNCATE_CAN_EXTEND 0
1305 /* maybe this unix doesn't separate RD and WR locks? */
1307 #define F_RDLCK F_WRLCK
1311 #define ENOTSOCK EINVAL
1315 #define SIGCLD SIGCHLD
1322 #ifndef HAVE_FCNTL_LOCK
1323 #define HAVE_FCNTL_LOCK 1
1327 #define WAIT3_CAST2 (struct rusage *)
1331 #define WAIT3_CAST1 (int *)
1335 #define QSORT_CAST (int (*)())
1338 #ifndef INADDR_LOOPBACK
1339 #define INADDR_LOOPBACK 0x7f000001
1340 #endif /* INADDR_LOOPBACK */
1342 /* this is a rough check to see if this machine has a lstat() call.
1343 it is not guaranteed to work */
1344 #if !defined(S_ISLNK)
1348 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1355 #define geteuid() getuid()
1356 #define getegid() getgid()
1357 #define seteuid(x) setuid(x)
1358 #define setegid(x) setgid(x)
1362 #if (HAVE_FCNTL_LOCK == 0)
1363 /* since there is no locking available, system includes */
1364 /* for DomainOS 10.4 do not contain any of the following */
1365 /* #define's. So, to satisfy the compiler, add these */
1366 /* #define's, although they arn't really necessary. */
1371 #endif /* HAVE_FCNTL_LOCK == 0 */
1374 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1375 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1381 #define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
1386 #define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
1390 #endif /* sprintf */
1391 #define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
1393 #define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
1394 #define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
1395 #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
1396 #define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
1399 #include "mem_man/mem_man.h"
1400 #endif /* MEM_MAN */
1402 #endif /* _INCLUDES_H */