libsecurity: Simplify struct ace_condition_script
[Samba.git] / third_party / uid_wrapper / wscript
blob5af76903fb98ec30ae9a5dfd09fe104ded2b4cba
1 #!/usr/bin/env python
3 from waflib import Options
4 import os, sys
6 VERSION="1.3.1"
8 def configure(conf):
9 if conf.CHECK_UID_WRAPPER():
10 conf.DEFINE('USING_SYSTEM_UID_WRAPPER', 1)
11 libuid_wrapper_so_path = 'libuid_wrapper.so'
12 else:
13 conf.CHECK_HEADERS('gnu/lib-names.h')
15 # check HAVE_GCC_ATOMIC_BUILTINS
16 conf.CHECK_CODE('''
17 #include <stdbool.h>
18 int main(void) {
19 bool x;
20 bool *p_x = &x;
21 __atomic_load(p_x, &x, __ATOMIC_RELAXED);
22 return 0;
23 ''',
24 'HAVE_GCC_ATOMIC_BUILTINS',
25 addmain=False,
26 msg='Checking for atomic builtins')
29 if conf.CONFIG_SET("HAVE___THREAD"):
30 conf.DEFINE("HAVE_GCC_THREAD_LOCAL_STORAGE", 1)
32 if Options.options.address_sanitizer:
33 # check HAVE_ADDRESS_SANITIZER_ATTRIBUTE
34 conf.CHECK_CODE('''
35 void test_address_sanitizer_attribute(void) __attribute__((no_sanitize_address));
37 void test_address_sanitizer_attribute(void)
39 return;
42 int main(void) {
43 return 0;
45 ''',
46 'HAVE_ADDRESS_SANITIZER_ATTRIBUTE',
47 addmain=False,
48 cflags='-Wall -Wextra',
49 strict=True,
50 msg='Checking for address sanitizer attribute')
52 # check HAVE_FUNCTION_ATTRIBUTE_FORMAT
53 conf.CHECK_CODE('''
54 void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
56 int main(void) {
57 return 0;
59 ''',
60 'HAVE_FUNCTION_ATTRIBUTE_FORMAT',
61 addmain=False,
62 strict=True,
63 msg='Checking for printf format validation support')
64 # Prototype checks
65 conf.CHECK_C_PROTOTYPE('setgroups',
66 'int setgroups(int ngroups, const gid_t *grouplist)',
67 define='HAVE_SETGROUPS_INT', headers='unistd.h sys/types.h')
68 conf.CHECK_C_PROTOTYPE('syscall',
69 'int syscall(int number, ...)',
70 define='HAVE_SYSCALL_INT', headers='unistd.h sys/syscall.h')
72 if (sys.platform.rfind('linux') > -1):
73 conf.CHECK_CODE('''
74 #if defined(HAVE_UNISTD_H)
75 #include <unistd.h>
76 #endif
77 #include <stdlib.h>
78 #include <stdio.h>
79 #include <sys/types.h>
80 #include <errno.h>
82 #ifdef HAVE_SYS_PRIV_H
83 #include <sys/priv.h>
84 #endif
85 #ifdef HAVE_SYS_ID_H
86 #include <sys/id.h>
87 #endif
89 #if defined(HAVE_SYSCALL_H)
90 #include <syscall.h>
91 #endif
93 #if defined(HAVE_SYS_SYSCALL_H)
94 #include <sys/syscall.h>
95 #endif
97 syscall(SYS_setresuid32, -1, -1, -1);
98 syscall(SYS_setresgid32, -1, -1, -1);
99 syscall(SYS_setreuid32, -1, -1);
100 syscall(SYS_setregid32, -1, -1);
101 syscall(SYS_setuid32, -1);
102 syscall(SYS_setgid32, -1);
103 syscall(SYS_setgroups32, 0, NULL);
104 ''',
105 'HAVE_LINUX_32BIT_SYSCALLS',
106 msg="Checking whether Linux has 32-bit credential calls");
108 conf.CHECK_FUNCS('getresuid getresgid')
110 # Create full path to uid_wrapper
111 blddir = os.path.realpath(conf.bldnode.abspath())
112 libuid_wrapper_so_path = blddir + '/default/third_party/uid_wrapper/libuid-wrapper.so'
114 conf.DEFINE('LIBUID_WRAPPER_SO_PATH', libuid_wrapper_so_path)
115 conf.DEFINE('UID_WRAPPER', 1)
117 def build(bld):
118 if not bld.CONFIG_SET("USING_SYSTEM_UID_WRAPPER"):
119 # We need to do it this way or the library wont work.
120 # We need force_unversioned=True as symbol versioning
121 # breaks preloading!
122 bld.SAMBA_LIBRARY('uid_wrapper',
123 source='uid_wrapper.c',
124 deps='dl pthread',
125 install=False,
126 force_unversioned=True,
127 realname='libuid-wrapper.so')