lib: Make ctdbd_db_attach return 0/errno
[Samba.git] / lib / uid_wrapper / wscript
blob016b33a4a73b4575ab5572b3f0e266c468097dad
1 #!/usr/bin/env python
3 import Options
4 import os, sys
6 VERSION="1.1.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 # check HAVE_CONSTRUCTOR_ATTRIBUTE
39 conf.CHECK_CODE('''
40 void test_constructor_attribute(void) __attribute__ ((constructor));
42 void test_constructor_attribute(void)
44 return;
47 int main(void) {
48 return 0;
50 ''',
51 'HAVE_CONSTRUCTOR_ATTRIBUTE',
52 addmain=False,
53 msg='Checking for library constructor support')
55 # check HAVE_DESTRUCTOR_ATTRIBUTE
56 conf.CHECK_CODE('''
57 void test_destructor_attribute(void) __attribute__ ((destructor));
59 void test_destructor_attribute(void)
61 return;
64 int main(void) {
65 return 0;
67 ''',
68 'HAVE_DESTRUCTOR_ATTRIBUTE',
69 addmain=False,
70 msg='Checking for library destructor support')
72 if Options.options.address_sanitizer:
73 # check HAVE_ADDRESS_SANITIZER_ATTRIBUTE
74 conf.CHECK_CODE('''
75 void test_address_sanitizer_attribute(void) __attribute__((no_sanitize_address));
77 void test_address_sanitizer_attribute(void)
79 return;
82 int main(void) {
83 return 0;
85 ''',
86 'HAVE_ADDRESS_SANITIZER_ATTRIBUTE',
87 addmain=False,
88 cflags='-Wall -Wextra -Werror',
89 msg='Checking for address sanitizer attribute')
91 # check HAVE_FUNCTION_ATTRIBUTE_FORMAT
92 conf.CHECK_CODE('''
93 void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
95 int main(void) {
96 return 0;
98 ''',
99 'HAVE_FUNCTION_ATTRIBUTE_FORMAT',
100 addmain=False,
101 msg='Checking for printf format validation support')
102 # Prototype checks
103 conf.CHECK_C_PROTOTYPE('setgroups',
104 'int setgroups(int ngroups, const gid_t *grouplist)',
105 define='HAVE_SETGROUPS_INT', headers='unistd.h sys/types.h')
106 conf.CHECK_C_PROTOTYPE('syscall',
107 'int syscall(int number, ...)',
108 define='HAVE_SYSCALL_INT', headers='unistd.h sys/syscall.h')
110 if (sys.platform.rfind('linux') > -1):
111 conf.CHECK_CODE('''
112 #if defined(HAVE_UNISTD_H)
113 #include <unistd.h>
114 #endif
115 #include <stdlib.h>
116 #include <stdio.h>
117 #include <sys/types.h>
118 #include <errno.h>
120 #ifdef HAVE_SYS_PRIV_H
121 #include <sys/priv.h>
122 #endif
123 #ifdef HAVE_SYS_ID_H
124 #include <sys/id.h>
125 #endif
127 #if defined(HAVE_SYSCALL_H)
128 #include <syscall.h>
129 #endif
131 #if defined(HAVE_SYS_SYSCALL_H)
132 #include <sys/syscall.h>
133 #endif
135 syscall(SYS_setresuid32, -1, -1, -1);
136 syscall(SYS_setresgid32, -1, -1, -1);
137 syscall(SYS_setreuid32, -1, -1);
138 syscall(SYS_setregid32, -1, -1);
139 syscall(SYS_setuid32, -1);
140 syscall(SYS_setgid32, -1);
141 syscall(SYS_setgroups32, 0, NULL);
142 ''',
143 'HAVE_LINUX_32BIT_SYSCALLS',
144 msg="Checking whether Linux has 32-bit credential calls");
146 conf.CHECK_FUNCS('getresuid getresgid')
148 # Create full path to uid_wrapper
149 srcdir = os.path.realpath(conf.srcdir)
150 libuid_wrapper_so_path = srcdir + '/bin/default/lib/uid_wrapper/libuid-wrapper.so'
152 conf.DEFINE('LIBUID_WRAPPER_SO_PATH', libuid_wrapper_so_path)
153 conf.DEFINE('UID_WRAPPER', 1)
155 def build(bld):
156 if not bld.CONFIG_SET("USING_SYSTEM_UID_WRAPPER"):
157 # We need to do it this way or the library wont work.
158 # Using private_library=True will add symbol version which
159 # breaks preloading!
160 bld.SAMBA_LIBRARY('uid_wrapper',
161 source='uid_wrapper.c',
162 cflags='-DNDEBUG',
163 deps='dl',
164 install=False,
165 realname='libuid-wrapper.so')