CVE-2023-42669 s4-rpc_server: Disable rpcecho server by default
[Samba.git] / third_party / uid_wrapper / wscript
blobc92388184665957239626e217f0d90f828f9b97d
1 #!/usr/bin/env python
3 from waflib import Options
4 import os, sys
6 VERSION="1.3.0"
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 # 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')
27 if conf.CONFIG_SET("HAVE___THREAD"):
28 conf.DEFINE("HAVE_GCC_THREAD_LOCAL_STORAGE", 1)
30 if Options.options.address_sanitizer:
31 # check HAVE_ADDRESS_SANITIZER_ATTRIBUTE
32 conf.CHECK_CODE('''
33 void test_address_sanitizer_attribute(void) __attribute__((no_sanitize_address));
35 void test_address_sanitizer_attribute(void)
37 return;
40 int main(void) {
41 return 0;
43 ''',
44 'HAVE_ADDRESS_SANITIZER_ATTRIBUTE',
45 addmain=False,
46 cflags='-Wall -Wextra',
47 strict=True,
48 msg='Checking for address sanitizer attribute')
50 # check HAVE_FUNCTION_ATTRIBUTE_FORMAT
51 conf.CHECK_CODE('''
52 void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
54 int main(void) {
55 return 0;
57 ''',
58 'HAVE_FUNCTION_ATTRIBUTE_FORMAT',
59 addmain=False,
60 strict=True,
61 msg='Checking for printf format validation support')
62 # Prototype checks
63 conf.CHECK_C_PROTOTYPE('setgroups',
64 'int setgroups(int ngroups, const gid_t *grouplist)',
65 define='HAVE_SETGROUPS_INT', headers='unistd.h sys/types.h')
66 conf.CHECK_C_PROTOTYPE('syscall',
67 'int syscall(int number, ...)',
68 define='HAVE_SYSCALL_INT', headers='unistd.h sys/syscall.h')
70 if (sys.platform.rfind('linux') > -1):
71 conf.CHECK_CODE('''
72 #if defined(HAVE_UNISTD_H)
73 #include <unistd.h>
74 #endif
75 #include <stdlib.h>
76 #include <stdio.h>
77 #include <sys/types.h>
78 #include <errno.h>
80 #ifdef HAVE_SYS_PRIV_H
81 #include <sys/priv.h>
82 #endif
83 #ifdef HAVE_SYS_ID_H
84 #include <sys/id.h>
85 #endif
87 #if defined(HAVE_SYSCALL_H)
88 #include <syscall.h>
89 #endif
91 #if defined(HAVE_SYS_SYSCALL_H)
92 #include <sys/syscall.h>
93 #endif
95 syscall(SYS_setresuid32, -1, -1, -1);
96 syscall(SYS_setresgid32, -1, -1, -1);
97 syscall(SYS_setreuid32, -1, -1);
98 syscall(SYS_setregid32, -1, -1);
99 syscall(SYS_setuid32, -1);
100 syscall(SYS_setgid32, -1);
101 syscall(SYS_setgroups32, 0, NULL);
102 ''',
103 'HAVE_LINUX_32BIT_SYSCALLS',
104 msg="Checking whether Linux has 32-bit credential calls");
106 conf.CHECK_FUNCS('getresuid getresgid')
108 # Create full path to uid_wrapper
109 blddir = os.path.realpath(conf.bldnode.abspath())
110 libuid_wrapper_so_path = blddir + '/default/third_party/uid_wrapper/libuid-wrapper.so'
112 conf.DEFINE('LIBUID_WRAPPER_SO_PATH', libuid_wrapper_so_path)
113 conf.DEFINE('UID_WRAPPER', 1)
115 def build(bld):
116 if not bld.CONFIG_SET("USING_SYSTEM_UID_WRAPPER"):
117 # We need to do it this way or the library wont work.
118 # Using private_library=True will add symbol version which
119 # breaks preloading!
120 bld.SAMBA_LIBRARY('uid_wrapper',
121 source='uid_wrapper.c',
122 deps='dl pthread',
123 install=False,
124 realname='libuid-wrapper.so')