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
325 struct semid_ds *buf;
330 #ifndef REPLACE_GETPASS
331 #define REPLACE_GETPASS
332 #endif /* REPLACE_GETPASS */
333 #define USE_SIGPROCMASK
339 #include <nfs/nfs_clnt.h>
341 #include <netinet/tcp.h>
348 #define SIGNAL_CAST (void(*)(int))
355 #include <netinet/tcp.h>
356 #include <sys/statfs.h>
362 #define SIGNAL_CAST (void (*)())
370 #if defined(SGI5) || defined(SGI6)
371 #include <arpa/inet.h>
372 #include <netinet/tcp.h>
373 #include <netinet/in_systm.h>
374 #include <netinet/ip.h>
375 #include <sys/statvfs.h>
384 #define SIGNAL_CAST (void (*)())
393 #include <bsd/net/soioctl.h>
397 #include <sys/statfs.h>
398 #include <sys/wait.h>
399 #include <sys/termio.h>
400 #define SIGNAL_CAST (void (*)())
402 extern struct group *getgrnam();
403 extern struct passwd *getpwnam();
406 #define REPLACE_STRSTR
414 #include <sys/statfs.h>
415 #include <sys/statvfs.h>
420 #define SIGNAL_CAST (void (*)(int))
430 #include <sys/statfs.h>
431 #include <sys/statvfs.h>
433 #include <sys/filio.h>
435 #include <sys/sockio.h>
436 #include <netinet/tcp.h>
441 #define SIGNAL_CAST (void (*)(int))
454 char *mktemp(char *); /* No standard include */
455 #include <netinet/in.h>
456 #include <arpa/inet.h> /* both for inet_ntoa */
457 #define SIGNAL_CAST ( void (*) (int) )
461 #include <netinet/tcp.h>
464 #include <sys/types.h>
465 #include <sys/security.h>
468 #define PASSWORD_LENGTH 16
469 #define NEED_AUTH_PARAMETERS
470 #endif /* OSF1_ENH_SEC */
477 #define SIGNAL_CAST (void (*)())
478 #include <sys/fcntl.h>
479 #include <sys/statfs.h>
487 #ifndef REPLACE_GETPASS
488 #define REPLACE_GETPASS
489 #endif /* REPLACE_GETPASS */
497 #include <netinet/tcp.h>
498 #define SIGNAL_CAST (void (*)())
505 #include <netinet/tcp.h>
506 /* you may not need this */
508 #define SIGNAL_CAST (void (*)())
510 #define REPLACE_INNETGR
516 #include <arpa/inet.h>
518 #include <netinet/tcp.h>
519 #include <netinet/in_systm.h>
520 #include <netinet/ip.h>
521 #define SIGNAL_CAST (void (*)())
529 #define HAVE_GETTIMEOFDAY
530 #define HAVE_PATHCONF
531 #define HAVE_GETGRNAM 1
539 #include <sys/select.h>
541 #include <sys/statfs.h>
544 #include <sys/priv.h>
545 #include <netinet/tcp.h>
550 #define SIGNAL_CAST (void (*)())
551 #define DEFAULT_PRINTING PRINT_AIX
552 /* we undef this because sys/param.h is broken in aix. uggh. */
553 #undef MAXHOSTNAMELEN
562 #include <sys/types.h>
563 #include <sys/termios.h>
564 #include <netinet/tcp.h>
565 #ifdef HPUX_10_TRUSTED
566 #include <hpsecurity.h>
568 #define NEED_AUTH_PARAMETERS
570 #define SIGNAL_CAST (void (*)(__harg))
571 #ifndef HPUX10 /* This is only needed for HPUX 9.x */
572 #define SELECT_CAST (int *)
576 #define WAIT3_CAST2 (int *)
581 #define DEFAULT_PRINTING PRINT_HPUX
582 /* Ken Weiss <krweiss@ucdavis.edu> tells us that SIGCLD_IGNORE is
584 /* #define SIGCLD_IGNORE */
592 #include <sys/types.h>
593 #include <sys/statfs.h>
594 #include <sys/stat.h>
596 #include <sys/socket.h>
599 #define SIGNAL_CAST (void (*)(int))
616 #include <sys/statfs.h>
617 #include <sys/statvfs.h>
620 #include <sys/sockio.h>
621 #include <netinet/tcp.h>
626 #define SIGNAL_CAST (void (*)(int))
630 #define seteuid(uid) setreuid(-1,uid)
633 #define setegid(gid) setregid(-1,gid)
639 #include <sys/types.h>
643 #define bzero(b,len) memset(b,0,len)
657 #define bzero(b,len) memset(b,0,len)
666 #define SIGNAL_CAST (void (*)(int))
667 #define WAIT3_CAST1 (union wait *)
676 #include <sys/statfs.h>
680 #define SIGNAL_CAST (void (*)())
681 #define HAVE_FCNTL_LOCK 0
682 #define HAVE_GETTIMEOFDAY
689 #include <sys/netinet/tcp.h>
690 #include <sys/netinet/in_systm.h>
691 #include <sys/netinet/ip.h>
696 #include <sys/statfs.h>
697 #include <sys/stropts.h>
704 #include <rpcsvc/ypclnt.h>
705 #endif /* NETGROUP */
707 #include <sys/security.h>
708 #include <sys/audit.h>
710 #define crypt bigcrypt
711 #endif /* SecureWare */
712 #define SIGNAL_CAST (void (*)(int))
717 #define setuid(u) setreuid(u,-1)
718 #define seteuid(u) setreuid(-1,u)
721 #define ftruncate(f,l) syscall(0x0a28,f,l)
723 #define NO_INITGROUPS
725 #endif /* SCO3_2_2 */
728 #define HAVE_PATHCONF
734 /* Definitions for RiscIX */
736 #define SIGNAL_CAST (void (*)(int))
737 #include <sys/dirent.h>
738 #include <sys/acct.h>
743 #define HAVE_GETTIMEOFDAY
751 #include <net/errno.h>
755 #include <sys/statfs.h>
757 #include <sys/sioctl.h>
760 #include <netinet/tcp.h>
761 #define FIONREAD FIORDCHK
764 #define SIGNAL_CAST (void (*)(int))
784 #define SIGNAL_CAST (void (*)(int))
785 char *strdup (char *);
798 #define SIGNAL_CAST (void (*)(int))
799 char *strdup (char *);
810 #include <sys/statfs.h>
811 #include <sys/stropts.h>
812 #define NO_GET_BROADCAST
818 #define PF_INET AF_INET
820 #define ftruncate(f,l) chsize(f,l)
824 #include <netinet/tcp.h>
825 #include <arpa/inet.h>
830 #define DONT_REINSTALL_SIG
833 #define SIGNAL_CAST (_SigFunc_Ptr_t)
836 extern char *mktemp(char *);
837 extern int fsync(int);
838 extern int seteuid(uid_t);
839 extern int setgroups(int, int *);
840 extern int initgroups(char *, int);
841 extern int statfs(char *, struct statfs *);
842 extern int setegid(gid_t);
843 extern int getopt(int, char *const *, const char *);
844 extern int chroot(char *);
845 extern int gettimeofday(struct timeval *, struct timezone *);
846 extern int gethostname(char *, int);
847 extern char *crypt(char *, char *);
848 extern char *getpass(char *);
853 #define MAXPATHLEN 1024
857 #include <sys/statfs.h>
858 #define SIGNAL_CAST (void (*)(int))
859 #define SIGCLD_IGNORE
860 #define HAVE_FCNTL_LOCK 1
870 #include <sys/fcntl.h>
871 #include <sys/statfs.h>
876 #define ptrdiff_t int
877 #define HAVE_GETGRNAM 0
882 #define NO_INITGROUPS
890 #define REPLACE_MKTIME
891 #define REPLACE_RENAME
892 #define REPLACE_STRSTR
899 #include <sys/statfs.h>
900 #include <sys/select.h>
903 #define SIGNAL_CAST (void (*)())
905 #define NO_INITGROUPS
907 #define HAVE_TIMEZONE
910 #define HAVE_FCNTL_LOCK 1
911 #define DEFAULT_PRINTING PRINT_QNX
919 #include <sys/timeb.h>
925 #include <sys/statfs.h>
928 #define SIGNAL_CAST (void (*)())
929 #define HAVE_FCNTL_LOCK 0
931 #define NO_GET_BROADCAST
934 #define NO_INITGROUPS
939 #define strcasecmp stricmp
940 #define strncasecmp strnicmp
945 #define SIGNAL_CAST (void (*)())
946 #define WAIT3_CAST1 (union wait *)
949 #include <resource.h>
953 #include <sys/statfs.h>
960 #define SIGNAL_CAST (void (*)(int))
963 #include <sys/select.h>
967 #include <sys/statfs.h>
968 #include <sys/bsdioctl.h>
972 #include <arpa/inet.h>
975 #include <netinet/tcp.h>
976 #include <sys/acct.h>
977 #include <sys/fcntl.h>
978 #include <sys/filio.h>
979 #include <sys/sockio.h>
980 #include <netinet/in_systm.h>
981 #include <netinet/ip.h>
982 #include <sys/termios.h>
984 #include <sys/timeb.h>
986 #define SIGNAL_CAST (void (*)(int))
990 #define USE_SIGPROCMASK
994 #define HAVE_FCNTL_LOCK 0
995 #define HAVE_GETTIMEOFDAY
996 #define HAVE_PATHCONF
999 #define NO_FORK_DEBUG
1001 #define HAVE_VFORK 1
1004 /* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */
1011 /*******************************************************************
1012 end of the platform specific sections
1013 ********************************************************************/
1015 #if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
1016 #include <sys/mman.h>
1020 #define NEED_AUTH_PARAMETERS
1023 #ifdef REPLACE_GETPASS
1024 extern char *getsmbpass(char *);
1025 #define getpass(s) getsmbpass(s)
1028 #ifdef REPLACE_INNETGR
1029 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
1033 #define FD_SETSIZE 255
1040 /* Now for some other grungy stuff */
1042 struct spwd { /* fake shadow password structure */
1049 #define bzero(p,s) memset(p,0,s)
1053 #ifndef HAVE_MEMMOVE
1055 #define memmove(d,s,n) MemMove(d,s,n)
1060 #include <sys/dir.h>
1063 /* some unixes have ENOTTY instead of TIOCNOTTY */
1066 #define TIOCNOTTY ENOTTY
1074 /* if undefined then use bsd or sysv printing */
1075 #ifndef DEFAULT_PRINTING
1077 #define DEFAULT_PRINTING PRINT_SYSV
1079 #define DEFAULT_PRINTING PRINT_BSD
1084 #include <sys/ipc.h>
1085 #include <sys/sem.h>
1086 #include <sys/shm.h>
1090 #include <afs/stds.h>
1091 #include <afs/kautils.h>
1095 #include <dce/dce_error.h>
1096 #include <dce/sec_login.h>
1112 extern char *sys_errlist[];
1113 #define strerror(i) sys_errlist[i]
1118 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1121 #ifndef MAXHOSTNAMELEN
1122 #define MAXHOSTNAMELEN 255
1125 #include "version.h"
1127 #include "nameserv.h"
1128 #include "ubiqx/ubi_dLinkList.h"
1130 #include "byteorder.h"
1133 #include "charset.h"
1135 /***** automatically generated prototypes *****/
1136 #include "rpc_pipes/rpc_proto.h"
1142 #define S_IFREG 0100000
1146 #define S_ISREG(x) ((S_IFREG & (x))!=0)
1150 #define S_ISDIR(x) ((S_IFDIR & (x))!=0)
1153 #if !defined(S_ISLNK) && defined(S_IFLNK)
1154 #define S_ISLNK(x) ((S_IFLNK & (x))!=0)
1158 #define crypt ufc_crypt
1161 #ifdef REPLACE_STRLEN
1162 #define strlen(s) Strlen(s)
1165 #ifdef REPLACE_STRSTR
1166 #define strstr(s,p) Strstr(s,p)
1169 #ifdef REPLACE_MKTIME
1170 #define mktime(t) Mktime(t)
1174 #define NGROUPS_MAX 128
1178 #define EDQUOT ENOSPC
1181 #ifndef HAVE_GETGRNAM
1182 #define HAVE_GETGRNAM 1
1189 /* default to using ftruncate workaround as this is safer than assuming
1190 it works and getting lots of bug reports */
1191 #ifndef FTRUNCATE_CAN_EXTEND
1192 #define FTRUNCATE_CAN_EXTEND 0
1195 /* maybe this unix doesn't separate RD and WR locks? */
1197 #define F_RDLCK F_WRLCK
1201 #define ENOTSOCK EINVAL
1205 #define SIGCLD SIGCHLD
1212 #ifndef HAVE_FCNTL_LOCK
1213 #define HAVE_FCNTL_LOCK 1
1217 #define WAIT3_CAST2 (struct rusage *)
1221 #define WAIT3_CAST1 (int *)
1225 #define QSORT_CAST (int (*)())
1228 #ifndef INADDR_LOOPBACK
1229 #define INADDR_LOOPBACK 0x7f000001
1230 #endif /* INADDR_LOOPBACK */
1232 /* this is a rough check to see if this machine has a lstat() call.
1233 it is not guaranteed to work */
1234 #if !defined(S_ISLNK)
1238 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1245 #define geteuid() getuid()
1246 #define getegid() getgid()
1247 #define seteuid(x) setuid(x)
1248 #define setegid(x) setgid(x)
1252 #if (HAVE_FCNTL_LOCK == 0)
1253 /* since there is no locking available, system includes */
1254 /* for DomainOS 10.4 do not contain any of the following */
1255 /* #define's. So, to satisfy the compiler, add these */
1256 /* #define's, although they arn't really necessary. */
1261 #endif /* HAVE_FCNTL_LOCK == 0 */
1264 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1265 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1269 #define strcpy(dest,src) StrCpy(dest,src)
1273 /* possibly wrap the malloc calls */
1276 /* undo the old malloc def if necessary */
1278 #define xx_old_malloc malloc
1282 #define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
1284 /* undo the old realloc def if necessary */
1286 #define xx_old_realloc realloc
1290 #define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
1292 /* undo the old free def if necessary */
1294 #define xx_old_free free
1298 #define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
1300 /* and the malloc prototypes */
1301 void *malloc_wrapped(int,char *,int);
1302 void *realloc_wrapped(void *,int,char *,int);
1303 void free_wrapped(void *,char *,int);
1309 /* undo the old memcpy def if necessary */
1311 #define xx_old_memcpy memcpy
1315 #define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
1316 void *memcpy_wrapped(void *d,void *s,int l,char *fname,int line);