TDB password backend support written by Simo Sorce <simo.sorce@polimi.it>
[ira/wip.git] / source3 / include / includes.h
1 #ifndef _INCLUDES_H
2 #define _INCLUDES_H
3 /* 
4    Unix SMB/Netbios implementation.
5    Version 1.9.
6    Machine customisation and include handling
7    Copyright (C) Andrew Tridgell 1994-1998
8    
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.
13    
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.
18    
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.
22 */
23
24 #ifndef NO_CONFIG_H /* for some tests */
25 #include "config.h"
26 #endif
27
28 #include "local.h"
29
30 #ifdef AIX
31 #define DEFAULT_PRINTING PRINT_AIX
32 #define PRINTCAP_NAME "/etc/qconfig"
33 #endif
34
35 #ifdef HPUX
36 #define DEFAULT_PRINTING PRINT_HPUX
37 #endif
38
39 #ifdef QNX
40 #define DEFAULT_PRINTING PRINT_QNX
41 #endif
42
43 #ifdef SUNOS4
44 /* on SUNOS4 termios.h conflicts with sys/ioctl.h */
45 #undef HAVE_TERMIOS_H
46 #endif
47
48 #ifdef LINUX
49 #ifndef DEFAULT_PRINTING
50 #define DEFAULT_PRINTING PRINT_BSD
51 #endif
52 #ifndef PRINTCAP_NAME
53 #define PRINTCAP_NAME "/etc/printcap"
54 #endif
55 #endif
56
57 #ifdef RELIANTUNIX
58 /*
59  * <unistd.h> has to be included before any other to get
60  * large file support on Reliant UNIX
61  */
62 #ifdef HAVE_UNISTD_H
63 #include <unistd.h>
64 #endif
65 #endif /* RELIANTUNIX */
66
67 #include <sys/types.h>
68
69 #ifdef TIME_WITH_SYS_TIME
70 #include <sys/time.h>
71 #include <time.h>
72 #else
73 #ifdef HAVE_SYS_TIME_H
74 #include <sys/time.h>
75 #else
76 #include <time.h>
77 #endif
78 #endif
79
80 #ifdef HAVE_SYS_RESOURCE_H
81 #include <sys/resource.h>
82 #endif
83
84 #ifdef HAVE_UNISTD_H
85 #include <unistd.h>
86 #endif
87
88 #include <stdio.h>
89 #include <stddef.h>
90
91 #ifdef HAVE_SYS_PARAM_H
92 #include <sys/param.h>
93 #endif
94
95 #ifdef HAVE_STDLIB_H
96 #include <stdlib.h>
97 #endif
98
99 #ifdef HAVE_SYS_SOCKET_H
100 #include <sys/socket.h>
101 #endif
102
103 #ifdef HAVE_SYS_UN_H
104 #include <sys/un.h>
105 #endif
106
107 #ifdef HAVE_SYS_SYSCALL_H
108 #include <sys/syscall.h>
109 #elif HAVE_SYSCALL_H
110 #include <syscall.h>
111 #endif
112
113 #ifdef HAVE_STRING_H
114 #include <string.h>
115 #endif
116
117 #ifdef HAVE_STRINGS_H
118 #include <strings.h>
119 #endif
120
121 #ifdef HAVE_MEMORY_H
122 #include <memory.h>
123 #endif
124
125 #ifdef HAVE_MALLOC_H
126 #include <malloc.h>
127 #endif
128
129 #ifdef HAVE_FCNTL_H
130 #include <fcntl.h>
131 #else
132 #ifdef HAVE_SYS_FCNTL_H
133 #include <sys/fcntl.h>
134 #endif
135 #endif
136
137 #include <sys/stat.h>
138
139 #ifdef HAVE_LIMITS_H
140 #include <limits.h>
141 #endif
142
143 #ifdef HAVE_SYS_IOCTL_H
144 #include <sys/ioctl.h>
145 #endif
146
147 #ifdef HAVE_SYS_FILIO_H
148 #include <sys/filio.h>
149 #endif
150
151 #include <signal.h>
152
153 #ifdef HAVE_SYS_WAIT_H
154 #include <sys/wait.h>
155 #endif
156 #ifdef HAVE_CTYPE_H
157 #include <ctype.h>
158 #endif
159 #ifdef HAVE_GRP_H
160 #include <grp.h>
161 #endif
162 #ifdef HAVE_SYS_PRIV_H
163 #include <sys/priv.h>
164 #endif
165 #ifdef HAVE_SYS_ID_H
166 #include <sys/id.h>
167 #endif
168
169 #include <errno.h>
170
171 #ifdef HAVE_UTIME_H
172 #include <utime.h>
173 #endif
174
175 #ifdef HAVE_SYS_SELECT_H
176 #include <sys/select.h>
177 #endif
178
179 #ifdef HAVE_SYS_MODE_H
180 /* apparently AIX needs this for S_ISLNK */
181 #ifndef S_ISLNK
182 #include <sys/mode.h>
183 #endif
184 #endif
185
186 #ifdef HAVE_GLOB_H
187 #include <glob.h>
188 #endif
189
190 #include <pwd.h>
191
192 #ifdef HAVE_STDARG_H
193 #include <stdarg.h>
194 #else
195 #include <varargs.h>
196 #endif
197
198 #include <netinet/in.h>
199 #include <arpa/inet.h>
200 #include <netdb.h>
201 #include <syslog.h>
202 #include <sys/file.h>
203
204 #ifdef HAVE_NETINET_TCP_H
205 #include <netinet/tcp.h>
206 #endif
207
208 /*
209  * The next three defines are needed to access the IPTOS_* options
210  * on some systems.
211  */
212
213 #ifdef HAVE_NETINET_IN_SYSTM_H
214 #include <netinet/in_systm.h>
215 #endif
216
217 #ifdef HAVE_NETINET_IN_IP_H
218 #include <netinet/in_ip.h>
219 #endif
220
221 #ifdef HAVE_NETINET_IP_H
222 #include <netinet/ip.h>
223 #endif
224
225 #if defined(HAVE_TERMIOS_H)
226 /* POSIX terminal handling. */
227 #include <termios.h>
228 #elif defined(HAVE_TERMIO_H)
229 /* Older SYSV terminal handling - don't use if we can avoid it. */
230 #include <termio.h>
231 #elif defined(HAVE_SYS_TERMIO_H)
232 /* Older SYSV terminal handling - don't use if we can avoid it. */
233 #include <sys/termio.h>
234 #endif
235
236 #if HAVE_DIRENT_H
237 # include <dirent.h>
238 # define NAMLEN(dirent) strlen((dirent)->d_name)
239 #else
240 # define dirent direct
241 # define NAMLEN(dirent) (dirent)->d_namlen
242 # if HAVE_SYS_NDIR_H
243 #  include <sys/ndir.h>
244 # endif
245 # if HAVE_SYS_DIR_H
246 #  include <sys/dir.h>
247 # endif
248 # if HAVE_NDIR_H
249 #  include <ndir.h>
250 # endif
251 #endif
252
253 #ifdef HAVE_SYS_MMAN_H
254 #include <sys/mman.h>
255 #endif
256
257 #ifdef HAVE_NET_IF_H
258 #include <net/if.h>
259 #endif
260
261
262 #ifdef HAVE_SYS_MOUNT_H
263 #include <sys/mount.h>
264 #endif
265
266 #ifdef HAVE_SYS_VFS_H
267 #include <sys/vfs.h>
268 #endif
269
270 #ifdef HAVE_SYS_ACL_H
271 #include <sys/acl.h>
272 #endif
273
274 #ifdef HAVE_SYS_FS_S5PARAM_H 
275 #include <sys/fs/s5param.h>
276 #endif
277
278 #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
279 #include <sys/filsys.h> 
280 #endif
281
282 #ifdef HAVE_SYS_STATFS_H
283 # include <sys/statfs.h>
284 #endif
285
286 #ifdef HAVE_DUSTAT_H              
287 #include <sys/dustat.h>
288 #endif
289
290 #ifdef HAVE_SYS_STATVFS_H          
291 #include <sys/statvfs.h>
292 #endif
293
294 #ifdef HAVE_SHADOW_H
295 #include <shadow.h>
296 #endif
297
298 #ifdef HAVE_GETPWANAM
299 #include <sys/label.h>
300 #include <sys/audit.h>
301 #include <pwdadj.h>
302 #endif
303
304 #ifdef HAVE_SYS_SECURITY_H
305 #include <sys/security.h>
306 #include <prot.h>
307 #define PASSWORD_LENGTH 16
308 #endif  /* HAVE_SYS_SECURITY_H */
309
310 #ifdef HAVE_COMPAT_H
311 #include <compat.h>
312 #endif
313
314 #ifdef HAVE_STROPTS_H
315 #include <stropts.h>
316 #endif
317
318 #ifdef HAVE_POLL_H
319 #include <poll.h>
320 #endif
321
322 #ifdef HAVE_SYS_CAPABILITY_H
323 #include <sys/capability.h>
324 #endif
325
326 #if defined(HAVE_RPC_RPC_H)
327 /*
328  * Check for AUTH_ERROR define conflict with rpc/rpc.h in prot.h.
329  */
330 #if defined(HAVE_SYS_SECURITY_H) && defined(HAVE_RPC_AUTH_ERROR_CONFLICT)
331 #undef AUTH_ERROR
332 #endif
333 #include <rpc/rpc.h>
334 #endif
335
336 #if defined(HAVE_YP_GET_DEFAULT_DOMAIN) && defined(HAVE_SETNETGRENT) && defined(HAVE_ENDNETGRENT) && defined(HAVE_GETNETGRENT)
337 #define HAVE_NETGROUP 1
338 #endif
339
340 #if defined (HAVE_NETGROUP)
341 #if defined(HAVE_RPCSVC_YP_PROT_H)
342 #include <rpcsvc/yp_prot.h>
343 #endif
344 #if defined(HAVE_RPCSVC_YPCLNT_H)
345 #include <rpcsvc/ypclnt.h>
346 #endif
347 #endif /* HAVE_NETGROUP */
348
349 /*
350  * Define VOLATILE if needed.
351  */
352
353 #if defined(HAVE_VOLATILE)
354 #define VOLATILE volatile
355 #else
356 #define VOLATILE
357 #endif
358
359 /*
360  * Define SIG_ATOMIC_T if needed.
361  */
362
363 #if defined(HAVE_SIG_ATOMIC_T_TYPE)
364 #define SIG_ATOMIC_T sig_atomic_t
365 #else
366 #define SIG_ATOMIC_T int
367 #endif
368
369 #ifndef uchar
370 #define uchar unsigned char
371 #endif
372
373 #ifdef HAVE_UNSIGNED_CHAR
374 #define schar signed char
375 #else
376 #define schar char
377 #endif
378
379 /*
380    Samba needs type definitions for int16, int32, uint16 and uint32.
381
382    Normally these are signed and unsigned 16 and 32 bit integers, but
383    they actually only need to be at least 16 and 32 bits
384    respectively. Thus if your word size is 8 bytes just defining them
385    as signed and unsigned int will work.
386 */
387
388 #ifndef uint8
389 #define uint8 unsigned char
390 #endif
391
392 #if !defined(int16) && !defined(HAVE_INT16_FROM_RPC_RPC_H)
393 #if (SIZEOF_SHORT == 4)
394 #define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
395 #else /* SIZEOF_SHORT != 4 */
396 #define int16 short
397 #endif /* SIZEOF_SHORT != 4 */
398 #endif
399
400 /*
401  * Note we duplicate the size tests in the unsigned 
402  * case as int16 may be a typedef from rpc/rpc.h
403  */
404
405 #if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H)
406 #if (SIZEOF_SHORT == 4)
407 #define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
408 #else /* SIZEOF_SHORT != 4 */
409 #define uint16 unsigned short
410 #endif /* SIZEOF_SHORT != 4 */
411 #endif
412
413 #if !defined(int32) && !defined(HAVE_INT32_FROM_RPC_RPC_H)
414 #if (SIZEOF_INT == 4)
415 #define int32 int
416 #elif (SIZEOF_LONG == 4)
417 #define int32 long
418 #elif (SIZEOF_SHORT == 4)
419 #define int32 short
420 #endif
421 #endif
422
423 /*
424  * Note we duplicate the size tests in the unsigned 
425  * case as int32 may be a typedef from rpc/rpc.h
426  */
427
428 #if !defined(uint32) && !defined(HAVE_UINT32_FROM_RPC_RPC_H)
429 #if (SIZEOF_INT == 4)
430 #define uint32 unsigned int
431 #elif (SIZEOF_LONG == 4)
432 #define uint32 unsigned long
433 #elif (SIZEOF_SHORT == 4)
434 #define uint32 unsigned short
435 #endif
436 #endif
437
438 /*
439  * Types for devices, inodes and offsets.
440  */
441
442 #ifndef SMB_DEV_T
443 #define SMB_DEV_T dev_t
444 #endif
445
446 /*
447  * Setup the correctly sized inode type.
448  */
449
450 #ifndef SMB_INO_T
451 #  if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_INO64_T)
452 #    define SMB_INO_T ino64_t
453 #  else
454 #    define SMB_INO_T ino_t
455 #  endif
456 #endif
457
458 #ifndef LARGE_SMB_INO_T
459 #  if (defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_INO64_T)) || (defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8))
460 #    define LARGE_SMB_INO_T 1
461 #  endif
462 #endif
463
464 #ifdef LARGE_SMB_INO_T
465 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
466 #else 
467 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
468 #endif
469
470 #ifndef SMB_OFF_T
471 #  if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T)
472 #    define SMB_OFF_T off64_t
473 #  else
474 #    define SMB_OFF_T off_t
475 #  endif
476 #endif
477
478 /* this should really be a 64 bit type if possible */
479 #define br_off SMB_BIG_UINT
480
481 #define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
482
483 /*
484  * Set the define that tells us if we can do 64 bit
485  * NT SMB calls.
486  */
487
488 #ifndef LARGE_SMB_OFF_T
489 #  if (defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T)) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8))
490 #    define LARGE_SMB_OFF_T 1
491 #  endif
492 #endif
493
494 #ifdef LARGE_SMB_OFF_T
495 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
496 #else 
497 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
498 #endif
499
500 /*
501  * Type for stat structure.
502  */
503
504 #ifndef SMB_STRUCT_STAT
505 #  if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STAT64) && defined(HAVE_OFF64_T)
506 #    define SMB_STRUCT_STAT struct stat64
507 #  else
508 #    define SMB_STRUCT_STAT struct stat
509 #  endif
510 #endif
511
512 /*
513  * Type for dirent structure.
514  */
515
516 #ifndef SMB_STRUCT_DIRENT
517 #  if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_DIRENT64)
518 #    define SMB_STRUCT_DIRENT struct dirent64
519 #  else
520 #    define SMB_STRUCT_DIRENT struct dirent
521 #  endif
522 #endif
523
524 /*
525  * Defines for 64 bit fcntl locks.
526  */
527
528 #ifndef SMB_STRUCT_FLOCK
529 #  if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
530 #    define SMB_STRUCT_FLOCK struct flock64
531 #  else
532 #    define SMB_STRUCT_FLOCK struct flock
533 #  endif
534 #endif
535
536 #ifndef SMB_F_SETLKW
537 #  if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
538 #    define SMB_F_SETLKW F_SETLKW64
539 #  else
540 #    define SMB_F_SETLKW F_SETLKW
541 #  endif
542 #endif
543
544 #ifndef SMB_F_SETLK
545 #  if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
546 #    define SMB_F_SETLK F_SETLK64
547 #  else
548 #    define SMB_F_SETLK F_SETLK
549 #  endif
550 #endif
551
552 #ifndef SMB_F_GETLK
553 #  if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
554 #    define SMB_F_GETLK F_GETLK64
555 #  else
556 #    define SMB_F_GETLK F_GETLK
557 #  endif
558 #endif
559
560 #if defined(HAVE_LONGLONG)
561 #define SMB_BIG_UINT unsigned long long
562 #define SMB_BIG_INT long long
563 #define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
564 #else
565 #define SMB_BIG_UINT unsigned long
566 #define SMB_BIG_INT long
567 #define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
568 #endif
569
570 #define SMB_BIG_UINT_BITS (sizeof(SMB_BIG_UINT)*8)
571
572 #ifndef MIN
573 #define MIN(a,b) ((a)<(b)?(a):(b))
574 #endif
575
576 #ifndef MAX
577 #define MAX(a,b) ((a)>(b)?(a):(b))
578 #endif
579
580 #ifndef HAVE_STRERROR
581 extern char *sys_errlist[];
582 #define strerror(i) sys_errlist[i]
583 #endif
584
585 #ifndef HAVE_STRCHR
586 # define strchr                 index
587 # define strrchr                rindex
588 #endif
589
590 #ifndef HAVE_ERRNO_DECL
591 extern int errno;
592 #endif
593
594 #ifdef HAVE_BROKEN_GETGROUPS
595 #define GID_T int
596 #else
597 #define GID_T gid_t
598 #endif
599
600 #ifndef NGROUPS_MAX
601 #define NGROUPS_MAX 32 /* Guess... */
602 #endif
603
604 /* Lists, trees, caching, database... */
605 #include "ubi_sLinkList.h"
606 #include "ubi_dLinkList.h"
607 #include "dlinklist.h"
608 #include "../tdb/tdb.h"
609 #include "talloc.h"
610 #include "interfaces.h"
611 #include "hash.h"
612 #include "trans2.h"
613 #include "nterr.h"
614 #include "secrets.h"
615 #include "messages.h"
616 #include "util_list.h"
617
618 #ifndef UBI_BINTREE_H
619 #include "ubi_Cache.h"
620 #endif /* UBI_BINTREE_H */
621
622 #include "debugparse.h"
623
624 #include "version.h"
625 #include "smb.h"
626 #include "smbw.h"
627 #include "nameserv.h"
628
629 #include "byteorder.h"
630
631 #include "kanji.h"
632 #include "charset.h"
633
634 #include "ntdomain.h"
635
636 #include "msdfs.h"
637
638 #include "profile.h"
639
640 #ifndef MAXCODEPAGELINES
641 #define MAXCODEPAGELINES 256
642 #endif
643
644 /*
645  * Type for wide character dirent structure.
646  * Only d_name is defined by POSIX.
647  */
648
649 typedef struct smb_wdirent {
650         wpstring        d_name;
651 } SMB_STRUCT_WDIRENT;
652
653 /*
654  * Type for wide character passwd structure.
655  */
656
657 typedef struct smb_wpasswd {
658         wfstring       pw_name;
659         char           *pw_passwd;
660         uid_t          pw_uid;
661         gid_t          pw_gid;
662         wpstring       pw_gecos;
663         wpstring       pw_dir;
664         wpstring       pw_shell;
665 } SMB_STRUCT_WPASSWD;
666
667 /* Defines for wisXXX functions. */
668 #define UNI_UPPER    0x1
669 #define UNI_LOWER    0x2
670 #define UNI_DIGIT    0x4
671 #define UNI_XDIGIT   0x8
672 #define UNI_SPACE    0x10
673
674 #ifdef HAVE_NSS_H
675 #include <nss.h>
676 #else
677
678 /* Minimal needed to compile.. */
679
680 enum nss_status {
681         NSS_STATUS_SUCCESS,
682         NSS_STATUS_NOTFOUND,
683         NSS_STATUS_UNAVAIL
684 };
685
686 #endif
687
688 /***** automatically generated prototypes *****/
689 #include "proto.h"
690
691 /* String routines */
692
693 #include "safe_string.h"
694
695 #ifdef __COMPAR_FN_T
696 #define QSORT_CAST (__compar_fn_t)
697 #endif
698
699 #ifndef QSORT_CAST
700 #define QSORT_CAST (int (*)(const void *, const void *))
701 #endif
702
703 /* this guess needs to be improved (tridge) */
704 #if (defined(STAT_STATVFS) || defined(STAT_STATVFS64)) && !defined(SYSV)
705 #define SYSV 1
706 #endif
707
708 #ifndef DEFAULT_PRINTING
709 #ifdef HAVE_LIBCUPS
710 #define DEFAULT_PRINTING PRINT_CUPS
711 #define PRINTCAP_NAME "cups"
712 #elif defined(SYSV)
713 #define DEFAULT_PRINTING PRINT_SYSV
714 #define PRINTCAP_NAME "lpstat"
715 #else
716 #define DEFAULT_PRINTING PRINT_BSD
717 #define PRINTCAP_NAME "/etc/printcap"
718 #endif
719 #endif
720
721 #ifndef PRINTCAP_NAME
722 #define PRINTCAP_NAME "/etc/printcap"
723 #endif
724
725 #ifndef SIGCLD
726 #define SIGCLD SIGCHLD
727 #endif
728
729 #ifndef MAP_FILE
730 #define MAP_FILE 0
731 #endif
732
733 #if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP) && !defined(WITH_TDBPWD))
734 #define USE_SMBPASS_DB 1
735 #endif
736
737 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
738 #define OSF1_ENH_SEC 1
739 #endif
740
741 #ifndef ALLOW_CHANGE_PASSWORD
742 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
743 #define ALLOW_CHANGE_PASSWORD 1
744 #endif
745 #endif
746
747 /* what is the longest significant password available on your system? 
748  Knowing this speeds up password searches a lot */
749 #ifndef PASSWORD_LENGTH
750 #define PASSWORD_LENGTH 8
751 #endif
752
753 #ifdef REPLACE_INET_NTOA
754 #define inet_ntoa rep_inet_ntoa
755 #endif
756
757 #ifndef HAVE_PIPE
758 #define SYNC_DNS 1
759 #endif
760
761 #ifndef MAXPATHLEN
762 #define MAXPATHLEN 256
763 #endif
764
765 #ifndef SEEK_SET
766 #define SEEK_SET 0
767 #endif
768
769 #ifndef INADDR_LOOPBACK
770 #define INADDR_LOOPBACK 0x7f000001
771 #endif
772
773 #ifndef INADDR_NONE
774 #define INADDR_NONE 0xffffffff
775 #endif
776
777 #ifndef HAVE_CRYPT
778 #define crypt ufc_crypt
779 #endif
780
781 #ifndef O_ACCMODE
782 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
783 #endif
784
785 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
786 #define ULTRIX_AUTH 1
787 #endif
788
789 #ifdef HAVE_LIBREADLINE
790 #  ifdef HAVE_READLINE_READLINE_H
791 #    include <readline/readline.h>
792 #    ifdef HAVE_READLINE_HISTORY_H
793 #      include <readline/history.h>
794 #    endif
795 #  else
796 #    ifdef HAVE_READLINE_H
797 #      include <readline.h>
798 #      ifdef HAVE_HISTORY_H
799 #        include <history.h>
800 #      endif
801 #    else
802 #      undef HAVE_LIBREADLINE
803 #    endif
804 #  endif
805 #endif
806
807 #ifndef HAVE_STRDUP
808 char *strdup(const char *s);
809 #endif
810
811 #ifndef HAVE_MEMMOVE
812 void *memmove(void *dest,const void *src,int size);
813 #endif
814
815 #ifndef HAVE_INITGROUPS
816 int initgroups(char *name,gid_t id);
817 #endif
818
819 #ifndef HAVE_RENAME
820 int rename(const char *zfrom, const char *zto);
821 #endif
822
823 #ifndef HAVE_MKTIME
824 time_t mktime(struct tm *t);
825 #endif
826
827 #ifndef HAVE_FTRUNCATE
828 int ftruncate(int f,long l);
829 #endif
830
831 #ifndef HAVE_STRTOUL
832 unsigned long strtoul(const char *nptr, char **endptr, int base);
833 #endif
834
835 #if (defined(USE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
836 /* stupid glibc */
837 int setresuid(uid_t ruid, uid_t euid, uid_t suid);
838 #endif
839 #if (defined(USE_SETRESUID) && !defined(HAVE_SETRESGID_DECL))
840 int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
841 #endif
842
843 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
844 #define bzero(a,b) memset((a),'\0',(b))
845 #endif
846
847 #ifdef REPLACE_GETPASS
848 #define getpass(prompt) getsmbpass((prompt))
849 #endif
850
851 /*
852  * Some older systems seem not to have MAXHOSTNAMELEN
853  * defined.
854  */
855 #ifndef MAXHOSTNAMELEN
856 #define MAXHOSTNAMELEN 254
857 #endif
858
859 /* yuck, I'd like a better way of doing this */
860 #define DIRP_SIZE (256 + 32)
861
862 /*
863  * glibc on linux doesn't seem to have MSG_WAITALL
864  * defined. I think the kernel has it though..
865  */
866
867 #ifndef MSG_WAITALL
868 #define MSG_WAITALL 0
869 #endif
870
871 /* default socket options. Dave Miller thinks we should default to TCP_NODELAY
872    given the socket IO pattern that Samba uses */
873 #ifdef TCP_NODELAY
874 #define DEFAULT_SOCKET_OPTIONS "TCP_NODELAY"
875 #else
876 #define DEFAULT_SOCKET_OPTIONS ""
877 #endif
878
879 /* Load header file for libdl stuff */
880
881 #ifdef HAVE_LIBDL
882 #include <dlfcn.h>
883 #endif
884
885 /* Some POSIX definitions for those without */
886  
887 #ifndef S_IFDIR
888 #define S_IFDIR         0x4000
889 #endif
890 #ifndef S_ISDIR
891 #define S_ISDIR(mode)   ((mode & 0xF000) == S_IFDIR)
892 #endif
893 #ifndef S_IRWXU
894 #define S_IRWXU 00700           /* read, write, execute: owner */
895 #endif
896 #ifndef S_IRUSR
897 #define S_IRUSR 00400           /* read permission: owner */
898 #endif
899 #ifndef S_IWUSR
900 #define S_IWUSR 00200           /* write permission: owner */
901 #endif
902 #ifndef S_IXUSR
903 #define S_IXUSR 00100           /* execute permission: owner */
904 #endif
905 #ifndef S_IRWXG
906 #define S_IRWXG 00070           /* read, write, execute: group */
907 #endif
908 #ifndef S_IRGRP
909 #define S_IRGRP 00040           /* read permission: group */
910 #endif
911 #ifndef S_IWGRP
912 #define S_IWGRP 00020           /* write permission: group */
913 #endif
914 #ifndef S_IXGRP
915 #define S_IXGRP 00010           /* execute permission: group */
916 #endif
917 #ifndef S_IRWXO
918 #define S_IRWXO 00007           /* read, write, execute: other */
919 #endif
920 #ifndef S_IROTH
921 #define S_IROTH 00004           /* read permission: other */
922 #endif
923 #ifndef S_IWOTH
924 #define S_IWOTH 00002           /* write permission: other */
925 #endif
926 #ifndef S_IXOTH
927 #define S_IXOTH 00001           /* execute permission: other */
928 #endif
929
930 /* Some systems (SCO) treat UNIX domain sockets as FIFOs */
931
932 #ifndef S_IFSOCK
933 #define S_IFSOCK S_IFIFO
934 #endif
935 #ifndef S_ISSOCK
936 #define S_ISSOCK(mode)  ((mode & S_IFSOCK) == S_IFSOCK)
937 #endif
938
939 #if HAVE_KERNEL_SHARE_MODES
940 #ifndef LOCK_MAND 
941 #define LOCK_MAND       32      /* This is a mandatory flock */
942 #define LOCK_READ       64      /* ... Which allows concurrent read operations */
943 #define LOCK_WRITE      128     /* ... Which allows concurrent write operations */
944 #define LOCK_RW         192     /* ... Which allows concurrent read & write ops */
945 #endif
946 #endif
947
948 extern int DEBUGLEVEL;
949
950 #define MAX_SEC_CTX_DEPTH 8    /* Maximum number of security contexts */
951
952
953 #ifdef GLIBC_HACK_FCNTL64
954 /* this is a gross hack. 64 bit locking is completely screwed up on
955    i386 Linux in glibc 2.1.95 (which ships with RedHat 7.0). This hack
956    "fixes" the problem with the current 2.4.0test kernels 
957 */
958 #define fcntl fcntl64
959 #undef F_SETLKW 
960 #undef F_SETLK 
961 #define F_SETLK 13
962 #define F_SETLKW 14
963 #endif
964
965 #endif /* _INCLUDES_H */
966