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 choose. For most
50 systems it is much faster to use SYSV IPC, but under Linux it is
51 about 5 times faster to use fcntl, so for Linux systems we force
52 fcntl based locking */
53 #if (defined(HAVE_SYSV_IPC) && defined(HAVE_SHARED_MMAP))
57 # undef HAVE_SHARED_MMAP
62 #include <sys/types.h>
64 #ifdef TIME_WITH_SYS_TIME
68 #ifdef HAVE_SYS_TIME_H
75 #ifdef HAVE_SYS_RESOURCE_H
76 #include <sys/resource.h>
86 #include <netinet/in.h>
87 #if defined(HAVE_RPC_RPC_H)
91 #ifdef HAVE_SYS_PARAM_H
92 #include <sys/param.h>
99 #ifdef HAVE_SYS_SOCKET_H
100 #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 */
334 #define uchar unsigned char
337 #ifdef HAVE_UNSIGNED_CHAR
338 #define schar signed char
344 Samba needs type definitions for int16, int32, uint16 and uint32.
346 Normally these are signed and unsigned 16 and 32 bit integers, but
347 they actually only need to be at least 16 and 32 bits
348 respectively. Thus if your word size is 8 bytes just defining them
349 as signed and unsigned int will work.
353 #define uint8 unsigned char
356 #if !defined(int16) && !defined(HAVE_INT16_FROM_RPC_RPC_H)
357 #if (SIZEOF_SHORT == 4)
358 #define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
359 #else /* SIZEOF_SHORT != 4 */
361 #endif /* SIZEOF_SHORT != 4 */
365 * Note we duplicate the size tests in the unsigned
366 * case as int16 may be a typedef from rpc/rpc.h
369 #if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H)
370 #if (SIZEOF_SHORT == 4)
371 #define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
372 #else /* SIZEOF_SHORT != 4 */
373 #define uint16 unsigned short
374 #endif /* SIZEOF_SHORT != 4 */
377 #if !defined(int32) && !defined(HAVE_INT32_FROM_RPC_RPC_H)
378 #if (SIZEOF_INT == 4)
380 #elif (SIZEOF_LONG == 4)
382 #elif (SIZEOF_SHORT == 4)
388 * Note we duplicate the size tests in the unsigned
389 * case as int32 may be a typedef from rpc/rpc.h
392 #if !defined(uint32) && !defined(HAVE_UINT32_FROM_RPC_RPC_H)
393 #if (SIZEOF_INT == 4)
394 #define uint32 unsigned int
395 #elif (SIZEOF_LONG == 4)
396 #define uint32 unsigned long
397 #elif (SIZEOF_SHORT == 4)
398 #define uint32 unsigned short
403 * Types for devices, inodes and offsets.
407 #define SMB_DEV_T dev_t
411 * Setup the correctly sized inode type.
416 # define SMB_INO_T ino64_t
418 # define SMB_INO_T ino_t
422 #ifndef LARGE_SMB_INO_T
423 # if defined(HAVE_INO64_T) || (defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8))
424 # define LARGE_SMB_INO_T 1
428 #ifdef LARGE_SMB_INO_T
429 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
431 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
436 # define SMB_OFF_T off64_t
438 # define SMB_OFF_T off_t
442 #define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
445 * Set the define that tells us if we can do 64 bit
449 #ifndef LARGE_SMB_OFF_T
450 # if defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8))
451 # define LARGE_SMB_OFF_T 1
455 #ifdef LARGE_SMB_OFF_T
456 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
458 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
462 * Type for stat structure.
465 #ifndef SMB_STRUCT_STAT
466 # if defined(HAVE_STAT64) && defined(HAVE_OFF64_T)
467 # define SMB_STRUCT_STAT struct stat64
469 # define SMB_STRUCT_STAT struct stat
474 * Defines for 64 bit fcntl locks.
477 #ifndef SMB_STRUCT_FLOCK
478 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
479 # define SMB_STRUCT_FLOCK struct flock64
481 # define SMB_STRUCT_FLOCK struct flock
486 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
487 # define SMB_F_SETLKW F_SETLKW64
489 # define SMB_F_SETLKW F_SETLKW
494 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
495 # define SMB_F_SETLK F_SETLK64
497 # define SMB_F_SETLK F_SETLK
502 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
503 # define SMB_F_GETLK F_GETLK64
505 # define SMB_F_GETLK F_GETLK
509 #if defined(HAVE_LONGLONG)
510 #define SMB_BIG_UINT unsigned long long
511 #define SMB_BIG_INT long long
513 #define SMB_BIG_UINT unsigned long
514 #define SMB_BIG_INT long
518 #define MIN(a,b) ((a)<(b)?(a):(b))
522 #define MAX(a,b) ((a)>(b)?(a):(b))
525 #ifndef HAVE_STRERROR
526 extern char *sys_errlist[];
527 #define strerror(i) sys_errlist[i]
531 # define strchr index
532 # define strrchr rindex
535 #ifndef HAVE_ERRNO_DECL
539 #ifdef HAVE_BROKEN_GETGROUPS
546 /* Lists, trees, caching, datbase... */
547 #include "ubi_sLinkList.h"
548 #include "ubi_dLinkList.h"
549 #include "dlinklist.h"
551 #ifndef UBI_BINTREE_H
552 #include "ubi_Cache.h"
553 #endif /* UBI_BINTREE_H */
558 #include "nameserv.h"
560 #include "byteorder.h"
567 #ifndef MAXCODEPAGELINES
568 #define MAXCODEPAGELINES 256
571 /***** automatically generated prototypes *****/
577 #define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
582 #define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
587 #define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
589 #define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
590 #define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
591 #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
592 #define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
595 #define QSORT_CAST (__compar_fn_t)
599 #define QSORT_CAST (int (*)(const void *, const void *))
602 /* this guess needs to be improved (tridge) */
603 #if defined(STAT_STATVFS) && !defined(SYSV)
607 #ifndef DEFAULT_PRINTING
609 #define DEFAULT_PRINTING PRINT_SYSV
610 #define PRINTCAP_NAME "lpstat"
612 #define DEFAULT_PRINTING PRINT_BSD
613 #define PRINTCAP_NAME "/etc/printcap"
617 #ifndef PRINTCAP_NAME
618 #define PRINTCAP_NAME "/etc/printcap"
622 #define SIGCLD SIGCHLD
625 #if (defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP))
626 #define FAST_SHARE_MODES 1
634 #ifndef HAVE_UNION_SEMUN
637 struct semid_ds *buf;
638 unsigned short *array;
643 #if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP))
644 #define USE_SMBPASS_DB 1
645 #define USE_SMBUNIX_DB 1
648 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
649 #define OSF1_ENH_SEC 1
652 #if defined(HAVE_PAM_AUTHENTICATE) && defined(HAVE_SECURITY_PAM_APPL_H)
656 #ifndef ALLOW_CHANGE_PASSWORD
657 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
658 #define ALLOW_CHANGE_PASSWORD 1
662 /* what is the longest significant password available on your system?
663 Knowing this speeds up password searches a lot */
664 #ifndef PASSWORD_LENGTH
665 #define PASSWORD_LENGTH 8
668 #ifdef REPLACE_INET_NTOA
669 #define inet_ntoa rep_inet_ntoa
677 #define MAXPATHLEN 256
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)
700 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
701 #define ULTRIX_AUTH 1
704 #ifdef HAVE_LIBREADLINE
705 # ifdef HAVE_READLINE_READLINE_H
706 # include <readline/readline.h>
707 # ifdef HAVE_READLINE_HISTORY_H
708 # include <readline/history.h>
711 # ifdef HAVE_READLINE_H
712 # include <readline.h>
713 # ifdef HAVE_HISTORY_H
714 # include <history.h>
717 # undef HAVE_LIBREADLINE
723 char *strdup(const char *s);
727 void *memmove(void *dest,const void *src,int size);
730 #ifndef HAVE_INITGROUPS
731 int initgroups(char *name,gid_t id);
735 int rename(const char *zfrom, const char *zto);
739 time_t mktime(struct tm *t);
742 #ifndef HAVE_FTRUNCATE
743 int ftruncate(int f,long l);
746 #if (defined(HAVE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
748 int setresuid(uid_t ruid, uid_t euid, uid_t suid);
749 int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
752 #if (defined(HAVE_CRYPT) && !defined(HAVE_CRYPT_DECL) && !defined(KRB4_AUTH))
754 int crypt(const char *key, const char *salt);
757 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
758 #define bzero(a,b) memset((a),'\0',(b))
761 #ifdef REPLACE_GETPASS
762 #define getpass(prompt) getsmbpass((prompt))
765 /* yuck, I'd like a better way of doing this */
766 #define DIRP_SIZE (256 + 32)
768 #endif /* _INCLUDES_H */