ldb: version 1.1.27
[Samba.git] / lib / uid_wrapper / wscript
blob8745fd0826b61af508efdf06701cf464a34e8c93
1 #!/usr/bin/env python
3 import Options
4 import os, sys
6 VERSION="1.2.1"
8 def configure(conf):
9 if conf.CHECK_BUNDLED_SYSTEM('uid_wrapper', minversion=VERSION, set_target=False):
10 conf.DEFINE('USING_SYSTEM_UID_WRAPPER', 1)
11 libuid_wrapper_so_path = 'libuid_wrapper.so'
12 else:
13 # check HAVE_GCC_ATOMIC_BUILTINS
14 conf.CHECK_CODE('''
15 #include <stdbool.h>
16 int main(void) {
17 bool x;
18 bool *p_x = &x;
19 __atomic_load(p_x, &x, __ATOMIC_RELAXED);
20 return 0;
21 ''',
22 'HAVE_GCC_ATOMIC_BUILTINS',
23 addmain=False,
24 msg='Checking for atomic builtins')
26 # check HAVE_GCC_THREAD_LOCAL_STORAGE
27 conf.CHECK_CODE('''
28 __thread int tls;
30 int main(void) {
31 return 0;
33 ''',
34 'HAVE_GCC_THREAD_LOCAL_STORAGE',
35 addmain=False,
36 msg='Checking for thread local storage')
38 if Options.options.address_sanitizer:
39 # check HAVE_ADDRESS_SANITIZER_ATTRIBUTE
40 conf.CHECK_CODE('''
41 void test_address_sanitizer_attribute(void) __attribute__((no_sanitize_address));
43 void test_address_sanitizer_attribute(void)
45 return;
48 int main(void) {
49 return 0;
51 ''',
52 'HAVE_ADDRESS_SANITIZER_ATTRIBUTE',
53 addmain=False,
54 cflags='-Wall -Wextra -Werror',
55 msg='Checking for address sanitizer attribute')
57 # check HAVE_FUNCTION_ATTRIBUTE_FORMAT
58 conf.CHECK_CODE('''
59 void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
61 int main(void) {
62 return 0;
64 ''',
65 'HAVE_FUNCTION_ATTRIBUTE_FORMAT',
66 addmain=False,
67 msg='Checking for printf format validation support')
68 # Prototype checks
69 conf.CHECK_C_PROTOTYPE('setgroups',
70 'int setgroups(int ngroups, const gid_t *grouplist)',
71 define='HAVE_SETGROUPS_INT', headers='unistd.h sys/types.h')
72 conf.CHECK_C_PROTOTYPE('syscall',
73 'int syscall(int number, ...)',
74 define='HAVE_SYSCALL_INT', headers='unistd.h sys/syscall.h')
76 if (sys.platform.rfind('linux') > -1):
77 conf.CHECK_CODE('''
78 #if defined(HAVE_UNISTD_H)
79 #include <unistd.h>
80 #endif
81 #include <stdlib.h>
82 #include <stdio.h>
83 #include <sys/types.h>
84 #include <errno.h>
86 #ifdef HAVE_SYS_PRIV_H
87 #include <sys/priv.h>
88 #endif
89 #ifdef HAVE_SYS_ID_H
90 #include <sys/id.h>
91 #endif
93 #if defined(HAVE_SYSCALL_H)
94 #include <syscall.h>
95 #endif
97 #if defined(HAVE_SYS_SYSCALL_H)
98 #include <sys/syscall.h>
99 #endif
101 syscall(SYS_setresuid32, -1, -1, -1);
102 syscall(SYS_setresgid32, -1, -1, -1);
103 syscall(SYS_setreuid32, -1, -1);
104 syscall(SYS_setregid32, -1, -1);
105 syscall(SYS_setuid32, -1);
106 syscall(SYS_setgid32, -1);
107 syscall(SYS_setgroups32, 0, NULL);
108 ''',
109 'HAVE_LINUX_32BIT_SYSCALLS',
110 msg="Checking whether Linux has 32-bit credential calls");
112 conf.CHECK_FUNCS('getresuid getresgid')
114 # Create full path to uid_wrapper
115 srcdir = os.path.realpath(conf.srcdir)
116 libuid_wrapper_so_path = srcdir + '/bin/default/lib/uid_wrapper/libuid-wrapper.so'
118 conf.DEFINE('LIBUID_WRAPPER_SO_PATH', libuid_wrapper_so_path)
119 conf.DEFINE('UID_WRAPPER', 1)
121 def build(bld):
122 if not bld.CONFIG_SET("USING_SYSTEM_UID_WRAPPER"):
123 # We need to do it this way or the library wont work.
124 # Using private_library=True will add symbol version which
125 # breaks preloading!
126 bld.SAMBA_LIBRARY('uid_wrapper',
127 source='uid_wrapper.c',
128 deps='dl',
129 install=False,
130 realname='libuid-wrapper.so')