4 Unix SMB/CIFS implementation.
5 Machine customisation and include handling
6 Copyright (C) Andrew Tridgell 1994-1998
7 Copyright (C) 2002 by Martin Pool <mbp@samba.org>
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 */
26 #include "smb_build.h"
32 #define DEFAULT_PRINTING PRINT_AIX
33 #define PRINTCAP_NAME "/etc/qconfig"
37 #define DEFAULT_PRINTING PRINT_HPUX
41 #define DEFAULT_PRINTING PRINT_QNX
45 /* on SUNOS4 termios.h conflicts with sys/ioctl.h */
49 #ifndef DEFAULT_PRINTING
50 #define DEFAULT_PRINTING PRINT_BSD
53 #define PRINTCAP_NAME "/etc/printcap"
57 /** Use gcc attribute to check printf fns. a1 is the 1-based index of
58 * the parameter containing the format, and a2 the index of the first
59 * argument. Note that some gcc 2.x versions don't handle this
61 #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
63 #define PRINTF_ATTRIBUTE(a1, a2)
67 /** gcc attribute used on function parameters so that it does not emit
68 * warnings about them being unused. **/
69 # define UNUSED(param) param __attribute__ ((unused))
71 # define UNUSED(param) param
72 /** Feel free to add definitions for other compilers here. */
79 #include <sys/types.h>
82 #ifdef HAVE_SYS_RESOURCE_H
83 #include <sys/resource.h>
91 #ifdef HAVE_SYS_PARAM_H
92 #include <sys/param.h>
103 #ifdef HAVE_STRINGS_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>
145 #ifdef HAVE_SYS_MODE_H
146 /* apparently AIX needs this for S_ISLNK */
148 #include <sys/mode.h>
158 #include <sys/file.h>
160 #ifdef HAVE_STROPTS_H
164 /* we support ADS if we want it and have krb5 and ldap libs */
165 #if defined(WITH_ADS) && defined(HAVE_KRB5) && defined(HAVE_LDAP)
170 * Define VOLATILE if needed.
173 #if defined(HAVE_VOLATILE)
174 #define VOLATILE volatile
180 * Define additional missing types
182 #ifndef HAVE_SIG_ATOMIC_T_TYPE
183 typedef int sig_atomic_t;
186 #ifndef HAVE_SOCKLEN_T_TYPE
187 typedef int socklen_t;
192 Samba needs type definitions for
193 int8_t, int16_t, int32_t, int64_t
194 uint8_t, uint16_t, uint32_t and uint64_t.
196 Normally these are signed and unsigned 8, 16, 32 and 64 bit integers, but
197 they actually only need to be at least 8, 16, 32 and 64 bits
198 respectively. Thus if your word size is 8 bytes just defining them
199 as signed and unsigned int will work.
207 #define uint8 uint8_t
211 #define int16 int16_t
215 #define uint16 uint16_t
219 #define int32 int32_t
223 #define uint32 uint32_t
227 #define int64 int64_t
231 #define uint64 uint64_t
235 we use struct ipv4_addr to avoid having to include all the
236 system networking headers everywhere
243 #define UINT8_MAX 255
247 #define UINT16_MAX 65535
251 * Type for stat structure.
255 #define MIN(a,b) ((a)<(b)?(a):(b))
259 #define MAX(a,b) ((a)>(b)?(a):(b))
262 #ifndef HAVE_STRERROR
263 extern char *sys_errlist[];
264 #define strerror(i) sys_errlist[i]
267 #ifndef HAVE_ERRNO_DECL
271 #ifdef HAVE_BROKEN_GETGROUPS
278 #define NGROUPS_MAX 32 /* Guess... */
281 /* Our own pstrings and fstrings */
284 /* Lists, trees, caching, database... */
286 #include "dlinklist.h"
287 #include "lib/ldb/include/ldb.h"
288 #include "lib/tdb/include/tdb.h"
289 #include "lib/tdb/include/spinlock.h"
290 #include "lib/tdb/include/tdbutil.h"
293 #include "nt_status.h"
297 #include "messages.h"
299 #include "dynconfig.h"
305 #include "lib/socket/socket.h"
306 #include "libcli/ldap/ldap.h"
307 #include "nameserv.h"
310 #include "byteorder.h"
323 #include "librpc/ndr/libndr.h"
324 #include "librpc/ndr/ndr_sec.h"
325 #include "librpc/gen_ndr/ndr_misc.h"
326 #include "librpc/gen_ndr/ndr_dcerpc.h"
327 #include "librpc/rpc/dcerpc.h"
328 #include "librpc/gen_ndr/tables.h"
330 #include "libcli/auth/ntlmssp.h"
331 #include "libcli/auth/credentials.h"
332 #include "libcli/auth/gensec.h"
333 #include "libcli/auth/spnego.h"
334 #include "auth/auth.h"
336 #include "smb_interfaces.h"
337 #include "smbd/server.h"
338 #include "smbd/service.h"
339 #include "rpc_server/dcerpc_server.h"
342 #include "smb_server/smb_server.h"
343 #include "ntvfs/ntvfs.h"
344 #include "cli_context.h"
345 #include "registry.h"
347 #include "ldap_server/ldap_server.h"
349 #include "libnet/libnet.h"
350 #include "utils/net/net.h"
352 #include "nsswitch/winbind_client.h"
354 /* hmm, this really is getting ugly isn't it .... we probably need to
355 have some way to have subsystem includes without including it
357 #include "ntvfs/posix/vfs_posix.h"
359 #define malloc_p(type) (type *)malloc(sizeof(type))
360 #define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count)
361 #define realloc_p(p, type, count) (type *)realloc_array(p, sizeof(type), count)
363 #ifndef HAVE_COMPARISON_FN_T
364 typedef int (*comparison_fn_t)(const void *, const void *);
367 /***** automatically generated prototypes *****/
368 #define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)
370 #undef _PRINTF_ATTRIBUTE
371 #define _PRINTF_ATTRIBUTE(a1, a2)
373 /* String routines */
375 #include "safe_string.h"
378 #define QSORT_CAST (__compar_fn_t)
382 #define QSORT_CAST (int (*)(const void *, const void *))
386 #define SIGCLD SIGCHLD
393 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
394 #define OSF1_ENH_SEC 1
397 #ifndef ALLOW_CHANGE_PASSWORD
398 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
399 #define ALLOW_CHANGE_PASSWORD 1
403 /* what is the longest significant password available on your system?
404 Knowing this speeds up password searches a lot */
405 #ifndef PASSWORD_LENGTH
406 #define PASSWORD_LENGTH 8
409 #ifdef REPLACE_INET_NTOA
410 #define inet_ntoa rep_inet_ntoa
418 #define MAXPATHLEN 256
425 #ifndef INADDR_LOOPBACK
426 #define INADDR_LOOPBACK 0x7f000001
430 #define INADDR_NONE 0xffffffff
434 #define crypt ufc_crypt
438 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
441 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
442 #define ULTRIX_AUTH 1
446 char *strdup(const char *s);
450 void *memmove(void *dest,const void *src,int size);
453 #ifndef HAVE_INITGROUPS
454 int initgroups(char *name,gid_t id);
458 int rename(const char *zfrom, const char *zto);
462 time_t mktime(struct tm *t);
466 size_t strlcpy(char *d, const char *s, size_t bufsize);
470 size_t strlcat(char *d, const char *s, size_t bufsize);
473 #ifndef HAVE_FTRUNCATE
474 int ftruncate(int f,long l);
478 char *strndup(const char *s, size_t n);
482 size_t strnlen(const char *s, size_t n);
486 unsigned long strtoul(const char *nptr, char **endptr, int base);
490 int setenv(const char *name, const char *value, int overwrite);
493 #ifndef HAVE_VASPRINTF_DECL
494 int vasprintf(char **ptr, const char *format, va_list ap);
497 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
498 #define bzero(a,b) memset((a),'\0',(b))
501 #ifdef REPLACE_GETPASS
502 #define getpass(prompt) getsmbpass((prompt))
506 * Some older systems seem not to have MAXHOSTNAMELEN
509 #ifndef MAXHOSTNAMELEN
510 #define MAXHOSTNAMELEN 254
513 /* yuck, I'd like a better way of doing this */
514 #define DIRP_SIZE (256 + 32)
517 * glibc on linux doesn't seem to have MSG_WAITALL
518 * defined. I think the kernel has it though..
522 #define MSG_WAITALL 0
525 /* default socket options. Dave Miller thinks we should default to TCP_NODELAY
526 given the socket IO pattern that Samba uses */
528 #define DEFAULT_SOCKET_OPTIONS "TCP_NODELAY"
530 #define DEFAULT_SOCKET_OPTIONS ""
533 /* Load header file for dynamic linking stuff */
539 /* dmalloc -- free heap debugger (dmalloc.org). This should be near
540 * the *bottom* of include files so as not to conflict. */
541 #ifdef ENABLE_DMALLOC
542 # include <dmalloc.h>
546 /* Some POSIX definitions for those without */
549 #define S_IFDIR 0x4000
552 #define S_ISDIR(mode) ((mode & 0xF000) == S_IFDIR)
555 #define S_IRWXU 00700 /* read, write, execute: owner */
558 #define S_IRUSR 00400 /* read permission: owner */
561 #define S_IWUSR 00200 /* write permission: owner */
564 #define S_IXUSR 00100 /* execute permission: owner */
567 #define S_IRWXG 00070 /* read, write, execute: group */
570 #define S_IRGRP 00040 /* read permission: group */
573 #define S_IWGRP 00020 /* write permission: group */
576 #define S_IXGRP 00010 /* execute permission: group */
579 #define S_IRWXO 00007 /* read, write, execute: other */
582 #define S_IROTH 00004 /* read permission: other */
585 #define S_IWOTH 00002 /* write permission: other */
588 #define S_IXOTH 00001 /* execute permission: other */
591 /* For sys_adminlog(). */
593 #define LOG_EMERG 0 /* system is unusable */
597 #define LOG_ALERT 1 /* action must be taken immediately */
601 #define LOG_CRIT 2 /* critical conditions */
605 #define LOG_ERR 3 /* error conditions */
609 #define LOG_WARNING 4 /* warning conditions */
613 #define LOG_NOTICE 5 /* normal but significant condition */
617 #define LOG_INFO 6 /* informational */
621 #define LOG_DEBUG 7 /* debug-level messages */
624 extern int DEBUGLEVEL;
630 /* needed for some systems without iconv. Doesn't really matter
631 what error code we use */
636 /* add varargs prototypes with printf checking */
637 #ifndef HAVE_SNPRINTF_DECL
638 int snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4);
640 #ifndef HAVE_ASPRINTF_DECL
641 int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3);
645 /* we used to use these fns, but now we have good replacements
646 for snprintf and vsnprintf */
647 #define slprintf snprintf
650 /* we need to use __va_copy() on some platforms */
652 #define VA_COPY(dest, src) __va_copy(dest, src)
654 #define VA_COPY(dest, src) (dest) = (src)
658 time_t timegm(struct tm *tm);
661 #if defined(VALGRIND)
662 #define strlen(x) valgrind_strlen(x)
666 * Veritas File System. Often in addition to native.
669 #if defined(HAVE_SYS_FS_VX_QUOTA_H)
673 #if HAVE_SYS_ATTRIBUTES_H
674 #include <sys/attributes.h>
677 /* mutually exclusive (SuSE 8.2) */
678 #if HAVE_ATTR_XATTR_H
679 #include <attr/xattr.h>
680 #elif HAVE_SYS_XATTR_H
681 #include <sys/xattr.h>
684 #define TALLOC_ABORT(reason) smb_panic(reason)
688 this is a warning hack. The idea is to use this everywhere that we
689 get the "discarding const" warning from gcc. That doesn't actually
690 fix the problem of course, but it means that when we do get to
691 cleaning them up we can do it by searching the code for
694 It also means that other error types aren't as swamped by the noise
695 of hundreds of const warnings, so we are more likely to notice when
698 Please only add more uses of this macro when you find it
699 _really_ hard to fix const warnings. Our aim is to eventually use
700 this function in only a very few places.
702 Also, please call this via the discard_const_p() macro interface, as that
703 makes the return type safe.
706 #define discard_const(ptr) ((void *)((intptr_t)(ptr)))
708 #define discard_const(ptr) ((void *)(ptr))
710 #define discard_const_p(type, ptr) ((type *)discard_const(ptr))
712 #endif /* _INCLUDES_H */