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>
176 /* AIX 4.1 and previous needs this for setpriv */
177 #if defined(HAVE_SETPRIV) && defined(HAVE_SYS_PRIV_H)
178 #include <sys/priv.h>
187 #ifdef HAVE_SYS_SELECT_H
188 #include <sys/select.h>
191 #ifdef HAVE_SYS_MODE_H
192 /* apparently AIX needs this for S_ISLNK */
194 #include <sys/mode.h>
211 #include <netinet/in.h>
212 #include <arpa/inet.h>
215 #include <sys/file.h>
217 #ifdef HAVE_NETINET_TCP_H
218 #include <netinet/tcp.h>
222 * The next three defines are needed to access the IPTOS_* options
226 #ifdef HAVE_NETINET_IN_SYSTM_H
227 #include <netinet/in_systm.h>
230 #ifdef HAVE_NETINET_IN_IP_H
231 #include <netinet/in_ip.h>
234 #ifdef HAVE_NETINET_IP_H
235 #include <netinet/ip.h>
238 #if defined(HAVE_TERMIOS_H)
239 /* POSIX terminal handling. */
241 #elif defined(HAVE_TERMIO_H)
242 /* Older SYSV terminal handling - don't use if we can avoid it. */
244 #elif defined(HAVE_SYS_TERMIO_H)
245 /* Older SYSV terminal handling - don't use if we can avoid it. */
246 #include <sys/termio.h>
251 # define NAMLEN(dirent) strlen((dirent)->d_name)
253 # define dirent direct
254 # define NAMLEN(dirent) (dirent)->d_namlen
256 # include <sys/ndir.h>
259 # include <sys/dir.h>
266 #ifdef HAVE_SYS_MMAN_H
267 #include <sys/mman.h>
281 #ifdef HAVE_SYS_MOUNT_H
282 #include <sys/mount.h>
285 #ifdef HAVE_SYS_VFS_H
289 #ifdef HAVE_SYS_ACL_H
293 #ifdef HAVE_SYS_FS_S5PARAM_H
294 #include <sys/fs/s5param.h>
297 #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
298 #include <sys/filsys.h>
301 #ifdef HAVE_SYS_STATFS_H
302 # include <sys/statfs.h>
306 #include <sys/dustat.h>
309 #ifdef HAVE_SYS_STATVFS_H
310 #include <sys/statvfs.h>
317 #ifdef HAVE_GETPWANAM
318 #include <sys/label.h>
319 #include <sys/audit.h>
323 #ifdef HAVE_SYS_SECURITY_H
324 #include <sys/security.h>
326 #define PASSWORD_LENGTH 16
327 #endif /* HAVE_SYS_SECURITY_H */
333 #ifdef HAVE_STROPTS_H
341 #ifdef HAVE_SYS_CAPABILITY_H
342 #include <sys/capability.h>
345 #if defined(HAVE_RPC_RPC_H)
347 * Check for AUTH_ERROR define conflict with rpc/rpc.h in prot.h.
349 #if defined(HAVE_SYS_SECURITY_H) && defined(HAVE_RPC_AUTH_ERROR_CONFLICT)
355 #if defined(HAVE_YP_GET_DEFAULT_DOMAIN) && defined(HAVE_SETNETGRENT) && defined(HAVE_ENDNETGRENT) && defined(HAVE_GETNETGRENT)
356 #define HAVE_NETGROUP 1
359 #if defined (HAVE_NETGROUP)
360 #if defined(HAVE_RPCSVC_YP_PROT_H)
361 #include <rpcsvc/yp_prot.h>
363 #if defined(HAVE_RPCSVC_YPCLNT_H)
364 #include <rpcsvc/ypclnt.h>
366 #endif /* HAVE_NETGROUP */
369 * Define VOLATILE if needed.
372 #if defined(HAVE_VOLATILE)
373 #define VOLATILE volatile
379 * Define SIG_ATOMIC_T if needed.
382 #if defined(HAVE_SIG_ATOMIC_T_TYPE)
383 #define SIG_ATOMIC_T sig_atomic_t
385 #define SIG_ATOMIC_T int
389 #define uchar unsigned char
392 #ifdef HAVE_UNSIGNED_CHAR
393 #define schar signed char
399 Samba needs type definitions for int16, int32, uint16 and uint32.
401 Normally these are signed and unsigned 16 and 32 bit integers, but
402 they actually only need to be at least 16 and 32 bits
403 respectively. Thus if your word size is 8 bytes just defining them
404 as signed and unsigned int will work.
408 #define uint8 unsigned char
411 #if !defined(int16) && !defined(HAVE_INT16_FROM_RPC_RPC_H)
412 #if (SIZEOF_SHORT == 4)
413 #define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
414 #else /* SIZEOF_SHORT != 4 */
416 #endif /* SIZEOF_SHORT != 4 */
420 * Note we duplicate the size tests in the unsigned
421 * case as int16 may be a typedef from rpc/rpc.h
424 #if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H)
425 #if (SIZEOF_SHORT == 4)
426 #define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
427 #else /* SIZEOF_SHORT != 4 */
428 #define uint16 unsigned short
429 #endif /* SIZEOF_SHORT != 4 */
432 #if !defined(int32) && !defined(HAVE_INT32_FROM_RPC_RPC_H)
433 #if (SIZEOF_INT == 4)
435 #elif (SIZEOF_LONG == 4)
437 #elif (SIZEOF_SHORT == 4)
443 * Note we duplicate the size tests in the unsigned
444 * case as int32 may be a typedef from rpc/rpc.h
447 #if !defined(uint32) && !defined(HAVE_UINT32_FROM_RPC_RPC_H)
448 #if (SIZEOF_INT == 4)
449 #define uint32 unsigned int
450 #elif (SIZEOF_LONG == 4)
451 #define uint32 unsigned long
452 #elif (SIZEOF_SHORT == 4)
453 #define uint32 unsigned short
458 * Types for devices, inodes and offsets.
462 #define SMB_DEV_T dev_t
466 * Setup the correctly sized inode type.
470 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_INO64_T)
471 # define SMB_INO_T ino64_t
473 # define SMB_INO_T ino_t
477 #ifndef LARGE_SMB_INO_T
478 # if (defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_INO64_T)) || (defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8))
479 # define LARGE_SMB_INO_T 1
483 #ifdef LARGE_SMB_INO_T
484 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
486 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
490 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T)
491 # define SMB_OFF_T off64_t
493 # define SMB_OFF_T off_t
497 #define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
500 * Set the define that tells us if we can do 64 bit
504 #ifndef LARGE_SMB_OFF_T
505 # if (defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T)) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8))
506 # define LARGE_SMB_OFF_T 1
510 #ifdef LARGE_SMB_OFF_T
511 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
513 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
517 * Type for stat structure.
520 #ifndef SMB_STRUCT_STAT
521 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STAT64) && defined(HAVE_OFF64_T)
522 # define SMB_STRUCT_STAT struct stat64
524 # define SMB_STRUCT_STAT struct stat
529 * Type for dirent structure.
532 #ifndef SMB_STRUCT_DIRENT
533 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_DIRENT64)
534 # define SMB_STRUCT_DIRENT struct dirent64
536 # define SMB_STRUCT_DIRENT struct dirent
541 * Defines for 64 bit fcntl locks.
544 #ifndef SMB_STRUCT_FLOCK
545 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
546 # define SMB_STRUCT_FLOCK struct flock64
548 # define SMB_STRUCT_FLOCK struct flock
553 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
554 # define SMB_F_SETLKW F_SETLKW64
556 # define SMB_F_SETLKW F_SETLKW
561 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
562 # define SMB_F_SETLK F_SETLK64
564 # define SMB_F_SETLK F_SETLK
569 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
570 # define SMB_F_GETLK F_GETLK64
572 # define SMB_F_GETLK F_GETLK
576 #if defined(HAVE_LONGLONG)
577 #define SMB_BIG_UINT unsigned long long
578 #define SMB_BIG_INT long long
579 #define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
581 #define SMB_BIG_UINT unsigned long
582 #define SMB_BIG_INT long
583 #define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
587 #define MIN(a,b) ((a)<(b)?(a):(b))
591 #define MAX(a,b) ((a)>(b)?(a):(b))
594 #ifndef HAVE_STRERROR
595 extern char *sys_errlist
[];
596 #define strerror(i) sys_errlist[i]
600 # define strchr index
601 # define strrchr rindex
604 #ifndef HAVE_ERRNO_DECL
608 #ifdef HAVE_BROKEN_GETGROUPS
615 /* Lists, trees, caching, datbase... */
616 #include "ubi_sLinkList.h"
617 #include "ubi_dLinkList.h"
618 #include "dlinklist.h"
620 #ifndef UBI_BINTREE_H
621 #include "ubi_Cache.h"
622 #endif /* UBI_BINTREE_H */
624 #include "debugparse.h"
629 #include "nameserv.h"
631 #include "byteorder.h"
638 #ifndef MAXCODEPAGELINES
639 #define MAXCODEPAGELINES 256
642 /***** automatically generated prototypes *****/
648 #define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
653 #define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
658 #define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
660 #define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
661 #define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
662 #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
663 #define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
666 #define QSORT_CAST (__compar_fn_t)
670 #define QSORT_CAST (int (*)(const void *, const void *))
673 /* this guess needs to be improved (tridge) */
674 #if (defined(STAT_STATVFS) || defined(STAT_STATVFS64)) && !defined(SYSV)
678 #ifndef DEFAULT_PRINTING
680 #define DEFAULT_PRINTING PRINT_SYSV
681 #define PRINTCAP_NAME "lpstat"
683 #define DEFAULT_PRINTING PRINT_BSD
684 #define PRINTCAP_NAME "/etc/printcap"
688 #ifndef PRINTCAP_NAME
689 #define PRINTCAP_NAME "/etc/printcap"
693 #define SIGCLD SIGCHLD
696 #if (defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP))
697 #define FAST_SHARE_MODES 1
705 #ifndef HAVE_UNION_SEMUN
708 struct semid_ds
*buf
;
709 unsigned short *array
;
714 #if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP))
715 #define USE_SMBPASS_DB 1
718 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
719 #define OSF1_ENH_SEC 1
722 #ifndef ALLOW_CHANGE_PASSWORD
723 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
724 #define ALLOW_CHANGE_PASSWORD 1
728 /* what is the longest significant password available on your system?
729 Knowing this speeds up password searches a lot */
730 #ifndef PASSWORD_LENGTH
731 #define PASSWORD_LENGTH 8
734 #ifdef REPLACE_INET_NTOA
735 #define inet_ntoa rep_inet_ntoa
743 #define MAXPATHLEN 256
750 #ifndef INADDR_LOOPBACK
751 #define INADDR_LOOPBACK 0x7f000001
755 #define INADDR_NONE 0xffffffff
759 #define crypt ufc_crypt
763 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
766 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
767 #define ULTRIX_AUTH 1
770 #ifdef HAVE_LIBREADLINE
771 # ifdef HAVE_READLINE_READLINE_H
772 # include <readline/readline.h>
773 # ifdef HAVE_READLINE_HISTORY_H
774 # include <readline/history.h>
777 # ifdef HAVE_READLINE_H
778 # include <readline.h>
779 # ifdef HAVE_HISTORY_H
780 # include <history.h>
783 # undef HAVE_LIBREADLINE
789 char *strdup(const char *s
);
793 void *memmove(void *dest
,const void *src
,int size
);
796 #ifndef HAVE_INITGROUPS
797 int initgroups(char *name
,gid_t id
);
801 int rename(const char *zfrom
, const char *zto
);
805 time_t mktime(struct tm
*t
);
808 #ifndef HAVE_FTRUNCATE
809 int ftruncate(int f
,long l
);
813 unsigned long strtoul(const char *nptr
, char **endptr
, int base
);
816 #if (defined(HAVE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
818 int setresuid(uid_t ruid
, uid_t euid
, uid_t suid
);
820 #if (defined(HAVE_SETRESGID) && !defined(HAVE_SETRESGID_DECL))
821 int setresgid(gid_t rgid
, gid_t egid
, gid_t sgid
);
824 #if (defined(HAVE_CRYPT) && !defined(HAVE_CRYPT_DECL) && !defined(KRB4_AUTH))
826 int crypt(const char *key
, const char *salt
);
829 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
830 #define bzero(a,b) memset((a),'\0',(b))
833 #ifdef REPLACE_GETPASS
834 #define getpass(prompt) getsmbpass((prompt))
838 * Some older systems seem not to have MAXHOSTNAMELEN
841 #ifndef MAXHOSTNAMELEN
842 #define MAXHOSTNAMELEN 254
845 /* yuck, I'd like a better way of doing this */
846 #define DIRP_SIZE (256 + 32)
849 * glibc on linux doesn't seem to have MSG_WAITALL
850 * defined. I think the kernel has it though..
854 #define MSG_WAITALL 0
857 #endif /* _INCLUDES_H */