4 Unix SMB/Netbios implementation.
6 Machine customisation and include handling
7 Copyright (C) Andrew Tridgell 1994-1995
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>
142 #include <sys/ioctl.h>
145 #include <posix/utime.h>
146 #include <bsd/sys/time.h>
147 #include <bsd/netinet/in.h>
149 #include <sys/time.h>
150 #include <netinet/in.h>
155 #include <sys/file.h>
156 #include <sys/stat.h>
157 #include <sys/param.h>
160 #include <sys/resource.h>
163 #include <sys/mount.h>
174 #include <sys/wait.h>
176 #include <sys/stream.h>
180 #include <bsd/net/if.h>
187 #include <sys/mman.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(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>
221 #define SIGNAL_CAST (__sighandler_t)
226 #if _LINUX_C_LIB_VERSION_MAJOR >= 5
231 #define crypt pw_encrypt
237 #define SIGNAL_CAST (void (*)(int))
238 #include <netinet/tcp.h>
240 #include <sys/acct.h>
244 #include <sys/wait.h>
246 /* #include <termios.h> */
250 #define mktime timelocal
251 typedef unsigned short mode_t;
256 #define REPLACE_GETPASS
264 #include <sys/acct.h>
265 #include <sys/statfs.h>
266 #include <sys/statvfs.h>
267 #include <sys/filio.h>
268 #include <sys/sockio.h>
269 #include <netinet/in_systm.h>
270 #include <netinet/tcp.h>
271 #include <netinet/ip.h>
273 #include <arpa/inet.h>
274 #include <rpcsvc/ypclnt.h>
277 extern int gettimeofday (struct timeval *, void *);
278 extern int gethostname (char *name, int namelen);
279 extern int innetgr (const char *, const char *, const char *, const char *);
281 #define SIGNAL_CAST (void (*)(int))
286 #define REPLACE_STRLEN
290 #define REPLACE_GETPASS
296 #include <nfs/nfs_clnt.h>
298 #include <netinet/tcp.h>
305 #define SIGNAL_CAST (void(*)(int))
311 #include <netinet/tcp.h>
312 #include <sys/statfs.h>
318 #define SIGNAL_CAST (void (*)())
325 #include <netinet/tcp.h>
326 #include <sys/statvfs.h>
335 #define SIGNAL_CAST (void (*)())
342 #include <bsd/net/soioctl.h>
346 #include <sys/statfs.h>
347 #include <sys/wait.h>
348 #include <sys/termio.h>
349 #define SIGNAL_CAST (void (*)())
351 extern struct group *getgrnam();
352 extern struct passwd *getpwnam();
355 #define REPLACE_STRSTR
363 #include <sys/statfs.h>
364 #include <sys/statvfs.h>
369 #define SIGNAL_CAST (void (*)(int))
379 #include <sys/statfs.h>
380 #include <sys/statvfs.h>
382 #include <sys/filio.h>
384 #include <sys/sockio.h>
385 #include <netinet/tcp.h>
390 #define SIGNAL_CAST (void (*)(int))
402 char *mktemp(char *); /* No standard include */
403 #include <netinet/in.h>
404 #include <arpa/inet.h> /* both for inet_ntoa */
405 #define SIGNAL_CAST ( void (*) (int) )
408 #include <netinet/tcp.h>
411 #include <sys/types.h>
412 #include <sys/security.h>
415 #define PASSWORD_LENGTH 16
416 #define NEED_AUTH_PARAMETERS
417 #endif /* OSF1_ENH_SEC */
423 #define SIGNAL_CAST (void (*)())
424 #include <sys/fcntl.h>
425 #include <sys/statfs.h>
433 #define REPLACE_GETPASS
441 #include <netinet/tcp.h>
442 #define SIGNAL_CAST (void (*)())
449 #include <netinet/tcp.h>
450 /* you may not need this */
452 #define SIGNAL_CAST (void (*)())
454 #define REPLACE_INNETGR
461 #include <netinet/tcp.h>
462 #include <netinet/in_systm.h>
463 #include <netinet/ip.h>
464 #define SIGNAL_CAST (void (*)())
473 #include <sys/select.h>
475 #include <sys/statfs.h>
478 #include <sys/priv.h>
479 #include <netinet/tcp.h>
482 #define SIGNAL_CAST (void (*)())
483 #define DEFAULT_PRINTING PRINT_AIX
484 /* we undef this because sys/param.h is broken in aix. uggh. */
485 #undef MAXHOSTNAMELEN
494 #include <sys/types.h>
495 #include <sys/termios.h>
496 #include <netinet/tcp.h>
497 #ifdef HPUX_10_TRUSTED
498 #include <hpsecurity.h>
500 #define NEED_AUTH_PARAMETERS
502 #define SIGNAL_CAST (void (*)(__harg))
503 #define SELECT_CAST (int *)
506 #define WAIT3_CAST2 (int *)
510 #define DEFAULT_PRINTING PRINT_HPUX
511 #define SIGCLD_IGNORE
519 #include <sys/types.h>
520 #include <sys/statfs.h>
521 #include <sys/stat.h>
523 #include <sys/socket.h>
526 #define SIGNAL_CAST (void (*)(int))
538 #include <sys/statfs.h>
539 #include <sys/statvfs.h>
542 #include <sys/sockio.h>
543 #include <netinet/tcp.h>
548 #define SIGNAL_CAST (void (*)(int))
552 #define seteuid(uid) setreuid(-1,uid)
555 #define setegid(gid) setregid(-1,gid)
561 #include <sys/types.h>
565 #define bzero(b,len) memset(b,0,len)
579 #define bzero(b,len) memset(b,0,len)
587 #define SIGNAL_CAST (void (*)(int))
588 #define WAIT3_CAST1 (union wait *)
597 #include <sys/statfs.h>
601 #define SIGNAL_CAST (void (*)())
602 #define HAVE_FCNTL_LOCK 0
603 #define HAVE_GETTIMEOFDAY
610 #include <sys/netinet/tcp.h>
611 #include <sys/netinet/in_systm.h>
612 #include <sys/netinet/ip.h>
616 #include <sys/statfs.h>
617 #include <sys/stropts.h>
623 #include <rpcsvc/ypclnt.h>
626 #include <sys/security.h>
627 #include <sys/audit.h>
629 #define crypt bigcrypt
632 #define ftruncate(f,l) syscall(0x0a28,f,l)
634 #define SIGNAL_CAST (void (*)(int))
648 #define NO_INITGROUPS
650 #define HAVE_PATHCONF
656 /* Definitions for RiscIX */
658 #define SIGNAL_CAST (void (*)(int))
659 #include <sys/dirent.h>
660 #include <sys/acct.h>
665 #define HAVE_GETTIMEOFDAY
673 #include <net/errno.h>
677 #include <sys/statfs.h>
679 #include <sys/sioctl.h>
682 #include <netinet/tcp.h>
683 #define FIONREAD FIORDCHK
686 #define SIGNAL_CAST (void (*)(int))
706 #define SIGNAL_CAST (void (*)(int))
707 char *strdup (char *);
720 #define SIGNAL_CAST (void (*)(int))
721 char *strdup (char *);
732 #include <sys/statfs.h>
733 #include <sys/stropts.h>
734 #define NO_GET_BROADCAST
740 #define PF_INET AF_INET
742 #define ftruncate(f,l) chsize(f,l)
746 #include <netinet/tcp.h>
747 #include <arpa/inet.h>
752 #define DONT_REINSTALL_SIG
755 #define SIGNAL_CAST (_SigFunc_Ptr_t)
758 extern char *mktemp(char *);
759 extern int fsync(int);
760 extern int seteuid(uid_t);
761 extern int setgroups(int, int *);
762 extern int initgroups(char *, int);
763 extern int statfs(char *, struct statfs *);
764 extern int setegid(gid_t);
765 extern int getopt(int, char *const *, const char *);
766 extern int chroot(char *);
767 extern int gettimeofday(struct timeval *, struct timezone *);
768 extern int gethostname(char *, int);
769 extern char *crypt(char *, char *);
770 extern char *getpass(char *);
775 #define MAXPATHLEN 1024
779 #include <sys/statfs.h>
780 #define SIGNAL_CAST (void (*)(int))
781 #define SIGCLD_IGNORE
782 #define HAVE_FCNTL_LOCK 1
792 #include <sys/fcntl.h>
793 #include <sys/statfs.h>
798 #define ptrdiff_t int
799 #define HAVE_GETGRNAM 0
804 #define NO_INITGROUPS
812 #define REPLACE_MKTIME
813 #define REPLACE_RENAME
814 #define REPLACE_STRSTR
821 #include <sys/statfs.h>
822 #include <sys/select.h>
825 #define SIGNAL_CAST (void (*)())
827 #define NO_INITGROUPS
829 #define HAVE_TIMEZONE
832 #define HAVE_FCNTL_LOCK 1
833 #define DEFAULT_PRINTING PRINT_QNX
841 #include <sys/timeb.h>
847 #include <sys/statfs.h>
850 #define SIGNAL_CAST (void (*)())
851 #define HAVE_FCNTL_LOCK 0
853 #define NO_GET_BROADCAST
856 #define NO_INITGROUPS
861 #define strcasecmp stricmp
862 #define strncasecmp strnicmp
867 #define SIGNAL_CAST (void (*)())
868 #define WAIT3_CAST1 (union wait *)
871 #include <resource.h>
875 #include <sys/statfs.h>
881 /*******************************************************************
882 end of the platform specific sections
883 ********************************************************************/
886 #define NEED_AUTH_PARAMETERS
889 #ifdef REPLACE_GETPASS
890 extern char *getsmbpass(char *);
891 #define getpass(s) getsmbpass(s)
894 #ifdef REPLACE_INNETGR
895 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
899 #define FD_SETSIZE 255
906 /* Now for some other grungy stuff */
908 struct spwd { /* fake shadow password structure */
915 #define bzero(p,s) memset(p,0,s)
921 #define memmove(d,s,n) MemMove(d,s,n)
929 /* some unixes have ENOTTY instead of TIOCNOTTY */
932 #define TIOCNOTTY ENOTTY
940 /* if undefined then use bsd or sysv printing */
941 #ifndef DEFAULT_PRINTING
943 #define DEFAULT_PRINTING PRINT_SYSV
945 #define DEFAULT_PRINTING PRINT_BSD
951 #include <afs/stds.h>
952 #include <afs/kautils.h>
956 #include <dce/dce_error.h>
957 #include <dce/sec_login.h>
969 extern char *sys_errlist[];
970 #define strerror(i) sys_errlist[i]
975 #define perror(m) printf("%s: %s\n",m,strerror(errno))
978 #ifndef MAXHOSTNAMELEN
979 #define MAXHOSTNAMELEN 255
984 #include "nameserv.h"
986 #include "byteorder.h"
992 #define S_IFREG 0100000
996 #define S_ISREG(x) ((S_IFREG & x)!=0)
1000 #define S_ISDIR(x) ((S_IFDIR & x)!=0)
1004 #define crypt ufc_crypt
1007 #ifdef REPLACE_STRLEN
1008 #define strlen(s) Strlen(s)
1011 #ifdef REPLACE_STRSTR
1012 #define strstr(s,p) Strstr(s,p)
1015 #ifdef REPLACE_MKTIME
1016 #define mktime(t) Mktime(t)
1020 #define NGROUPS_MAX 128
1024 #define EDQUOT ENOSPC
1027 #ifndef HAVE_GETGRNAM
1028 #define HAVE_GETGRNAM 1
1035 /* default to using ftruncate workaround as this is safer than assuming
1036 it works and getting lots of bug reports */
1037 #ifndef FTRUNCATE_CAN_EXTEND
1038 #define FTRUNCATE_CAN_EXTEND 0
1041 /* maybe this unix doesn't separate RD and WR locks? */
1043 #define F_RDLCK F_WRLCK
1047 #define ENOTSOCK EINVAL
1051 #define SIGCLD SIGCHLD
1054 #ifndef HAVE_FCNTL_LOCK
1055 #define HAVE_FCNTL_LOCK 1
1059 #define WAIT3_CAST2 (struct rusage *)
1063 #define WAIT3_CAST1 (int *)
1067 #define QSORT_CAST (int (*)())
1070 /* this is a rough check to see if this machine has a lstat() call.
1071 it is not guaranteed to work */
1072 #if !(defined(S_ISLNK) || defined(S_IFLNK))
1076 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1083 #define geteuid() getuid()
1084 #define getegid() getgid()
1085 #define seteuid(x) setuid(x)
1086 #define setegid(x) setgid(x)
1090 #if (HAVE_FCNTL_LOCK == 0)
1091 /* since there is no locking available, system includes */
1092 /* for DomainOS 10.4 do not contain any of the following */
1093 /* #define's. So, to satisfy the compiler, add these */
1094 /* #define's, although they arn't really necessary. */
1099 #endif /* HAVE_FCNTL_LOCK == 0 */
1102 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1103 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1107 #define strcpy(dest,src) StrCpy(dest,src)
1111 /* possibly wrap the malloc calls */
1114 /* undo the old malloc def if necessary */
1116 #define xx_old_malloc malloc
1120 #define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
1122 /* undo the old realloc def if necessary */
1124 #define xx_old_realloc realloc
1128 #define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
1130 /* undo the old free def if necessary */
1132 #define xx_old_free free
1136 #define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
1138 /* and the malloc prototypes */
1139 void *malloc_wrapped(int,char *,int);
1140 void *realloc_wrapped(void *,int,char *,int);
1141 void free_wrapped(void *,char *,int);
1147 /* undo the old memcpy def if necessary */
1149 #define xx_old_memcpy memcpy
1153 #define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
1154 void *memcpy_wrapped(void *d,void *s,int l,char *fname,int line);