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 #ifndef NO_CONFIG_H /* for some tests */
31 #define DEFAULT_PRINTING PRINT_AIX
32 #define PRINTCAP_NAME "/etc/qconfig"
36 #define DEFAULT_PRINTING PRINT_HPUX
40 #define DEFAULT_PRINTING PRINT_QNX
44 /* on SUNOS4 termios.h conflicts with sys/ioctl.h */
49 #define DEFAULT_PRINTING PRINT_BSD
50 #define PRINTCAP_NAME "/etc/printcap"
55 * <unistd.h> has to be included before any other to get
56 * large file support on Reliant UNIX
61 #endif /* RELIANTUNIX */
67 #ifdef HAVE_SHARED_MMAP
68 #define USE_SHARED_MMAP
72 /* if we have both SYSV IPC and shared mmap then we need to choose */
73 #if (defined(USE_SYSV_IPC) && defined(USE_SHARED_MMAP))
74 # undef USE_SHARED_MMAP
77 #include <sys/types.h>
79 #ifdef TIME_WITH_SYS_TIME
83 #ifdef HAVE_SYS_TIME_H
90 #ifdef HAVE_SYS_RESOURCE_H
91 #include <sys/resource.h>
101 #ifdef HAVE_SYS_PARAM_H
102 #include <sys/param.h>
109 #ifdef HAVE_SYS_SOCKET_H
110 #include <sys/socket.h>
113 #ifdef HAVE_SYS_SYSCALL_H
114 #include <sys/syscall.h>
123 #ifdef HAVE_STRINGS_H
132 #include "../mem_man/mem_man.h"
142 #ifdef HAVE_SYS_FCNTL_H
143 #include <sys/fcntl.h>
147 #include <sys/stat.h>
153 #ifdef HAVE_SYS_IOCTL_H
154 #include <sys/ioctl.h>
157 #ifdef HAVE_SYS_FILIO_H
158 #include <sys/filio.h>
163 #ifdef HAVE_SYS_WAIT_H
164 #include <sys/wait.h>
172 #ifdef HAVE_SYS_PRIV_H
173 #include <sys/priv.h>
185 #ifdef HAVE_SYS_SELECT_H
186 #include <sys/select.h>
189 #ifdef HAVE_SYS_MODE_H
190 /* apparently AIX needs this for S_ISLNK */
192 #include <sys/mode.h>
208 #include <netinet/in.h>
209 #include <arpa/inet.h>
212 #include <sys/file.h>
214 #ifdef HAVE_NETINET_TCP_H
215 #include <netinet/tcp.h>
219 * The next three defines are needed to access the IPTOS_* options
223 #ifdef HAVE_NETINET_IN_SYSTM_H
224 #include <netinet/in_systm.h>
227 #ifdef HAVE_NETINET_IN_IP_H
228 #include <netinet/in_ip.h>
231 #ifdef HAVE_NETINET_IP_H
232 #include <netinet/ip.h>
235 #if defined(HAVE_TERMIOS_H)
236 /* POSIX terminal handling. */
238 #elif defined(HAVE_TERMIO_H)
239 /* Older SYSV terminal handling - don't use if we can avoid it. */
241 #elif defined(HAVE_SYS_TERMIO_H)
242 /* Older SYSV terminal handling - don't use if we can avoid it. */
243 #include <sys/termio.h>
248 # define NAMLEN(dirent) strlen((dirent)->d_name)
250 # define dirent direct
251 # define NAMLEN(dirent) (dirent)->d_namlen
253 # include <sys/ndir.h>
256 # include <sys/dir.h>
263 #ifdef HAVE_SYS_MMAN_H
264 #include <sys/mman.h>
273 * The following is needed if compiling
274 * with gcc on SGI IRIX 6.5.x systems as
275 * the structure packing for system calls is
276 * different between IRIX cc and gcc.
279 #ifdef NEED_SGI_SEMUN_HACK
282 struct semid_ds
*buf
;
283 unsigned short *array
;
286 #define semun semun_hack
287 #endif /* NEED_SGI_SEMUN_HACK */
288 #endif /* HAVE_SYSV_IPC */
295 #ifdef HAVE_SYS_MOUNT_H
296 #include <sys/mount.h>
299 #ifdef HAVE_SYS_VFS_H
303 #ifdef HAVE_SYS_ACL_H
307 #ifdef HAVE_SYS_FS_S5PARAM_H
308 #include <sys/fs/s5param.h>
311 #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
312 #include <sys/filsys.h>
315 #ifdef HAVE_SYS_STATFS_H
316 # include <sys/statfs.h>
320 #include <sys/dustat.h>
323 #ifdef HAVE_SYS_STATVFS_H
324 #include <sys/statvfs.h>
331 #ifdef HAVE_GETPWANAM
332 #include <sys/label.h>
333 #include <sys/audit.h>
337 #ifdef HAVE_SYS_SECURITY_H
338 #include <sys/security.h>
340 #define PASSWORD_LENGTH 16
341 #endif /* HAVE_SYS_SECURITY_H */
347 #ifdef HAVE_STROPTS_H
355 #ifdef HAVE_SYS_CAPABILITY_H
356 #include <sys/capability.h>
359 #if defined(HAVE_RPC_RPC_H)
361 * Check for AUTH_ERROR define conflict with rpc/rpc.h in prot.h.
363 #if defined(HAVE_SYS_SECURITY_H) && defined(HAVE_RPC_AUTH_ERROR_CONFLICT)
369 #if defined(HAVE_YP_GET_DEFAULT_DOMAIN) && defined(HAVE_SETNETGRENT) && defined(HAVE_ENDNETGRENT) && defined(HAVE_GETNETGRENT)
370 #define HAVE_NETGROUP 1
373 #if defined (HAVE_NETGROUP)
374 #if defined(HAVE_RPCSVC_YP_PROT_H)
375 #include <rpcsvc/yp_prot.h>
377 #if defined(HAVE_RPCSVC_YPCLNT_H)
378 #include <rpcsvc/ypclnt.h>
380 #endif /* HAVE_NETGROUP */
383 * Define VOLATILE if needed.
386 #if defined(HAVE_VOLATILE)
387 #define VOLATILE volatile
393 * Define SIG_ATOMIC_T if needed.
396 #if defined(HAVE_SIG_ATOMIC_T_TYPE)
397 #define SIG_ATOMIC_T sig_atomic_t
399 #define SIG_ATOMIC_T int
403 #define uchar unsigned char
406 #ifdef HAVE_UNSIGNED_CHAR
407 #define schar signed char
413 Samba needs type definitions for int16, int32, uint16 and uint32.
415 Normally these are signed and unsigned 16 and 32 bit integers, but
416 they actually only need to be at least 16 and 32 bits
417 respectively. Thus if your word size is 8 bytes just defining them
418 as signed and unsigned int will work.
422 #define uint8 unsigned char
425 #if !defined(int16) && !defined(HAVE_INT16_FROM_RPC_RPC_H)
426 #if (SIZEOF_SHORT == 4)
427 #define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
428 #else /* SIZEOF_SHORT != 4 */
430 #endif /* SIZEOF_SHORT != 4 */
434 * Note we duplicate the size tests in the unsigned
435 * case as int16 may be a typedef from rpc/rpc.h
438 #if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H)
439 #if (SIZEOF_SHORT == 4)
440 #define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
441 #else /* SIZEOF_SHORT != 4 */
442 #define uint16 unsigned short
443 #endif /* SIZEOF_SHORT != 4 */
446 #if !defined(int32) && !defined(HAVE_INT32_FROM_RPC_RPC_H)
447 #if (SIZEOF_INT == 4)
449 #elif (SIZEOF_LONG == 4)
451 #elif (SIZEOF_SHORT == 4)
457 * Note we duplicate the size tests in the unsigned
458 * case as int32 may be a typedef from rpc/rpc.h
461 #if !defined(uint32) && !defined(HAVE_UINT32_FROM_RPC_RPC_H)
462 #if (SIZEOF_INT == 4)
463 #define uint32 unsigned int
464 #elif (SIZEOF_LONG == 4)
465 #define uint32 unsigned long
466 #elif (SIZEOF_SHORT == 4)
467 #define uint32 unsigned short
472 * Types for devices, inodes and offsets.
476 #define SMB_DEV_T dev_t
480 * Setup the correctly sized inode type.
484 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_INO64_T)
485 # define SMB_INO_T ino64_t
487 # define SMB_INO_T ino_t
491 #ifndef LARGE_SMB_INO_T
492 # if (defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_INO64_T)) || (defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8))
493 # define LARGE_SMB_INO_T 1
497 #ifdef LARGE_SMB_INO_T
498 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
500 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
504 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T)
505 # define SMB_OFF_T off64_t
507 # define SMB_OFF_T off_t
511 #define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
514 * Set the define that tells us if we can do 64 bit
518 #ifndef LARGE_SMB_OFF_T
519 # if (defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T)) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8))
520 # define LARGE_SMB_OFF_T 1
524 #ifdef LARGE_SMB_OFF_T
525 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
527 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
531 * Type for stat structure.
534 #ifndef SMB_STRUCT_STAT
535 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STAT64) && defined(HAVE_OFF64_T)
536 # define SMB_STRUCT_STAT struct stat64
538 # define SMB_STRUCT_STAT struct stat
543 * Type for dirent structure.
546 #ifndef SMB_STRUCT_DIRENT
547 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_DIRENT64)
548 # define SMB_STRUCT_DIRENT struct dirent64
550 # define SMB_STRUCT_DIRENT struct dirent
555 * Defines for 64 bit fcntl locks.
558 #ifndef SMB_STRUCT_FLOCK
559 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
560 # define SMB_STRUCT_FLOCK struct flock64
562 # define SMB_STRUCT_FLOCK struct flock
567 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
568 # define SMB_F_SETLKW F_SETLKW64
570 # define SMB_F_SETLKW F_SETLKW
575 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
576 # define SMB_F_SETLK F_SETLK64
578 # define SMB_F_SETLK F_SETLK
583 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
584 # define SMB_F_GETLK F_GETLK64
586 # define SMB_F_GETLK F_GETLK
590 #if defined(HAVE_LONGLONG)
591 #define SMB_BIG_UINT unsigned long long
592 #define SMB_BIG_INT long long
593 #define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
595 #define SMB_BIG_UINT unsigned long
596 #define SMB_BIG_INT long
597 #define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
601 #define MIN(a,b) ((a)<(b)?(a):(b))
605 #define MAX(a,b) ((a)>(b)?(a):(b))
608 #ifndef HAVE_STRERROR
609 extern char *sys_errlist
[];
610 #define strerror(i) sys_errlist[i]
614 # define strchr index
615 # define strrchr rindex
618 #ifndef HAVE_ERRNO_DECL
622 #ifdef HAVE_BROKEN_GETGROUPS
629 #define NGROUPS_MAX 32 /* Guess... */
632 /* Lists, trees, caching, datbase... */
633 #include "ubi_sLinkList.h"
634 #include "ubi_dLinkList.h"
635 #include "dlinklist.h"
637 #include "interfaces.h"
646 #ifndef UBI_BINTREE_H
647 #include "ubi_Cache.h"
648 #endif /* UBI_BINTREE_H */
650 #include "debugparse.h"
655 #include "nameserv.h"
657 #include "byteorder.h"
668 #ifndef MAXCODEPAGELINES
669 #define MAXCODEPAGELINES 256
672 /***** automatically generated prototypes *****/
678 #define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
683 #define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
688 #define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
690 #define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
691 #define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
692 #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
693 #define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
696 #define QSORT_CAST (__compar_fn_t)
700 #define QSORT_CAST (int (*)(const void *, const void *))
703 /* this guess needs to be improved (tridge) */
704 #if (defined(STAT_STATVFS) || defined(STAT_STATVFS64)) && !defined(SYSV)
709 * Veritas File System. Often in addition to native.
712 #if defined(HAVE_SYS_FS_VX_QUOTA_H)
716 #ifndef DEFAULT_PRINTING
718 #define DEFAULT_PRINTING PRINT_CUPS
719 #define PRINTCAP_NAME "cups"
721 #define DEFAULT_PRINTING PRINT_SYSV
722 #define PRINTCAP_NAME "lpstat"
724 #define DEFAULT_PRINTING PRINT_BSD
725 #define PRINTCAP_NAME "/etc/printcap"
729 #ifndef PRINTCAP_NAME
730 #define PRINTCAP_NAME "/etc/printcap"
734 #define SIGCLD SIGCHLD
737 #if (defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP))
738 #define FAST_SHARE_MODES 1
746 #ifndef HAVE_UNION_SEMUN
749 struct semid_ds
*buf
;
750 unsigned short *array
;
755 #if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP))
756 #define USE_SMBPASS_DB 1
759 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
760 #define OSF1_ENH_SEC 1
763 #ifndef ALLOW_CHANGE_PASSWORD
764 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
765 #define ALLOW_CHANGE_PASSWORD 1
769 /* what is the longest significant password available on your system?
770 Knowing this speeds up password searches a lot */
771 #ifndef PASSWORD_LENGTH
772 #define PASSWORD_LENGTH 8
775 #ifdef REPLACE_INET_NTOA
776 #define inet_ntoa rep_inet_ntoa
784 #define MAXPATHLEN 256
791 #ifndef INADDR_LOOPBACK
792 #define INADDR_LOOPBACK 0x7f000001
796 #define INADDR_NONE 0xffffffff
800 #define crypt ufc_crypt
804 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
807 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
808 #define ULTRIX_AUTH 1
811 #ifdef HAVE_LIBREADLINE
812 # ifdef HAVE_READLINE_READLINE_H
813 # include <readline/readline.h>
814 # ifdef HAVE_READLINE_HISTORY_H
815 # include <readline/history.h>
818 # ifdef HAVE_READLINE_H
819 # include <readline.h>
820 # ifdef HAVE_HISTORY_H
821 # include <history.h>
824 # undef HAVE_LIBREADLINE
830 char *strdup(const char *s
);
834 void *memmove(void *dest
,const void *src
,int size
);
837 #ifndef HAVE_INITGROUPS
838 int initgroups(char *name
,gid_t id
);
842 int rename(const char *zfrom
, const char *zto
);
846 time_t mktime(struct tm
*t
);
849 #ifndef HAVE_FTRUNCATE
850 int ftruncate(int f
,long l
);
854 unsigned long strtoul(const char *nptr
, char **endptr
, int base
);
857 #if (defined(USE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
859 int setresuid(uid_t ruid
, uid_t euid
, uid_t suid
);
861 #if (defined(USE_SETRESUID) && !defined(HAVE_SETRESGID_DECL))
862 int setresgid(gid_t rgid
, gid_t egid
, gid_t sgid
);
865 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
866 #define bzero(a,b) memset((a),'\0',(b))
869 #ifdef REPLACE_GETPASS
870 #define getpass(prompt) getsmbpass((prompt))
874 * Some older systems seem not to have MAXHOSTNAMELEN
877 #ifndef MAXHOSTNAMELEN
878 #define MAXHOSTNAMELEN 254
881 /* yuck, I'd like a better way of doing this */
882 #define DIRP_SIZE (256 + 32)
885 * glibc on linux doesn't seem to have MSG_WAITALL
886 * defined. I think the kernel has it though..
890 #define MSG_WAITALL 0
893 /* default socket options. Dave Miller thinks we should default to TCP_NODELAY
894 given the socket IO pattern that Samba uses */
896 #define DEFAULT_SOCKET_OPTIONS "TCP_NODELAY"
898 #define DEFAULT_SOCKET_OPTIONS ""
901 #endif /* _INCLUDES_H */