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>
267 #include <sys/wait.h>
269 /* #include <termios.h> */
273 #define mktime timelocal
274 typedef unsigned short mode_t;
279 #ifndef REPLACE_GETPASS
280 #define REPLACE_GETPASS
285 #ifndef USE_SIGPROCMASK
286 #define USE_SIGPROCMASK
292 /* SunOS doesn't have POSIX atexit */
293 #define atexit on_exit
300 #include <sys/acct.h>
301 #include <sys/statfs.h>
302 #include <sys/statvfs.h>
303 #include <sys/filio.h>
304 #include <sys/sockio.h>
305 #include <netinet/in_systm.h>
306 #include <netinet/tcp.h>
307 #include <netinet/ip.h>
309 #include <arpa/inet.h>
310 #include <rpcsvc/ypclnt.h>
312 #include <sys/stropts.h>
313 #if !defined(USE_LIBDES) && !defined(KRB4_AUTH)
315 #endif /* !USE_LIBDES && !KRB4_AUTH */
316 extern int gettimeofday (struct timeval *, void *);
317 extern int gethostname (char *name, int namelen);
318 extern int innetgr (const char *, const char *, const char *, const char *);
320 #define SIGNAL_CAST (void (*)(int))
325 #define REPLACE_STRLEN
331 #ifndef REPLACE_GETPASS
332 #define REPLACE_GETPASS
333 #endif /* REPLACE_GETPASS */
334 #define USE_SIGPROCMASK
336 #define QSORT_CAST (int (*)(const void *, const void *))
337 #endif /* QSORT_CAST */
338 #define HAVE_VSNPRINTF
344 #include <nfs/nfs_clnt.h>
346 #include <netinet/tcp.h>
353 #define SIGNAL_CAST (void(*)(int))
360 #include <netinet/tcp.h>
361 #include <sys/statfs.h>
367 #define SIGNAL_CAST (void (*)())
375 #if defined(SGI5) || defined(SGI6)
376 #include <arpa/inet.h>
377 #include <netinet/tcp.h>
378 #include <netinet/in_systm.h>
379 #include <netinet/ip.h>
380 #include <sys/statvfs.h>
389 #define SIGNAL_CAST (void (*)())
395 #define QSORT_CAST (int (*)(const void *, const void *))
396 #endif /* QSORT_CAST */
401 #include <bsd/net/soioctl.h>
405 #include <sys/statfs.h>
406 #include <sys/wait.h>
407 #include <sys/termio.h>
408 #define SIGNAL_CAST (void (*)())
410 extern struct group *getgrnam();
411 extern struct passwd *getpwnam();
414 #define REPLACE_STRSTR
422 #include <sys/statfs.h>
423 #include <sys/statvfs.h>
428 #define SIGNAL_CAST (void (*)(int))
438 #include <sys/statfs.h>
439 #include <sys/statvfs.h>
441 #include <sys/filio.h>
443 #include <sys/sockio.h>
444 #include <netinet/tcp.h>
449 #define SIGNAL_CAST (void (*)(int))
463 char *mktemp(char *); /* No standard include */
464 #include <netinet/in.h>
465 #include <arpa/inet.h> /* both for inet_ntoa */
466 #define SIGNAL_CAST ( void (*) (int) )
470 #include <netinet/tcp.h>
473 #include <sys/types.h>
474 #include <sys/security.h>
477 #define PASSWORD_LENGTH 16
478 #define NEED_AUTH_PARAMETERS
479 #endif /* OSF1_ENH_SEC */
487 #define SIGNAL_CAST (void (*)())
488 #include <sys/fcntl.h>
489 #include <sys/statfs.h>
497 #ifndef REPLACE_GETPASS
498 #define REPLACE_GETPASS
499 #endif /* REPLACE_GETPASS */
507 #include <netinet/tcp.h>
508 #define SIGNAL_CAST (void (*)())
516 #ifdef ALLOW_CHANGE_PASSWORD
518 #endif /* ALLOW_CHANGE_PASSWORD */
519 #else /* NetBSD1_3 */
521 #endif /* NetBSD1_3 */
522 #include <netinet/tcp.h>
523 /* you may not need this */
525 #define SIGNAL_CAST (void (*)())
527 #define REPLACE_INNETGR
532 #include <arpa/inet.h>
534 #include <netinet/tcp.h>
535 #include <netinet/in_systm.h>
536 #include <netinet/ip.h>
544 #define SIGNAL_CAST (void (*)(int))
551 #define HAVE_GETTIMEOFDAY
552 #define HAVE_PATHCONF
553 #define HAVE_GETGRNAM 1
554 #define HAVE_VSNPRINTF
555 #define QSORT_CAST (int (*)(const void *, const void *))
558 #define O_SYNC O_FSYNC
559 #else /* defined(O_FSYNC) */
561 #endif /* defined(O_FSYNC) */
562 #endif /* !defined(O_SYNC) */
567 #include <netinet/tcp.h>
569 #define SIGNAL_CAST (void (*)())
571 #define REPLACE_INNETGR
573 #define HAVE_PATHCONF
574 #define HAVE_GETGRNAM 1
575 #define HAVE_GETTIMEOFDAY
584 #include <sys/select.h>
586 #include <sys/statfs.h>
589 #include <sys/priv.h>
590 /* According to AIX 4.1 man pages, inet_ntoa needs the following headers */
591 #include <sys/socket.h>
592 #include <netinet/in.h>
593 #include <arpa/inet.h>
594 #include <netinet/tcp.h>
599 #define SIGNAL_CAST (void (*)())
600 #define DEFAULT_PRINTING PRINT_AIX
601 /* we undef this because sys/param.h is broken in aix. uggh. */
602 #undef MAXHOSTNAMELEN
611 #include <sys/types.h>
612 #include <sys/termios.h>
613 #include <netinet/tcp.h>
614 #include <arpa/inet.h> /* needed for inet_ntoa proto */
615 #ifdef HPUX_10_TRUSTED
616 #include <hpsecurity.h>
618 #define NEED_AUTH_PARAMETERS
620 #define SIGNAL_CAST (void (*)(__harg))
621 #ifndef HPUX10 /* This is only needed for HPUX 9.x */
622 #define SELECT_CAST (int *)
626 #define WAIT3_CAST2 (int *)
633 #define DEFAULT_PRINTING PRINT_HPUX
634 /* Ken Weiss <krweiss@ucdavis.edu> tells us that SIGCLD_IGNORE is
636 /* #define SIGCLD_IGNORE */
637 #define USE_SIGPROCMASK /* Needed to stop zombie processes on HPUX 9.x and 10.x.*/
645 #include <sys/types.h>
646 #include <sys/statfs.h>
647 #include <sys/stat.h>
649 #include <sys/socket.h>
652 #define SIGNAL_CAST (void (*)(int))
669 #include <sys/statfs.h>
670 #include <sys/statvfs.h>
673 #include <sys/sockio.h>
674 #include <netinet/tcp.h>
679 #define SIGNAL_CAST (void (*)(int))
683 #define seteuid(uid) setreuid(-1,uid)
686 #define setegid(gid) setregid(-1,gid)
692 #include <sys/types.h>
696 #define bzero(b,len) memset(b,0,len)
710 #define bzero(b,len) memset(b,0,len)
719 #define SIGNAL_CAST (void (*)(int))
720 #define WAIT3_CAST1 (union wait *)
729 #include <sys/statfs.h>
733 #define SIGNAL_CAST (void (*)())
734 #define HAVE_FCNTL_LOCK 0
735 #define HAVE_GETTIMEOFDAY
742 #include <sys/netinet/tcp.h>
743 #include <sys/netinet/in_systm.h>
744 #include <sys/netinet/ip.h>
749 #include <sys/statfs.h>
750 #include <sys/stropts.h>
757 #include <rpcsvc/ypclnt.h>
758 #endif /* NETGROUP */
760 #include <sys/security.h>
761 #include <sys/audit.h>
763 #define crypt bigcrypt
764 #endif /* SecureWare */
765 #define SIGNAL_CAST (void (*)(int))
770 #define setuid(u) setreuid(u,-1)
771 #define seteuid(u) setreuid(-1,u)
774 #define ftruncate(f,l) syscall(0x0a28,f,l)
776 #define NO_INITGROUPS
778 #endif /* SCO3_2_2 */
781 #define HAVE_PATHCONF
787 /* Definitions for RiscIX */
789 #define SIGNAL_CAST (void (*)(int))
790 #include <sys/dirent.h>
791 #include <sys/acct.h>
796 #define HAVE_GETTIMEOFDAY
804 #include <net/errno.h>
808 #include <sys/statfs.h>
810 #include <sys/sioctl.h>
813 #include <netinet/tcp.h>
814 #define FIONREAD FIORDCHK
817 #define SIGNAL_CAST (void (*)(int))
837 #define SIGNAL_CAST (void (*)(int))
838 char *strdup (char *);
851 #define SIGNAL_CAST (void (*)(int))
852 char *strdup (char *);
863 #include <sys/statfs.h>
864 #include <sys/stropts.h>
865 #define NO_GET_BROADCAST
871 #define PF_INET AF_INET
873 #define ftruncate(f,l) chsize(f,l)
877 #include <netinet/tcp.h>
878 #include <arpa/inet.h>
883 #define DONT_REINSTALL_SIG
886 #define SIGNAL_CAST (_SigFunc_Ptr_t)
889 extern char *mktemp(char *);
890 extern int fsync(int);
891 extern int seteuid(uid_t);
892 extern int setgroups(int, int *);
893 extern int initgroups(char *, int);
894 extern int statfs(char *, struct statfs *);
895 extern int setegid(gid_t);
896 extern int getopt(int, char *const *, const char *);
897 extern int chroot(char *);
898 extern int gettimeofday(struct timeval *, struct timezone *);
899 extern int gethostname(char *, int);
900 extern char *crypt(char *, char *);
901 extern char *getpass(char *);
906 #define MAXPATHLEN 1024
910 #include <sys/statfs.h>
911 #define SIGNAL_CAST (void (*)(int))
912 #define SIGCLD_IGNORE
913 #define HAVE_FCNTL_LOCK 1
923 #include <sys/fcntl.h>
924 #include <sys/statfs.h>
929 #define ptrdiff_t int
930 #define HAVE_GETGRNAM 0
935 #define NO_INITGROUPS
943 #define REPLACE_MKTIME
944 #define REPLACE_RENAME
945 #define REPLACE_STRSTR
952 #include <sys/statfs.h>
953 #include <sys/select.h>
956 #define SIGNAL_CAST (void (*)())
958 #define NO_INITGROUPS
960 #define HAVE_TIMEZONE
963 #define HAVE_FCNTL_LOCK 1
964 #define DEFAULT_PRINTING PRINT_QNX
972 #include <sys/timeb.h>
978 #include <sys/statfs.h>
981 #define SIGNAL_CAST (void (*)())
982 #define HAVE_FCNTL_LOCK 0
984 #define NO_GET_BROADCAST
987 #define NO_INITGROUPS
992 #define strcasecmp stricmp
993 #define strncasecmp strnicmp
998 #define SIGNAL_CAST (void (*)())
999 #define WAIT3_CAST1 (union wait *)
1002 #include <resource.h>
1006 #include <sys/statfs.h>
1013 #define SIGNAL_CAST (void (*)(int))
1015 #include <sys/dir.h>
1016 #include <sys/select.h>
1020 #include <sys/statfs.h>
1021 #include <sys/bsdioctl.h>
1025 #include <arpa/inet.h>
1028 #include <netinet/tcp.h>
1029 #include <sys/acct.h>
1030 #include <sys/fcntl.h>
1031 #include <sys/filio.h>
1032 #include <sys/sockio.h>
1033 #include <netinet/in_systm.h>
1034 #include <netinet/ip.h>
1035 #include <sys/termios.h>
1037 #include <sys/timeb.h>
1039 #define SIGNAL_CAST (void (*)(int))
1042 #define HAVE_MEMMOVE
1043 #define USE_SIGPROCMASK
1047 #define HAVE_FCNTL_LOCK 0
1048 #define HAVE_GETTIMEOFDAY
1049 #define HAVE_PATHCONF
1051 #define HAVE_NO_PROC
1052 #define NO_FORK_DEBUG
1054 #define HAVE_VFORK 1
1057 /* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */
1064 /*******************************************************************
1065 end of the platform specific sections
1066 ********************************************************************/
1068 #if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
1069 #include <sys/mman.h>
1073 #define NEED_AUTH_PARAMETERS
1076 #ifdef REPLACE_GETPASS
1077 extern char *getsmbpass(char *);
1078 #define getpass(s) getsmbpass(s)
1081 #ifdef REPLACE_INNETGR
1082 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
1086 #define FD_SETSIZE 255
1093 /* Now for some other grungy stuff */
1095 struct spwd { /* fake shadow password structure */
1102 #define bzero(p,s) memset(p,0,s)
1106 #ifndef HAVE_MEMMOVE
1108 #define memmove(d,s,n) MemMove(d,s,n)
1113 #include <sys/dir.h>
1116 /* some unixes have ENOTTY instead of TIOCNOTTY */
1119 #define TIOCNOTTY ENOTTY
1127 /* if undefined then use bsd or sysv printing */
1128 #ifndef DEFAULT_PRINTING
1130 #define DEFAULT_PRINTING PRINT_SYSV
1132 #define DEFAULT_PRINTING PRINT_BSD
1136 /* This defines the name of the printcap file. It is MOST UNLIKELY that
1137 this will change BUT! Specifying a file with the format of a printcap
1138 file but containing only a subset of the printers actually in your real
1139 printcap file is a quick-n-dirty way to allow dynamic access to a subset
1140 of available printers.
1142 #ifndef PRINTCAP_NAME
1144 #define PRINTCAP_NAME "/etc/qconfig"
1146 #define PRINTCAP_NAME "lpstat"
1148 #define PRINTCAP_NAME "/etc/printcap"
1154 #include <sys/ipc.h>
1155 #include <sys/sem.h>
1156 #include <sys/shm.h>
1160 struct semid_ds *buf;
1161 unsigned short *array;
1164 #if defined(HPUX) && defined(HPUX10)
1168 #endif /* HPUX && HPUX10 */
1172 #include <afs/stds.h>
1173 #include <afs/kautils.h>
1177 #include <dce/dce_error.h>
1178 #include <dce/sec_login.h>
1203 extern char *sys_errlist[];
1204 #define strerror(i) sys_errlist[i]
1209 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1212 #ifndef MAXHOSTNAMELEN
1213 #define MAXHOSTNAMELEN 255
1216 #include "version.h"
1218 #include "nameserv.h"
1219 #include "ubiqx/ubi_dLinkList.h"
1221 #include "byteorder.h"
1224 #include "charset.h"
1226 #ifndef MAXCODEPAGELINES
1227 #define MAXCODEPAGELINES 256
1230 /***** automatically generated prototypes *****/
1236 #define S_IFREG 0100000
1240 #define S_ISREG(x) ((S_IFREG & (x))!=0)
1244 #define S_ISDIR(x) ((S_IFDIR & (x))!=0)
1247 #if !defined(S_ISLNK) && defined(S_IFLNK)
1248 #define S_ISLNK(x) ((S_IFLNK & (x))!=0)
1252 #define crypt ufc_crypt
1255 #ifdef REPLACE_STRLEN
1256 #define strlen(s) Strlen(s)
1259 #ifdef REPLACE_STRSTR
1260 #define strstr(s,p) Strstr(s,p)
1263 #ifdef REPLACE_MKTIME
1264 #define mktime(t) Mktime(t)
1268 #define NGROUPS_MAX 128
1272 #define EDQUOT ENOSPC
1275 #ifndef HAVE_GETGRNAM
1276 #define HAVE_GETGRNAM 1
1283 /* default to using ftruncate workaround as this is safer than assuming
1284 it works and getting lots of bug reports */
1285 #ifndef FTRUNCATE_CAN_EXTEND
1286 #define FTRUNCATE_CAN_EXTEND 0
1289 /* maybe this unix doesn't separate RD and WR locks? */
1291 #define F_RDLCK F_WRLCK
1295 #define ENOTSOCK EINVAL
1299 #define SIGCLD SIGCHLD
1306 #ifndef HAVE_FCNTL_LOCK
1307 #define HAVE_FCNTL_LOCK 1
1311 #define WAIT3_CAST2 (struct rusage *)
1315 #define WAIT3_CAST1 (int *)
1319 #define QSORT_CAST (int (*)())
1322 #ifndef INADDR_LOOPBACK
1323 #define INADDR_LOOPBACK 0x7f000001
1324 #endif /* INADDR_LOOPBACK */
1326 /* this is a rough check to see if this machine has a lstat() call.
1327 it is not guaranteed to work */
1328 #if !defined(S_ISLNK)
1332 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1339 #define geteuid() getuid()
1340 #define getegid() getgid()
1341 #define seteuid(x) setuid(x)
1342 #define setegid(x) setgid(x)
1346 #if (HAVE_FCNTL_LOCK == 0)
1347 /* since there is no locking available, system includes */
1348 /* for DomainOS 10.4 do not contain any of the following */
1349 /* #define's. So, to satisfy the compiler, add these */
1350 /* #define's, although they arn't really necessary. */
1355 #endif /* HAVE_FCNTL_LOCK == 0 */
1358 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1359 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1365 #define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
1370 #define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
1374 #endif /* sprintf */
1375 #define sprintf __ERROR__XX__NEVER_USE_SPRINTF__>;
1377 #define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
1378 #define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
1379 #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
1380 #define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
1383 #include "mem_man/mem_man.h"
1384 #endif /* MEM_MAN */