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
237 /* SETFS disabled until we can check on some bug reports */
238 #if _LINUX_C_LIB_VERSION_MAJOR >= 5
243 #if _LINUX_C_LIB_VERSION_MAJOR < 5
245 #define crypt pw_encrypt
252 #define SIGNAL_CAST (void (*)(int))
253 #include <netinet/tcp.h>
255 #include <sys/acct.h>
259 #include <sys/wait.h>
261 /* #include <termios.h> */
265 #define mktime timelocal
266 typedef unsigned short mode_t;
271 #ifndef REPLACE_GETPASS
272 #define REPLACE_GETPASS
277 #ifndef USE_SIGPROCMASK
278 #define USE_SIGPROCMASK
284 /* SunOS doesn't have POSIX atexit */
285 #define atexit on_exit
292 #include <sys/acct.h>
293 #include <sys/statfs.h>
294 #include <sys/statvfs.h>
295 #include <sys/filio.h>
296 #include <sys/sockio.h>
297 #include <netinet/in_systm.h>
298 #include <netinet/tcp.h>
299 #include <netinet/ip.h>
301 #include <arpa/inet.h>
302 #include <rpcsvc/ypclnt.h>
304 #include <sys/stropts.h>
307 #endif /* USE_LIBDES */
308 extern int gettimeofday (struct timeval *, void *);
309 extern int gethostname (char *name, int namelen);
310 extern int innetgr (const char *, const char *, const char *, const char *);
312 #define SIGNAL_CAST (void (*)(int))
317 #define REPLACE_STRLEN
323 #ifndef REPLACE_GETPASS
324 #define REPLACE_GETPASS
325 #endif /* REPLACE_GETPASS */
326 #define USE_SIGPROCMASK
332 #include <nfs/nfs_clnt.h>
334 #include <netinet/tcp.h>
341 #define SIGNAL_CAST (void(*)(int))
348 #include <netinet/tcp.h>
349 #include <sys/statfs.h>
355 #define SIGNAL_CAST (void (*)())
363 #if defined(SGI5) || defined(SGI6)
364 #include <arpa/inet.h>
365 #include <netinet/tcp.h>
366 #include <netinet/in_systm.h>
367 #include <netinet/ip.h>
368 #include <sys/statvfs.h>
377 #define SIGNAL_CAST (void (*)())
386 #include <bsd/net/soioctl.h>
390 #include <sys/statfs.h>
391 #include <sys/wait.h>
392 #include <sys/termio.h>
393 #define SIGNAL_CAST (void (*)())
395 extern struct group *getgrnam();
396 extern struct passwd *getpwnam();
399 #define REPLACE_STRSTR
407 #include <sys/statfs.h>
408 #include <sys/statvfs.h>
413 #define SIGNAL_CAST (void (*)(int))
423 #include <sys/statfs.h>
424 #include <sys/statvfs.h>
426 #include <sys/filio.h>
428 #include <sys/sockio.h>
429 #include <netinet/tcp.h>
434 #define SIGNAL_CAST (void (*)(int))
448 char *mktemp(char *); /* No standard include */
449 #include <netinet/in.h>
450 #include <arpa/inet.h> /* both for inet_ntoa */
451 #define SIGNAL_CAST ( void (*) (int) )
455 #include <netinet/tcp.h>
458 #include <sys/types.h>
459 #include <sys/security.h>
462 #define PASSWORD_LENGTH 16
463 #define NEED_AUTH_PARAMETERS
464 #endif /* OSF1_ENH_SEC */
472 #define SIGNAL_CAST (void (*)())
473 #include <sys/fcntl.h>
474 #include <sys/statfs.h>
482 #ifndef REPLACE_GETPASS
483 #define REPLACE_GETPASS
484 #endif /* REPLACE_GETPASS */
492 #include <netinet/tcp.h>
493 #define SIGNAL_CAST (void (*)())
500 #include <netinet/tcp.h>
501 /* you may not need this */
503 #define SIGNAL_CAST (void (*)())
505 #define REPLACE_INNETGR
511 #include <arpa/inet.h>
513 #include <netinet/tcp.h>
514 #include <netinet/in_systm.h>
515 #include <netinet/ip.h>
516 #define SIGNAL_CAST (void (*)())
524 #define HAVE_GETTIMEOFDAY
525 #define HAVE_PATHCONF
526 #define HAVE_GETGRNAM 1
534 #include <sys/select.h>
536 #include <sys/statfs.h>
539 #include <sys/priv.h>
540 #include <netinet/tcp.h>
545 #define SIGNAL_CAST (void (*)())
546 #define DEFAULT_PRINTING PRINT_AIX
547 /* we undef this because sys/param.h is broken in aix. uggh. */
548 #undef MAXHOSTNAMELEN
557 #include <sys/types.h>
558 #include <sys/termios.h>
559 #include <netinet/tcp.h>
560 #ifdef HPUX_10_TRUSTED
561 #include <hpsecurity.h>
563 #define NEED_AUTH_PARAMETERS
565 #define SIGNAL_CAST (void (*)(__harg))
566 #ifndef HPUX10 /* This is only needed for HPUX 9.x */
567 #define SELECT_CAST (int *)
571 #define WAIT3_CAST2 (int *)
576 #define DEFAULT_PRINTING PRINT_HPUX
577 /* Ken Weiss <krweiss@ucdavis.edu> tells us that SIGCLD_IGNORE is
579 /* #define SIGCLD_IGNORE */
587 #include <sys/types.h>
588 #include <sys/statfs.h>
589 #include <sys/stat.h>
591 #include <sys/socket.h>
594 #define SIGNAL_CAST (void (*)(int))
611 #include <sys/statfs.h>
612 #include <sys/statvfs.h>
615 #include <sys/sockio.h>
616 #include <netinet/tcp.h>
621 #define SIGNAL_CAST (void (*)(int))
625 #define seteuid(uid) setreuid(-1,uid)
628 #define setegid(gid) setregid(-1,gid)
634 #include <sys/types.h>
638 #define bzero(b,len) memset(b,0,len)
652 #define bzero(b,len) memset(b,0,len)
661 #define SIGNAL_CAST (void (*)(int))
662 #define WAIT3_CAST1 (union wait *)
671 #include <sys/statfs.h>
675 #define SIGNAL_CAST (void (*)())
676 #define HAVE_FCNTL_LOCK 0
677 #define HAVE_GETTIMEOFDAY
684 #include <sys/netinet/tcp.h>
685 #include <sys/netinet/in_systm.h>
686 #include <sys/netinet/ip.h>
691 #include <sys/statfs.h>
692 #include <sys/stropts.h>
699 #include <rpcsvc/ypclnt.h>
700 #endif /* NETGROUP */
702 #include <sys/security.h>
703 #include <sys/audit.h>
705 #define crypt bigcrypt
706 #endif /* SecureWare */
707 #define SIGNAL_CAST (void (*)(int))
712 #define setuid(u) setreuid(u,-1)
713 #define seteuid(u) setreuid(-1,u)
716 #define ftruncate(f,l) syscall(0x0a28,f,l)
718 #define NO_INITGROUPS
720 #endif /* SCO3_2_2 */
723 #define HAVE_PATHCONF
729 /* Definitions for RiscIX */
731 #define SIGNAL_CAST (void (*)(int))
732 #include <sys/dirent.h>
733 #include <sys/acct.h>
738 #define HAVE_GETTIMEOFDAY
746 #include <net/errno.h>
750 #include <sys/statfs.h>
752 #include <sys/sioctl.h>
755 #include <netinet/tcp.h>
756 #define FIONREAD FIORDCHK
759 #define SIGNAL_CAST (void (*)(int))
779 #define SIGNAL_CAST (void (*)(int))
780 char *strdup (char *);
793 #define SIGNAL_CAST (void (*)(int))
794 char *strdup (char *);
805 #include <sys/statfs.h>
806 #include <sys/stropts.h>
807 #define NO_GET_BROADCAST
813 #define PF_INET AF_INET
815 #define ftruncate(f,l) chsize(f,l)
819 #include <netinet/tcp.h>
820 #include <arpa/inet.h>
825 #define DONT_REINSTALL_SIG
828 #define SIGNAL_CAST (_SigFunc_Ptr_t)
831 extern char *mktemp(char *);
832 extern int fsync(int);
833 extern int seteuid(uid_t);
834 extern int setgroups(int, int *);
835 extern int initgroups(char *, int);
836 extern int statfs(char *, struct statfs *);
837 extern int setegid(gid_t);
838 extern int getopt(int, char *const *, const char *);
839 extern int chroot(char *);
840 extern int gettimeofday(struct timeval *, struct timezone *);
841 extern int gethostname(char *, int);
842 extern char *crypt(char *, char *);
843 extern char *getpass(char *);
848 #define MAXPATHLEN 1024
852 #include <sys/statfs.h>
853 #define SIGNAL_CAST (void (*)(int))
854 #define SIGCLD_IGNORE
855 #define HAVE_FCNTL_LOCK 1
865 #include <sys/fcntl.h>
866 #include <sys/statfs.h>
871 #define ptrdiff_t int
872 #define HAVE_GETGRNAM 0
877 #define NO_INITGROUPS
885 #define REPLACE_MKTIME
886 #define REPLACE_RENAME
887 #define REPLACE_STRSTR
894 #include <sys/statfs.h>
895 #include <sys/select.h>
898 #define SIGNAL_CAST (void (*)())
900 #define NO_INITGROUPS
902 #define HAVE_TIMEZONE
905 #define HAVE_FCNTL_LOCK 1
906 #define DEFAULT_PRINTING PRINT_QNX
914 #include <sys/timeb.h>
920 #include <sys/statfs.h>
923 #define SIGNAL_CAST (void (*)())
924 #define HAVE_FCNTL_LOCK 0
926 #define NO_GET_BROADCAST
929 #define NO_INITGROUPS
934 #define strcasecmp stricmp
935 #define strncasecmp strnicmp
940 #define SIGNAL_CAST (void (*)())
941 #define WAIT3_CAST1 (union wait *)
944 #include <resource.h>
948 #include <sys/statfs.h>
955 #define SIGNAL_CAST (void (*)(int))
958 #include <sys/select.h>
962 #include <sys/statfs.h>
963 #include <sys/bsdioctl.h>
967 #include <arpa/inet.h>
970 #include <netinet/tcp.h>
971 #include <sys/acct.h>
972 #include <sys/fcntl.h>
973 #include <sys/filio.h>
974 #include <sys/sockio.h>
975 #include <netinet/in_systm.h>
976 #include <netinet/ip.h>
977 #include <sys/termios.h>
979 #include <sys/timeb.h>
981 #define SIGNAL_CAST (void (*)(int))
985 #define USE_SIGPROCMASK
989 #define HAVE_FCNTL_LOCK 0
990 #define HAVE_GETTIMEOFDAY
991 #define HAVE_PATHCONF
994 #define NO_FORK_DEBUG
999 /* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */
1006 /*******************************************************************
1007 end of the platform specific sections
1008 ********************************************************************/
1010 #if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
1011 #include <sys/mman.h>
1015 #define NEED_AUTH_PARAMETERS
1018 #ifdef REPLACE_GETPASS
1019 extern char *getsmbpass(char *);
1020 #define getpass(s) getsmbpass(s)
1023 #ifdef REPLACE_INNETGR
1024 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
1028 #define FD_SETSIZE 255
1035 /* Now for some other grungy stuff */
1037 struct spwd { /* fake shadow password structure */
1044 #define bzero(p,s) memset(p,0,s)
1048 #ifndef HAVE_MEMMOVE
1050 #define memmove(d,s,n) MemMove(d,s,n)
1055 #include <sys/dir.h>
1058 /* some unixes have ENOTTY instead of TIOCNOTTY */
1061 #define TIOCNOTTY ENOTTY
1069 /* if undefined then use bsd or sysv printing */
1070 #ifndef DEFAULT_PRINTING
1072 #define DEFAULT_PRINTING PRINT_SYSV
1074 #define DEFAULT_PRINTING PRINT_BSD
1079 #include <sys/ipc.h>
1080 #include <sys/sem.h>
1081 #include <sys/shm.h>
1085 struct semid_ds *buf;
1086 unsigned short *array;
1092 #include <afs/stds.h>
1093 #include <afs/kautils.h>
1097 #include <dce/dce_error.h>
1098 #include <dce/sec_login.h>
1114 extern char *sys_errlist[];
1115 #define strerror(i) sys_errlist[i]
1120 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1123 #ifndef MAXHOSTNAMELEN
1124 #define MAXHOSTNAMELEN 255
1127 #include "version.h"
1129 #include "nameserv.h"
1130 #include "ubiqx/ubi_dLinkList.h"
1132 #include "byteorder.h"
1135 #include "charset.h"
1137 /***** automatically generated prototypes *****/
1143 #define S_IFREG 0100000
1147 #define S_ISREG(x) ((S_IFREG & (x))!=0)
1151 #define S_ISDIR(x) ((S_IFDIR & (x))!=0)
1154 #if !defined(S_ISLNK) && defined(S_IFLNK)
1155 #define S_ISLNK(x) ((S_IFLNK & (x))!=0)
1159 #define crypt ufc_crypt
1162 #ifdef REPLACE_STRLEN
1163 #define strlen(s) Strlen(s)
1166 #ifdef REPLACE_STRSTR
1167 #define strstr(s,p) Strstr(s,p)
1170 #ifdef REPLACE_MKTIME
1171 #define mktime(t) Mktime(t)
1175 #define NGROUPS_MAX 128
1179 #define EDQUOT ENOSPC
1182 #ifndef HAVE_GETGRNAM
1183 #define HAVE_GETGRNAM 1
1190 /* default to using ftruncate workaround as this is safer than assuming
1191 it works and getting lots of bug reports */
1192 #ifndef FTRUNCATE_CAN_EXTEND
1193 #define FTRUNCATE_CAN_EXTEND 0
1196 /* maybe this unix doesn't separate RD and WR locks? */
1198 #define F_RDLCK F_WRLCK
1202 #define ENOTSOCK EINVAL
1206 #define SIGCLD SIGCHLD
1213 #ifndef HAVE_FCNTL_LOCK
1214 #define HAVE_FCNTL_LOCK 1
1218 #define WAIT3_CAST2 (struct rusage *)
1222 #define WAIT3_CAST1 (int *)
1226 #define QSORT_CAST (int (*)())
1229 #ifndef INADDR_LOOPBACK
1230 #define INADDR_LOOPBACK 0x7f000001
1231 #endif /* INADDR_LOOPBACK */
1233 /* this is a rough check to see if this machine has a lstat() call.
1234 it is not guaranteed to work */
1235 #if !defined(S_ISLNK)
1239 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1246 #define geteuid() getuid()
1247 #define getegid() getgid()
1248 #define seteuid(x) setuid(x)
1249 #define setegid(x) setgid(x)
1253 #if (HAVE_FCNTL_LOCK == 0)
1254 /* since there is no locking available, system includes */
1255 /* for DomainOS 10.4 do not contain any of the following */
1256 /* #define's. So, to satisfy the compiler, add these */
1257 /* #define's, although they arn't really necessary. */
1262 #endif /* HAVE_FCNTL_LOCK == 0 */
1265 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1266 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1270 #define strcpy(dest,src) StrCpy(dest,src)
1274 /* possibly wrap the malloc calls */
1277 /* undo the old malloc def if necessary */
1279 #define xx_old_malloc malloc
1283 #define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
1285 /* undo the old realloc def if necessary */
1287 #define xx_old_realloc realloc
1291 #define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
1293 /* undo the old free def if necessary */
1295 #define xx_old_free free
1299 #define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
1301 /* and the malloc prototypes */
1302 void *malloc_wrapped(int,char *,int);
1303 void *realloc_wrapped(void *,int,char *,int);
1304 void free_wrapped(void *,char *,int);
1310 /* undo the old memcpy def if necessary */
1312 #define xx_old_memcpy memcpy
1316 #define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
1317 void *memcpy_wrapped(void *d,void *s,int l,char *fname,int line);