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 defined(HAVE_RPC_RPC_H)
53 #include <sys/types.h>
55 #ifdef TIME_WITH_SYS_TIME
59 #ifdef HAVE_SYS_TIME_H
66 #ifdef HAVE_SYS_RESOURCE_H
67 #include <sys/resource.h>
77 #ifdef HAVE_SYS_PARAM_H
78 #include <sys/param.h>
85 #ifdef HAVE_SYS_SOCKET_H
86 #include <sys/socket.h>
89 #ifdef HAVE_SYS_SYSCALL_H
90 #include <sys/syscall.h>
108 #include "../mem_man/mem_man.h"
118 #ifdef HAVE_SYS_FCNTL_H
119 #include <sys/fcntl.h>
123 #include <sys/stat.h>
129 #ifdef HAVE_SYS_IOCTL_H
130 #include <sys/ioctl.h>
133 #ifdef HAVE_SYS_FILIO_H
134 #include <sys/filio.h>
139 #ifdef HAVE_SYS_WAIT_H
140 #include <sys/wait.h>
158 #ifdef HAVE_SYS_SELECT_H
159 #include <sys/select.h>
162 #ifdef HAVE_SYS_MODE_H
163 /* apparently AIX needs this for S_ISLNK */
165 #include <sys/mode.h>
182 #include <netinet/in.h>
183 #include <arpa/inet.h>
186 #include <sys/file.h>
188 #ifdef HAVE_NETINET_TCP_H
189 #include <netinet/tcp.h>
192 #ifdef HAVE_TERMIOS_H
198 # define NAMLEN(dirent) strlen((dirent)->d_name)
200 # define dirent direct
201 # define NAMLEN(dirent) (dirent)->d_namlen
203 # include <sys/ndir.h>
206 # include <sys/dir.h>
213 #ifdef HAVE_SHARED_MMAP
214 #include <sys/mman.h>
225 * I have removed this as it prevents compilation under SCO Server
226 * 3.2. If you need to add it back in then please add a comment as to
227 * why it's needed and what OS it's needed for so we can work out how
228 * to test for it properly (tridge) */
229 #ifdef HAVE_NET_ROUTE_H
230 #include <net/route.h>
239 #ifdef HAVE_SYS_MOUNT_H
240 #include <sys/mount.h>
243 #ifdef HAVE_SYS_VFS_H
247 #ifdef HAVE_SYS_ACL_H
251 #ifdef HAVE_SYS_FS_S5PARAM_H
252 #include <sys/fs/s5param.h>
255 #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
256 #include <sys/filsys.h>
259 #ifdef HAVE_SYS_STATFS_H
260 # include <sys/statfs.h>
264 #include <sys/dustat.h>
267 #ifdef HAVE_SYS_STATVFS_H
268 #include <sys/statvfs.h>
275 #ifdef HAVE_GETPWANAM
276 #include <sys/label.h>
277 #include <sys/audit.h>
281 #ifdef HAVE_SYS_SECURITY_H
282 #include <sys/security.h>
284 #define PASSWORD_LENGTH 16
285 #endif /* HAVE_SYS_SECURITY_H */
291 #ifdef HAVE_STROPTS_H
299 #ifdef HAVE_SYS_CAPABILITY_H
300 #include <sys/capability.h>
303 #if defined(HAVE_RPC_RPC_H)
307 #if defined(HAVE_YP_GET_DEFAULT_DOMAIN) && defined(HAVE_SETNETGRENT) && defined(HAVE_ENDNETGRENT) && defined(HAVE_GETNETGRENT)
308 #define HAVE_NETGROUP 1
311 #if defined (HAVE_NETGROUP)
312 #if defined(HAVE_RPCSVC_YP_PROT_H)
313 #include <rpcsvc/yp_prot.h>
315 #if defined(HAVE_RPCSVC_YPCLNT_H)
316 #include <rpcsvc/ypclnt.h>
318 #endif /* HAVE_NETGROUP */
321 #define uchar unsigned char
324 #ifdef HAVE_UNSIGNED_CHAR
325 #define schar signed char
331 Samba needs type definitions for int16, int32, uint16 and uint32.
333 Normally these are signed and unsigned 16 and 32 bit integers, but
334 they actually only need to be at least 16 and 32 bits
335 respectively. Thus if your word size is 8 bytes just defining them
336 as signed and unsigned int will work.
340 #define uint8 unsigned char
343 #if !defined(int16) && !defined(HAVE_INT16_FROM_RPC_RPC_H)
344 #if (SIZEOF_SHORT == 4)
345 #define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
346 #else /* SIZEOF_SHORT != 4 */
348 #endif /* SIZEOF_SHORT != 4 */
352 * Note we duplicate the size tests in the unsigned
353 * case as int16 may be a typedef from rpc/rpc.h
356 #if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H)
357 #if (SIZEOF_SHORT == 4)
358 #define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
359 #else /* SIZEOF_SHORT != 4 */
360 #define uint16 unsigned short
361 #endif /* SIZEOF_SHORT != 4 */
364 #if !defined(int32) && !defined(HAVE_INT32_FROM_RPC_RPC_H)
365 #if (SIZEOF_INT == 4)
367 #elif (SIZEOF_LONG == 4)
369 #elif (SIZEOF_SHORT == 4)
375 * Note we duplicate the size tests in the unsigned
376 * case as int32 may be a typedef from rpc/rpc.h
379 #if !defined(uint32) && !defined(HAVE_UINT32_FROM_RPC_RPC_H)
380 #if (SIZEOF_INT == 4)
381 #define uint32 unsigned int
382 #elif (SIZEOF_LONG == 4)
383 #define uint32 unsigned long
384 #elif (SIZEOF_SHORT == 4)
385 #define uint32 unsigned short
390 * Types for devices, inodes and offsets.
394 #define SMB_DEV_T dev_t
398 * Setup the correctly sized inode type.
403 # define SMB_INO_T ino64_t
405 # define SMB_INO_T ino_t
409 #ifndef LARGE_SMB_INO_T
410 # if defined(HAVE_INO64_T) || (defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8))
411 # define LARGE_SMB_INO_T 1
415 #ifdef LARGE_SMB_INO_T
416 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
418 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
423 # define SMB_OFF_T off64_t
425 # define SMB_OFF_T off_t
429 #define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
432 * Set the define that tells us if we can do 64 bit
436 #ifndef LARGE_SMB_OFF_T
437 # if defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8))
438 # define LARGE_SMB_OFF_T 1
442 #ifdef LARGE_SMB_OFF_T
443 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
445 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
449 * Type for stat structure.
452 #ifndef SMB_STRUCT_STAT
453 # if defined(HAVE_STAT64) && defined(HAVE_OFF64_T)
454 # define SMB_STRUCT_STAT struct stat64
456 # define SMB_STRUCT_STAT struct stat
461 * Defines for 64 bit fcntl locks.
464 #ifndef SMB_STRUCT_FLOCK
465 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
466 # define SMB_STRUCT_FLOCK struct flock64
468 # define SMB_STRUCT_FLOCK struct flock
473 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
474 # define SMB_F_SETLKW F_SETLKW64
476 # define SMB_F_SETLKW F_SETLKW
481 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
482 # define SMB_F_SETLK F_SETLK64
484 # define SMB_F_SETLK F_SETLK
489 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
490 # define SMB_F_GETLK F_GETLK64
492 # define SMB_F_GETLK F_GETLK
496 #if defined(HAVE_LONGLONG)
497 #define SMB_BIG_UINT unsigned long long
498 #define SMB_BIG_INT long long
500 #define SMB_BIG_UINT unsigned long
501 #define SMB_BIG_INT long
505 #define MIN(a,b) ((a)<(b)?(a):(b))
509 #define MAX(a,b) ((a)>(b)?(a):(b))
512 #ifndef HAVE_STRERROR
513 extern char *sys_errlist[];
514 #define strerror(i) sys_errlist[i]
518 # define strchr index
519 # define strrchr rindex
522 #ifndef HAVE_ERRNO_DECL
526 #ifdef HAVE_BROKEN_GETGROUPS
533 /* Lists, trees, caching, datbase... */
534 #include "ubi_sLinkList.h"
535 #include "ubi_dLinkList.h"
536 #include "dlinklist.h"
538 #ifndef UBI_BINTREE_H
539 #include "ubi_Cache.h"
540 #endif /* UBI_BINTREE_H */
542 #include "debugparse.h"
547 #include "nameserv.h"
549 #include "byteorder.h"
556 #ifndef MAXCODEPAGELINES
557 #define MAXCODEPAGELINES 256
560 /***** automatically generated prototypes *****/
566 #define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
571 #define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
576 #define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
578 #define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
579 #define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
580 #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
581 #define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
584 #define QSORT_CAST (__compar_fn_t)
588 #define QSORT_CAST (int (*)(const void *, const void *))
591 /* this guess needs to be improved (tridge) */
592 #if defined(STAT_STATVFS) && !defined(SYSV)
596 #ifndef DEFAULT_PRINTING
598 #define DEFAULT_PRINTING PRINT_SYSV
599 #define PRINTCAP_NAME "lpstat"
601 #define DEFAULT_PRINTING PRINT_BSD
602 #define PRINTCAP_NAME "/etc/printcap"
606 #ifndef PRINTCAP_NAME
607 #define PRINTCAP_NAME "/etc/printcap"
611 #define SIGCLD SIGCHLD
614 #if (defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP))
615 #define FAST_SHARE_MODES 1
623 #ifndef HAVE_UNION_SEMUN
626 struct semid_ds *buf;
627 unsigned short *array;
632 #if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP))
633 #define USE_SMBPASS_DB 1
634 #define USE_SMBUNIX_DB 1
637 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
638 #define OSF1_ENH_SEC 1
641 #if defined(HAVE_PAM_AUTHENTICATE) && defined(HAVE_SECURITY_PAM_APPL_H)
645 #ifndef ALLOW_CHANGE_PASSWORD
646 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
647 #define ALLOW_CHANGE_PASSWORD 1
651 /* what is the longest significant password available on your system?
652 Knowing this speeds up password searches a lot */
653 #ifndef PASSWORD_LENGTH
654 #define PASSWORD_LENGTH 8
657 #ifdef REPLACE_INET_NTOA
658 #define inet_ntoa rep_inet_ntoa
666 #define MAXPATHLEN 256
673 #ifndef INADDR_LOOPBACK
674 #define INADDR_LOOPBACK 0x7f000001
678 #define INADDR_NONE 0xffffffff
682 #define crypt ufc_crypt
686 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
689 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
690 #define ULTRIX_AUTH 1
693 #ifdef HAVE_LIBREADLINE
694 # ifdef HAVE_READLINE_READLINE_H
695 # include <readline/readline.h>
696 # ifdef HAVE_READLINE_HISTORY_H
697 # include <readline/history.h>
700 # ifdef HAVE_READLINE_H
701 # include <readline.h>
702 # ifdef HAVE_HISTORY_H
703 # include <history.h>
706 # undef HAVE_LIBREADLINE
712 char *strdup(const char *s);
716 void *memmove(void *dest,const void *src,int size);
719 #ifndef HAVE_INITGROUPS
720 int initgroups(char *name,gid_t id);
724 int rename(const char *zfrom, const char *zto);
728 time_t mktime(struct tm *t);
731 #ifndef HAVE_FTRUNCATE
732 int ftruncate(int f,long l);
735 #if (defined(HAVE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
737 int setresuid(uid_t ruid, uid_t euid, uid_t suid);
738 int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
741 #if (defined(HAVE_CRYPT) && !defined(HAVE_CRYPT_DECL) && !defined(KRB4_AUTH))
743 int crypt(const char *key, const char *salt);
746 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
747 #define bzero(a,b) memset((a),'\0',(b))
750 #ifdef REPLACE_GETPASS
751 #define getpass(prompt) getsmbpass((prompt))
754 /* yuck, I'd like a better way of doing this */
755 #define DIRP_SIZE (256 + 32)
757 #endif /* _INCLUDES_H */