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 /* if we have both SYSV IPC and shared mmap then we need to
50 choose. For most systems it is much faster to use SYSV IPC. We used
51 to make an exception for Linux, but now Linux 2.2 has made it
52 better to use sysv if possible */
53 #if (defined(HAVE_SYSV_IPC) && defined(HAVE_SHARED_MMAP))
54 # undef HAVE_SHARED_MMAP
58 #include <sys/types.h>
60 #ifdef TIME_WITH_SYS_TIME
64 #ifdef HAVE_SYS_TIME_H
71 #ifdef HAVE_SYS_RESOURCE_H
72 #include <sys/resource.h>
82 #include <netinet/in.h>
83 #if defined(HAVE_RPC_RPC_H)
87 #ifdef HAVE_SYS_PARAM_H
88 #include <sys/param.h>
95 #ifdef HAVE_SYS_SOCKET_H
96 #include <sys/socket.h>
103 #ifdef HAVE_SYS_SYSCALL_H
104 #include <sys/syscall.h>
113 #ifdef HAVE_STRINGS_H
122 #include "../mem_man/mem_man.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>
172 #ifdef HAVE_SYS_SELECT_H
173 #include <sys/select.h>
176 #ifdef HAVE_SYS_MODE_H
177 /* apparently AIX needs this for S_ISLNK */
179 #include <sys/mode.h>
196 #include <arpa/inet.h>
199 #include <sys/file.h>
201 #ifdef HAVE_NETINET_TCP_H
202 #include <netinet/tcp.h>
205 #ifdef HAVE_TERMIOS_H
211 # define NAMLEN(dirent) strlen((dirent)->d_name)
213 # define dirent direct
214 # define NAMLEN(dirent) (dirent)->d_namlen
216 # include <sys/ndir.h>
219 # include <sys/dir.h>
226 #ifdef HAVE_SYS_MMAN_H
227 #include <sys/mman.h>
238 * I have removed this as it prevents compilation under SCO Server
239 * 3.2. If you need to add it back in then please add a comment as to
240 * why it's needed and what OS it's needed for so we can work out how
241 * to test for it properly (tridge) */
242 #ifdef HAVE_NET_ROUTE_H
243 #include <net/route.h>
252 #ifdef HAVE_SYS_MOUNT_H
253 #include <sys/mount.h>
256 #ifdef HAVE_SYS_VFS_H
260 #ifdef HAVE_SYS_ACL_H
264 #ifdef HAVE_SYS_FS_S5PARAM_H
265 #include <sys/fs/s5param.h>
268 #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
269 #include <sys/filsys.h>
272 #ifdef HAVE_SYS_STATFS_H
273 # include <sys/statfs.h>
277 #include <sys/dustat.h>
280 #ifdef HAVE_SYS_STATVFS_H
281 #include <sys/statvfs.h>
288 #ifdef HAVE_GETPWANAM
289 #include <sys/label.h>
290 #include <sys/audit.h>
294 #ifdef HAVE_SYS_SECURITY_H
295 #include <sys/security.h>
297 #define PASSWORD_LENGTH 16
298 #endif /* HAVE_SYS_SECURITY_H */
304 #ifdef HAVE_STROPTS_H
312 #ifdef HAVE_SYS_CAPABILITY_H
313 #include <sys/capability.h>
316 #if defined(HAVE_RPC_RPC_H)
320 #if defined(HAVE_YP_GET_DEFAULT_DOMAIN) && defined(HAVE_SETNETGRENT) && defined(HAVE_ENDNETGRENT) && defined(HAVE_GETNETGRENT)
321 #define HAVE_NETGROUP 1
324 #if defined (HAVE_NETGROUP)
325 #if defined(HAVE_RPCSVC_YP_PROT_H)
326 #include <rpcsvc/yp_prot.h>
328 #if defined(HAVE_RPCSVC_YPCLNT_H)
329 #include <rpcsvc/ypclnt.h>
331 #endif /* HAVE_NETGROUP */
333 #if defined(HAVE_MYSQL_H)
336 /* needed to get make proto to work with no <mysql.h> */
338 #define MYSQL_ROW void
342 #define uchar unsigned char
345 #ifdef HAVE_UNSIGNED_CHAR
346 #define schar signed char
352 Samba needs type definitions for int16, int32, uint16 and uint32.
354 Normally these are signed and unsigned 16 and 32 bit integers, but
355 they actually only need to be at least 16 and 32 bits
356 respectively. Thus if your word size is 8 bytes just defining them
357 as signed and unsigned int will work.
361 #define uint8 unsigned char
364 #if !defined(int16) && !defined(HAVE_INT16_FROM_RPC_RPC_H)
365 #if (SIZEOF_SHORT == 4)
366 #define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
367 #else /* SIZEOF_SHORT != 4 */
369 #endif /* SIZEOF_SHORT != 4 */
373 * Note we duplicate the size tests in the unsigned
374 * case as int16 may be a typedef from rpc/rpc.h
377 #if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H)
378 #if (SIZEOF_SHORT == 4)
379 #define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
380 #else /* SIZEOF_SHORT != 4 */
381 #define uint16 unsigned short
382 #endif /* SIZEOF_SHORT != 4 */
385 #if !defined(int32) && !defined(HAVE_INT32_FROM_RPC_RPC_H)
386 #if (SIZEOF_INT == 4)
388 #elif (SIZEOF_LONG == 4)
390 #elif (SIZEOF_SHORT == 4)
396 * Note we duplicate the size tests in the unsigned
397 * case as int32 may be a typedef from rpc/rpc.h
400 #if !defined(uint32) && !defined(HAVE_UINT32_FROM_RPC_RPC_H)
401 #if (SIZEOF_INT == 4)
402 #define uint32 unsigned int
403 #elif (SIZEOF_LONG == 4)
404 #define uint32 unsigned long
405 #elif (SIZEOF_SHORT == 4)
406 #define uint32 unsigned short
411 * Types for devices, inodes and offsets.
415 #define SMB_DEV_T dev_t
419 * Setup the correctly sized inode type.
424 # define SMB_INO_T ino64_t
426 # define SMB_INO_T ino_t
430 #ifndef LARGE_SMB_INO_T
431 # if defined(HAVE_INO64_T) || (defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8))
432 # define LARGE_SMB_INO_T 1
436 #ifdef LARGE_SMB_INO_T
437 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
439 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
444 # define SMB_OFF_T off64_t
446 # define SMB_OFF_T off_t
450 #define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
453 * Set the define that tells us if we can do 64 bit
457 #ifndef LARGE_SMB_OFF_T
458 # if defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8))
459 # define LARGE_SMB_OFF_T 1
463 #ifdef LARGE_SMB_OFF_T
464 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
466 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
470 * Type for stat structure.
473 #ifndef SMB_STRUCT_STAT
474 # if defined(HAVE_STAT64) && defined(HAVE_OFF64_T)
475 # define SMB_STRUCT_STAT struct stat64
477 # define SMB_STRUCT_STAT struct stat
482 * Defines for 64 bit fcntl locks.
485 #ifndef SMB_STRUCT_FLOCK
486 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
487 # define SMB_STRUCT_FLOCK struct flock64
489 # define SMB_STRUCT_FLOCK struct flock
494 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
495 # define SMB_F_SETLKW F_SETLKW64
497 # define SMB_F_SETLKW F_SETLKW
502 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
503 # define SMB_F_SETLK F_SETLK64
505 # define SMB_F_SETLK F_SETLK
510 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
511 # define SMB_F_GETLK F_GETLK64
513 # define SMB_F_GETLK F_GETLK
517 #if defined(HAVE_LONGLONG)
518 #define SMB_BIG_UINT unsigned long long
519 #define SMB_BIG_INT long long
521 #define SMB_BIG_UINT unsigned long
522 #define SMB_BIG_INT long
526 #define MIN(a,b) ((a)<(b)?(a):(b))
530 #define MAX(a,b) ((a)>(b)?(a):(b))
533 #ifndef HAVE_STRERROR
534 extern char *sys_errlist[];
535 #define strerror(i) sys_errlist[i]
539 # define strchr index
540 # define strrchr rindex
543 #ifndef HAVE_ERRNO_DECL
547 #ifdef HAVE_BROKEN_GETGROUPS
554 /* Lists, trees, caching, datbase... */
555 #include "ubi_sLinkList.h"
556 #include "ubi_dLinkList.h"
557 #include "dlinklist.h"
559 #ifndef UBI_BINTREE_H
560 #include "ubi_Cache.h"
561 #endif /* UBI_BINTREE_H */
566 #include "nameserv.h"
568 #include "byteorder.h"
579 #ifndef MAXCODEPAGELINES
580 #define MAXCODEPAGELINES 256
583 /***** automatically generated prototypes *****/
586 /* String routines */
588 #include "safe_string.h"
591 #define QSORT_CAST (__compar_fn_t)
595 #define QSORT_CAST (int (*)(const void *, const void *))
598 /* this guess needs to be improved (tridge) */
599 #if defined(STAT_STATVFS) && !defined(SYSV)
603 #ifndef DEFAULT_PRINTING
605 #define DEFAULT_PRINTING PRINT_SYSV
606 #define PRINTCAP_NAME "lpstat"
608 #define DEFAULT_PRINTING PRINT_BSD
609 #define PRINTCAP_NAME "/etc/printcap"
613 #ifndef PRINTCAP_NAME
614 #define PRINTCAP_NAME "/etc/printcap"
618 #define SIGCLD SIGCHLD
621 #if (defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP))
622 #define FAST_SHARE_MODES 1
630 #ifndef HAVE_UNION_SEMUN
633 struct semid_ds *buf;
634 unsigned short *array;
639 #if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP))
640 #define USE_SMBPASS_DB 1
641 #define USE_SMBUNIX_DB 1
644 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
645 #define OSF1_ENH_SEC 1
648 #if defined(HAVE_PAM_AUTHENTICATE) && defined(HAVE_SECURITY_PAM_APPL_H)
652 #ifndef ALLOW_CHANGE_PASSWORD
653 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
654 #define ALLOW_CHANGE_PASSWORD 1
658 /* what is the longest significant password available on your system?
659 Knowing this speeds up password searches a lot */
660 #ifndef PASSWORD_LENGTH
661 #define PASSWORD_LENGTH 8
664 #ifdef REPLACE_INET_NTOA
665 #define inet_ntoa rep_inet_ntoa
673 #define MAXPATHLEN 256
676 #ifndef MAX_SERVER_POLICY_HANDLES
677 #define MAX_SERVER_POLICY_HANDLES 64
684 #ifndef INADDR_LOOPBACK
685 #define INADDR_LOOPBACK 0x7f000001
689 #define INADDR_NONE 0xffffffff
693 #define crypt ufc_crypt
697 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
708 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
709 #define ULTRIX_AUTH 1
712 #ifdef HAVE_LIBREADLINE
713 # ifdef HAVE_READLINE_READLINE_H
714 # include <readline/readline.h>
715 # ifdef HAVE_READLINE_HISTORY_H
716 # include <readline/history.h>
719 # ifdef HAVE_READLINE_H
720 # include <readline.h>
721 # ifdef HAVE_HISTORY_H
722 # include <history.h>
725 # undef HAVE_LIBREADLINE
729 /* Some old versions of readline don't define a prototype for
730 filename_completion_function() */
732 # ifndef HAVE_READLINE_FCF_PROTO
733 char *filename_completion_function(void);
739 char *strdup(const char *s);
743 void *memmove(void *dest,const void *src,int size);
746 #ifndef HAVE_INITGROUPS
747 int initgroups(char *name,gid_t id);
751 int rename(const char *zfrom, const char *zto);
755 time_t mktime(struct tm *t);
758 #ifndef HAVE_FTRUNCATE
759 int ftruncate(int f,long l);
762 #if (defined(HAVE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
764 int setresuid(uid_t ruid, uid_t euid, uid_t suid);
765 int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
768 #if (defined(HAVE_CRYPT) && !defined(HAVE_CRYPT_DECL) && !defined(KRB4_AUTH))
770 int crypt(const char *key, const char *salt);
773 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
774 #define bzero(a,b) memset((a),'\0',(b))
777 #ifdef REPLACE_GETPASS
778 #define getpass(prompt) getsmbpass((prompt))
781 /* yuck, I'd like a better way of doing this */
782 #define DIRP_SIZE (256 + 32)
784 #endif /* _INCLUDES_H */