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
120 #include "ubi_dLinkList.h"
123 #include <posix/stdlib.h>
132 #include <sys/types.h>
135 #include <sys/statfs.h>
136 #include <sys/stream.h>
137 #include <netinet/types.h>
138 #include <netinet/ether.h>
139 #include <netinet/ip_if.h>
142 #include <sys/socket.h>
146 #include <sys/ioctl.h>
149 #include <posix/utime.h>
150 #include <bsd/sys/time.h>
151 #include <bsd/netinet/in.h>
153 #include <sys/time.h>
154 #include <netinet/in.h>
159 #include <sys/file.h>
160 #include <sys/stat.h>
161 #include <sys/param.h>
164 #include <sys/resource.h>
167 #include <sys/mount.h>
178 #include <sys/wait.h>
180 #include <sys/stream.h>
184 #include <bsd/net/if.h>
190 #if defined(GETPWANAM)
191 #include <sys/types.h>
192 #include <sys/label.h>
193 #include <sys/audit.h>
197 #if defined(SHADOW_PWD) && !defined(NETBSD) && !defined(FreeBSD) && !defined(CONVEX)
207 /***************************************************************************
208 Here come some platform specific sections
209 ***************************************************************************/
213 #include <arpa/inet.h>
217 #include <netinet/in.h>
218 #ifndef NO_ASMSIGNALH
219 #include <asm/signal.h>
222 #define _LINUX_C_LIB_VERSION_MAJOR 6
224 #include <rpcsvc/ypclnt.h>
226 #include <netinet/tcp.h>
227 #include <netinet/ip.h>
229 #define SIGNAL_CAST (__sighandler_t)
234 #define USE_SIGPROCMASK
238 /* SETFS disabled until we can check on some bug reports */
239 #if _LINUX_C_LIB_VERSION_MAJOR >= 5
244 #if _LINUX_C_LIB_VERSION_MAJOR < 5
246 #define crypt pw_encrypt
253 #define SIGNAL_CAST (void (*)(int))
254 #include <netinet/tcp.h>
256 #include <sys/acct.h>
260 #include <sys/wait.h>
262 /* #include <termios.h> */
266 #define mktime timelocal
267 typedef unsigned short mode_t;
272 #ifndef REPLACE_GETPASS
273 #define REPLACE_GETPASS
278 #ifndef USE_SIGPROCMASK
279 #define USE_SIGPROCMASK
285 /* SunOS doesn't have POSIX atexit */
286 #define atexit on_exit
293 #include <sys/acct.h>
294 #include <sys/statfs.h>
295 #include <sys/statvfs.h>
296 #include <sys/filio.h>
297 #include <sys/sockio.h>
298 #include <netinet/in_systm.h>
299 #include <netinet/tcp.h>
300 #include <netinet/ip.h>
302 #include <arpa/inet.h>
303 #include <rpcsvc/ypclnt.h>
305 #include <sys/stropts.h>
308 #endif /* USE_LIBDES */
309 extern int gettimeofday (struct timeval *, void *);
310 extern int gethostname (char *name, int namelen);
311 extern int innetgr (const char *, const char *, const char *, const char *);
313 #define SIGNAL_CAST (void (*)(int))
318 #define REPLACE_STRLEN
326 struct semid_ds *buf;
331 #ifndef REPLACE_GETPASS
332 #define REPLACE_GETPASS
333 #endif /* REPLACE_GETPASS */
334 #define USE_SIGPROCMASK
340 #include <nfs/nfs_clnt.h>
342 #include <netinet/tcp.h>
349 #define SIGNAL_CAST (void(*)(int))
356 #include <netinet/tcp.h>
357 #include <sys/statfs.h>
363 #define SIGNAL_CAST (void (*)())
371 #if defined(SGI5) || defined(SGI6)
372 #include <arpa/inet.h>
373 #include <netinet/tcp.h>
374 #include <netinet/in_systm.h>
375 #include <netinet/ip.h>
376 #include <sys/statvfs.h>
385 #define SIGNAL_CAST (void (*)())
394 #include <bsd/net/soioctl.h>
398 #include <sys/statfs.h>
399 #include <sys/wait.h>
400 #include <sys/termio.h>
401 #define SIGNAL_CAST (void (*)())
403 extern struct group *getgrnam();
404 extern struct passwd *getpwnam();
407 #define REPLACE_STRSTR
415 #include <sys/statfs.h>
416 #include <sys/statvfs.h>
421 #define SIGNAL_CAST (void (*)(int))
431 #include <sys/statfs.h>
432 #include <sys/statvfs.h>
434 #include <sys/filio.h>
436 #include <sys/sockio.h>
437 #include <netinet/tcp.h>
442 #define SIGNAL_CAST (void (*)(int))
455 char *mktemp(char *); /* No standard include */
456 #include <netinet/in.h>
457 #include <arpa/inet.h> /* both for inet_ntoa */
458 #define SIGNAL_CAST ( void (*) (int) )
462 #include <netinet/tcp.h>
465 #include <sys/types.h>
466 #include <sys/security.h>
469 #define PASSWORD_LENGTH 16
470 #define NEED_AUTH_PARAMETERS
471 #endif /* OSF1_ENH_SEC */
478 #define SIGNAL_CAST (void (*)())
479 #include <sys/fcntl.h>
480 #include <sys/statfs.h>
488 #ifndef REPLACE_GETPASS
489 #define REPLACE_GETPASS
490 #endif /* REPLACE_GETPASS */
498 #include <netinet/tcp.h>
499 #define SIGNAL_CAST (void (*)())
506 #include <netinet/tcp.h>
507 /* you may not need this */
509 #define SIGNAL_CAST (void (*)())
511 #define REPLACE_INNETGR
517 #include <arpa/inet.h>
519 #include <netinet/tcp.h>
520 #include <netinet/in_systm.h>
521 #include <netinet/ip.h>
522 #define SIGNAL_CAST (void (*)())
530 #define HAVE_GETTIMEOFDAY
531 #define HAVE_PATHCONF
532 #define HAVE_GETGRNAM 1
540 #include <sys/select.h>
542 #include <sys/statfs.h>
545 #include <sys/priv.h>
546 #include <netinet/tcp.h>
551 #define SIGNAL_CAST (void (*)())
552 #define DEFAULT_PRINTING PRINT_AIX
553 /* we undef this because sys/param.h is broken in aix. uggh. */
554 #undef MAXHOSTNAMELEN
563 #include <sys/types.h>
564 #include <sys/termios.h>
565 #include <netinet/tcp.h>
566 #ifdef HPUX_10_TRUSTED
567 #include <hpsecurity.h>
569 #define NEED_AUTH_PARAMETERS
571 #define SIGNAL_CAST (void (*)(__harg))
572 #ifndef HPUX10 /* This is only needed for HPUX 9.x */
573 #define SELECT_CAST (int *)
577 #define WAIT3_CAST2 (int *)
582 #define DEFAULT_PRINTING PRINT_HPUX
583 /* Ken Weiss <krweiss@ucdavis.edu> tells us that SIGCLD_IGNORE is
585 /* #define SIGCLD_IGNORE */
593 #include <sys/types.h>
594 #include <sys/statfs.h>
595 #include <sys/stat.h>
597 #include <sys/socket.h>
600 #define SIGNAL_CAST (void (*)(int))
617 #include <sys/statfs.h>
618 #include <sys/statvfs.h>
621 #include <sys/sockio.h>
622 #include <netinet/tcp.h>
627 #define SIGNAL_CAST (void (*)(int))
631 #define seteuid(uid) setreuid(-1,uid)
634 #define setegid(gid) setregid(-1,gid)
640 #include <sys/types.h>
644 #define bzero(b,len) memset(b,0,len)
658 #define bzero(b,len) memset(b,0,len)
667 #define SIGNAL_CAST (void (*)(int))
668 #define WAIT3_CAST1 (union wait *)
677 #include <sys/statfs.h>
681 #define SIGNAL_CAST (void (*)())
682 #define HAVE_FCNTL_LOCK 0
683 #define HAVE_GETTIMEOFDAY
690 #include <sys/netinet/tcp.h>
691 #include <sys/netinet/in_systm.h>
692 #include <sys/netinet/ip.h>
697 #include <sys/statfs.h>
698 #include <sys/stropts.h>
705 #include <rpcsvc/ypclnt.h>
706 #endif /* NETGROUP */
708 #include <sys/security.h>
709 #include <sys/audit.h>
711 #define crypt bigcrypt
712 #endif /* SecureWare */
713 #define SIGNAL_CAST (void (*)(int))
718 #define setuid(u) setreuid(u,-1)
719 #define seteuid(u) setreuid(-1,u)
722 #define ftruncate(f,l) syscall(0x0a28,f,l)
724 #define NO_INITGROUPS
726 #endif /* SCO3_2_2 */
729 #define HAVE_PATHCONF
735 /* Definitions for RiscIX */
737 #define SIGNAL_CAST (void (*)(int))
738 #include <sys/dirent.h>
739 #include <sys/acct.h>
744 #define HAVE_GETTIMEOFDAY
752 #include <net/errno.h>
756 #include <sys/statfs.h>
758 #include <sys/sioctl.h>
761 #include <netinet/tcp.h>
762 #define FIONREAD FIORDCHK
765 #define SIGNAL_CAST (void (*)(int))
785 #define SIGNAL_CAST (void (*)(int))
786 char *strdup (char *);
799 #define SIGNAL_CAST (void (*)(int))
800 char *strdup (char *);
811 #include <sys/statfs.h>
812 #include <sys/stropts.h>
813 #define NO_GET_BROADCAST
819 #define PF_INET AF_INET
821 #define ftruncate(f,l) chsize(f,l)
825 #include <netinet/tcp.h>
826 #include <arpa/inet.h>
831 #define DONT_REINSTALL_SIG
834 #define SIGNAL_CAST (_SigFunc_Ptr_t)
837 extern char *mktemp(char *);
838 extern int fsync(int);
839 extern int seteuid(uid_t);
840 extern int setgroups(int, int *);
841 extern int initgroups(char *, int);
842 extern int statfs(char *, struct statfs *);
843 extern int setegid(gid_t);
844 extern int getopt(int, char *const *, const char *);
845 extern int chroot(char *);
846 extern int gettimeofday(struct timeval *, struct timezone *);
847 extern int gethostname(char *, int);
848 extern char *crypt(char *, char *);
849 extern char *getpass(char *);
854 #define MAXPATHLEN 1024
858 #include <sys/statfs.h>
859 #define SIGNAL_CAST (void (*)(int))
860 #define SIGCLD_IGNORE
861 #define HAVE_FCNTL_LOCK 1
871 #include <sys/fcntl.h>
872 #include <sys/statfs.h>
877 #define ptrdiff_t int
878 #define HAVE_GETGRNAM 0
883 #define NO_INITGROUPS
891 #define REPLACE_MKTIME
892 #define REPLACE_RENAME
893 #define REPLACE_STRSTR
900 #include <sys/statfs.h>
901 #include <sys/select.h>
904 #define SIGNAL_CAST (void (*)())
906 #define NO_INITGROUPS
908 #define HAVE_TIMEZONE
911 #define HAVE_FCNTL_LOCK 1
912 #define DEFAULT_PRINTING PRINT_QNX
920 #include <sys/timeb.h>
926 #include <sys/statfs.h>
929 #define SIGNAL_CAST (void (*)())
930 #define HAVE_FCNTL_LOCK 0
932 #define NO_GET_BROADCAST
935 #define NO_INITGROUPS
940 #define strcasecmp stricmp
941 #define strncasecmp strnicmp
946 #define SIGNAL_CAST (void (*)())
947 #define WAIT3_CAST1 (union wait *)
950 #include <resource.h>
954 #include <sys/statfs.h>
961 #define SIGNAL_CAST (void (*)(int))
964 #include <sys/select.h>
968 #include <sys/statfs.h>
969 #include <sys/bsdioctl.h>
973 #include <arpa/inet.h>
976 #include <netinet/tcp.h>
977 #include <sys/acct.h>
978 #include <sys/fcntl.h>
979 #include <sys/filio.h>
980 #include <sys/sockio.h>
981 #include <netinet/in_systm.h>
982 #include <netinet/ip.h>
983 #include <sys/termios.h>
985 #include <sys/timeb.h>
987 #define SIGNAL_CAST (void (*)(int))
991 #define USE_SIGPROCMASK
995 #define HAVE_FCNTL_LOCK 0
996 #define HAVE_GETTIMEOFDAY
997 #define HAVE_PATHCONF
1000 #define NO_FORK_DEBUG
1002 #define HAVE_VFORK 1
1005 /* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */
1012 /*******************************************************************
1013 end of the platform specific sections
1014 ********************************************************************/
1016 #if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
1017 #include <sys/mman.h>
1021 #define NEED_AUTH_PARAMETERS
1024 #ifdef REPLACE_GETPASS
1025 extern char *getsmbpass(char *);
1026 #define getpass(s) getsmbpass(s)
1029 #ifdef REPLACE_INNETGR
1030 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
1034 #define FD_SETSIZE 255
1041 /* Now for some other grungy stuff */
1043 struct spwd { /* fake shadow password structure */
1050 #define bzero(p,s) memset(p,0,s)
1054 #ifndef HAVE_MEMMOVE
1056 #define memmove(d,s,n) MemMove(d,s,n)
1061 #include <sys/dir.h>
1064 /* some unixes have ENOTTY instead of TIOCNOTTY */
1067 #define TIOCNOTTY ENOTTY
1075 /* if undefined then use bsd or sysv printing */
1076 #ifndef DEFAULT_PRINTING
1078 #define DEFAULT_PRINTING PRINT_SYSV
1080 #define DEFAULT_PRINTING PRINT_BSD
1085 #include <sys/ipc.h>
1086 #include <sys/sem.h>
1087 #include <sys/shm.h>
1091 #include <afs/stds.h>
1092 #include <afs/kautils.h>
1096 #include <dce/dce_error.h>
1097 #include <dce/sec_login.h>
1113 extern char *sys_errlist[];
1114 #define strerror(i) sys_errlist[i]
1119 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1122 #ifndef MAXHOSTNAMELEN
1123 #define MAXHOSTNAMELEN 255
1126 #include "version.h"
1128 #include "nameserv.h"
1130 #include "byteorder.h"
1133 #include "charset.h"
1136 #define S_IFREG 0100000
1140 #define S_ISREG(x) ((S_IFREG & (x))!=0)
1144 #define S_ISDIR(x) ((S_IFDIR & (x))!=0)
1147 #if !defined(S_ISLNK) && defined(S_IFLNK)
1148 #define S_ISLNK(x) ((S_IFLNK & (x))!=0)
1152 #define crypt ufc_crypt
1155 #ifdef REPLACE_STRLEN
1156 #define strlen(s) Strlen(s)
1159 #ifdef REPLACE_STRSTR
1160 #define strstr(s,p) Strstr(s,p)
1163 #ifdef REPLACE_MKTIME
1164 #define mktime(t) Mktime(t)
1168 #define NGROUPS_MAX 128
1172 #define EDQUOT ENOSPC
1175 #ifndef HAVE_GETGRNAM
1176 #define HAVE_GETGRNAM 1
1183 /* default to using ftruncate workaround as this is safer than assuming
1184 it works and getting lots of bug reports */
1185 #ifndef FTRUNCATE_CAN_EXTEND
1186 #define FTRUNCATE_CAN_EXTEND 0
1189 /* maybe this unix doesn't separate RD and WR locks? */
1191 #define F_RDLCK F_WRLCK
1195 #define ENOTSOCK EINVAL
1199 #define SIGCLD SIGCHLD
1206 #ifndef HAVE_FCNTL_LOCK
1207 #define HAVE_FCNTL_LOCK 1
1211 #define WAIT3_CAST2 (struct rusage *)
1215 #define WAIT3_CAST1 (int *)
1219 #define QSORT_CAST (int (*)())
1222 #ifndef INADDR_LOOPBACK
1223 #define INADDR_LOOPBACK 0x7f000001
1224 #endif /* INADDR_LOOPBACK */
1226 /* this is a rough check to see if this machine has a lstat() call.
1227 it is not guaranteed to work */
1228 #if !defined(S_ISLNK)
1232 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1239 #define geteuid() getuid()
1240 #define getegid() getgid()
1241 #define seteuid(x) setuid(x)
1242 #define setegid(x) setgid(x)
1246 #if (HAVE_FCNTL_LOCK == 0)
1247 /* since there is no locking available, system includes */
1248 /* for DomainOS 10.4 do not contain any of the following */
1249 /* #define's. So, to satisfy the compiler, add these */
1250 /* #define's, although they arn't really necessary. */
1255 #endif /* HAVE_FCNTL_LOCK == 0 */
1258 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1259 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1263 #define strcpy(dest,src) StrCpy(dest,src)
1267 /* possibly wrap the malloc calls */
1270 /* undo the old malloc def if necessary */
1272 #define xx_old_malloc malloc
1276 #define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
1278 /* undo the old realloc def if necessary */
1280 #define xx_old_realloc realloc
1284 #define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
1286 /* undo the old free def if necessary */
1288 #define xx_old_free free
1292 #define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
1294 /* and the malloc prototypes */
1295 void *malloc_wrapped(int,char *,int);
1296 void *realloc_wrapped(void *,int,char *,int);
1297 void free_wrapped(void *,char *,int);
1303 /* undo the old memcpy def if necessary */
1305 #define xx_old_memcpy memcpy
1309 #define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
1310 void *memcpy_wrapped(void *d,void *s,int l,char *fname,int line);