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
35 #define DEFAULT_PRINTING PRINT_HPUX
39 #define DEFAULT_PRINTING PRINT_QNX
43 /* on SUNOS4 termios.h conflicts with sys/ioctl.h */
48 #include <sys/types.h>
50 #ifdef TIME_WITH_SYS_TIME
54 #ifdef HAVE_SYS_TIME_H
61 #ifdef HAVE_SYS_RESOURCE_H
62 #include <sys/resource.h>
72 #ifdef HAVE_SYS_PARAM_H
73 #include <sys/param.h>
80 #ifdef HAVE_SYS_SOCKET_H
81 #include <sys/socket.h>
84 #ifdef HAVE_SYS_SYSCALL_H
85 #include <sys/syscall.h>
103 #include "../mem_man/mem_man.h"
113 #ifdef HAVE_SYS_FCNTL_H
114 #include <sys/fcntl.h>
118 #include <sys/stat.h>
124 #ifdef HAVE_SYS_IOCTL_H
125 #include <sys/ioctl.h>
128 #ifdef HAVE_SYS_FILIO_H
129 #include <sys/filio.h>
134 #ifdef HAVE_SYS_WAIT_H
135 #include <sys/wait.h>
153 #ifdef HAVE_SYS_SELECT_H
154 #include <sys/select.h>
157 #ifdef HAVE_SYS_MODE_H
158 /* apparently AIX needs this for S_ISLNK */
160 #include <sys/mode.h>
177 #include <netinet/in.h>
178 #include <arpa/inet.h>
181 #include <sys/file.h>
183 #ifdef HAVE_NETINET_TCP_H
184 #include <netinet/tcp.h>
187 #ifdef HAVE_TERMIOS_H
193 # define NAMLEN(dirent) strlen((dirent)->d_name)
195 # define dirent direct
196 # define NAMLEN(dirent) (dirent)->d_namlen
198 # include <sys/ndir.h>
201 # include <sys/dir.h>
208 #ifdef HAVE_SHARED_MMAP
209 #include <sys/mman.h>
223 #ifdef HAVE_SYS_MOUNT_H
224 #include <sys/mount.h>
227 #ifdef HAVE_SYS_VFS_H
231 #ifdef HAVE_SYS_ACL_H
235 #ifdef HAVE_SYS_FS_S5PARAM_H
236 #include <sys/fs/s5param.h>
239 #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
240 #include <sys/filsys.h>
243 #ifdef HAVE_SYS_STATFS_H
244 # include <sys/statfs.h>
248 #include <sys/dustat.h>
251 #ifdef HAVE_SYS_STATVFS_H
252 #include <sys/statvfs.h>
259 #ifdef HAVE_GETPWANAM
260 #include <sys/label.h>
261 #include <sys/audit.h>
265 #ifdef HAVE_SYS_SECURITY_H
266 #include <sys/security.h>
268 #define PASSWORD_LENGTH 16
269 #endif /* HAVE_SYS_SECURITY_H */
275 #ifdef HAVE_STROPTS_H
283 #ifdef HAVE_SYS_CAPABILITY_H
284 #include <sys/capability.h>
288 #define uchar unsigned char
291 #ifdef HAVE_UNSIGNED_CHAR
292 #define schar signed char
298 Samba needs type definitions for int16, int32, uint16 and uint32.
300 Normally these are signed and unsigned 16 and 32 bit integers, but
301 they actually only need to be at least 16 and 32 bits
302 respectively. Thus if your word size is 8 bytes just defining them
303 as signed and unsigned int will work.
307 #define uint8 unsigned char
311 #if (SIZEOF_SHORT == 4)
312 #define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
313 #else /* SIZEOF_SHORT != 4 */
315 #endif /* SIZEOF_SHORT != 4 */
319 #define uint16 unsigned int16
323 #if (SIZEOF_INT == 4)
325 #elif (SIZEOF_LONG == 4)
327 #elif (SIZEOF_SHORT == 4)
333 #define uint32 unsigned int32
337 * Types for devices, inodes and offsets.
341 #define SMB_DEV_T dev_t
345 * Setup the correctly sized inode type.
350 # define SMB_INO_T ino64_t
352 # define SMB_INO_T ino_t
356 #ifndef LARGE_SMB_INO_T
357 # if defined(HAVE_INO64_T) || (defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8))
358 # define LARGE_SMB_INO_T 1
362 #ifdef LARGE_SMB_INO_T
363 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
365 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
370 # define SMB_OFF_T off64_t
372 # define SMB_OFF_T off_t
376 #define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
379 * Set the define that tells us if we can do 64 bit
383 #ifndef LARGE_SMB_OFF_T
384 # if defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8))
385 # define LARGE_SMB_OFF_T 1
389 #ifdef LARGE_SMB_OFF_T
390 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
392 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
396 * Type for stat structure.
399 #ifndef SMB_STRUCT_STAT
400 # if defined(HAVE_STAT64) && defined(HAVE_OFF64_T)
401 # define SMB_STRUCT_STAT struct stat64
403 # define SMB_STRUCT_STAT struct stat
408 * Defines for 64 bit fcntl locks.
411 #ifndef SMB_STRUCT_FLOCK
412 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
413 # define SMB_STRUCT_FLOCK struct flock64
415 # define SMB_STRUCT_FLOCK struct flock
420 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
421 # define SMB_F_SETLKW F_SETLKW64
423 # define SMB_F_SETLKW F_SETLKW
428 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
429 # define SMB_F_SETLK F_SETLK64
431 # define SMB_F_SETLK F_SETLK
436 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
437 # define SMB_F_GETLK F_GETLK64
439 # define SMB_F_GETLK F_GETLK
443 #if defined(HAVE_LONGLONG)
444 #define SMB_BIG_UINT unsigned long long
445 #define SMB_BIG_INT long long
447 #define SMB_BIG_UINT unsigned long
448 #define SMB_BIG_INT long
452 #define MIN(a,b) ((a)<(b)?(a):(b))
456 #define MAX(a,b) ((a)>(b)?(a):(b))
459 #ifndef HAVE_STRERROR
460 extern char *sys_errlist[];
461 #define strerror(i) sys_errlist[i]
465 # define strchr index
466 # define strrchr rindex
469 #ifndef HAVE_ERRNO_DECL
473 #ifdef HAVE_BROKEN_GETGROUPS
480 /* Lists, trees, caching, datbase... */
481 #include "ubi_sLinkList.h"
482 #include "ubi_dLinkList.h"
483 #include "dlinklist.h"
485 #ifndef UBI_BINTREE_H
486 #include "ubi_Cache.h"
487 #endif /* UBI_BINTREE_H */
489 #include "debugparse.h"
494 #include "nameserv.h"
496 #include "byteorder.h"
503 #ifndef MAXCODEPAGELINES
504 #define MAXCODEPAGELINES 256
507 /***** automatically generated prototypes *****/
513 #define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
518 #define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
523 #define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
525 #define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
526 #define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
527 #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
528 #define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
531 #define QSORT_CAST (__compar_fn_t)
535 #define QSORT_CAST (int (*)(const void *, const void *))
538 /* this guess needs to be improved (tridge) */
539 #if defined(STAT_STATVFS) && !defined(SYSV)
543 #ifndef DEFAULT_PRINTING
545 #define DEFAULT_PRINTING PRINT_SYSV
547 #define DEFAULT_PRINTING PRINT_BSD
552 #define SIGCLD SIGCHLD
555 #if (defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP))
556 #define FAST_SHARE_MODES 1
564 #ifndef HAVE_UNION_SEMUN
567 struct semid_ds *buf;
568 unsigned short *array;
573 #if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP))
574 #define USE_SMBPASS_DB 1
577 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
578 #define OSF1_ENH_SEC 1
581 #if defined(HAVE_PAM_AUTHENTICATE) && defined(HAVE_SECURITY_PAM_APPL_H)
585 #if defined(HAVE_YP_GET_DEFAULT_DOMAIN)
586 #define HAVE_NETGROUP 1
589 #if defined (HAVE_NETGROUP)
590 #if defined(HAVE_RPC_RPC_H)
593 #if defined(HAVE_RPCSVC_YP_PROT_H)
594 #include <rpcsvc/yp_prot.h>
596 #if defined(HAVE_RPCSVC_YPCLNT_H)
597 #include <rpcsvc/ypclnt.h>
599 #endif /* HAVE_NETGROUP */
601 #ifndef ALLOW_CHANGE_PASSWORD
602 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
603 #define ALLOW_CHANGE_PASSWORD 1
607 /* what is the longest significant password available on your system?
608 Knowing this speeds up password searches a lot */
609 #ifndef PASSWORD_LENGTH
610 #define PASSWORD_LENGTH 8
613 #ifdef REPLACE_INET_NTOA
614 #define inet_ntoa rep_inet_ntoa
622 #define MAXPATHLEN 256
629 #ifndef INADDR_LOOPBACK
630 #define INADDR_LOOPBACK 0x7f000001
634 #define INADDR_NONE 0xffffffff
638 #define crypt ufc_crypt
642 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
645 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
646 #define ULTRIX_AUTH 1
649 #ifdef HAVE_LIBREADLINE
650 # ifdef HAVE_READLINE_READLINE_H
651 # include <readline/readline.h>
652 # ifdef HAVE_READLINE_HISTORY_H
653 # include <readline/history.h>
656 # ifdef HAVE_READLINE_H
657 # include <readline.h>
658 # ifdef HAVE_HISTORY_H
659 # include <history.h>
662 # undef HAVE_LIBREADLINE
668 char *strdup(const char *s);
672 void *memmove(void *dest,const void *src,int size);
675 #ifndef HAVE_INITGROUPS
676 int initgroups(char *name,gid_t id);
680 int rename(const char *zfrom, const char *zto);
684 time_t mktime(struct tm *t);
687 #ifndef HAVE_FTRUNCATE
688 int ftruncate(int f,long l);
691 #if (defined(HAVE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
693 int setresuid(uid_t ruid, uid_t euid, uid_t suid);
694 int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
697 #if (defined(HAVE_CRYPT) && !defined(HAVE_CRYPT_DECL) && !defined(KRB4_AUTH))
699 int crypt(const char *key, const char *salt);
702 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
703 #define bzero(a,b) memset((a),'\0',(b))
706 #ifdef REPLACE_GETPASS
707 #define getpass(prompt) getsmbpass((prompt))
710 /* yuck, I'd like a better way of doing this */
711 #define DIRP_SIZE (256 + 32)
713 #endif /* _INCLUDES_H */