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
302 #include <sys/acct.h>
303 #include <sys/statfs.h>
304 #include <sys/statvfs.h>
305 #include <sys/filio.h>
306 #include <sys/sockio.h>
307 #include <netinet/in_systm.h>
308 #include <netinet/tcp.h>
309 #include <netinet/ip.h>
311 #include <arpa/inet.h>
312 #include <rpcsvc/ypclnt.h>
314 #include <sys/stropts.h>
315 #if !defined(USE_LIBDES) && !defined(KRB4_AUTH)
317 #endif /* !USE_LIBDES && !KRB4_AUTH */
318 extern int gettimeofday (struct timeval *, void *);
319 extern int gethostname (char *name, int namelen);
320 extern int innetgr (const char *, const char *, const char *, const char *);
322 #define SIGNAL_CAST (void (*)(int))
327 #define REPLACE_STRLEN
333 #ifndef REPLACE_GETPASS
334 #define REPLACE_GETPASS
335 #endif /* REPLACE_GETPASS */
336 #define USE_SIGPROCMASK
338 #define QSORT_CAST (int (*)(const void *, const void *))
339 #endif /* QSORT_CAST */
345 #include <nfs/nfs_clnt.h>
347 #include <netinet/tcp.h>
354 #define SIGNAL_CAST (void(*)(int))
361 #include <netinet/tcp.h>
362 #include <sys/statfs.h>
368 #define SIGNAL_CAST (void (*)())
376 #if defined(SGI5) || defined(SGI6)
377 #include <arpa/inet.h>
378 #include <netinet/tcp.h>
379 #include <netinet/in_systm.h>
380 #include <netinet/ip.h>
381 #include <sys/statvfs.h>
390 #define SIGNAL_CAST (void (*)())
396 #define QSORT_CAST (int (*)(const void *, const void *))
397 #endif /* QSORT_CAST */
402 #include <bsd/net/soioctl.h>
406 #include <sys/statfs.h>
407 #include <sys/wait.h>
408 #include <sys/termio.h>
409 #define SIGNAL_CAST (void (*)())
411 extern struct group *getgrnam();
412 extern struct passwd *getpwnam();
415 #define REPLACE_STRSTR
423 #include <sys/statfs.h>
424 #include <sys/statvfs.h>
429 #define SIGNAL_CAST (void (*)(int))
439 #include <sys/statfs.h>
440 #include <sys/statvfs.h>
442 #include <sys/filio.h>
444 #include <sys/sockio.h>
445 #include <netinet/tcp.h>
450 #define SIGNAL_CAST (void (*)(int))
464 char *mktemp(char *); /* No standard include */
465 #include <netinet/in.h>
466 #include <arpa/inet.h> /* both for inet_ntoa */
467 #define SIGNAL_CAST ( void (*) (int) )
471 #include <netinet/tcp.h>
474 #include <sys/types.h>
475 #include <sys/security.h>
478 #define PASSWORD_LENGTH 16
479 #define NEED_AUTH_PARAMETERS
480 #endif /* OSF1_ENH_SEC */
488 #define SIGNAL_CAST (void (*)())
489 #include <sys/fcntl.h>
490 #include <sys/statfs.h>
498 #ifndef REPLACE_GETPASS
499 #define REPLACE_GETPASS
500 #endif /* REPLACE_GETPASS */
508 #include <netinet/tcp.h>
509 #define SIGNAL_CAST (void (*)())
517 #ifdef ALLOW_CHANGE_PASSWORD
519 #endif /* ALLOW_CHANGE_PASSWORD */
520 #else /* NetBSD1_3 */
522 #endif /* NetBSD1_3 */
523 #include <netinet/tcp.h>
524 /* you may not need this */
526 #define SIGNAL_CAST (void (*)())
528 #define REPLACE_INNETGR
533 #include <arpa/inet.h>
535 #include <netinet/tcp.h>
536 #include <netinet/in_systm.h>
537 #include <netinet/ip.h>
545 #define SIGNAL_CAST (void (*)(int))
552 #define HAVE_GETTIMEOFDAY
553 #define HAVE_PATHCONF
554 #define HAVE_GETGRNAM 1
555 #define HAVE_VSNPRINTF
556 #define QSORT_CAST (int (*)(const void *, const void *))
559 #define O_SYNC O_FSYNC
560 #else /* defined(O_FSYNC) */
562 #endif /* defined(O_FSYNC) */
563 #endif /* !defined(O_SYNC) */
568 #include <netinet/tcp.h>
570 #define SIGNAL_CAST (void (*)())
572 #define REPLACE_INNETGR
574 #define HAVE_PATHCONF
575 #define HAVE_GETGRNAM 1
576 #define HAVE_GETTIMEOFDAY
585 #include <sys/select.h>
587 #include <sys/statfs.h>
590 #include <sys/priv.h>
591 /* According to AIX 4.1 man pages, inet_ntoa needs the following headers */
592 #include <sys/socket.h>
593 #include <netinet/in.h>
594 #include <arpa/inet.h>
595 #include <netinet/tcp.h>
600 #define SIGNAL_CAST (void (*)())
601 #define DEFAULT_PRINTING PRINT_AIX
602 /* we undef this because sys/param.h is broken in aix. uggh. */
603 #undef MAXHOSTNAMELEN
612 #include <sys/types.h>
613 #include <sys/termios.h>
614 #include <netinet/tcp.h>
615 #include <arpa/inet.h> /* needed for inet_ntoa proto */
616 #ifdef HPUX_10_TRUSTED
617 #include <hpsecurity.h>
619 #define NEED_AUTH_PARAMETERS
621 #define SIGNAL_CAST (void (*)(__harg))
625 /* This is only needed for HPUX 9.x */
626 #define SELECT_CAST (int *)
630 #define WAIT3_CAST2 (int *)
636 #define DEFAULT_PRINTING PRINT_HPUX
637 /* Ken Weiss <krweiss@ucdavis.edu> tells us that SIGCLD_IGNORE is
639 /* #define SIGCLD_IGNORE */
640 #define USE_SIGPROCMASK /* Needed to stop zombie processes on HPUX 9.x and 10.x.*/
648 #include <sys/types.h>
649 #include <sys/statfs.h>
650 #include <sys/stat.h>
652 #include <sys/socket.h>
655 #define SIGNAL_CAST (void (*)(int))
672 #include <sys/statfs.h>
673 #include <sys/statvfs.h>
676 #include <sys/sockio.h>
677 #include <netinet/tcp.h>
682 #define SIGNAL_CAST (void (*)(int))
686 #define seteuid(uid) setreuid(-1,uid)
689 #define setegid(gid) setregid(-1,gid)
695 #include <sys/types.h>
699 #define bzero(b,len) memset(b,0,len)
713 #define bzero(b,len) memset(b,0,len)
722 #define SIGNAL_CAST (void (*)(int))
723 #define WAIT3_CAST1 (union wait *)
732 #include <sys/statfs.h>
736 #define SIGNAL_CAST (void (*)())
737 #define HAVE_FCNTL_LOCK 0
738 #define HAVE_GETTIMEOFDAY
745 #include <sys/netinet/tcp.h>
746 #include <sys/netinet/in_systm.h>
747 #include <sys/netinet/ip.h>
752 #include <sys/statfs.h>
753 #include <sys/stropts.h>
760 #include <rpcsvc/ypclnt.h>
761 #endif /* NETGROUP */
763 #include <sys/security.h>
764 #include <sys/audit.h>
766 #define crypt bigcrypt
767 #endif /* SecureWare */
768 #define SIGNAL_CAST (void (*)(int))
773 #define setuid(u) setreuid(u,-1)
774 #define seteuid(u) setreuid(-1,u)
777 #define ftruncate(f,l) syscall(0x0a28,f,l)
779 #define NO_INITGROUPS
781 #endif /* SCO3_2_2 */
784 #define HAVE_PATHCONF
790 /* Definitions for RiscIX */
792 #define SIGNAL_CAST (void (*)(int))
793 #include <sys/dirent.h>
794 #include <sys/acct.h>
799 #define HAVE_GETTIMEOFDAY
807 #include <net/errno.h>
811 #include <sys/statfs.h>
813 #include <sys/sioctl.h>
816 #include <netinet/tcp.h>
817 #define FIONREAD FIORDCHK
820 #define SIGNAL_CAST (void (*)(int))
840 #define SIGNAL_CAST (void (*)(int))
841 char *strdup (char *);
854 #define SIGNAL_CAST (void (*)(int))
855 char *strdup (char *);
866 #include <sys/statfs.h>
867 #include <sys/stropts.h>
868 #define NO_GET_BROADCAST
874 #define PF_INET AF_INET
876 #define ftruncate(f,l) chsize(f,l)
880 #include <netinet/tcp.h>
881 #include <arpa/inet.h>
886 #define DONT_REINSTALL_SIG
889 #define SIGNAL_CAST (_SigFunc_Ptr_t)
892 extern char *mktemp(char *);
893 extern int fsync(int);
894 extern int seteuid(uid_t);
895 extern int setgroups(int, int *);
896 extern int initgroups(char *, int);
897 extern int statfs(char *, struct statfs *);
898 extern int setegid(gid_t);
899 extern int getopt(int, char *const *, const char *);
900 extern int chroot(char *);
901 extern int gettimeofday(struct timeval *, struct timezone *);
902 extern int gethostname(char *, int);
903 extern char *crypt(char *, char *);
904 extern char *getpass(char *);
909 #define MAXPATHLEN 1024
913 #include <sys/statfs.h>
914 #define SIGNAL_CAST (void (*)(int))
915 #define SIGCLD_IGNORE
916 #define HAVE_FCNTL_LOCK 1
926 #include <sys/fcntl.h>
927 #include <sys/statfs.h>
932 #define ptrdiff_t int
933 #define HAVE_GETGRNAM 0
938 #define NO_INITGROUPS
946 #define REPLACE_MKTIME
947 #define REPLACE_RENAME
948 #define REPLACE_STRSTR
955 #include <sys/statfs.h>
956 #include <sys/select.h>
959 #define SIGNAL_CAST (void (*)())
961 #define NO_INITGROUPS
963 #define HAVE_TIMEZONE
966 #define HAVE_FCNTL_LOCK 1
967 #define DEFAULT_PRINTING PRINT_QNX
975 #include <sys/timeb.h>
981 #include <sys/statfs.h>
984 #define SIGNAL_CAST (void (*)())
985 #define HAVE_FCNTL_LOCK 0
987 #define NO_GET_BROADCAST
990 #define NO_INITGROUPS
995 #define strcasecmp stricmp
996 #define strncasecmp strnicmp
1001 #define SIGNAL_CAST (void (*)())
1002 #define WAIT3_CAST1 (union wait *)
1005 #include <resource.h>
1009 #include <sys/statfs.h>
1016 #define SIGNAL_CAST (void (*)(int))
1018 #include <sys/dir.h>
1019 #include <sys/select.h>
1023 #include <sys/statfs.h>
1024 #include <sys/bsdioctl.h>
1028 #include <arpa/inet.h>
1031 #include <netinet/tcp.h>
1032 #include <sys/acct.h>
1033 #include <sys/fcntl.h>
1034 #include <sys/filio.h>
1035 #include <sys/sockio.h>
1036 #include <netinet/in_systm.h>
1037 #include <netinet/ip.h>
1038 #include <sys/termios.h>
1040 #include <sys/timeb.h>
1042 #define SIGNAL_CAST (void (*)(int))
1045 #define HAVE_MEMMOVE
1046 #define USE_SIGPROCMASK
1050 #define HAVE_FCNTL_LOCK 0
1051 #define HAVE_GETTIMEOFDAY
1052 #define HAVE_PATHCONF
1054 #define HAVE_NO_PROC
1055 #define NO_FORK_DEBUG
1057 #define HAVE_VFORK 1
1060 /* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */
1067 /*******************************************************************
1068 end of the platform specific sections
1069 ********************************************************************/
1071 #if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
1072 #include <sys/mman.h>
1076 #define NEED_AUTH_PARAMETERS
1079 #ifdef REPLACE_GETPASS
1080 extern char *getsmbpass(char *);
1081 #define getpass(s) getsmbpass(s)
1084 #ifdef REPLACE_INNETGR
1085 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
1089 #define FD_SETSIZE 255
1096 /* Now for some other grungy stuff */
1098 struct spwd { /* fake shadow password structure */
1105 #define bzero(p,s) memset(p,0,s)
1109 #ifndef HAVE_MEMMOVE
1111 #define memmove(d,s,n) MemMove(d,s,n)
1116 #include <sys/dir.h>
1119 /* some unixes have ENOTTY instead of TIOCNOTTY */
1122 #define TIOCNOTTY ENOTTY
1130 /* if undefined then use bsd or sysv printing */
1131 #ifndef DEFAULT_PRINTING
1133 #define DEFAULT_PRINTING PRINT_SYSV
1135 #define DEFAULT_PRINTING PRINT_BSD
1139 /* This defines the name of the printcap file. It is MOST UNLIKELY that
1140 this will change BUT! Specifying a file with the format of a printcap
1141 file but containing only a subset of the printers actually in your real
1142 printcap file is a quick-n-dirty way to allow dynamic access to a subset
1143 of available printers.
1145 #ifndef PRINTCAP_NAME
1147 #define PRINTCAP_NAME "/etc/qconfig"
1149 #define PRINTCAP_NAME "lpstat"
1151 #define PRINTCAP_NAME "/etc/printcap"
1157 #include <sys/ipc.h>
1158 #include <sys/sem.h>
1159 #include <sys/shm.h>
1163 struct semid_ds *buf;
1164 unsigned short *array;
1167 #if defined(HPUX) && defined(HPUX10)
1171 #endif /* HPUX && HPUX10 */
1175 #include <afs/stds.h>
1176 #include <afs/kautils.h>
1180 #include <dce/dce_error.h>
1181 #include <dce/sec_login.h>
1206 extern char *sys_errlist[];
1207 #define strerror(i) sys_errlist[i]
1212 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1215 #ifndef MAXHOSTNAMELEN
1216 #define MAXHOSTNAMELEN 255
1219 #include "version.h"
1221 #include "nameserv.h"
1222 #include "ubiqx/ubi_dLinkList.h"
1224 #include "byteorder.h"
1227 #include "charset.h"
1229 #ifndef MAXCODEPAGELINES
1230 #define MAXCODEPAGELINES 256
1233 /***** automatically generated prototypes *****/
1239 #define S_IFREG 0100000
1243 #define S_ISREG(x) ((S_IFREG & (x))!=0)
1247 #define S_ISDIR(x) ((S_IFDIR & (x))!=0)
1250 #if !defined(S_ISLNK) && defined(S_IFLNK)
1251 #define S_ISLNK(x) ((S_IFLNK & (x))!=0)
1255 #define crypt ufc_crypt
1258 #ifdef REPLACE_STRLEN
1259 #define strlen(s) Strlen(s)
1262 #ifdef REPLACE_STRSTR
1263 #define strstr(s,p) Strstr(s,p)
1266 #ifdef REPLACE_MKTIME
1267 #define mktime(t) Mktime(t)
1271 #define NGROUPS_MAX 128
1275 #define EDQUOT ENOSPC
1278 #ifndef HAVE_GETGRNAM
1279 #define HAVE_GETGRNAM 1
1286 /* default to using ftruncate workaround as this is safer than assuming
1287 it works and getting lots of bug reports */
1288 #ifndef FTRUNCATE_CAN_EXTEND
1289 #define FTRUNCATE_CAN_EXTEND 0
1292 /* maybe this unix doesn't separate RD and WR locks? */
1294 #define F_RDLCK F_WRLCK
1298 #define ENOTSOCK EINVAL
1302 #define SIGCLD SIGCHLD
1309 #ifndef HAVE_FCNTL_LOCK
1310 #define HAVE_FCNTL_LOCK 1
1314 #define WAIT3_CAST2 (struct rusage *)
1318 #define WAIT3_CAST1 (int *)
1322 #define QSORT_CAST (int (*)())
1325 #ifndef INADDR_LOOPBACK
1326 #define INADDR_LOOPBACK 0x7f000001
1327 #endif /* INADDR_LOOPBACK */
1329 /* this is a rough check to see if this machine has a lstat() call.
1330 it is not guaranteed to work */
1331 #if !defined(S_ISLNK)
1335 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1342 #define geteuid() getuid()
1343 #define getegid() getgid()
1344 #define seteuid(x) setuid(x)
1345 #define setegid(x) setgid(x)
1349 #if (HAVE_FCNTL_LOCK == 0)
1350 /* since there is no locking available, system includes */
1351 /* for DomainOS 10.4 do not contain any of the following */
1352 /* #define's. So, to satisfy the compiler, add these */
1353 /* #define's, although they arn't really necessary. */
1358 #endif /* HAVE_FCNTL_LOCK == 0 */
1361 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1362 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1368 #define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
1373 #define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
1377 #endif /* sprintf */
1378 #define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
1380 #define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
1381 #define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
1382 #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
1383 #define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
1386 #include "mem_man/mem_man.h"
1387 #endif /* MEM_MAN */