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 */
30 #define DEFAULT_PRINTING PRINT_AIX
34 #define DEFAULT_PRINTING PRINT_HPUX
38 #define DEFAULT_PRINTING PRINT_QNX
42 /* on SUNOS4 termios.h conflicts with sys/ioctl.h */
47 #include <sys/types.h>
49 #ifdef TIME_WITH_SYS_TIME
53 #ifdef HAVE_SYS_TIME_H
60 #ifdef HAVE_SYS_RESOURCE_H
61 #include <sys/resource.h>
71 #ifdef HAVE_SYS_PARAM_H
72 #include <sys/param.h>
79 #ifdef HAVE_SYS_SOCKET_H
80 #include <sys/socket.h>
102 #ifdef HAVE_SYS_FCNTL_H
103 #include <sys/fcntl.h>
107 #include <sys/stat.h>
113 #ifdef HAVE_SYS_IOCTL_H
114 #include <sys/ioctl.h>
117 #ifdef HAVE_SYS_FILIO_H
118 #include <sys/filio.h>
123 #ifdef HAVE_SYS_WAIT_H
124 #include <sys/wait.h>
142 #ifdef HAVE_SYS_SELECT_H
143 #include <sys/select.h>
146 #ifdef HAVE_SYS_MODE_H
147 /* apparently AIX needs this for S_ISLNK */
149 #include <sys/mode.h>
166 #include <netinet/in.h>
167 #include <arpa/inet.h>
170 #include <sys/file.h>
172 #ifdef HAVE_NETINET_TCP_H
173 #include <netinet/tcp.h>
176 #ifdef HAVE_TERMIOS_H
182 # define NAMLEN(dirent) strlen((dirent)->d_name)
184 # define dirent direct
185 # define NAMLEN(dirent) (dirent)->d_namlen
187 # include <sys/ndir.h>
190 # include <sys/dir.h>
197 #ifdef HAVE_SHARED_MMAP
198 #include <sys/mman.h>
212 #ifdef HAVE_SYS_MOUNT_H
213 #include <sys/mount.h>
216 #ifdef HAVE_SYS_VFS_H
220 #ifdef HAVE_SYS_FS_S5PARAM_H
221 #include <sys/fs/s5param.h>
224 #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
225 #include <sys/filsys.h>
228 #ifdef HAVE_SYS_STATFS_H
229 # include <sys/statfs.h>
233 #include <sys/dustat.h>
236 #ifdef HAVE_SYS_STATVFS_H
237 #include <sys/statvfs.h>
244 #ifdef HAVE_GETPWANAM
245 #include <sys/label.h>
246 #include <sys/audit.h>
250 #ifdef HAVE_SYS_SECURITY_H
251 #include <sys/security.h>
253 #define PASSWORD_LENGTH 16
254 #endif /* HAVE_SYS_SECURITY_H */
260 #ifdef HAVE_STROPTS_H
268 #ifdef HAVE_SYS_CAPABILITY_H
269 #include <sys/capability.h>
273 #define uchar unsigned char
276 #ifdef HAVE_UNSIGNED_CHAR
277 #define schar signed char
283 Samba needs type definitions for int16, int32, uint16 and uint32.
285 Normally these are signed and unsigned 16 and 32 bit integers, but
286 they actually only need to be at least 16 and 32 bits
287 respectively. Thus if your word size is 8 bytes just defining them
288 as signed and unsigned int will work.
292 #define uint8 unsigned char
296 #if (SIZEOF_SHORT == 4)
297 #define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
298 #else /* SIZEOF_SHORT != 4 */
300 #endif /* SIZEOF_SHORT != 4 */
304 #define uint16 unsigned int16
308 #if (SIZEOF_INT == 4)
310 #elif (SIZEOF_LONG == 4)
312 #elif (SIZEOF_SHORT == 4)
318 #define uint32 unsigned int32
322 * Types for devices, inodes and offsets.
326 #define SMB_DEV_T dev_t
330 * Setup the correctly sized inode type.
335 # define SMB_INO_T ino64_t
337 # define SMB_INO_T ino_t
341 #ifndef LARGE_SMB_INO_T
342 # if defined(HAVE_INO64_T) || (defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8))
343 # define LARGE_SMB_INO_T 1
349 # define SMB_OFF_T off64_t
351 # define SMB_OFF_T off_t
355 #define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
358 * Set the define that tells us if we can do 64 bit
362 #ifndef LARGE_SMB_OFF_T
363 # if defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8))
364 # define LARGE_SMB_OFF_T 1
368 #ifdef LARGE_SMB_OFF_T
369 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
371 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
375 * Type for stat structure.
378 #ifndef SMB_STRUCT_STAT
379 # if defined(HAVE_STAT64) && defined(HAVE_OFF64_T)
380 # define SMB_STRUCT_STAT struct stat64
382 # define SMB_STRUCT_STAT struct stat
387 * Defines for 64 bit fcntl locks.
390 #ifndef SMB_STRUCT_FLOCK
391 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
392 # define SMB_STRUCT_FLOCK struct flock64
394 # define SMB_STRUCT_FLOCK struct flock
399 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
400 # define SMB_F_SETLKW F_SETLKW64
402 # define SMB_F_SETLKW F_SETLKW
407 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
408 # define SMB_F_SETLK F_SETLK64
410 # define SMB_F_SETLK F_SETLK
415 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
416 # define SMB_F_GETLK F_GETLK64
418 # define SMB_F_GETLK F_GETLK
422 #if defined(HAVE_LONGLONG)
423 #define SMB_BIG_UINT unsigned long long
424 #define SMB_BIG_INT long long
426 #define SMB_BIG_UINT unsigned long
427 #define SMB_BIG_INT long
431 #define MIN(a,b) ((a)<(b)?(a):(b))
435 #define MAX(a,b) ((a)>(b)?(a):(b))
438 #ifndef HAVE_STRERROR
439 extern char *sys_errlist[];
440 #define strerror(i) sys_errlist[i]
444 # define strchr index
445 # define strrchr rindex
448 #ifndef HAVE_ERRNO_DECL
452 #ifdef HAVE_BROKEN_GETGROUPS
459 /* Lists, trees, caching, datbase... */
460 #include "ubi_sLinkList.h"
461 #include "ubi_dLinkList.h"
462 #include "dlinklist.h"
464 #ifndef UBI_BINTREE_H
465 #include "ubi_Cache.h"
466 #endif /* UBI_BINTREE_H */
470 #include "nameserv.h"
472 #include "byteorder.h"
479 #ifndef MAXCODEPAGELINES
480 #define MAXCODEPAGELINES 256
483 /***** automatically generated prototypes *****/
489 #define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
494 #define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
499 #define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
501 #define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
502 #define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
503 #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
504 #define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
507 #define QSORT_CAST (__compar_fn_t)
511 #define QSORT_CAST (int (*)(const void *, const void *))
514 /* this guess needs to be improved (tridge) */
515 #if defined(STAT_STATVFS) && !defined(SYSV)
519 #ifndef DEFAULT_PRINTING
521 #define DEFAULT_PRINTING PRINT_SYSV
523 #define DEFAULT_PRINTING PRINT_BSD
528 #define SIGCLD SIGCHLD
531 #if (defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP))
532 #define FAST_SHARE_MODES 1
540 #ifndef HAVE_UNION_SEMUN
543 struct semid_ds *buf;
544 unsigned short *array;
549 #if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP))
550 #define USE_SMBPASS_DB 1
553 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
554 #define OSF1_ENH_SEC 1
557 #if defined(HAVE_PAM_AUTHENTICATE) && defined(HAVE_SECURITY_PAM_APPL_H)
561 #if defined(HAVE_YP_GET_DEFAULT_DOMAIN)
562 #define HAVE_NETGROUP 1
565 #if defined (HAVE_NETGROUP) && defined(HAVE_RPCSVC_YPCLNT_H)
566 #include "rpcsvc/ypclnt.h"
569 #ifndef ALLOW_CHANGE_PASSWORD
570 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
571 #define ALLOW_CHANGE_PASSWORD 1
575 /* what is the longest significant password available on your system?
576 Knowing this speeds up password searches a lot */
577 #ifndef PASSWORD_LENGTH
578 #define PASSWORD_LENGTH 8
581 #ifdef REPLACE_INET_NTOA
582 #define inet_ntoa rep_inet_ntoa
590 #define MAXPATHLEN 256
597 #ifndef INADDR_LOOPBACK
598 #define INADDR_LOOPBACK 0x7f000001
602 #define INADDR_NONE 0xffffffff
606 #define crypt ufc_crypt
609 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
610 #define ULTRIX_AUTH 1
613 #ifdef HAVE_LIBREADLINE
614 # ifdef HAVE_READLINE_READLINE_H
615 # include <readline/readline.h>
616 # ifdef HAVE_READLINE_HISTORY_H
617 # include <readline/history.h>
620 # ifdef HAVE_READLINE_H
621 # include <readline.h>
622 # ifdef HAVE_HISTORY_H
623 # include <history.h>
626 # undef HAVE_LIBREADLINE
632 char *strdup(const char *s);
636 void *memmove(void *dest,const void *src,int size);
639 #ifndef HAVE_INITGROUPS
640 int initgroups(char *name,gid_t id);
644 int rename(const char *zfrom, const char *zto);
648 time_t mktime(struct tm *t);
651 #ifndef HAVE_FTRUNCATE
652 int ftruncate(int f,long l);
655 #if (defined(HAVE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
657 int setresuid(uid_t ruid, uid_t euid, uid_t suid);
658 int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
661 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
662 #define bzero(a,b) memset((a),'\0',(b))
665 #ifdef REPLACE_GETPASS
666 #define getpass(prompt) getsmbpass((prompt))
669 #endif /* _INCLUDES_H */