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>
109 #ifdef HAVE_SYS_FCNTL_H
110 #include <sys/fcntl.h>
114 #include <sys/stat.h>
120 #ifdef HAVE_SYS_IOCTL_H
121 #include <sys/ioctl.h>
124 #ifdef HAVE_SYS_FILIO_H
125 #include <sys/filio.h>
130 #ifdef HAVE_SYS_WAIT_H
131 #include <sys/wait.h>
149 #ifdef HAVE_SYS_SELECT_H
150 #include <sys/select.h>
153 #ifdef HAVE_SYS_MODE_H
154 /* apparently AIX needs this for S_ISLNK */
156 #include <sys/mode.h>
173 #include <netinet/in.h>
174 #include <arpa/inet.h>
177 #include <sys/file.h>
179 #ifdef HAVE_NETINET_TCP_H
180 #include <netinet/tcp.h>
183 #ifdef HAVE_TERMIOS_H
189 # define NAMLEN(dirent) strlen((dirent)->d_name)
191 # define dirent direct
192 # define NAMLEN(dirent) (dirent)->d_namlen
194 # include <sys/ndir.h>
197 # include <sys/dir.h>
204 #ifdef HAVE_SHARED_MMAP
205 #include <sys/mman.h>
219 #ifdef HAVE_SYS_MOUNT_H
220 #include <sys/mount.h>
223 #ifdef HAVE_SYS_VFS_H
227 #ifdef HAVE_SYS_ACL_H
231 #ifdef HAVE_SYS_FS_S5PARAM_H
232 #include <sys/fs/s5param.h>
235 #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
236 #include <sys/filsys.h>
239 #ifdef HAVE_SYS_STATFS_H
240 # include <sys/statfs.h>
244 #include <sys/dustat.h>
247 #ifdef HAVE_SYS_STATVFS_H
248 #include <sys/statvfs.h>
255 #ifdef HAVE_GETPWANAM
256 #include <sys/label.h>
257 #include <sys/audit.h>
261 #ifdef HAVE_SYS_SECURITY_H
262 #include <sys/security.h>
264 #define PASSWORD_LENGTH 16
265 #endif /* HAVE_SYS_SECURITY_H */
271 #ifdef HAVE_STROPTS_H
279 #ifdef HAVE_SYS_CAPABILITY_H
280 #include <sys/capability.h>
284 #define uchar unsigned char
287 #ifdef HAVE_UNSIGNED_CHAR
288 #define schar signed char
294 Samba needs type definitions for int16, int32, uint16 and uint32.
296 Normally these are signed and unsigned 16 and 32 bit integers, but
297 they actually only need to be at least 16 and 32 bits
298 respectively. Thus if your word size is 8 bytes just defining them
299 as signed and unsigned int will work.
303 #define uint8 unsigned char
307 #if (SIZEOF_SHORT == 4)
308 #define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
309 #else /* SIZEOF_SHORT != 4 */
311 #endif /* SIZEOF_SHORT != 4 */
315 #define uint16 unsigned int16
319 #if (SIZEOF_INT == 4)
321 #elif (SIZEOF_LONG == 4)
323 #elif (SIZEOF_SHORT == 4)
329 #define uint32 unsigned int32
333 * Types for devices, inodes and offsets.
337 #define SMB_DEV_T dev_t
341 * Setup the correctly sized inode type.
346 # define SMB_INO_T ino64_t
348 # define SMB_INO_T ino_t
352 #ifndef LARGE_SMB_INO_T
353 # if defined(HAVE_INO64_T) || (defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8))
354 # define LARGE_SMB_INO_T 1
360 # define SMB_OFF_T off64_t
362 # define SMB_OFF_T off_t
366 #define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
369 * Set the define that tells us if we can do 64 bit
373 #ifndef LARGE_SMB_OFF_T
374 # if defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8))
375 # define LARGE_SMB_OFF_T 1
379 #ifdef LARGE_SMB_OFF_T
380 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
382 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
386 * Type for stat structure.
389 #ifndef SMB_STRUCT_STAT
390 # if defined(HAVE_STAT64) && defined(HAVE_OFF64_T)
391 # define SMB_STRUCT_STAT struct stat64
393 # define SMB_STRUCT_STAT struct stat
398 * Defines for 64 bit fcntl locks.
401 #ifndef SMB_STRUCT_FLOCK
402 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
403 # define SMB_STRUCT_FLOCK struct flock64
405 # define SMB_STRUCT_FLOCK struct flock
410 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
411 # define SMB_F_SETLKW F_SETLKW64
413 # define SMB_F_SETLKW F_SETLKW
418 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
419 # define SMB_F_SETLK F_SETLK64
421 # define SMB_F_SETLK F_SETLK
426 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
427 # define SMB_F_GETLK F_GETLK64
429 # define SMB_F_GETLK F_GETLK
433 #if defined(HAVE_LONGLONG)
434 #define SMB_BIG_UINT unsigned long long
435 #define SMB_BIG_INT long long
437 #define SMB_BIG_UINT unsigned long
438 #define SMB_BIG_INT long
442 #define MIN(a,b) ((a)<(b)?(a):(b))
446 #define MAX(a,b) ((a)>(b)?(a):(b))
449 #ifndef HAVE_STRERROR
450 extern char *sys_errlist[];
451 #define strerror(i) sys_errlist[i]
455 # define strchr index
456 # define strrchr rindex
459 #ifndef HAVE_ERRNO_DECL
463 #ifdef HAVE_BROKEN_GETGROUPS
470 /* Lists, trees, caching, datbase... */
471 #include "ubi_sLinkList.h"
472 #include "ubi_dLinkList.h"
473 #include "dlinklist.h"
475 #ifndef UBI_BINTREE_H
476 #include "ubi_Cache.h"
477 #endif /* UBI_BINTREE_H */
482 #include "nameserv.h"
484 #include "byteorder.h"
491 #ifndef MAXCODEPAGELINES
492 #define MAXCODEPAGELINES 256
495 /***** automatically generated prototypes *****/
501 #define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
506 #define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
511 #define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
513 #define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
514 #define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
515 #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
516 #define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
519 #define QSORT_CAST (__compar_fn_t)
523 #define QSORT_CAST (int (*)(const void *, const void *))
526 /* this guess needs to be improved (tridge) */
527 #if defined(STAT_STATVFS) && !defined(SYSV)
531 #ifndef DEFAULT_PRINTING
533 #define DEFAULT_PRINTING PRINT_SYSV
535 #define DEFAULT_PRINTING PRINT_BSD
540 #define SIGCLD SIGCHLD
543 #if (defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP))
544 #define FAST_SHARE_MODES 1
552 #ifndef HAVE_UNION_SEMUN
555 struct semid_ds *buf;
556 unsigned short *array;
561 #if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP))
562 #define USE_SMBPASS_DB 1
565 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
566 #define OSF1_ENH_SEC 1
569 #if defined(HAVE_PAM_AUTHENTICATE) && defined(HAVE_SECURITY_PAM_APPL_H)
573 #if defined(HAVE_YP_GET_DEFAULT_DOMAIN)
574 #define HAVE_NETGROUP 1
577 #if defined (HAVE_NETGROUP) && defined(HAVE_RPCSVC_YPCLNT_H)
578 #include "rpcsvc/ypclnt.h"
581 #ifndef ALLOW_CHANGE_PASSWORD
582 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
583 #define ALLOW_CHANGE_PASSWORD 1
587 /* what is the longest significant password available on your system?
588 Knowing this speeds up password searches a lot */
589 #ifndef PASSWORD_LENGTH
590 #define PASSWORD_LENGTH 8
593 #ifdef REPLACE_INET_NTOA
594 #define inet_ntoa rep_inet_ntoa
602 #define MAXPATHLEN 256
609 #ifndef INADDR_LOOPBACK
610 #define INADDR_LOOPBACK 0x7f000001
614 #define INADDR_NONE 0xffffffff
618 #define crypt ufc_crypt
622 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
625 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
626 #define ULTRIX_AUTH 1
629 #ifdef HAVE_LIBREADLINE
630 # ifdef HAVE_READLINE_READLINE_H
631 # include <readline/readline.h>
632 # ifdef HAVE_READLINE_HISTORY_H
633 # include <readline/history.h>
636 # ifdef HAVE_READLINE_H
637 # include <readline.h>
638 # ifdef HAVE_HISTORY_H
639 # include <history.h>
642 # undef HAVE_LIBREADLINE
648 char *strdup(const char *s);
652 void *memmove(void *dest,const void *src,int size);
655 #ifndef HAVE_INITGROUPS
656 int initgroups(char *name,gid_t id);
660 int rename(const char *zfrom, const char *zto);
664 time_t mktime(struct tm *t);
667 #ifndef HAVE_FTRUNCATE
668 int ftruncate(int f,long l);
671 #if (defined(HAVE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
673 int setresuid(uid_t ruid, uid_t euid, uid_t suid);
674 int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
677 #if (defined(HAVE_CRYPT) && !defined(HAVE_CRYPT_DECL))
679 int crypt(const char *key, const char *salt);
682 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
683 #define bzero(a,b) memset((a),'\0',(b))
686 #ifdef REPLACE_GETPASS
687 #define getpass(prompt) getsmbpass((prompt))
690 /* yuck, I'd like a better way of doing this */
691 #define DIRP_SIZE (256 + 32)
693 #endif /* _INCLUDES_H */