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 #ifndef DEFAULT_PRINTING
50 #define DEFAULT_PRINTING PRINT_BSD
53 #define PRINTCAP_NAME "/etc/printcap"
59 * <unistd.h> has to be included before any other to get
60 * large file support on Reliant UNIX
65 #endif /* RELIANTUNIX */
67 #include <sys/types.h>
69 #ifdef TIME_WITH_SYS_TIME
73 #ifdef HAVE_SYS_TIME_H
80 #ifdef HAVE_SYS_RESOURCE_H
81 #include <sys/resource.h>
91 #ifdef HAVE_SYS_PARAM_H
92 #include <sys/param.h>
99 #ifdef HAVE_SYS_SOCKET_H
100 #include <sys/socket.h>
107 #ifdef HAVE_SYS_SYSCALL_H
108 #include <sys/syscall.h>
117 #ifdef HAVE_STRINGS_H
132 #ifdef HAVE_SYS_FCNTL_H
133 #include <sys/fcntl.h>
137 #include <sys/stat.h>
143 #ifdef HAVE_SYS_IOCTL_H
144 #include <sys/ioctl.h>
147 #ifdef HAVE_SYS_FILIO_H
148 #include <sys/filio.h>
153 #ifdef HAVE_SYS_WAIT_H
154 #include <sys/wait.h>
162 #ifdef HAVE_SYS_PRIV_H
163 #include <sys/priv.h>
175 #ifdef HAVE_SYS_SELECT_H
176 #include <sys/select.h>
179 #ifdef HAVE_SYS_MODE_H
180 /* apparently AIX needs this for S_ISLNK */
182 #include <sys/mode.h>
198 #include <netinet/in.h>
199 #include <arpa/inet.h>
202 #include <sys/file.h>
204 #ifdef HAVE_NETINET_TCP_H
205 #include <netinet/tcp.h>
209 * The next three defines are needed to access the IPTOS_* options
213 #ifdef HAVE_NETINET_IN_SYSTM_H
214 #include <netinet/in_systm.h>
217 #ifdef HAVE_NETINET_IN_IP_H
218 #include <netinet/in_ip.h>
221 #ifdef HAVE_NETINET_IP_H
222 #include <netinet/ip.h>
225 #if defined(HAVE_TERMIOS_H)
226 /* POSIX terminal handling. */
228 #elif defined(HAVE_TERMIO_H)
229 /* Older SYSV terminal handling - don't use if we can avoid it. */
231 #elif defined(HAVE_SYS_TERMIO_H)
232 /* Older SYSV terminal handling - don't use if we can avoid it. */
233 #include <sys/termio.h>
238 # define NAMLEN(dirent) strlen((dirent)->d_name)
240 # define dirent direct
241 # define NAMLEN(dirent) (dirent)->d_namlen
243 # include <sys/ndir.h>
246 # include <sys/dir.h>
253 #ifdef HAVE_SYS_MMAN_H
254 #include <sys/mman.h>
262 #ifdef HAVE_SYS_MOUNT_H
263 #include <sys/mount.h>
266 #ifdef HAVE_SYS_VFS_H
270 #ifdef HAVE_SYS_ACL_H
274 #ifdef HAVE_SYS_FS_S5PARAM_H
275 #include <sys/fs/s5param.h>
278 #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
279 #include <sys/filsys.h>
282 #ifdef HAVE_SYS_STATFS_H
283 # include <sys/statfs.h>
287 #include <sys/dustat.h>
290 #ifdef HAVE_SYS_STATVFS_H
291 #include <sys/statvfs.h>
298 #ifdef HAVE_GETPWANAM
299 #include <sys/label.h>
300 #include <sys/audit.h>
304 #ifdef HAVE_SYS_SECURITY_H
305 #include <sys/security.h>
307 #define PASSWORD_LENGTH 16
308 #endif /* HAVE_SYS_SECURITY_H */
314 #ifdef HAVE_STROPTS_H
322 #ifdef HAVE_SYS_CAPABILITY_H
323 #include <sys/capability.h>
326 #if defined(HAVE_RPC_RPC_H)
328 * Check for AUTH_ERROR define conflict with rpc/rpc.h in prot.h.
330 #if defined(HAVE_SYS_SECURITY_H) && defined(HAVE_RPC_AUTH_ERROR_CONFLICT)
336 #if defined(HAVE_YP_GET_DEFAULT_DOMAIN) && defined(HAVE_SETNETGRENT) && defined(HAVE_ENDNETGRENT) && defined(HAVE_GETNETGRENT)
337 #define HAVE_NETGROUP 1
340 #if defined (HAVE_NETGROUP)
341 #if defined(HAVE_RPCSVC_YP_PROT_H)
342 #include <rpcsvc/yp_prot.h>
344 #if defined(HAVE_RPCSVC_YPCLNT_H)
345 #include <rpcsvc/ypclnt.h>
347 #endif /* HAVE_NETGROUP */
350 * Define VOLATILE if needed.
353 #if defined(HAVE_VOLATILE)
354 #define VOLATILE volatile
360 * Define SIG_ATOMIC_T if needed.
363 #if defined(HAVE_SIG_ATOMIC_T_TYPE)
364 #define SIG_ATOMIC_T sig_atomic_t
366 #define SIG_ATOMIC_T int
370 #define uchar unsigned char
373 #ifdef HAVE_UNSIGNED_CHAR
374 #define schar signed char
380 Samba needs type definitions for int16, int32, uint16 and uint32.
382 Normally these are signed and unsigned 16 and 32 bit integers, but
383 they actually only need to be at least 16 and 32 bits
384 respectively. Thus if your word size is 8 bytes just defining them
385 as signed and unsigned int will work.
389 #define uint8 unsigned char
392 #if !defined(int16) && !defined(HAVE_INT16_FROM_RPC_RPC_H)
393 #if (SIZEOF_SHORT == 4)
394 #define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
395 #else /* SIZEOF_SHORT != 4 */
397 #endif /* SIZEOF_SHORT != 4 */
401 * Note we duplicate the size tests in the unsigned
402 * case as int16 may be a typedef from rpc/rpc.h
405 #if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H)
406 #if (SIZEOF_SHORT == 4)
407 #define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
408 #else /* SIZEOF_SHORT != 4 */
409 #define uint16 unsigned short
410 #endif /* SIZEOF_SHORT != 4 */
413 #if !defined(int32) && !defined(HAVE_INT32_FROM_RPC_RPC_H)
414 #if (SIZEOF_INT == 4)
416 #elif (SIZEOF_LONG == 4)
418 #elif (SIZEOF_SHORT == 4)
424 * Note we duplicate the size tests in the unsigned
425 * case as int32 may be a typedef from rpc/rpc.h
428 #if !defined(uint32) && !defined(HAVE_UINT32_FROM_RPC_RPC_H)
429 #if (SIZEOF_INT == 4)
430 #define uint32 unsigned int
431 #elif (SIZEOF_LONG == 4)
432 #define uint32 unsigned long
433 #elif (SIZEOF_SHORT == 4)
434 #define uint32 unsigned short
439 * Types for devices, inodes and offsets.
443 #define SMB_DEV_T dev_t
447 * Setup the correctly sized inode type.
451 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_INO64_T)
452 # define SMB_INO_T ino64_t
454 # define SMB_INO_T ino_t
458 #ifndef LARGE_SMB_INO_T
459 # if (defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_INO64_T)) || (defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8))
460 # define LARGE_SMB_INO_T 1
464 #ifdef LARGE_SMB_INO_T
465 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
467 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
471 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T)
472 # define SMB_OFF_T off64_t
474 # define SMB_OFF_T off_t
478 /* this should really be a 64 bit type if possible */
479 #define br_off SMB_BIG_UINT
481 #define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
484 * Set the define that tells us if we can do 64 bit
488 #ifndef LARGE_SMB_OFF_T
489 # if (defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T)) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8))
490 # define LARGE_SMB_OFF_T 1
494 #ifdef LARGE_SMB_OFF_T
495 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
497 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
501 * Type for stat structure.
504 #ifndef SMB_STRUCT_STAT
505 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STAT64) && defined(HAVE_OFF64_T)
506 # define SMB_STRUCT_STAT struct stat64
508 # define SMB_STRUCT_STAT struct stat
513 * Type for dirent structure.
516 #ifndef SMB_STRUCT_DIRENT
517 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_DIRENT64)
518 # define SMB_STRUCT_DIRENT struct dirent64
520 # define SMB_STRUCT_DIRENT struct dirent
525 * Defines for 64 bit fcntl locks.
528 #ifndef SMB_STRUCT_FLOCK
529 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
530 # define SMB_STRUCT_FLOCK struct flock64
532 # define SMB_STRUCT_FLOCK struct flock
537 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
538 # define SMB_F_SETLKW F_SETLKW64
540 # define SMB_F_SETLKW F_SETLKW
545 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
546 # define SMB_F_SETLK F_SETLK64
548 # define SMB_F_SETLK F_SETLK
553 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
554 # define SMB_F_GETLK F_GETLK64
556 # define SMB_F_GETLK F_GETLK
560 #if defined(HAVE_LONGLONG)
561 #define SMB_BIG_UINT unsigned long long
562 #define SMB_BIG_INT long long
563 #define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
565 #define SMB_BIG_UINT unsigned long
566 #define SMB_BIG_INT long
567 #define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
570 #define SMB_BIG_UINT_BITS (sizeof(SMB_BIG_UINT)*8)
573 #define MIN(a,b) ((a)<(b)?(a):(b))
577 #define MAX(a,b) ((a)>(b)?(a):(b))
580 #ifndef HAVE_STRERROR
581 extern char *sys_errlist[];
582 #define strerror(i) sys_errlist[i]
586 # define strchr index
587 # define strrchr rindex
590 #ifndef HAVE_ERRNO_DECL
594 #ifdef HAVE_BROKEN_GETGROUPS
601 #define NGROUPS_MAX 32 /* Guess... */
604 /* Lists, trees, caching, datbase... */
605 #include "ubi_sLinkList.h"
606 #include "ubi_dLinkList.h"
607 #include "dlinklist.h"
608 #include "../tdb/tdb.h"
610 #include "interfaces.h"
621 #ifndef UBI_BINTREE_H
622 #include "ubi_Cache.h"
623 #endif /* UBI_BINTREE_H */
625 #include "debugparse.h"
630 #include "nameserv.h"
632 #include "byteorder.h"
645 #ifndef MAXCODEPAGELINES
646 #define MAXCODEPAGELINES 256
650 * Type for wide character dirent structure.
651 * Only d_name is defined by POSIX.
654 typedef struct smb_wdirent {
656 } SMB_STRUCT_WDIRENT;
659 * Type for wide character passwd structure.
662 typedef struct smb_wpasswd {
670 } SMB_STRUCT_WPASSWD;
672 /* Defines for wisXXX functions. */
673 #define UNI_UPPER 0x1
674 #define UNI_LOWER 0x2
675 #define UNI_DIGIT 0x4
676 #define UNI_XDIGIT 0x8
677 #define UNI_SPACE 0x10
679 /***** automatically generated prototypes *****/
682 /* String routines */
684 #include "safe_string.h"
687 #define QSORT_CAST (__compar_fn_t)
691 #define QSORT_CAST (int (*)(const void *, const void *))
694 /* this guess needs to be improved (tridge) */
695 #if (defined(STAT_STATVFS) || defined(STAT_STATVFS64)) && !defined(SYSV)
699 #ifndef DEFAULT_PRINTING
701 #define DEFAULT_PRINTING PRINT_CUPS
702 #define PRINTCAP_NAME "cups"
704 #define DEFAULT_PRINTING PRINT_SYSV
705 #define PRINTCAP_NAME "lpstat"
707 #define DEFAULT_PRINTING PRINT_BSD
708 #define PRINTCAP_NAME "/etc/printcap"
712 #ifndef PRINTCAP_NAME
713 #define PRINTCAP_NAME "/etc/printcap"
717 #define SIGCLD SIGCHLD
724 #if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP))
725 #define USE_SMBPASS_DB 1
728 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
729 #define OSF1_ENH_SEC 1
732 #ifndef ALLOW_CHANGE_PASSWORD
733 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
734 #define ALLOW_CHANGE_PASSWORD 1
738 /* what is the longest significant password available on your system?
739 Knowing this speeds up password searches a lot */
740 #ifndef PASSWORD_LENGTH
741 #define PASSWORD_LENGTH 8
744 #ifdef REPLACE_INET_NTOA
745 #define inet_ntoa rep_inet_ntoa
753 #define MAXPATHLEN 256
760 #ifndef INADDR_LOOPBACK
761 #define INADDR_LOOPBACK 0x7f000001
765 #define INADDR_NONE 0xffffffff
769 #define crypt ufc_crypt
773 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
776 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
777 #define ULTRIX_AUTH 1
780 #ifdef HAVE_LIBREADLINE
781 # ifdef HAVE_READLINE_READLINE_H
782 # include <readline/readline.h>
783 # ifdef HAVE_READLINE_HISTORY_H
784 # include <readline/history.h>
787 # ifdef HAVE_READLINE_H
788 # include <readline.h>
789 # ifdef HAVE_HISTORY_H
790 # include <history.h>
793 # undef HAVE_LIBREADLINE
799 char *strdup(const char *s);
803 void *memmove(void *dest,const void *src,int size);
806 #ifndef HAVE_INITGROUPS
807 int initgroups(char *name,gid_t id);
811 int rename(const char *zfrom, const char *zto);
815 time_t mktime(struct tm *t);
818 #ifndef HAVE_FTRUNCATE
819 int ftruncate(int f,long l);
823 unsigned long strtoul(const char *nptr, char **endptr, int base);
826 #if (defined(USE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
828 int setresuid(uid_t ruid, uid_t euid, uid_t suid);
830 #if (defined(USE_SETRESUID) && !defined(HAVE_SETRESGID_DECL))
831 int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
834 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
835 #define bzero(a,b) memset((a),'\0',(b))
838 #ifdef REPLACE_GETPASS
839 #define getpass(prompt) getsmbpass((prompt))
843 * Some older systems seem not to have MAXHOSTNAMELEN
846 #ifndef MAXHOSTNAMELEN
847 #define MAXHOSTNAMELEN 254
850 /* yuck, I'd like a better way of doing this */
851 #define DIRP_SIZE (256 + 32)
854 * glibc on linux doesn't seem to have MSG_WAITALL
855 * defined. I think the kernel has it though..
859 #define MSG_WAITALL 0
862 /* default socket options. Dave Miller thinks we should default to TCP_NODELAY
863 given the socket IO pattern that Samba uses */
865 #define DEFAULT_SOCKET_OPTIONS "TCP_NODELAY"
867 #define DEFAULT_SOCKET_OPTIONS ""
870 /* Load header file for libdl stuff */
876 extern int DEBUGLEVEL;
878 #endif /* _INCLUDES_H */