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>
218 #define _LINUX_C_LIB_VERSION_MAJOR 6
220 #include <rpcsvc/ypclnt.h>
222 #include <netinet/tcp.h>
223 #include <netinet/ip.h>
225 #define SIGNAL_CAST (__sighandler_t)
230 #define USE_SIGPROCMASK
234 /* SETFS disabled until we can check on some bug reports */
235 #if _LINUX_C_LIB_VERSION_MAJOR >= 5
240 #if _LINUX_C_LIB_VERSION_MAJOR < 5
242 #define crypt pw_encrypt
249 #define SIGNAL_CAST (void (*)(int))
250 #include <netinet/tcp.h>
252 #include <sys/acct.h>
256 #include <sys/wait.h>
258 /* #include <termios.h> */
262 #define mktime timelocal
263 typedef unsigned short mode_t;
268 #ifndef REPLACE_GETPASS
269 #define REPLACE_GETPASS
274 #ifndef USE_SIGPROCMASK
275 #define USE_SIGPROCMASK
281 /* SunOS doesn't have POSIX atexit */
282 #define atexit on_exit
289 #include <sys/acct.h>
290 #include <sys/statfs.h>
291 #include <sys/statvfs.h>
292 #include <sys/filio.h>
293 #include <sys/sockio.h>
294 #include <netinet/in_systm.h>
295 #include <netinet/tcp.h>
296 #include <netinet/ip.h>
298 #include <arpa/inet.h>
299 #include <rpcsvc/ypclnt.h>
301 #include <sys/stropts.h>
304 #endif /* USE_LIBDES */
305 extern int gettimeofday (struct timeval *, void *);
306 extern int gethostname (char *name, int namelen);
307 extern int innetgr (const char *, const char *, const char *, const char *);
309 #define SIGNAL_CAST (void (*)(int))
314 #define REPLACE_STRLEN
320 #ifndef REPLACE_GETPASS
321 #define REPLACE_GETPASS
322 #endif /* REPLACE_GETPASS */
323 #define USE_SIGPROCMASK
329 #include <nfs/nfs_clnt.h>
331 #include <netinet/tcp.h>
338 #define SIGNAL_CAST (void(*)(int))
345 #include <netinet/tcp.h>
346 #include <sys/statfs.h>
352 #define SIGNAL_CAST (void (*)())
360 #if defined(SGI5) || defined(SGI6)
361 #include <arpa/inet.h>
362 #include <netinet/tcp.h>
363 #include <netinet/in_systm.h>
364 #include <netinet/ip.h>
365 #include <sys/statvfs.h>
374 #define SIGNAL_CAST (void (*)())
383 #include <bsd/net/soioctl.h>
387 #include <sys/statfs.h>
388 #include <sys/wait.h>
389 #include <sys/termio.h>
390 #define SIGNAL_CAST (void (*)())
392 extern struct group *getgrnam();
393 extern struct passwd *getpwnam();
396 #define REPLACE_STRSTR
404 #include <sys/statfs.h>
405 #include <sys/statvfs.h>
410 #define SIGNAL_CAST (void (*)(int))
420 #include <sys/statfs.h>
421 #include <sys/statvfs.h>
423 #include <sys/filio.h>
425 #include <sys/sockio.h>
426 #include <netinet/tcp.h>
431 #define SIGNAL_CAST (void (*)(int))
445 char *mktemp(char *); /* No standard include */
446 #include <netinet/in.h>
447 #include <arpa/inet.h> /* both for inet_ntoa */
448 #define SIGNAL_CAST ( void (*) (int) )
452 #include <netinet/tcp.h>
455 #include <sys/types.h>
456 #include <sys/security.h>
459 #define PASSWORD_LENGTH 16
460 #define NEED_AUTH_PARAMETERS
461 #endif /* OSF1_ENH_SEC */
469 #define SIGNAL_CAST (void (*)())
470 #include <sys/fcntl.h>
471 #include <sys/statfs.h>
479 #ifndef REPLACE_GETPASS
480 #define REPLACE_GETPASS
481 #endif /* REPLACE_GETPASS */
489 #include <netinet/tcp.h>
490 #define SIGNAL_CAST (void (*)())
497 #include <netinet/tcp.h>
498 /* you may not need this */
500 #define SIGNAL_CAST (void (*)())
502 #define REPLACE_INNETGR
508 #include <arpa/inet.h>
510 #include <netinet/tcp.h>
511 #include <netinet/in_systm.h>
512 #include <netinet/ip.h>
513 #define SIGNAL_CAST (void (*)())
521 #define HAVE_GETTIMEOFDAY
522 #define HAVE_PATHCONF
523 #define HAVE_GETGRNAM 1
531 #include <sys/select.h>
533 #include <sys/statfs.h>
536 #include <sys/priv.h>
537 #include <netinet/tcp.h>
542 #define SIGNAL_CAST (void (*)())
543 #define DEFAULT_PRINTING PRINT_AIX
544 /* we undef this because sys/param.h is broken in aix. uggh. */
545 #undef MAXHOSTNAMELEN
554 #include <sys/types.h>
555 #include <sys/termios.h>
556 #include <netinet/tcp.h>
557 #ifdef HPUX_10_TRUSTED
558 #include <hpsecurity.h>
560 #define NEED_AUTH_PARAMETERS
562 #define SIGNAL_CAST (void (*)(__harg))
563 #ifndef HPUX10 /* This is only needed for HPUX 9.x */
564 #define SELECT_CAST (int *)
568 #define WAIT3_CAST2 (int *)
574 #define DEFAULT_PRINTING PRINT_HPUX
575 /* Ken Weiss <krweiss@ucdavis.edu> tells us that SIGCLD_IGNORE is
577 /* #define SIGCLD_IGNORE */
585 #include <sys/types.h>
586 #include <sys/statfs.h>
587 #include <sys/stat.h>
589 #include <sys/socket.h>
592 #define SIGNAL_CAST (void (*)(int))
609 #include <sys/statfs.h>
610 #include <sys/statvfs.h>
613 #include <sys/sockio.h>
614 #include <netinet/tcp.h>
619 #define SIGNAL_CAST (void (*)(int))
623 #define seteuid(uid) setreuid(-1,uid)
626 #define setegid(gid) setregid(-1,gid)
632 #include <sys/types.h>
636 #define bzero(b,len) memset(b,0,len)
650 #define bzero(b,len) memset(b,0,len)
659 #define SIGNAL_CAST (void (*)(int))
660 #define WAIT3_CAST1 (union wait *)
669 #include <sys/statfs.h>
673 #define SIGNAL_CAST (void (*)())
674 #define HAVE_FCNTL_LOCK 0
675 #define HAVE_GETTIMEOFDAY
682 #include <sys/netinet/tcp.h>
683 #include <sys/netinet/in_systm.h>
684 #include <sys/netinet/ip.h>
689 #include <sys/statfs.h>
690 #include <sys/stropts.h>
697 #include <rpcsvc/ypclnt.h>
698 #endif /* NETGROUP */
700 #include <sys/security.h>
701 #include <sys/audit.h>
703 #define crypt bigcrypt
704 #endif /* SecureWare */
705 #define SIGNAL_CAST (void (*)(int))
710 #define setuid(u) setreuid(u,-1)
711 #define seteuid(u) setreuid(-1,u)
714 #define ftruncate(f,l) syscall(0x0a28,f,l)
716 #define NO_INITGROUPS
718 #endif /* SCO3_2_2 */
721 #define HAVE_PATHCONF
727 /* Definitions for RiscIX */
729 #define SIGNAL_CAST (void (*)(int))
730 #include <sys/dirent.h>
731 #include <sys/acct.h>
736 #define HAVE_GETTIMEOFDAY
744 #include <net/errno.h>
748 #include <sys/statfs.h>
750 #include <sys/sioctl.h>
753 #include <netinet/tcp.h>
754 #define FIONREAD FIORDCHK
757 #define SIGNAL_CAST (void (*)(int))
777 #define SIGNAL_CAST (void (*)(int))
778 char *strdup (char *);
791 #define SIGNAL_CAST (void (*)(int))
792 char *strdup (char *);
803 #include <sys/statfs.h>
804 #include <sys/stropts.h>
805 #define NO_GET_BROADCAST
811 #define PF_INET AF_INET
813 #define ftruncate(f,l) chsize(f,l)
817 #include <netinet/tcp.h>
818 #include <arpa/inet.h>
823 #define DONT_REINSTALL_SIG
826 #define SIGNAL_CAST (_SigFunc_Ptr_t)
829 extern char *mktemp(char *);
830 extern int fsync(int);
831 extern int seteuid(uid_t);
832 extern int setgroups(int, int *);
833 extern int initgroups(char *, int);
834 extern int statfs(char *, struct statfs *);
835 extern int setegid(gid_t);
836 extern int getopt(int, char *const *, const char *);
837 extern int chroot(char *);
838 extern int gettimeofday(struct timeval *, struct timezone *);
839 extern int gethostname(char *, int);
840 extern char *crypt(char *, char *);
841 extern char *getpass(char *);
846 #define MAXPATHLEN 1024
850 #include <sys/statfs.h>
851 #define SIGNAL_CAST (void (*)(int))
852 #define SIGCLD_IGNORE
853 #define HAVE_FCNTL_LOCK 1
863 #include <sys/fcntl.h>
864 #include <sys/statfs.h>
869 #define ptrdiff_t int
870 #define HAVE_GETGRNAM 0
875 #define NO_INITGROUPS
883 #define REPLACE_MKTIME
884 #define REPLACE_RENAME
885 #define REPLACE_STRSTR
892 #include <sys/statfs.h>
893 #include <sys/select.h>
896 #define SIGNAL_CAST (void (*)())
898 #define NO_INITGROUPS
900 #define HAVE_TIMEZONE
903 #define HAVE_FCNTL_LOCK 1
904 #define DEFAULT_PRINTING PRINT_QNX
912 #include <sys/timeb.h>
918 #include <sys/statfs.h>
921 #define SIGNAL_CAST (void (*)())
922 #define HAVE_FCNTL_LOCK 0
924 #define NO_GET_BROADCAST
927 #define NO_INITGROUPS
932 #define strcasecmp stricmp
933 #define strncasecmp strnicmp
938 #define SIGNAL_CAST (void (*)())
939 #define WAIT3_CAST1 (union wait *)
942 #include <resource.h>
946 #include <sys/statfs.h>
953 #define SIGNAL_CAST (void (*)(int))
956 #include <sys/select.h>
960 #include <sys/statfs.h>
961 #include <sys/bsdioctl.h>
965 #include <arpa/inet.h>
968 #include <netinet/tcp.h>
969 #include <sys/acct.h>
970 #include <sys/fcntl.h>
971 #include <sys/filio.h>
972 #include <sys/sockio.h>
973 #include <netinet/in_systm.h>
974 #include <netinet/ip.h>
975 #include <sys/termios.h>
977 #include <sys/timeb.h>
979 #define SIGNAL_CAST (void (*)(int))
983 #define USE_SIGPROCMASK
987 #define HAVE_FCNTL_LOCK 0
988 #define HAVE_GETTIMEOFDAY
989 #define HAVE_PATHCONF
992 #define NO_FORK_DEBUG
997 /* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */
1004 /*******************************************************************
1005 end of the platform specific sections
1006 ********************************************************************/
1008 #if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
1009 #include <sys/mman.h>
1013 #define NEED_AUTH_PARAMETERS
1016 #ifdef REPLACE_GETPASS
1017 extern char *getsmbpass(char *);
1018 #define getpass(s) getsmbpass(s)
1021 #ifdef REPLACE_INNETGR
1022 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
1026 #define FD_SETSIZE 255
1033 /* Now for some other grungy stuff */
1035 struct spwd { /* fake shadow password structure */
1042 #define bzero(p,s) memset(p,0,s)
1046 #ifndef HAVE_MEMMOVE
1048 #define memmove(d,s,n) MemMove(d,s,n)
1053 #include <sys/dir.h>
1056 /* some unixes have ENOTTY instead of TIOCNOTTY */
1059 #define TIOCNOTTY ENOTTY
1067 /* if undefined then use bsd or sysv printing */
1068 #ifndef DEFAULT_PRINTING
1070 #define DEFAULT_PRINTING PRINT_SYSV
1072 #define DEFAULT_PRINTING PRINT_BSD
1076 /* This defines the name of the printcap file. It is MOST UNLIKELY that
1077 this will change BUT! Specifying a file with the format of a printcap
1078 file but containing only a subset of the printers actually in your real
1079 printcap file is a quick-n-dirty way to allow dynamic access to a subset
1080 of available printers.
1082 #ifndef PRINTCAP_NAME
1084 #define PRINTCAP_NAME "/etc/qconfig"
1086 #define PRINTCAP_NAME "lpstat"
1088 #define PRINTCAP_NAME "/etc/printcap"
1094 #include <sys/ipc.h>
1095 #include <sys/sem.h>
1096 #include <sys/shm.h>
1100 struct semid_ds *buf;
1101 unsigned short *array;
1107 #include <afs/stds.h>
1108 #include <afs/kautils.h>
1112 #include <dce/dce_error.h>
1113 #include <dce/sec_login.h>
1129 extern char *sys_errlist[];
1130 #define strerror(i) sys_errlist[i]
1135 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1138 #ifndef MAXHOSTNAMELEN
1139 #define MAXHOSTNAMELEN 255
1142 #include "version.h"
1144 #include "nameserv.h"
1145 #include "ubiqx/ubi_dLinkList.h"
1147 #include "byteorder.h"
1150 #include "charset.h"
1152 /***** automatically generated prototypes *****/
1158 #define S_IFREG 0100000
1162 #define S_ISREG(x) ((S_IFREG & (x))!=0)
1166 #define S_ISDIR(x) ((S_IFDIR & (x))!=0)
1169 #if !defined(S_ISLNK) && defined(S_IFLNK)
1170 #define S_ISLNK(x) ((S_IFLNK & (x))!=0)
1174 #define crypt ufc_crypt
1177 #ifdef REPLACE_STRLEN
1178 #define strlen(s) Strlen(s)
1181 #ifdef REPLACE_STRSTR
1182 #define strstr(s,p) Strstr(s,p)
1185 #ifdef REPLACE_MKTIME
1186 #define mktime(t) Mktime(t)
1190 #define NGROUPS_MAX 128
1194 #define EDQUOT ENOSPC
1197 #ifndef HAVE_GETGRNAM
1198 #define HAVE_GETGRNAM 1
1205 /* default to using ftruncate workaround as this is safer than assuming
1206 it works and getting lots of bug reports */
1207 #ifndef FTRUNCATE_CAN_EXTEND
1208 #define FTRUNCATE_CAN_EXTEND 0
1211 /* maybe this unix doesn't separate RD and WR locks? */
1213 #define F_RDLCK F_WRLCK
1217 #define ENOTSOCK EINVAL
1221 #define SIGCLD SIGCHLD
1228 #ifndef HAVE_FCNTL_LOCK
1229 #define HAVE_FCNTL_LOCK 1
1233 #define WAIT3_CAST2 (struct rusage *)
1237 #define WAIT3_CAST1 (int *)
1241 #define QSORT_CAST (int (*)())
1244 #ifndef INADDR_LOOPBACK
1245 #define INADDR_LOOPBACK 0x7f000001
1246 #endif /* INADDR_LOOPBACK */
1248 /* this is a rough check to see if this machine has a lstat() call.
1249 it is not guaranteed to work */
1250 #if !defined(S_ISLNK)
1254 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1261 #define geteuid() getuid()
1262 #define getegid() getgid()
1263 #define seteuid(x) setuid(x)
1264 #define setegid(x) setgid(x)
1268 #if (HAVE_FCNTL_LOCK == 0)
1269 /* since there is no locking available, system includes */
1270 /* for DomainOS 10.4 do not contain any of the following */
1271 /* #define's. So, to satisfy the compiler, add these */
1272 /* #define's, although they arn't really necessary. */
1277 #endif /* HAVE_FCNTL_LOCK == 0 */
1280 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1281 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1285 #define strcpy(dest,src) StrCpy(dest,src)
1289 /* possibly wrap the malloc calls */
1292 /* undo the old malloc def if necessary */
1294 #define xx_old_malloc malloc
1298 #define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
1300 /* undo the old realloc def if necessary */
1302 #define xx_old_realloc realloc
1306 #define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
1308 /* undo the old free def if necessary */
1310 #define xx_old_free free
1314 #define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
1316 /* and the malloc prototypes */
1317 void *malloc_wrapped(int,char *,int);
1318 void *realloc_wrapped(void *,int,char *,int);
1319 void free_wrapped(void *,char *,int);
1325 /* undo the old memcpy def if necessary */
1327 #define xx_old_memcpy memcpy
1331 #define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
1332 void *memcpy_wrapped(void *d,void *s,int l,char *fname,int line);