2010-03-28 01:48:49 +03:00
#!/usr/bin/env python
2018-02-02 17:34:33 +03:00
from waflib import Options
2015-08-14 11:59:05 +03:00
import os, sys
2010-03-07 15:48:57 +03:00
2024-06-13 08:41:41 +03:00
VERSION="1.3.1"
2010-03-07 15:48:57 +03:00
def configure(conf):
2017-11-07 14:02:19 +03:00
if conf.CHECK_UID_WRAPPER():
2014-01-17 17:43:01 +04:00
conf.DEFINE('USING_SYSTEM_UID_WRAPPER', 1)
libuid_wrapper_so_path = 'libuid_wrapper.so'
else:
2024-06-13 08:41:41 +03:00
conf.CHECK_HEADERS('gnu/lib-names.h')
2015-01-23 17:15:04 +03:00
# check HAVE_GCC_ATOMIC_BUILTINS
conf.CHECK_CODE('''
#include <stdbool.h>
int main(void) {
bool x;
bool *p_x = &x;
__atomic_load(p_x, &x, __ATOMIC_RELAXED);
return 0;
''',
'HAVE_GCC_ATOMIC_BUILTINS',
addmain=False,
msg='Checking for atomic builtins')
2014-01-17 17:43:01 +04:00
2018-07-18 09:54:22 +03:00
if conf.CONFIG_SET("HAVE___THREAD"):
conf.DEFINE("HAVE_GCC_THREAD_LOCAL_STORAGE", 1)
2014-01-17 17:43:01 +04:00
2015-01-23 17:22:18 +03:00
if Options.options.address_sanitizer:
# check HAVE_ADDRESS_SANITIZER_ATTRIBUTE
conf.CHECK_CODE('''
void test_address_sanitizer_attribute(void) __attribute__((no_sanitize_address));
void test_address_sanitizer_attribute(void)
{
return;
}
int main(void) {
return 0;
}
''',
'HAVE_ADDRESS_SANITIZER_ATTRIBUTE',
addmain=False,
2018-07-03 07:45:39 +03:00
cflags='-Wall -Wextra',
strict=True,
2015-01-23 17:22:18 +03:00
msg='Checking for address sanitizer attribute')
2014-07-31 12:18:13 +04:00
# check HAVE_FUNCTION_ATTRIBUTE_FORMAT
conf.CHECK_CODE('''
void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
int main(void) {
return 0;
}
''',
'HAVE_FUNCTION_ATTRIBUTE_FORMAT',
addmain=False,
2018-07-03 07:45:39 +03:00
strict=True,
2014-07-31 12:18:13 +04:00
msg='Checking for printf format validation support')
2018-09-17 15:17:25 +03:00
# Prototype checks
conf.CHECK_C_PROTOTYPE('setgroups',
'int setgroups(int ngroups, const gid_t *grouplist)',
define='HAVE_SETGROUPS_INT', headers='unistd.h sys/types.h')
conf.CHECK_C_PROTOTYPE('syscall',
'int syscall(int number, ...)',
define='HAVE_SYSCALL_INT', headers='unistd.h sys/syscall.h')
2014-07-31 12:18:13 +04:00
2015-08-14 11:59:05 +03:00
if (sys.platform.rfind('linux') > -1):
conf.CHECK_CODE('''
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <errno.h>
#ifdef HAVE_SYS_PRIV_H
#include <sys/priv.h>
#endif
#ifdef HAVE_SYS_ID_H
#include <sys/id.h>
#endif
#if defined(HAVE_SYSCALL_H)
#include <syscall.h>
#endif
#if defined(HAVE_SYS_SYSCALL_H)
#include <sys/syscall.h>
#endif
syscall(SYS_setresuid32, -1, -1, -1);
syscall(SYS_setresgid32, -1, -1, -1);
syscall(SYS_setreuid32, -1, -1);
syscall(SYS_setregid32, -1, -1);
syscall(SYS_setuid32, -1);
syscall(SYS_setgid32, -1);
syscall(SYS_setgroups32, 0, NULL);
''',
'HAVE_LINUX_32BIT_SYSCALLS',
msg="Checking whether Linux has 32-bit credential calls");
2015-01-23 17:27:25 +03:00
conf.CHECK_FUNCS('getresuid getresgid')
2014-01-17 17:43:01 +04:00
# Create full path to uid_wrapper
2018-02-02 17:34:33 +03:00
blddir = os.path.realpath(conf.bldnode.abspath())
2017-11-07 14:02:19 +03:00
libuid_wrapper_so_path = blddir + '/default/third_party/uid_wrapper/libuid-wrapper.so'
2014-01-17 17:43:01 +04:00
conf.DEFINE('LIBUID_WRAPPER_SO_PATH', libuid_wrapper_so_path)
conf.DEFINE('UID_WRAPPER', 1)
def build(bld):
if not bld.CONFIG_SET("USING_SYSTEM_UID_WRAPPER"):
# We need to do it this way or the library wont work.
2023-12-29 17:32:51 +03:00
# We need force_unversioned=True as symbol versioning
2014-01-17 17:43:01 +04:00
# breaks preloading!
bld.SAMBA_LIBRARY('uid_wrapper',
source='uid_wrapper.c',
2019-09-23 18:40:13 +03:00
deps='dl pthread',
2014-01-17 17:43:01 +04:00
install=False,
2023-12-29 17:32:51 +03:00
force_unversioned=True,
2014-01-17 17:43:01 +04:00
realname='libuid-wrapper.so')