s3:smbd: support xconn=NULL in init_smb_request()
[Samba.git] / source3 / wscript
blobb285c5f38c45e56b7376832cc9d42deeb4acf8f3
1 #!/usr/bin/env python
3 srcdir=".."
5 import sys, os
6 from optparse import SUPPRESS_HELP
7 sys.path.insert(0, srcdir+"/buildtools/wafsamba")
8 sys.path.insert(0, "source3")
9 import wafsamba, Options, Logs, Utils, Scripting
10 import build.charset
11 import samba_utils, samba_version
12 import samba3
14 Options.default_prefix = '/usr/local/samba'
16 def set_options(opt):
18 opt.add_option('--with-static-modules',
19 help=("Comma-separated list of names of modules to statically link in"),
20 action="store", dest='static_modules', default=None)
21 opt.add_option('--with-shared-modules',
22 help=("Comma-separated list of names of modules to build shared"),
23 action="store", dest='shared_modules', default=None)
25 opt.SAMBA3_ADD_OPTION('winbind')
26 opt.SAMBA3_ADD_OPTION('ads')
27 opt.SAMBA3_ADD_OPTION('ldap')
28 opt.SAMBA3_ADD_OPTION('cups', with_name="enable", without_name="disable")
29 opt.SAMBA3_ADD_OPTION('iprint', with_name="enable", without_name="disable")
30 opt.SAMBA3_ADD_OPTION('pam')
31 opt.SAMBA3_ADD_OPTION('pam_smbpass')
32 opt.SAMBA3_ADD_OPTION('quotas')
33 opt.SAMBA3_ADD_OPTION('sendfile-support')
34 opt.SAMBA3_ADD_OPTION('utmp')
35 opt.SAMBA3_ADD_OPTION('pthreadpool', with_name="enable", without_name="disable", default=True)
36 opt.SAMBA3_ADD_OPTION('avahi', with_name="enable", without_name="disable")
37 opt.SAMBA3_ADD_OPTION('iconv')
38 opt.SAMBA3_ADD_OPTION('acl-support')
39 opt.SAMBA3_ADD_OPTION('dnsupdate')
40 opt.SAMBA3_ADD_OPTION('syslog')
41 opt.SAMBA3_ADD_OPTION('automount')
42 opt.SAMBA3_ADD_OPTION('aio-support')
43 opt.SAMBA3_ADD_OPTION('dmapi', default=None) # None means autodetection
44 opt.SAMBA3_ADD_OPTION('fam', default=None) # None means autodetection
45 opt.SAMBA3_ADD_OPTION('profiling-data', default=False)
46 opt.SAMBA3_ADD_OPTION('libarchive', default=None)
48 opt.SAMBA3_ADD_OPTION('cluster-support', default=None)
50 opt.SAMBA3_ADD_OPTION('regedit', default=None)
52 opt.SAMBA3_ADD_OPTION('fake-kaserver',
53 help=("Include AFS fake-kaserver support"), default=False)
55 opt.add_option('--with-ctdb-dir',
56 help=("Directory under which ctdb is installed"),
57 action="store", dest='ctdb_dir', default=None)
58 opt.add_option('--enable-old-ctdb',
59 help=("enable building against (too) old version of ctdb (default=false)"),
60 action="store_true", dest='enable_old_ctdb', default=False)
62 opt.add_option('--with-libcephfs',
63 help=("Directory under which libcephfs is installed"),
64 action="store", dest='libcephfs_dir', default=None)
66 opt.SAMBA3_ADD_OPTION('glusterfs', with_name="enable", without_name="disable", default=True)
68 opt.add_option('--enable-vxfs',
69 help=("enable support for VxFS (default=no)"),
70 action="store_true", dest='enable_vxfs', default=False)
73 def configure(conf):
74 from samba_utils import TO_LIST
76 default_static_modules = []
77 default_shared_modules = []
79 if Options.options.developer:
80 conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
81 conf.env.developer = True
83 if sys.platform != 'openbsd5':
84 conf.ADD_LDFLAGS("-Wl,--export-dynamic", testflags=True)
86 conf.CHECK_HEADERS('execinfo.h libexc.h libunwind.h netdb.h')
87 conf.CHECK_HEADERS('linux/falloc.h')
89 conf.CHECK_FUNCS('getcwd fchown chmod fchmod mknod')
90 conf.CHECK_FUNCS('strtol strchr strupr chflags')
91 conf.CHECK_FUNCS('getrlimit fsync fdatasync setpgid')
92 conf.CHECK_FUNCS('setsid glob strpbrk crypt16 getauthuid')
93 conf.CHECK_FUNCS('sigprocmask sigblock sigaction sigset innetgr')
94 conf.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
95 conf.CHECK_FUNCS('setpriv setgidx setuidx setgroups syscall sysconf')
96 conf.CHECK_FUNCS('atexit grantpt posix_openpt fallocate posix_fallocate')
97 conf.CHECK_FUNCS('fseeko setluid')
98 conf.CHECK_FUNCS('getpwnam', headers='sys/types.h pwd.h')
99 conf.CHECK_FUNCS('fdopendir')
100 conf.CHECK_FUNCS('fstatat')
101 conf.CHECK_FUNCS('getpwent_r setenv strcasecmp fcvt fcvtl')
102 conf.CHECK_FUNCS('syslog vsyslog timegm setlocale')
103 conf.CHECK_FUNCS_IN('nanosleep', 'rt')
104 conf.CHECK_FUNCS('lutimes futimes utimensat futimens')
105 conf.CHECK_FUNCS('mlock munlock mlockall munlockall')
106 conf.CHECK_FUNCS('memalign posix_memalign hstrerror')
107 conf.CHECK_FUNCS('shmget')
108 conf.CHECK_FUNCS_IN('shm_open', 'rt', checklibc=True)
109 #FIXME: for some reason this one still fails
110 conf.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
111 conf.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
112 conf.CHECK_FUNCS_IN('dn_expand', 'inet')
113 conf.CHECK_DECLS('fdatasync', reverse=True)
114 conf.CHECK_DECLS('readahead', reverse=True, headers='fcntl.h')
116 if conf.CHECK_CODE('''
117 #if defined(HAVE_UNISTD_H)
118 #include <unistd.h>
119 #endif
120 long ret = splice(0,0,1,0,400,SPLICE_F_MOVE);
121 ''',
122 'HAVE_LINUX_SPLICE',
123 headers='fcntl.h'):
124 conf.CHECK_DECLS('splice', reverse=True, headers='fcntl.h')
126 # Check for inotify support
127 conf.CHECK_HEADERS('sys/inotify.h')
128 if "HAVE_SYS_INOTIFY_H" in conf.env:
129 conf.DEFINE('HAVE_INOTIFY', 1)
131 # Check for kernel change notify support
132 conf.CHECK_CODE('''
133 #ifndef F_NOTIFY
134 #define F_NOTIFY 1026
135 #endif
136 main() {
137 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
138 }''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain=False, execute=True,
139 headers='fcntl.h signal.h',
140 msg="Checking for kernel change notify support")
142 # Check for Linux kernel oplocks
143 conf.CHECK_CODE('''
144 #include <sys/types.h>
145 #include <fcntl.h>
146 #include <signal.h>
147 #ifndef F_NOTIFY
148 #define F_NOTIFY 1026
149 #endif
150 main() {
151 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
152 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain=False, execute=True,
153 msg="Checking for Linux kernel oplocks")
155 # Check for IRIX kernel oplock types
156 conf.CHECK_CODE('oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;',
157 'HAVE_KERNEL_OPLOCKS_IRIX', headers='fcntl.h',
158 msg="Checking for IRIX kernel oplock types")
160 # Check for kernel share modes
161 conf.CHECK_CODE('''
162 #include <sys/types.h>
163 #include <fcntl.h>
164 #include <signal.h>
165 #include <sys/file.h>
166 #ifndef LOCK_MAND
167 #define LOCK_MAND 32
168 #define LOCK_READ 64
169 #endif
170 main() {
171 exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
172 }''', 'HAVE_KERNEL_SHARE_MODES', addmain=False, execute=True,
173 msg="Checking for kernel share modes")
175 # check for fam libs
176 samba_fam_libs=None
177 check_for_fam=False
178 if Options.options.with_fam is None:
179 check_for_fam=True
180 elif Options.options.with_fam == True:
181 check_for_fam=True
183 if check_for_fam and conf.CHECK_HEADERS('fam.h'):
184 if conf.CHECK_FUNCS_IN('FAMOpen2', 'fam'):
185 samba_fam_libs='fam'
186 elif conf.CHECK_FUNCS_IN('FAMOpen2', 'fam C'):
187 samba_fam_libs='fam C'
188 conf.CHECK_TYPE('enum FAMCodes', headers='fam.h',
189 define='HAVE_FAM_H_FAMCODES_TYPEDEF',
190 msg='Checking whether enum FAMCodes is available')
191 conf.CHECK_FUNCS_IN('FAMNoExists', 'fam')
193 if samba_fam_libs is not None:
194 conf.DEFINE('SAMBA_FAM_LIBS', samba_fam_libs)
195 else:
196 if Options.options.with_fam == True:
197 conf.fatal('FAM support requested, but no suitable FAM library found')
198 elif check_for_fam:
199 Logs.warn('no suitable FAM library found')
201 # check for libarchive (tar command in smbclient)
202 # None means autodetect, True/False means enable/disable
203 conf.env['archive_lib'] = ''
204 if Options.options.with_libarchive is not False:
205 libarchive_mandatory = Options.options.with_libarchive == True
206 Logs.info("Checking for libarchive existence")
207 if conf.CHECK_BUNDLED_SYSTEM('libarchive', minversion='3.1.2'):
208 conf.env['archive_lib'] = 'libarchive'
209 elif libarchive_mandatory:
210 conf.fatal('libarchive support requested, but no suitable pkgconfig found')
212 # check for DMAPI libs
213 if Options.options.with_dmapi == False:
214 have_dmapi = False
215 else:
216 have_dmapi = True
217 Logs.info("Checking for DMAPI library existence")
218 samba_dmapi_lib = ''
219 if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'dm'):
220 samba_dmapi_lib = 'dm'
221 else:
222 if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'jfsdm'):
223 samba_dmapi_lib = 'jfsdm'
224 else:
225 if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'dmapi'):
226 samba_dmapi_lib = 'dmapi'
227 else:
228 if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'xdsm'):
229 samba_dmapi_lib = 'xdsm'
230 # only bother to test headers and compilation when a candidate
231 # library has been found
232 if samba_dmapi_lib == '':
233 have_dmapi = False
234 broken_dmapi = "no suitable DMAPI library found"
236 if have_dmapi:
237 conf.CHECK_HEADERS('sys/dmi.h xfs/dmapi.h sys/jfsdmapi.h sys/dmapi.h dmapi.h')
238 conf.CHECK_CODE('''
239 #include <time.h> /* needed by Tru64 */
240 #include <sys/types.h> /* needed by AIX */
241 #ifdef HAVE_XFS_DMAPI_H
242 #include <xfs/dmapi.h>
243 #elif defined(HAVE_SYS_DMI_H)
244 #include <sys/dmi.h>
245 #elif defined(HAVE_SYS_JFSDMAPI_H)
246 #include <sys/jfsdmapi.h>
247 #elif defined(HAVE_SYS_DMAPI_H)
248 #include <sys/dmapi.h>
249 #elif defined(HAVE_DMAPI_H)
250 #include <dmapi.h>
251 #endif
253 /* This link test is designed to fail on IRI 6.4, but should
254 * succeed on Linux, IRIX 6.5 and AIX.
256 int main(int argc, char **argv)
258 char * version;
259 dm_eventset_t events;
260 /* This doesn't take an argument on IRIX 6.4. */
261 dm_init_service(&version);
262 /* IRIX 6.4 expects events to be a pointer. */
263 DMEV_ISSET(DM_EVENT_READ, events);
265 return 0;
267 ''',
268 'USEABLE_DMAPI_LIBRARY',
269 addmain=False,
270 execute=False,
271 lib=samba_dmapi_lib,
272 msg='Checking whether DMAPI lib '+samba_dmapi_lib+' can be used')
273 if not conf.CONFIG_SET('USEABLE_DMAPI_LIBRARY'):
274 have_dmapi = False
275 broken_dmapi = "no usable DMAPI library found"
277 if have_dmapi:
278 Logs.info("Building with DMAPI support.")
279 conf.env['dmapi_lib'] = samba_dmapi_lib
280 conf.DEFINE('USE_DMAPI', 1)
281 else:
282 if Options.options.with_dmapi == False:
283 Logs.info("Building without DMAPI support (--without-dmapi).")
284 elif Options.options.with_dmapi == True:
285 Logs.error("DMAPI support not available: " + broken_dmapi)
286 conf.fatal('DMAPI support requested but not found.');
287 else:
288 Logs.warn("Building without DMAPI support: " + broken_dmapi)
289 conf.env['dmapi_lib'] = ''
291 # Check for various members of the stat structure
292 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define='HAVE_STAT_ST_BLOCKS',
293 headers='sys/stat.h')
294 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blksize', define='HAVE_STAT_ST_BLKSIZE',
295 headers='sys/stat.h')
296 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_flags', define='HAVE_STAT_ST_FLAGS',
297 headers='sys/types.h sys/stat.h unistd.h')
299 if "HAVE_BLKCNT_T" in conf.env:
300 conf.CHECK_CODE('''
301 static int test_array[1 - 2 * !(((long int)(sizeof(blkcnt_t))) <= 4)];''',
302 'SIZEOF_BLKCNT_T_4',
303 headers='replace.h sys/types.h sys/stat.h unistd.h',
304 msg="Checking whether blkcnt_t is 32 bit")
306 # If sizeof is 4 it can't be 8
307 if "HAVE_BLKCNT_T" in conf.env:
308 if not conf.CONFIG_SET('SIZEOF_BLKCNT_T_4'):
309 conf.CHECK_CODE('''
310 static int test_array[1 - 2 * !(((long int)(sizeof(blkcnt_t))) <= 8)];''',
311 'SIZEOF_BLKCNT_T_8',
312 headers='replace.h sys/types.h sys/stat.h unistd.h',
313 msg="Checking whether blkcnt_t is 64 bit")
315 # Check for POSIX capability support
316 conf.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers='sys/capability.h')
318 if "HAVE_SYS_CAPABILITY_H" in conf.env:
319 conf.CHECK_CODE('''
320 cap_t cap;
321 cap_value_t vals[1];
322 if (!(cap = cap_get_proc())) exit(1);
323 vals[0] = CAP_CHOWN;
324 cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
325 cap_set_proc(cap);''',
326 'HAVE_POSIX_CAPABILITIES', execute=True, lib="cap",
327 headers='sys/capability.h',
328 msg="Checking whether POSIX capabilities are available")
330 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from
331 # rpc/rpc.h. This is *really* broken but some systems (DEC OSF1) do this.
332 # -- JRA.
333 if conf.CONFIG_SET("HAVE_RPC_RPC_H"):
334 conf.CHECK_TYPE('int16', headers='rpc/rpc.h',
335 define='HAVE_INT16_FROM_RPC_RPC_H',
336 msg="Checking for int16 typedef included by rpc/rpc.h")
337 conf.CHECK_CODE('uint16 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
338 headers='sys/types.h rpc/rpc.h',
339 msg="Checking for uint16 typedef included by rpc/rpc.h")
340 conf.CHECK_CODE('int32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
341 headers='sys/types.h rpc/rpc.h',
342 msg="Checking for int32 typedef included by rpc/rpc.h")
343 conf.CHECK_CODE('uint32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
344 headers='sys/types.h rpc/rpc.h',
345 msg="Checking for uint32 typedef included by rpc/rpc.h")
346 conf.CHECK_CODE('int i;', 'BROKEN_NISPLUS_INCLUDE_FILES',
347 headers='sys/types.h sys/acl.h rpcsvc/nis.h',
348 msg="Checking for broken nisplus include files")
350 # Check if the compiler will optimize out functions
351 conf.CHECK_CODE('''
352 if (0) {
353 this_function_does_not_exist();
354 } else {
355 return 1;
356 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
357 msg="Checking if the compiler will optimize out functions")
359 # Check if the compiler supports the LL suffix on long long integers
360 # AIX needs this
361 conf.CHECK_CODE('long long i = 0x8000000000LL', 'COMPILER_SUPPORTS_LL',
362 headers='stdio.h',
363 msg="Checking for LL suffix on long long integers")
365 conf.CHECK_FUNCS('''
366 _acl __acl atexit
367 _chdir __chdir chflags chmod _close __close _closedir
368 __closedir crypt16 devnm dirfd
369 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent execl
370 _facl __facl _fchdir
371 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
372 _fork __fork fseeko
373 fsetxattr _fstat __fstat fsync
374 futimens futimes __fxstat getauthuid
375 getcwd _getcwd __getcwd getdents __getdents getdirentries
376 getgrent getgrnam getgrouplist getgrset getmntent getpagesize
377 getpwanam getpwent_r getrlimit
378 glob grantpt hstrerror initgroups innetgr
379 llseek _llseek __llseek _lseek __lseek
380 _lstat __lstat lutimes
381 __lxstat memalign mknod mlock mlockall munlock munlockall
382 _open __open _opendir __opendir
383 pathconf poll posix_fallocate
384 posix_memalign pread _pread __pread
385 pwrite _pwrite __pwrite
386 rdchk _read __read _readdir __readdir
387 _seekdir __seekdir
388 select setenv setgidx setgroups setlocale setluid
389 setmntent setpgid setpriv setsid setuidx
390 shmget shm_open sigaction sigblock sigprocmask sigset
391 _stat __stat statvfs
392 strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctl sysctlbyname
393 __sys_llseek syslog _telldir __telldir timegm
394 utimensat vsyslog _write __write __xstat
395 ''')
397 conf.CHECK_SAMBA3_CHARSET() # see build/charset.py
399 # FIXME: these should be tests for features, but the old build system just
400 # checks for OSes.
401 host_os = sys.platform
402 Logs.info("building on %s" % host_os)
404 # Python doesn't have case switches... :/
405 # FIXME: original was *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
406 # the search for .rfind('gnu') covers gnu* and *-gnu is that too broad?
408 conf.SET_TARGET_TYPE('sunacl', 'EMPTY')
409 if (host_os.rfind('linux') > -1) or (host_os.rfind('gnu') > -1) or (host_os.rfind('qnx') > -1):
410 if host_os.rfind('linux') > -1:
411 conf.DEFINE('LINUX', '1')
412 elif host_os.rfind('qnx') > -1:
413 conf.DEFINE('QNX', '1')
414 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
415 elif (host_os.rfind('darwin') > -1):
416 conf.DEFINE('DARWINOS', 1)
417 conf.ADD_CFLAGS('-fno-common')
418 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
419 elif (host_os.rfind('freebsd') > -1):
420 conf.DEFINE('FREEBSD', 1)
421 if conf.CHECK_HEADERS('sunacl.h'):
422 conf.DEFINE('HAVE_FREEBSD_SUNACL_H', '1')
423 conf.CHECK_FUNCS_IN(['acl'], 'sunacl')
424 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
425 elif (host_os.rfind('irix') > -1):
426 conf.DEFINE('IRIX', 1)
427 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
428 elif (host_os.rfind('aix') > -1):
429 conf.DEFINE('AIX', 1)
430 conf.DEFINE('STAT_ST_BLOCKSIZE', 'DEV_BSIZE')
431 elif (host_os.rfind('hpux') > -1):
432 conf.DEFINE('HPUX', 1)
433 conf.DEFINE('STAT_ST_BLOCKSIZE', '8192')
434 elif (host_os.rfind('osf') > -1):
435 conf.DEFINE('OSF1', 1)
436 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
438 # FIXME: Add more checks here.
439 else:
440 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
442 if Options.options.with_acl_support:
443 if (host_os.rfind('hpux') > -1):
444 Logs.info('Using HPUX ACLs')
445 conf.DEFINE('HAVE_HPUX_ACLS',1)
446 conf.DEFINE('POSIX_ACL_NEEDS_MASK',1)
447 default_static_modules.extend(TO_LIST('vfs_hpuxacl'))
448 elif (host_os.rfind('aix') > -1):
449 Logs.info('Using AIX ACLs')
450 conf.DEFINE('HAVE_AIX_ACLS',1)
451 default_static_modules.extend(TO_LIST('vfs_aixacl vfs_aixacl2'))
452 elif (host_os.rfind('darwin') > -1):
453 Logs.warn('ACLs on Darwin currently not supported')
454 conf.fatal("ACL support not available on Darwin/MacOS. "
455 "Use --without-acl-support for building without "
456 "ACL support. "
457 "ACL support is required to change permissions "
458 "from Windows clients.")
459 else:
460 conf.CHECK_FUNCS_IN(['acl_get_file'], 'acl')
461 if conf.CHECK_CODE('''
462 acl_t acl;
463 int entry_id;
464 acl_entry_t *entry_p;
465 return acl_get_entry(acl, entry_id, entry_p);
466 ''',
467 'HAVE_POSIX_ACLS',
468 headers='sys/types.h sys/acl.h', link=False,
469 msg="Checking for POSIX ACL support") :
470 conf.CHECK_CODE('''
471 acl_permset_t permset_d;
472 acl_perm_t perm;
473 return acl_get_perm_np(permset_d, perm);
474 ''',
475 'HAVE_ACL_GET_PERM_NP',
476 headers='sys/types.h sys/acl.h', link=True,
477 msg="Checking whether acl_get_perm_np() is available")
478 default_static_modules.extend(TO_LIST('vfs_posixacl'))
479 elif conf.CHECK_FUNCS_IN(['facl'], 'sec'):
480 Logs.info('Using solaris or UnixWare ACLs')
481 conf.DEFINE('HAVE_SOLARIS_UNIXWARE_ACLS',1)
482 default_static_modules.extend(TO_LIST('vfs_solarisacl'))
483 elif conf.CHECK_FUNCS_IN(['acl_get_fd'], 'pacl'):
484 Logs.info('Using Tru64 ACLs')
485 conf.DEFINE('HAVE_TRU64_ACLS',1)
486 default_static_modules.extend(TO_LIST('vfs_tru64acl'))
487 else:
488 conf.fatal("ACL support not found. Try installing libacl1-dev "
489 "or libacl-devel. "
490 "Otherwise, use --without-acl-support to build "
491 "without ACL support. "
492 "ACL support is required to change permissions from "
493 "Windows clients.")
495 if conf.CHECK_FUNCS('dirfd'):
496 conf.DEFINE('HAVE_DIRFD_DECL', 1)
498 conf.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);',
499 'HAVE_STATFS_F_FSID',
500 msg="vfs_fileid checking for statfs() and struct statfs.f_fsid",
501 headers='sys/types.h sys/statfs.h',
502 execute=True)
504 if conf.CONFIG_SET('HAVE_FALLOCATE'):
505 conf.CHECK_CODE('''
506 int ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
507 'HAVE_LINUX_FALLOCATE',
508 msg="Checking whether the Linux 'fallocate' function is available",
509 headers='unistd.h sys/types.h fcntl.h linux/falloc.h')
510 conf.CHECK_CODE('''
511 ssize_t err = readahead(0,0,0x80000);''',
512 'HAVE_LINUX_READAHEAD',
513 msg="Checking whether Linux readahead is available",
514 headers='unistd.h fcntl.h')
515 conf.CHECK_DECLS('readahead', headers='fcntl.h', always=True)
517 conf.CHECK_CODE('int fd = openat(AT_FDCWD, ".", O_RDONLY);',
518 'HAVE_OPENAT',
519 msg='Checking for openat',
520 headers='fcntl.h')
522 if Options.options.with_aio_support:
523 conf.CHECK_FUNCS_IN('aio_read', 'aio')
524 conf.CHECK_FUNCS_IN('aio_read', 'rt')
525 conf.CHECK_CODE('struct aiocb a; return aio_read(&a);',
526 'HAVE_AIO',
527 msg='Checking for asynchronous io support',
528 headers='sys/types.h aio.h',
529 lib='aio rt')
530 if conf.CONFIG_SET('HAVE_AIO'):
531 conf.CHECK_CODE('struct aiocb a; return aio_read(&a);', 'HAVE_AIO_READ', msg='Checking for aio_read', headers='aio.h', lib='aio rt')
532 conf.CHECK_CODE('struct aiocb a; return aio_write(&a);', 'HAVE_AIO_WRITE', msg='Checking for aio_write', headers='aio.h', lib='aio rt')
533 conf.CHECK_CODE('struct aiocb a; return aio_fsync(1, &a);', 'HAVE_AIO_FSYNC', msg='Checking for aio_fsync', headers='aio.h', lib='aio rt')
534 conf.CHECK_CODE('struct aiocb a; return aio_return(&a);', 'HAVE_AIO_RETURN', msg='Checking for aio_return', headers='aio.h', lib='aio rt')
535 conf.CHECK_CODE('struct aiocb a; return aio_error(&a);', 'HAVE_AIO_ERROR', msg='Checking for aio_error', headers='aio.h', lib='aio rt')
536 conf.CHECK_CODE('struct aiocb a; return aio_cancel(1, &a);', 'HAVE_AIO_CANCEL', msg='Checking for aio_cancel', headers='aio.h', lib='aio rt')
537 conf.CHECK_CODE('const struct aiocb * const a[1]; struct timespec t; return aio_suspend(&a, 1, &t);', 'HAVE_AIO_SUSPEND', msg='Checking for aio_suspend', headers='aio.h', lib='aio rt')
538 if not conf.CONFIG_SET('HAVE_AIO'):
539 conf.DEFINE('HAVE_NO_AIO', '1')
540 else:
541 conf.DEFINE('HAVE_NO_AIO', '1')
543 if host_os.rfind('linux') > -1:
544 conf.CHECK_FUNCS_IN('io_submit', 'aio')
545 conf.CHECK_CODE('''
546 struct io_event ioev;
547 struct iocb *ioc;
548 io_context_t ctx;
549 struct timespec ts;
550 int fd;
551 char *buf;
552 fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
553 io_queue_init(128,&ctx);
554 io_prep_pwrite(ioc, 1, buf, 1, 0);
555 io_prep_pread(ioc, 1, buf, 1, 0);
556 io_set_eventfd(ioc, fd);
557 io_set_callback(ioc, (io_callback_t)(0));
558 io_submit(ctx, 1, &ioc);
559 io_getevents(ctx, 1, 1, &ioev, &ts);
560 ''',
561 'HAVE_LINUX_KERNEL_AIO',
562 msg='Checking for linux kernel asynchronous io support',
563 headers='unistd.h stdlib.h sys/types.h fcntl.h sys/eventfd.h libaio.h',
564 lib='aio')
566 conf.CHECK_CODE('''
567 struct msghdr msg;
568 union {
569 struct cmsghdr cm;
570 char control[CMSG_SPACE(sizeof(int))];
571 } control_un;
572 msg.msg_control = control_un.control;
573 msg.msg_controllen = sizeof(control_un.control);
574 ''',
575 'HAVE_STRUCT_MSGHDR_MSG_CONTROL',
576 msg='Checking if we can use msg_control for passing file descriptors',
577 headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
578 conf.CHECK_CODE('''
579 struct msghdr msg;
580 int fd;
581 msg.msg_accrights = (caddr_t) &fd;
582 msg.msg_accrightslen = sizeof(fd);
583 ''',
584 'HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS',
585 msg='Checking if we can use msg_accrights for passing file descriptors',
586 headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
588 if Options.options.with_winbind:
589 conf.env.build_winbind = True
590 conf.DEFINE('WITH_WINBIND', '1')
592 conf.find_program('awk', var='AWK')
594 conf.CHECK_HEADERS('asm/types.h')
596 conf.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
597 headers='unistd.h sys/types.h',
598 msg="Checking for major macro")
600 conf.CHECK_CODE('dev_t dev; int i = minor(dev); return 0', "HAVE_DEVICE_MINOR_FN",
601 headers='unistd.h sys/types.h',
602 msg="Checking for minor macro")
604 conf.CHECK_STRUCTURE_MEMBER('struct dirent', 'd_off',
605 headers='unistd.h sys/types.h dirent.h',
606 define='HAVE_DIRENT_D_OFF')
608 conf.CHECK_FUNCS('setnetgrent getnetgrent endnetgrent')
609 if conf.CHECK_CFLAGS('-Werror-implicit-function-declaration'):
610 netgrent_cflags = '-Werror-implicit-function-declaration'
611 else:
612 netgrent_cflags = ''
613 conf.CHECK_CODE('setnetgrent("foo")', 'HAVE_SETNETGRENT_PROTOTYPE',
614 msg="Checking for setnetgrent prototype",
615 headers='netdb.h netgroup.h',
616 cflags=netgrent_cflags)
617 conf.CHECK_CODE('getnetgrent', 'HAVE_GETNETGRENT_PROTOTYPE',
618 msg="Checking for getnetgrent prototype",
619 headers='netdb.h netgroup.h',
620 cflags=netgrent_cflags)
621 conf.CHECK_CODE('endnetgrent', 'HAVE_ENDNETGRENT_PROTOTYPE',
622 msg="Checking for endnetgrent prototype",
623 headers='netdb.h netgroup.h',
624 cflags=netgrent_cflags)
627 # Look for CUPS
628 if Options.options.with_cups:
629 conf.find_program('cups-config', var='CUPS_CONFIG')
630 if conf.env.CUPS_CONFIG:
631 # we would normally use --libs here, but cups-config incorrectly adds
632 # gssapi_krb5 and other libraries to its --libs output. That breaks the use
633 # of an in-tree heimdal kerberos
634 conf.check_cfg(path=conf.env.CUPS_CONFIG, args="--cflags --ldflags",
635 package="", uselib_store="CUPS")
636 conf.CHECK_HEADERS('cups/cups.h cups/language.h', lib='cups')
637 conf.CHECK_FUNCS_IN('httpConnect httpConnectEncrypt', 'cups')
638 if conf.CONFIG_SET('HAVE_CUPS_CUPS_H') and conf.CONFIG_SET('HAVE_CUPS_LANGUAGE_H'):
639 conf.DEFINE('HAVE_CUPS', '1')
640 else:
641 conf.undefine('HAVE_CUPS')
642 conf.SET_TARGET_TYPE('cups', 'EMPTY')
643 else:
644 # define an empty subsystem for cups, to allow it to be used as an empty dependency
645 conf.SET_TARGET_TYPE('cups', 'EMPTY')
647 if Options.options.with_iprint:
648 if conf.CONFIG_SET('HAVE_CUPS'):
649 conf.DEFINE('HAVE_IPRINT', '1')
650 else:
651 Logs.warn("--enable-iprint=yes but cups support not sufficient")
652 if Options.options.with_syslog:
653 conf.DEFINE('WITH_SYSLOG', '1')
654 if Options.options.with_automount:
655 conf.DEFINE('WITH_AUTOMOUNT', '1')
657 # Check for LDAP
658 if Options.options.with_ldap:
659 conf.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h')
660 conf.CHECK_TYPE('ber_tag_t', 'unsigned int', headers='ldap.h lber.h')
661 conf.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
662 conf.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers='ldap.h')
664 # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
665 # for the samba logs
666 conf.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
667 define='HAVE_LBER_LOG_PRINT_FN', headers='lber.h')
669 conf.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap')
670 conf.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
672 # Check if ldap_set_rebind_proc() takes three arguments
673 if conf.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
674 'LDAP_SET_REBIND_PROC_ARGS',
675 msg="Checking whether ldap_set_rebind_proc takes 3 arguments",
676 headers='ldap.h lber.h', link=False):
677 conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
678 else:
679 conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
681 # last but not least, if ldap_init() exists, we want to use ldap
682 if conf.CONFIG_SET('HAVE_LDAP_INIT') and conf.CONFIG_SET('HAVE_LDAP_H'):
683 conf.DEFINE('HAVE_LDAP', '1')
684 conf.DEFINE('LDAP_DEPRECATED', '1')
685 conf.env['HAVE_LDAP'] = '1'
686 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
687 # SASL wrapping hooks
688 if conf.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
689 conf.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
690 conf.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
691 else:
692 conf.fatal("LDAP support not found. "
693 "Try installing libldap2-dev or openldap-devel. "
694 "Otherwise, use --without-ldap to build without "
695 "LDAP support. "
696 "LDAP support is required for the LDAP passdb backend, "
697 "LDAP idmap backends and ADS. "
698 "ADS support improves communication with "
699 "Active Directory domain controllers.")
700 else:
701 conf.SET_TARGET_TYPE('ldap', 'EMPTY')
702 conf.SET_TARGET_TYPE('lber', 'EMPTY')
704 if Options.options.with_ads == False:
705 use_ads = False
706 use_ads_krb5 = False
707 use_ads_ldap = False
708 else:
709 use_ads = True
710 use_ads_krb5 = True
711 use_ads_ldap = True
712 if not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and \
713 not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC'):
714 Logs.warn("arcfour-hmac-md5 encryption type not found in -lkrb5")
715 use_ads_krb5 = False
716 if not conf.CONFIG_SET('HAVE_KRB5_MK_REQ_EXTENDED'):
717 Logs.warn("krb5_mk_req_extended not found in -lkrb5")
718 use_ads_krb5 = False
719 if not conf.CONFIG_SET('HAVE_KRB5_GET_HOST_REALM'):
720 Logs.warn("krb5_get_host_realm not found in -lkrb5")
721 use_ads_krb5 = False
722 if not conf.CONFIG_SET('HAVE_KRB5_FREE_HOST_REALM'):
723 Logs.warn("krb5_free_host_realm not found in -lkrb5")
724 use_ads_krb5 = False
725 if not conf.CONFIG_SET('HAVE_KRB5_FWD_TGT_CREDS'):
726 Logs.warn("krb5_fwd_tgt_creds found in -lkrb5")
727 use_ads_krb5 = False
728 if not conf.CONFIG_SET('HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC'):
729 Logs.warn("krb5_get_init_creds_opt_alloc not found in -lkrb5")
730 use_ads_krb5 = False
731 if not conf.CONFIG_SET('KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT'):
732 Logs.warn("krb5_get_init_creds_opt_free was not found or was too old in -lkrb5")
733 use_ads_krb5 = False
734 if not conf.CONFIG_SET('HAVE_KRB5_GET_RENEWED_CREDS'):
735 Logs.warn("krb5_get_renewed_creds not found in -lkrb5")
736 use_ads_krb5 = False
737 if not conf.CONFIG_SET('HAVE_KRB5_PRINCIPAL_COMPARE_ANY_REALM'):
738 Logs.warn("krb5_principal_compare_any_realm not found in -lkrb5")
739 use_ads_krb5 = False
740 if not conf.CONFIG_SET('HAVE_KRB5_C_STRING_TO_KEY') and \
741 not conf.CONFIG_SET('HAVE_KRB5_STRING_TO_KEY_SALT'):
742 Logs.warn("krb5_c_string_to_key not found in -lkrb5")
743 use_ads_krb5 = False
744 if not conf.CONFIG_SET('HAVE_KRB5_PRINCIPAL2SALT') and \
745 not conf.CONFIG_SET('HAVE_KRB5_GET_PW_SALT'):
746 Logs.warn("no CREATE_KEY_FUNCTIONS detected")
747 use_ads_krb5 = False
748 if not conf.CONFIG_SET('HAVE_KRB5_GET_PERMITTED_ENCTYPES') and \
749 not conf.CONFIG_SET('HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES'):
750 Logs.warn("no GET_ENCTYPES_FUNCTIONS detected")
751 use_ads_krb5 = False
752 if not conf.CONFIG_SET('HAVE_KRB5_KT_FREE_ENTRY') and \
753 not conf.CONFIG_SET('HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS'):
754 Logs.warn("no KT_FREE_FUNCTION detected")
755 use_ads_krb5 = False
756 if not conf.CONFIG_SET('HAVE_KRB5_C_VERIFY_CHECKSUM'):
757 Logs.warn("krb5_c_verify_checksum_compare not found in -lkrb5")
758 use_ads_krb5 = False
760 # We don't actually use
761 # gsskrb5_extract_authz_data_from_sec_context, but it is a
762 # clue that this Heimdal, which does the PAC processing we
763 # need on the standard gss_inquire_sec_context_by_oid
764 if not conf.CONFIG_SET('HAVE_GSS_GET_NAME_ATTRIBUTE') and \
765 not (conf.CONFIG_SET('HAVE_GSSKRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT') and \
766 conf.CONFIG_SET('HAVE_GSS_INQUIRE_SEC_CONTEXT_BY_OID')):
767 Logs.warn("need either gss_get_name_attribute or gsskrb5_extract_authz_data_from_sec_context and gss_inquire_sec_context_by_oid in -lgssapi for PAC support")
768 use_ads_krb5 = False
770 if not conf.CONFIG_SET('HAVE_GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT'):
771 Logs.warn("need gss_krb5_export_lucid_sec_context for SPNEGO and gss_wrap support")
772 use_ads_krb5 = False
774 if use_ads_krb5:
775 conf.DEFINE('HAVE_KRB5', '1')
776 conf.env['HAVE_KRB5'] = '1'
777 else:
778 conf.undefine('HAVE_KRB5_H')
779 conf.undefine('HAVE_GSSAPI_H')
780 conf.undefine('HAVE_GSSAPI_GSSAPI_GENERIC_H')
781 conf.undefine('HAVE_GSSAPI_GSSAPI_H')
782 use_ads = False
784 if not conf.CONFIG_SET('HAVE_LDAP'):
785 use_ads = False
786 use_ads_ldap = False
788 if use_ads:
789 conf.DEFINE('WITH_ADS', '1')
790 conf.env['HAVE_ADS'] = '1'
791 Logs.info("Building with Active Directory support.")
792 elif Options.options.with_ads == False:
793 Logs.info("Building without Active Directory support (--without-ads).")
794 else:
795 if not use_ads_krb5:
796 Logs.warn("Active Directory support not available: krb5 libs don't have all required features")
797 if not use_ads_ldap:
798 Logs.warn("Active Directory support not available: LDAP support is not available.")
799 if Options.options.with_ads:
800 conf.fatal("Active Directory support not found. Use --without-ads "
801 "for building without Active Directory support. "
802 "ADS support improves communication with "
803 "Active Directory domain controllers.")
804 else:
805 # this is the auto-mode case
806 Logs.warn("Building without Active Directory support.")
809 if Options.options.with_utmp:
810 conf.env.with_utmp = True
811 if not conf.CHECK_HEADERS('utmp.h'): conf.env.with_utmp = False
812 conf.CHECK_FUNCS('pututline pututxline updwtmp updwtmpx getutmpx getutxent')
813 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_name', headers='utmp.h',
814 define='HAVE_UT_UT_NAME')
815 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_user', headers='utmp.h',
816 define='HAVE_UT_UT_USER')
817 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_id', headers='utmp.h',
818 define='HAVE_UT_UT_ID')
819 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_host', headers='utmp.h',
820 define='HAVE_UT_UT_HOST')
821 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_time', headers='utmp.h',
822 define='HAVE_UT_UT_TIME')
823 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_tv', headers='utmp.h',
824 define='HAVE_UT_UT_TV')
825 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_type', headers='utmp.h',
826 define='HAVE_UT_UT_TYPE')
827 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_pid', headers='utmp.h',
828 define='HAVE_UT_UT_PID')
829 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_exit.e_exit', headers='utmp.h',
830 define='HAVE_UT_UT_EXIT')
831 conf.CHECK_STRUCTURE_MEMBER('struct utmpx', 'ut_syslen', headers='utmpx.h',
832 define='HAVE_UX_UT_SYSLEN')
833 conf.CHECK_CODE('struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);',
834 'PUTUTLINE_RETURNS_UTMP', headers='utmp.h',
835 msg="Checking whether pututline returns pointer")
836 conf.CHECK_SIZEOF(['((struct utmp *)NULL)->ut_line'], headers='utmp.h',
837 define='SIZEOF_UTMP_UT_LINE', critical=False)
838 if not conf.CONFIG_SET('SIZEOF_UTMP_UT_LINE'):
839 conf.env.with_utmp = False
840 elif int(conf.env.SIZEOF_UTMP_UT_LINE) < 15:
841 conf.env.with_utmp = False
842 if conf.env.with_utmp:
843 conf.DEFINE('WITH_UTMP', 1)
844 else:
845 Logs.warn("--with-utmp but utmp support not sufficient")
847 if Options.options.with_avahi:
848 conf.env.with_avahi = True
849 if not conf.CHECK_HEADERS('avahi-common/watch.h avahi-client/client.h'): conf.env.with_avahi = False
850 if not conf.CHECK_FUNCS_IN('avahi_client_new', 'avahi-client'): conf.env.with_avahi = False
851 if not conf.CHECK_FUNCS_IN('avahi_strerror', 'avahi-common'): conf.env.with_avahi = False
852 if conf.env.with_avahi:
853 conf.DEFINE('WITH_AVAHI_SUPPORT', 1)
854 else:
855 conf.SET_TARGET_TYPE('avahi-common', 'EMPTY')
856 conf.SET_TARGET_TYPE('avahi-client', 'EMPTY')
858 if Options.options.with_iconv:
859 conf.env.with_iconv = True
860 if not conf.CHECK_FUNCS_IN('iconv_open', 'iconv', headers='iconv.h'):
861 conf.env.with_iconv = False
862 if conf.env.with_iconv:
863 conf.DEFINE('HAVE_ICONV', 1)
865 if Options.options.with_pam:
866 use_pam=True
867 conf.CHECK_HEADERS('security/pam_appl.h pam/pam_appl.h')
868 if not conf.CONFIG_SET('HAVE_SECURITY_PAM_APPL_H') and not conf.CONFIG_SET('HAVE_PAM_PAM_APPL_H'):
869 Logs.warn("--with-pam=yes but pam_appl.h not found")
870 use_pam=False
871 conf.CHECK_FUNCS_IN('pam_get_data', 'pam')
872 conf.CHECK_HEADERS('security/pam_modules.h pam/pam_modules.h')
873 if not conf.CONFIG_SET('HAVE_SECURITY_PAM_MODULES_H') and not conf.CONFIG_SET('HAVE_PAM_PAM_MODULES_H'):
874 Logs.warn("--with-pam=yes but pam_modules.h not found")
875 use_pam=False
876 conf.CHECK_HEADERS('security/pam_ext.h security/_pam_macros.h')
877 conf.CHECK_HEADERS('pam/pam_ext.h pam/_pam_macros.h')
878 conf.CHECK_FUNCS_IN('pam_vsyslog', 'pam')
879 conf.CHECK_CODE('''
880 #if defined(HAVE_SECURITY_PAM_APPL_H)
881 #include <security/pam_appl.h>
882 #elif defined(HAVE_PAM_PAM_APPL_H)
883 #include <pam/pam_appl.h>
884 #endif
885 pam_set_item(0, PAM_RHOST, 0);
886 ''',
887 'HAVE_PAM_RHOST',
888 lib='pam',
889 msg="Checking whether PAM_RHOST is available");
890 conf.CHECK_CODE('''
891 #if defined(HAVE_SECURITY_PAM_APPL_H)
892 #include <security/pam_appl.h>
893 #elif defined(HAVE_PAM_PAM_APPL_H)
894 #include <pam/pam_appl.h>
895 #endif
896 pam_set_item(0, PAM_TTY, 0);
897 ''',
898 'HAVE_PAM_TTY',
899 lib='pam',
900 msg="Checking whether PAM_TTY is available");
901 conf.CHECK_CODE('''
902 #if (!defined(LINUX))
904 #define PAM_EXTERN extern
905 #if defined(HAVE_SECURITY_PAM_APPL_H)
906 #include <security/pam_appl.h>
907 #elif defined(HAVE_PAM_PAM_APPL_H)
908 #include <pam/pam_appl.h>
909 #endif
911 #endif
913 #if defined(HAVE_SECURITY_PAM_MODULES_H)
914 #include <security/pam_modules.h>
915 #elif defined(HAVE_PAM_PAM_MODULES_H)
916 #include <pam/pam_modules.h>
917 #endif
919 #if defined(HAVE_SECURITY__PAM_MACROS_H)
920 #include <security/_pam_macros.h>
921 #elif defined(HAVE_PAM__PAM_MACROS_H)
922 #include <pam/_pam_macros.h>
923 #endif
925 #ifdef HAVE_SECURITY_PAM_EXT_H
926 #include <security/pam_ext.h>
927 #endif
929 int i; i = PAM_RADIO_TYPE;
930 ''',
931 'HAVE_PAM_RADIO_TYPE',
932 lib='pam',
933 msg="Checking whether PAM_RADIO_TYPE is available");
934 if use_pam:
935 conf.DEFINE('WITH_PAM', 1)
936 conf.DEFINE('WITH_PAM_MODULES', 1)
938 if Options.options.with_pam_smbpass:
939 conf.env.with_pam_smbpass = True
941 seteuid = False
944 # Ensure we select the correct set of system calls on Linux.
946 if (host_os.rfind('linux') > -1):
947 conf.CHECK_CODE('''
948 #if defined(HAVE_UNISTD_H)
949 #include <unistd.h>
950 #endif
951 #include <stdlib.h>
952 #include <stdio.h>
953 #include <sys/types.h>
954 #include <errno.h>
956 #ifdef HAVE_SYS_PRIV_H
957 #include <sys/priv.h>
958 #endif
959 #ifdef HAVE_SYS_ID_H
960 #include <sys/id.h>
961 #endif
963 #if defined(HAVE_SYSCALL_H)
964 #include <syscall.h>
965 #endif
967 #if defined(HAVE_SYS_SYSCALL_H)
968 #include <sys/syscall.h>
969 #endif
971 syscall(SYS_setresuid32, -1, -1, -1);
972 syscall(SYS_setresgid32, -1, -1, -1);
973 syscall(SYS_setreuid32, -1, -1);
974 syscall(SYS_setregid32, -1, -1);
975 syscall(SYS_setuid32, -1);
976 syscall(SYS_setgid32, -1);
977 syscall(SYS_setgroups32, 0, NULL);
978 ''',
979 'USE_LINUX_32BIT_SYSCALLS',
980 msg="Checking whether Linux should use 32-bit credential calls");
982 if (conf.CONFIG_SET('USE_LINUX_32BIT_SYSCALLS')):
983 seteuid = conf.CHECK_CODE('''
984 #define AUTOCONF_TEST 1
985 #define USE_LINUX_THREAD_CREDENTIALS 1
986 #define USE_LINUX_32BIT_SYSCALLS 1
987 #include "../lib/util/setid.c"
988 #include "./lib/util_sec.c"
989 ''',
990 'USE_LINUX_THREAD_CREDENTIALS',
991 addmain=False,
992 execute=True,
993 msg="Checking whether we can use Linux thread-specific credentials with 32-bit system calls")
994 else:
995 seteuid = conf.CHECK_CODE('''
996 #define AUTOCONF_TEST 1
997 #define USE_LINUX_THREAD_CREDENTIALS 1
998 #include "../lib/util/setid.c"
999 #include "./lib/util_sec.c"
1000 ''',
1001 'USE_LINUX_THREAD_CREDENTIALS',
1002 addmain=False,
1003 execute=True,
1004 msg="Checking whether we can use Linux thread-specific credentials")
1005 if not seteuid:
1006 seteuid = conf.CHECK_CODE('''
1007 #define AUTOCONF_TEST 1
1008 #define USE_SETREUID 1
1009 #include "../lib/util/setid.c"
1010 #include "./lib/util_sec.c"
1011 ''',
1012 'USE_SETREUID',
1013 addmain=False,
1014 execute=True,
1015 msg="Checking whether setreuid is available")
1016 if not seteuid:
1017 seteuid = conf.CHECK_CODE('''
1018 #define AUTOCONF_TEST 1
1019 #define USE_SETRESUID 1
1020 #include "../lib/util/setid.c"
1021 #include "./lib/util_sec.c"
1022 ''',
1023 'USE_SETRESUID',
1024 addmain=False,
1025 execute=True,
1026 msg="Checking whether setresuid is available")
1027 if not seteuid:
1028 seteuid = conf.CHECK_CODE('''
1029 #define AUTOCONF_TEST 1
1030 #define USE_SETEUID 1
1031 #include "../lib/util/setid.c"
1032 #include "./lib/util_sec.c"
1033 ''',
1034 'USE_SETEUID',
1035 addmain=False,
1036 execute=True,
1037 msg="Checking whether seteuid is available")
1038 if not seteuid:
1039 seteuid = conf.CHECK_CODE('''
1040 #define AUTOCONF_TEST 1
1041 #define USE_SETUIDX 1
1042 #include "../lib/util/setid.c"
1043 #include "./lib/util_sec.c"
1044 ''',
1045 'USE_SETUIDX',
1046 addmain=False,
1047 execute=True,
1048 mandatory=True,
1049 msg="Checking whether setuidx is available")
1050 if Options.options.with_dnsupdate:
1051 if not conf.CONFIG_SET('HAVE_KRB5'):
1052 Logs.warn("--with-dnsupdate=yes but gssapi support not sufficient")
1053 else:
1054 conf.DEFINE('WITH_DNS_UPDATES', 1)
1055 conf.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
1056 if Options.options.developer:
1057 if conf.CONFIG_SET('HAVE_VALGRIND_H') or conf.CONFIG_SET('HAVE_VALGRIND_VALGRIND_H'):
1058 conf.DEFINE('VALGRIND', '1')
1060 if conf.CHECK_CODE('''
1061 #include <bits/sockaddr.h>
1062 #include <linux/netlink.h>
1063 ''',
1064 'HAVE_LINUX_NETLINK_H',
1065 msg="Checking whether Linux netlink is available"):
1067 conf.CHECK_CODE('''
1068 #include <bits/sockaddr.h>
1069 #include <linux/netlink.h>
1070 #include <linux/rtnetlink.h>
1071 ''',
1072 'HAVE_LINUX_RTNETLINK_H',
1073 msg='Checking whether Linux rtnetlink is available')
1075 conf.CHECK_CODE('''
1076 #include "../tests/fcntl_lock.c"
1077 ''',
1078 'HAVE_FCNTL_LOCK',
1079 addmain=False,
1080 execute=True,
1081 msg='Checking whether fcntl locking is available')
1083 # glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
1084 if not conf.CHECK_CODE('''
1085 #define _XOPEN_SOURCE 600
1086 #include <stdlib.h>
1087 #if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4))
1088 #error probably broken posix_fallocate
1089 #endif
1090 ''',
1091 '_HAVE_UNBROKEN_POSIX_FALLOCATE',
1092 msg='Checking for broken posix_fallocate'):
1093 conf.DEFINE('HAVE_BROKEN_POSIX_FALLOCATE', '1')
1096 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec',
1097 define='HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') # Linux, Solaris
1098 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimensec',
1099 define='HAVE_STRUCT_STAT_ST_MTIMENSEC') # BSD, if defined _POSIX_SOURCE
1100 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimespec.tv_nsec',
1101 define='HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') # BSD, if not defined _POSIX_SOURCE
1102 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtime_n',
1103 define='HAVE_STRUCT_STAT_ST_MTIME_N') # AIX
1104 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_umtime',
1105 define='HAVE_STRUCT_STAT_ST_UMTIME') # Tru64
1106 if conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') or \
1107 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMENSEC') or \
1108 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') or \
1109 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIME_N') or \
1110 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_UMTIME'):
1111 conf.DEFINE('HAVE_STAT_HIRES_TIMESTAMPS', '1')
1113 # recent FreeBSD, NetBSD have creation timestamps called birthtime:
1114 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtime',
1115 define='HAVE_STRUCT_STAT_ST_BIRTHTIME')
1116 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimespec.tv_nsec',
1117 define='HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC')
1118 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimensec',
1119 define='HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC')
1121 conf.CHECK_CODE('''
1122 ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);
1123 ''',
1124 'HAVE_POSIX_FADVISE',
1125 msg='Checking whether posix_fadvise is available',
1126 headers='unistd.h fcntl.h')
1128 for v in ['_SC_NGROUPS_MAX', '_SC_NPROC_ONLN', '_SC_NPROCESSORS_ONLN', '_SC_PAGESIZE' ]:
1129 conf.CHECK_CODE('''
1130 #include <unistd.h>
1131 return sysconf(%s) == -1 ? 1 : 0;
1132 ''' % v,
1133 'SYSCONF%s' % v,
1134 msg='Checking whether sysconf(%s) is available' % v)
1136 conf.CHECK_CODE('''
1137 #include <sys/syscall.h>
1138 #include <unistd.h>
1139 syscall(SYS_initgroups, 16, NULL, NULL, 0);
1140 ''',
1141 'HAVE_DARWIN_INITGROUPS',
1142 msg='Checking whether to use the Darwin-specific initgroups system call')
1144 conf.CHECK_CODE('''struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));''',
1145 'HAVE_UTIMBUF',
1146 headers='sys/types.h utime.h',
1147 msg='Checking whether struct utimbuf is available')
1149 if conf.CHECK_CODE('''struct sigevent s;''',
1150 'HAVE_STRUCT_SIGEVENT',
1151 headers='sys/types.h stdlib.h stddef.h signal.h',
1152 msg='Checking whether we have the struct sigevent'):
1153 conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sival_ptr',
1154 define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR',
1155 headers='signal.h');
1156 conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sigval_ptr',
1157 define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR',
1158 headers='signal.h');
1160 if os.path.exists('/proc/sys/kernel/core_pattern'):
1161 conf.DEFINE('HAVE_SYS_KERNEL_PROC_CORE_PATTERN', '1')
1163 if conf.CHECK_CODE('''
1164 #include <time.h>
1165 main() {
1166 struct tm *tm;
1167 if (sizeof(time_t) == 8) {
1168 time_t max_time = 0x7fffffffffffffffll;
1169 tm = gmtime(&max_time);
1170 /* This should fail with 32-bit tm_year. */
1171 if (tm == NULL) {
1172 /* Max time_t that works with 32-bit int tm_year in struct tm. */
1173 max_time = 67768036191676799ll;
1174 tm = gmtime(&max_time);
1175 if (tm) {
1176 exit(0);
1180 exit(1);
1181 }''',
1182 '__TIME_T_MAX',
1183 addmain=False,
1184 execute=True,
1185 msg="Checking for the maximum value of the 'time_t' type"):
1186 conf.DEFINE('TIME_T_MAX', '67768036191676799ll')
1188 conf.CHECK_CODE('''
1189 #if defined(HAVE_UNISTD_H)
1190 #include <unistd.h>
1191 #endif
1192 #include <sys/types.h>
1193 main() { dev_t dev = makedev(1,2); return 0; }
1194 ''',
1195 'HAVE_MAKEDEV',
1196 addmain=False,
1197 msg='Checking whether the macro for makedev is available')
1199 conf.CHECK_CODE('''
1200 #include <stdio.h>
1201 #include <limits.h>
1202 #include <signal.h>
1204 void exit_on_core(int ignored) {
1205 exit(1);
1208 main() {
1209 char *newpath;
1210 signal(SIGSEGV, exit_on_core);
1211 newpath = realpath("/tmp", NULL);
1212 exit((newpath != NULL) ? 0 : 1);
1214 ''',
1215 'REALPATH_TAKES_NULL',
1216 addmain=False,
1217 execute=True,
1218 msg='Checking whether the realpath function allows a NULL argument')
1220 conf.CHECK_CODE('''#include "../tests/ftruncate.c"''',
1221 'HAVE_FTRUNCATE_EXTEND',
1222 msg='Checking for ftruncate extend',
1223 addmain=False,
1224 execute=True)
1226 if Options.options.with_sendfile_support:
1227 if (host_os.rfind('linux') > -1) or (host_os.rfind('gnu') > -1) or (host_os.rfind('k*bsd*-gnu') > -1) or (host_os.rfind('kopensolaris*-gnu') > -1):
1228 conf.CHECK_CODE('''
1229 int tofd, fromfd;
1230 off_t offset;
1231 size_t total;
1232 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
1233 ''',
1234 '_HAVE_SENDFILE',
1235 headers='sys/sendfile.h',
1236 msg='Checking for linux sendfile support')
1238 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1239 conf.DEFINE('HAVE_SENDFILE', '1')
1240 conf.DEFINE('LINUX_SENDFILE_API', '1')
1241 conf.DEFINE('WITH_SENDFILE', '1')
1242 elif (host_os.rfind('freebsd') > -1) or (host_os.rfind('dragonfly') > -1):
1243 conf.CHECK_CODE('''
1244 #include <sys/types.h>
1245 #include <unistd.h>
1246 #include <sys/socket.h>
1247 #include <sys/uio.h>
1248 int fromfd, tofd, ret, total=0;
1249 off_t offset, nwritten;
1250 struct sf_hdtr hdr;
1251 struct iovec hdtrl;
1252 hdr.headers = &hdtrl;
1253 hdr.hdr_cnt = 1;
1254 hdr.trailers = NULL;
1255 hdr.trl_cnt = 0;
1256 hdtrl.iov_base = NULL;
1257 hdtrl.iov_len = 0;
1258 ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0)
1259 ''',
1260 '_HAVE_SENDFILE',
1261 msg='Checking for freebsd sendfile support')
1262 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1263 conf.DEFINE('HAVE_SENDFILE', '1')
1264 conf.DEFINE('FREEBSD_SENDFILE_API', '1')
1265 conf.DEFINE('WITH_SENDFILE', '1')
1266 elif (host_os.rfind('darwin') > -1):
1267 conf.CHECK_CODE('''
1268 #include <sys/types.h>
1269 #include <sys/socket.h>
1270 #include <sys/uio.h>
1271 int fromfd, tofd, ret;
1272 off_t offset, nwritten;
1273 struct sf_hdtr hdr;
1274 struct iovec hdtrl;
1275 hdr.headers = &hdtrl;
1276 hdr.hdr_cnt = 1;
1277 hdr.trailers = (void *)0;
1278 hdr.trl_cnt = 0;
1279 hdtrl.iov_base = (void *)0;
1280 hdtrl.iov_len = 0;
1281 ret = sendfile(fromfd, tofd, offset, &nwritten, &hdr, 0);
1282 ''',
1283 '_HAVE_SENDFILE',
1284 msg='Checking for darwin sendfile support')
1285 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1286 conf.DEFINE('HAVE_SENDFILE', '1')
1287 conf.DEFINE('DARWIN_SENDFILE_API', '1')
1288 conf.DEFINE('WITH_SENDFILE', '1')
1289 elif (host_os.rfind('hpux') > -1) or (host_os.rfind('osf') > -1):
1290 conf.CHECK_CODE('''
1291 #include <sys/socket.h>
1292 #include <sys/uio.h>
1293 int fromfd, tofd;
1294 size_t total=0;
1295 struct iovec hdtrl[2];
1296 ssize_t nwritten;
1297 off_t offset;
1298 hdtrl[0].iov_base = 0;
1299 hdtrl[0].iov_len = 0;
1300 nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
1301 ''',
1302 '_HAVE_SENDFILE',
1303 msg='Checking for osf/hpux sendfile support')
1304 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1305 conf.DEFINE('HAVE_SENDFILE', '1')
1306 conf.DEFINE('HPUX_SENDFILE_API', '1')
1307 conf.DEFINE('WITH_SENDFILE', '1')
1308 elif (host_os.rfind('solaris') > -1):
1309 conf.CHECK_FUNCS_IN('sendfile', 'sendfilev')
1310 conf.CHECK_CODE('''
1311 #include <sys/sendfile.h>,
1312 int sfvcnt;
1313 size_t xferred;
1314 struct sendfilevec vec[2];
1315 ssize_t nwritten;
1316 int tofd;
1317 sfvcnt = 2;
1318 vec[0].sfv_fd = SFV_FD_SELF;
1319 vec[0].sfv_flag = 0;
1320 vec[0].sfv_off = 0;
1321 vec[0].sfv_len = 0;
1322 vec[1].sfv_fd = 0;
1323 vec[1].sfv_flag = 0;
1324 vec[1].sfv_off = 0;
1325 vec[1].sfv_len = 0;
1326 nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
1327 ''',
1328 '_HAVE_SENDFILEV',
1329 msg='Checking for solaris sendfilev support')
1330 if conf.CONFIG_SET('_HAVE_SENDFILEV'):
1331 conf.DEFINE('HAVE_SENDFILEV', '1')
1332 conf.DEFINE('SOLARIS_SENDFILE_API', '1')
1333 conf.DEFINE('WITH_SENDFILE', '1')
1334 elif (host_os.rfind('aix') > -1):
1335 conf.CHECK_CODE('''
1336 #include <sys/socket.h>
1337 int fromfd, tofd;
1338 size_t total=0;
1339 struct sf_parms hdtrl;
1340 ssize_t nwritten;
1341 hdtrl.header_data = 0;
1342 hdtrl.header_length = 0;
1343 hdtrl.file_descriptor = fromfd;
1344 hdtrl.file_offset = 0;
1345 hdtrl.file_bytes = 0;
1346 hdtrl.trailer_data = 0;
1347 hdtrl.trailer_length = 0;
1348 nwritten = send_file(&tofd, &hdtrl, 0);
1349 ''',
1350 '_HAVE_SENDFILE',
1351 msg='Checking for AIX send_file support')
1352 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1353 conf.DEFINE('HAVE_SENDFILE', '1')
1354 conf.DEFINE('AIX_SENDFILE_API', '1')
1355 conf.DEFINE('WITH_SENDFILE', '1')
1357 # Check for getcwd allowing a NULL arg.
1358 conf.CHECK_CODE('''
1359 #include <unistd.h>
1360 main() {
1361 char *s = getcwd(NULL,0);
1362 exit(s != NULL ? 0 : 1);
1363 }''', 'GETCWD_TAKES_NULL', addmain=False, execute=True,
1364 msg="getcwd takes a NULL argument")
1367 # UnixWare 7.x has its getspnam in -lgen
1368 conf.CHECK_FUNCS_IN('getspnam', 'gen')
1369 conf.CHECK_FUNCS_IN('getspnam', 'security')
1370 conf.CHECK_FUNCS_IN('getspnam', 'sec')
1372 if Options.options.with_quotas:
1373 # For quotas on Veritas VxFS filesystems
1374 conf.CHECK_HEADERS('sys/fs/vx_quota.h')
1375 # For sys/quota.h and linux/quota.h
1376 conf.CHECK_HEADERS('sys/quota.h')
1377 # For quotas on BSD systems
1378 conf.CHECK_HEADERS('ufs/ufs/quota.h')
1379 # For quotas on Linux XFS filesystems
1380 if conf.CHECK_HEADERS('xfs/xqm.h'):
1381 conf.DEFINE('HAVE_XFS_QUOTAS', '1')
1382 else:
1383 # For Irix XFS
1384 conf.CHECK_CODE('''
1385 #include "confdefs.h"
1386 #ifdef HAVE_SYS_TYPES_H
1387 #include <sys/types.h>
1388 #endif
1389 #ifdef HAVE_ASM_TYPES_H
1390 #include <asm/types.h>
1391 #endif
1392 #include <sys/quota.h>
1393 int i = Q_XGETQUOTA;''',
1394 define='HAVE_XFS_QUOTAS',
1395 msg='for XFS QUOTA in <sys/quota.h>',
1396 execute=False,
1397 local_include=False)
1399 # For IRIX like dqb_isoftlimit instead of dqb_fsoftlimit in struc dqblk
1400 conf.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_fsoftlimit', define='HAVE_DQB_FSOFTLIMIT',
1401 headers='sys/quota.h')
1402 #darwin style quota bytecount
1403 conf.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_curbytes', define='HAVE_STRUCT_DQBLK_DQB_CURBYTES',
1404 headers='sys/quota.h')
1405 if conf.CHECK_HEADERS('rpcsvc/rquota.h'):
1406 conf.DEFINE('HAVE_NFS_QUOTAS', '1')
1407 conf.CHECK_STRUCTURE_MEMBER('struct getquota_rslt', 'getquota_rslt_u',
1408 define='HAVE_GETQUOTA_RSLT_GETQUOTA_RSLT_U',
1409 headers='rpcsvc/rquota.h')
1411 if (host_os.rfind('linux') > -1):
1412 conf.DEFINE('HAVE_QUOTACTL_LINUX', '1')
1413 elif not conf.CONFIG_SET("HAVE_XFS_QUOTAS"):
1414 if not conf.CHECK_CODE('''
1415 #define HAVE_QUOTACTL_4A 1
1416 #define AUTOCONF_TEST 1
1417 #include "../tests/sysquotas.c"
1418 ''',
1419 cflags=conf.env['WERROR_CFLAGS'],
1420 define='HAVE_QUOTACTL_4A',
1421 msg='for QUOTACTL_4A: long quotactl(int cmd, char *special, qid_t id, caddr_t addr)',
1422 execute=True,
1423 addmain=False):
1425 conf.CHECK_CODE('''
1426 #define HAVE_QUOTACTL_4B 1
1427 #define AUTOCONF_TEST 1
1428 #include "../tests/sysquotas.c"
1429 ''',
1430 cflags=conf.env['WERROR_CFLAGS'],
1431 define='HAVE_QUOTACTL_4B',
1432 msg='for QUOTACTL_4B: int quotactl(const char *path, int cmd, int id, char *addr)',
1433 execute=True,
1434 addmain=False)
1436 conf.CHECK_CODE('''
1437 clnt_create("", RQUOTAPROG, RQUOTAVERS, "udp");
1438 ''',
1439 headers="rpc/rpc.h rpc/types.h rpcsvc/rquota.h rpc/nettype.h rpc/xdr.h",
1440 define='HAVE_NFS_QUOTAS',
1441 msg='for NFS QUOTAS',
1442 execute=True,
1443 local_include=False)
1445 if conf.CONFIG_SET('HAVE_QUOTACTL_LINUX') or \
1446 conf.CONFIG_SET('HAVE_QUOTACTL_4A') or \
1447 conf.CONFIG_SET('HAVE_QUOTACTL_4B') or \
1448 conf.CONFIG_SET('HAVE_XFS_QUOTAS'):
1449 conf.DEFINE('HAVE_SYS_QUOTAS', '1')
1450 conf.DEFINE('WITH_QUOTAS', '1')
1453 # checking for clustering extensions (CTDB)
1455 if Options.options.with_cluster_support == False:
1456 # configure is called with --without-cluster-support,
1457 # so don't check for and build w/o ctdb support.
1458 have_cluster_support = False
1460 else:
1462 have_cluster_support = True
1463 ctdb_broken = ""
1464 CTDB_CFLAGS = ""
1466 srcdir = os.path.realpath(conf.srcdir)
1467 if 'EXTRA_INCLUDES' in conf.env:
1468 includes = ' '.join(conf.env['EXTRA_INCLUDES']).replace('#', srcdir + '/')
1469 else:
1470 includes = ''
1472 if Options.options.ctdb_dir:
1473 CTDB_INCLUDE = Options.options.ctdb_dir + '/include'
1474 else:
1475 CTDB_INCLUDE = conf.srcdir + '/ctdb/include'
1476 includes = includes + ' ' + CTDB_INCLUDE
1478 if not conf.env.USING_SYSTEM_TDB:
1479 includes = includes + ' ' + srcdir + '/lib/tdb/include'
1481 if not conf.env.USING_SYSTEM_TALLOC:
1482 includes = includes + ' ' + srcdir + '/lib/talloc'
1484 ok = conf.CHECK_CODE('''
1485 #define NO_CONFIG_H
1486 #include "replace.h"
1487 #include "system/wait.h"
1488 #include "system/network.h"
1489 #define private #error __USED_RESERVED_WORD_private__
1490 #include <talloc.h>
1491 #include <tdb.h>
1492 #include <ctdb.h>
1494 int main(void)
1496 return 0;
1498 ''',
1499 'HAVE_CTDB_CHECK_CODE',
1500 addmain=False,
1501 includes=includes,
1502 msg='Checking for header ctdb.h')
1503 if ok:
1504 CTDB_CFLAGS += ' -DHAVE_CTDB_H=1'
1505 else:
1506 have_cluster_support = False
1507 ctdb_broken = "ctdb.h is required for cluster support"
1509 conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1510 if have_cluster_support:
1511 ok = conf.CHECK_CODE('''
1512 #define NO_CONFIG_H
1513 #include "replace.h"
1514 #include "system/wait.h"
1515 #include "system/network.h"
1516 #define private #error __USED_RESERVED_WORD_private__
1517 #include <talloc.h>
1518 #include <tdb.h>
1519 #include <ctdb.h>
1520 #include <ctdb_private.h>
1522 int main(void)
1524 return 0;
1526 ''',
1527 'HAVE_CTDB_CHECK_CODE',
1528 addmain=False,
1529 includes=includes,
1530 msg='Checking for header ctdb_private.h')
1531 if ok:
1532 CTDB_CFLAGS += ' -DHAVE_CTDB_PRIVATE_H=1'
1533 else:
1534 have_cluster_support = False
1535 ctdb_broken = "ctdb_private.h is required for cluster support"
1537 conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1538 if have_cluster_support:
1539 ok = conf.CHECK_CODE('''
1540 #define NO_CONFIG_H
1541 #include "replace.h"
1542 #include "system/wait.h"
1543 #include "system/network.h"
1544 #define private #error __USED_RESERVED_WORD_private__
1545 #include <talloc.h>
1546 #include <tdb.h>
1547 #include <ctdb.h>
1548 #include <ctdb_protocol.h>
1550 int main(void)
1552 return 0;
1554 ''',
1555 'HAVE_CTDB_CHECK_CODE',
1556 addmain=False,
1557 includes=includes,
1558 msg='Checking for header ctdb_protocol.h')
1559 if ok:
1560 CTDB_CFLAGS += ' -DHAVE_CTDB_PROTOCOL_H=1'
1562 conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1563 if have_cluster_support:
1564 ok = conf.CHECK_CODE('''
1565 #define NO_CONFIG_H
1566 #include "replace.h"
1567 #include "system/wait.h"
1568 #include "system/network.h"
1569 #include <talloc.h>
1570 #include <tdb.h>
1571 #include <ctdb.h>
1572 #include <ctdb_private.h>
1574 int main(void)
1576 int i = (int)CTDB_CONTROL_TRANS3_COMMIT;
1577 return 0;
1579 ''',
1580 'HAVE_CTDB_CHECK_CODE',
1581 addmain=False,
1582 includes=includes,
1583 msg='Checking for transaction support (TRANS3_COMMIT control)')
1584 if ok:
1585 CTDB_CFLAGS += ' -DHAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL=1'
1586 else:
1587 have_cluster_support = False
1588 ctdb_broken = "ctdb transaction support missing or too old"
1590 conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1591 if have_cluster_support:
1592 ok = conf.CHECK_CODE('''
1593 #define NO_CONFIG_H
1594 #include "replace.h"
1595 #include "system/wait.h"
1596 #include "system/network.h"
1597 #include <talloc.h>
1598 #include <tdb.h>
1599 #include <ctdb.h>
1600 #include <ctdb_private.h>
1602 int main(void)
1604 int i = (int)CTDB_CONTROL_SCHEDULE_FOR_DELETION;
1605 return 0;
1607 ''',
1608 'HAVE_CTDB_CHECK_CODE',
1609 addmain=False,
1610 includes=includes,
1611 msg='Checking for SCHEDULE_FOR_DELETION control')
1612 if ok:
1613 CTDB_CFLAGS += ' -DHAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL=1'
1614 else:
1615 if not Options.options.enable_old_ctdb:
1616 have_cluster_support = False
1617 ctdb_broken = "SCHEDULE_FOR_DELETION control missing"
1618 else:
1619 Logs.warn("ignoring missing SCHEDULE_FOR_DELETION control (--enable-old-ctdb)")
1621 conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1622 if have_cluster_support:
1623 ok = conf.CHECK_CODE('''
1624 #define NO_CONFIG_H
1625 #include "replace.h"
1626 #include "system/wait.h"
1627 #include "system/network.h"
1628 #include <talloc.h>
1629 #include <tdb.h>
1630 #include <ctdb.h>
1632 int main(void)
1634 int i = (int)CTDB_WANT_READONLY;
1635 return 0;
1637 ''',
1638 'HAVE_CTDB_CHECK_CODE',
1639 addmain=False,
1640 includes=includes,
1641 msg='Checking for CTDB readonly records support')
1642 if ok:
1643 CTDB_CFLAGS += ' -DHAVE_CTDB_WANT_READONLY_DECL=1'
1644 else:
1645 if not Options.options.enable_old_ctdb:
1646 have_cluster_support = False
1647 ctdb_broken = "support for CTDB readonly records missing"
1648 else:
1649 Logs.warn("ignoring missing READONLY support (--enable-old-ctdb)")
1651 conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1652 if have_cluster_support:
1653 ok = conf.CHECK_CODE('''
1654 #define NO_CONFIG_H
1655 #include "replace.h"
1656 #include "system/wait.h"
1657 #include "system/network.h"
1658 #include <talloc.h>
1659 #include <tdb.h>
1660 #include <ctdb.h>
1661 #include <ctdb_private.h>
1663 int main(void)
1665 struct ctdb_control_tcp _x;
1666 return 0;
1668 ''',
1669 'HAVE_CTDB_CHECK_CODE',
1670 addmain=False,
1671 includes=includes,
1672 msg='Checking for ctdb ipv4 support')
1673 if ok:
1674 CTDB_CFLAGS += ' -DHAVE_STRUCT_CTDB_CONTROL_TCP=1'
1675 else:
1676 have_cluster_support = False
1677 ctdb_broken = "missing struct ctdb_control_tcp"
1679 conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1680 if have_cluster_support:
1681 ok = conf.CHECK_CODE('''
1682 #define NO_CONFIG_H
1683 #include "replace.h"
1684 #include "system/wait.h"
1685 #include "system/network.h"
1686 #include <talloc.h>
1687 #include <tdb.h>
1688 #include <ctdb.h>
1689 #include <ctdb_private.h>
1691 int main(void)
1693 struct ctdb_control_tcp_addr _x;
1694 return 0;
1696 ''',
1697 'HAVE_CTDB_CHECK_CODE',
1698 addmain=False,
1699 includes=includes,
1700 msg='Checking for ctdb ipv6 support')
1701 if ok:
1702 CTDB_CFLAGS += ' -DHAVE_STRUCT_CTDB_CONTROL_TCP_ADDR=1'
1704 conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1705 if have_cluster_support:
1706 ok = conf.CHECK_CODE('''
1707 #define NO_CONFIG_H
1708 #include "replace.h"
1709 #include "system/wait.h"
1710 #include "system/network.h"
1711 #include <talloc.h>
1712 #include <tdb.h>
1713 #include <ctdb.h>
1714 #include <ctdb_private.h>
1716 int main(void)
1718 int i = (int)CTDB_CONTROL_CHECK_SRVIDS;
1719 return 0;
1721 ''',
1722 'HAVE_CTDB_CHECK_CODE',
1723 addmain=False,
1724 includes=includes,
1725 msg='Checking for CHECK_SRVIDS control')
1726 if ok:
1727 CTDB_CFLAGS += ' -DHAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL=1'
1728 else:
1729 if not Options.options.enable_old_ctdb:
1730 have_cluster_support = False
1731 ctdb_broken = "CHECK_SRVIDS control missing"
1732 else:
1733 Logs.warn("ignoring missing CHECK_SRVIDS control (--enable-old-ctdb)")
1735 conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1736 conf.undefine('HAVE_CTDB_CHECK_CODE')
1737 if have_cluster_support:
1738 Logs.info("building with cluster support")
1739 conf.env['CTDB_CFLAGS'] = CTDB_CFLAGS
1740 conf.env['CTDB_INCLUDE'] = CTDB_INCLUDE
1741 else:
1742 if Options.options.with_cluster_support == False:
1743 Logs.info("building without cluster support (--without-cluster-support)")
1744 elif Options.options.with_cluster_support == True:
1745 Logs.error("Cluster support not available: " + ctdb_broken)
1746 conf.fatal("Cluster support not found, but --with-cluster-support was specified")
1747 else:
1748 Logs.info("building without cluster support: " + ctdb_broken)
1749 conf.env['CTDB_CFLAGS'] = ''
1752 conf.CHECK_CODE('__attribute__((destructor)) static void cleanup(void) { }',
1753 'HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR',
1754 addmain=False,
1755 link=False,
1756 msg='Checking whether we can compile with __attribute__((destructor))')
1758 conf.CHECK_CODE('void seekdir(DIR *d, long loc) { return; }',
1759 'SEEKDIR_RETURNS_VOID',
1760 headers='sys/types.h dirent.h',
1761 msg='Checking whether seekdir returns void')
1763 if Options.options.with_profiling_data:
1764 conf.DEFINE('WITH_PROFILE', 1);
1766 if Options.options.with_pthreadpool:
1767 if conf.CONFIG_SET('HAVE_PTHREAD'):
1768 conf.DEFINE('WITH_PTHREADPOOL', '1')
1769 else:
1770 Logs.warn("pthreadpool support cannot be enabled when pthread support was not found")
1771 conf.undefine('WITH_PTHREADPOOL')
1773 if conf.CHECK_HEADERS('gpfs_gpl.h'):
1774 conf.DEFINE('HAVE_GPFS', '1')
1776 if (conf.CHECK_HEADERS('linux/ioctl.h sys/ioctl.h linux/fs.h') and
1777 conf.CHECK_DECLS('FS_IOC_GETFLAGS FS_COMPR_FL', headers='linux/fs.h')):
1778 conf.DEFINE('HAVE_LINUX_IOCTL', '1')
1780 conf.env['CCFLAGS_CEPHFS'] = "-D_FILE_OFFSET_BITS=64"
1781 if Options.options.libcephfs_dir:
1782 conf.env['CPPPATH_CEPHFS'] = Options.options.libcephfs_dir + '/include'
1783 conf.env['LIBPATH_CEPHFS'] = Options.options.libcephfs_dir + '/lib'
1785 if conf.CHECK_HEADERS('cephfs/libcephfs.h', False, False, 'cephfs') and conf.CHECK_LIB('cephfs'):
1786 conf.DEFINE('HAVE_CEPH', '1')
1788 if Options.options.with_glusterfs:
1789 conf.check_cfg(package='glusterfs-api', args='"glusterfs-api >= 4" --cflags --libs',
1790 msg='Checking for glusterfs-api >= 4', uselib_store="GFAPI")
1791 conf.CHECK_HEADERS('api/glfs.h', lib='gfapi')
1792 conf.CHECK_LIB('gfapi', shlib=True)
1794 if conf.CONFIG_SET('HAVE_API_GLFS_H'):
1795 conf.DEFINE('HAVE_GLUSTERFS', '1')
1796 else:
1797 conf.SET_TARGET_TYPE('gfapi', 'EMPTY')
1798 conf.undefine('HAVE_GLUSTERFS')
1799 else:
1800 conf.SET_TARGET_TYPE('gfapi', 'EMPTY')
1801 conf.undefine('HAVE_GLUSTERFS')
1803 if Options.options.enable_vxfs:
1804 conf.DEFINE('HAVE_VXFS', '1')
1806 if conf.check_cfg(package='dbus-1', args='--cflags --libs',
1807 msg='Checking for dbus', uselib_store="DBUS-1"):
1808 if (conf.CHECK_HEADERS('dbus/dbus.h', lib='dbus-1')
1809 and conf.CHECK_LIB('dbus-1', shlib=True)):
1810 conf.DEFINE('HAVE_DBUS', '1')
1812 conf.env.build_regedit = False
1813 if not Options.options.with_regedit == False:
1814 conf.PROCESS_SEPARATE_RULE('system_ncurses')
1815 if conf.CONFIG_SET('HAVE_NCURSES'):
1816 conf.env.build_regedit = True
1818 if conf.env.build_regedit:
1819 Logs.info("building regedit")
1820 else:
1821 if Options.options.with_regedit == False:
1822 Logs.info("not building regedit (--without-regedit)")
1823 elif Options.options.with_regedit == True:
1824 Logs.error("ncurses not available, cannot build regedit")
1825 conf.fatal("ncurses not available, but --with-regedit was specified")
1826 else:
1827 Logs.info("ncurses not available, not building regedit")
1829 conf.CHECK_FUNCS_IN('DES_pcbc_encrypt', 'crypto')
1830 if Options.options.with_fake_kaserver == True:
1831 conf.CHECK_HEADERS('afs/param.h afs/stds.h', together=True)
1832 conf.CHECK_HEADERS('afs/param.h afs/stds.h', together=True)
1833 if (conf.CONFIG_SET('HAVE_AFS_PARAM_H') and conf.CONFIG_SET('HAVE_AFS_STDS_H') and conf.CONFIG_SET('HAVE_DES_PCBC_ENCRYPT')):
1834 conf.DEFINE('WITH_FAKE_KASERVER', '1')
1835 else:
1836 conf.fatal('AFS headers not available, but --with-fake-kaserver was specified')
1840 default_static_modules.extend(TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam
1841 auth_sam auth_unix auth_winbind auth_wbc
1842 auth_domain auth_builtin vfs_default
1843 nss_info_template idmap_tdb idmap_passdb
1844 idmap_nss'''))
1846 default_shared_modules.extend(TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
1847 vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
1848 vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2
1849 auth_script vfs_readahead vfs_xattr_tdb vfs_posix_eadb
1850 vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
1851 vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
1852 vfs_media_harmony vfs_fruit
1853 vfs_commit
1854 vfs_worm
1855 vfs_crossrename vfs_linux_xfs_sgid
1856 vfs_time_audit idmap_autorid idmap_tdb2
1857 idmap_ad
1858 idmap_rid idmap_hash idmap_rfc2307'''))
1860 if Options.options.developer:
1861 default_static_modules.extend(TO_LIST('charset_weird'))
1862 default_shared_modules.extend(TO_LIST('perfcount_test'))
1863 default_shared_modules.extend(TO_LIST('vfs_skel_opaque vfs_skel_transparent vfs_shadow_copy_test'))
1864 default_shared_modules.extend(TO_LIST('auth_skel pdb_test'))
1866 if Options.options.enable_selftest or Options.options.developer:
1867 default_shared_modules.extend(TO_LIST('vfs_fake_acls vfs_nfs4acl_xattr'))
1870 if conf.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
1871 default_static_modules.extend(TO_LIST('pdb_samba_dsdb auth_samba4 vfs_dfs_samba4'))
1873 if conf.CONFIG_SET('HAVE_FREEBSD_SUNACL_H'):
1874 default_shared_modules.extend(TO_LIST('vfs_zfsacl'))
1876 if conf.CONFIG_SET('HAVE_DIRFD_DECL'):
1877 default_shared_modules.extend(TO_LIST('vfs_syncops vfs_dirsort'))
1879 if conf.CONFIG_SET('HAVE_STATFS_F_FSID'):
1880 default_shared_modules.extend(TO_LIST('vfs_fileid'))
1882 if (conf.CONFIG_SET('HAVE_STRUCT_MSGHDR_MSG_CONTROL') or conf.CONFIG_SET('HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS')):
1883 default_shared_modules.extend(TO_LIST('vfs_aio_fork'))
1885 if Options.options.with_pthreadpool:
1886 default_shared_modules.extend(TO_LIST('vfs_aio_pthread'))
1888 if conf.CONFIG_SET('HAVE_AIO'):
1889 default_shared_modules.extend(TO_LIST('vfs_aio_posix'))
1891 if conf.CONFIG_SET('HAVE_LINUX_KERNEL_AIO'):
1892 default_shared_modules.extend(TO_LIST('vfs_aio_linux'))
1894 if conf.CONFIG_SET('HAVE_LDAP'):
1895 default_static_modules.extend(TO_LIST('pdb_ldapsam idmap_ldap'))
1897 if conf.CONFIG_SET('DARWINOS'):
1898 default_static_modules.extend(TO_LIST('charset_macosxfs'))
1900 if conf.CONFIG_SET('HAVE_GPFS'):
1901 default_shared_modules.extend(TO_LIST('vfs_gpfs'))
1903 if conf.CONFIG_SET('HAVE_LINUX_IOCTL'):
1904 default_shared_modules.extend(TO_LIST('vfs_btrfs'))
1906 if conf.CONFIG_SET('SAMBA_FAM_LIBS'):
1907 default_shared_modules.extend(TO_LIST('vfs_notify_fam'))
1909 if conf.CONFIG_SET("HAVE_CEPH"):
1910 default_shared_modules.extend(TO_LIST('vfs_ceph'))
1912 if conf.CONFIG_SET('HAVE_GLUSTERFS'):
1913 default_shared_modules.extend(TO_LIST('vfs_glusterfs'))
1915 if conf.CONFIG_SET('HAVE_VXFS'):
1916 default_shared_modules.extend(TO_LIST('vfs_vxfs'))
1918 if conf.CONFIG_SET('HAVE_DBUS'):
1919 default_shared_modules.extend(TO_LIST('vfs_snapper'))
1921 explicit_shared_modules = TO_LIST(Options.options.shared_modules, delimiter=',')
1922 explicit_static_modules = TO_LIST(Options.options.static_modules, delimiter=',')
1924 def replace_list_item(lst, item, value):
1925 try:
1926 idx = lst.index(item)
1927 lst[idx] = value
1928 except:
1929 pass
1930 # PDB module file name should have the same name as module registers itself
1931 # In Autoconf build we export LDAP passdb module as ldapsam but WAF build
1932 # was always exporting pdb_ldap. In order to support existing packages
1933 # allow referring to pdb_ldapsam as pdb_ldap but use proper name internally.
1934 replace_list_item(explicit_shared_modules, 'pdb_ldap', 'pdb_ldapsam')
1935 replace_list_item(explicit_static_modules, 'pdb_ldap', 'pdb_ldapsam')
1937 final_static_modules = default_static_modules
1938 final_shared_modules = default_shared_modules
1940 for m in explicit_static_modules:
1941 if m in final_shared_modules:
1942 final_shared_modules.remove(m)
1943 final_static_modules.append(m)
1944 for m in explicit_shared_modules:
1945 if m in final_static_modules:
1946 final_static_modules.remove(m)
1947 final_shared_modules.append(m)
1949 if ("auth_domain" not in final_static_modules) or \
1950 ("auth_builtin" not in final_static_modules) or \
1951 ("auth_sam" not in final_static_modules) or \
1952 ("auth_winbind" not in final_static_modules):
1953 raise Utils.WafError('These auth modules MUST be configured as static modules: auth_domain, auth_builtin, auth_sam, auth_winbind')
1955 conf.env['static_modules'] = final_static_modules
1956 conf.env['shared_modules'] = final_shared_modules
1958 conf.DEFINE('STRING_STATIC_MODULES', ' '.join(final_static_modules), quote=True)
1960 static_list = {}
1961 shared_list = {}
1963 prefixes = ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount']
1964 conf.env['MODULE_PREFIXES'] = prefixes
1965 for p in prefixes:
1966 for m in final_static_modules:
1967 if m.find(p) == 0:
1968 if not p in static_list:
1969 static_list[p] = []
1970 static_list[p].append(m)
1971 for m in final_shared_modules:
1972 if m.find(p) == 0:
1973 if not p in shared_list:
1974 shared_list[p] = []
1975 shared_list[p].append(m)
1977 for p in prefixes:
1978 static_env = "%s_STATIC" % p.upper()
1979 shared_env = "%s_SHARED" % p.upper()
1980 conf.env[static_env] = []
1981 conf.env[shared_env] = []
1982 if p in static_list:
1983 decl_list=""
1984 for entry in static_list[p]:
1985 decl_list += "extern NTSTATUS %s_init(void); " % entry
1986 conf.env[static_env].append('%s' % entry)
1987 decl_list = decl_list.rstrip()
1988 conf.DEFINE('static_decl_%s' % p, decl_list)
1989 conf.DEFINE('static_init_%s' % p, '{ %s_init(); }' % '_init(); '.join(static_list[p]))
1990 else:
1991 conf.DEFINE('static_decl_%s' % p, '')
1992 conf.DEFINE('static_init_%s' % p, '{}')
1993 if p in shared_list:
1994 for entry in shared_list[p]:
1995 conf.DEFINE('%s_init' % entry, 'samba_init_module')
1996 conf.env[shared_env].append('%s' % entry)
1998 conf.SAMBA_CONFIG_H('include/config.h')
2000 def ctags(ctx):
2001 "build 'tags' file using ctags"
2002 import Utils
2003 source_root = os.path.dirname(Utils.g_module.root_path)
2004 cmd = 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
2005 print("Running: %s" % cmd)
2006 os.system(cmd)