python:tests: Store keys as bytes rather than as lists of ints
[samba.git] / third_party / pam_wrapper / wscript
1 #!/usr/bin/env python
2
3 import os
4
5 VERSION="1.1.4"
6
7 def find_library(library_names, lookup_paths):
8     for directory in lookup_paths:
9         for filename in library_names:
10             so_path = os.path.join(directory, filename)
11             if os.path.exists(so_path):
12                 return so_path
13     return ''
14
15 def configure(conf):
16     if conf.CHECK_PAM_WRAPPER():
17         conf.DEFINE('USING_SYSTEM_PAM_WRAPPER', 1)
18         libpam_wrapper_so_path = 'libpam_wrapper.so'
19
20         pam_set_items_so_path = find_library(['pam_set_items.so'],
21                                              ['/usr/lib64/pam_wrapper', '/usr/lib/pam_wrapper'])
22     else:
23
24         if conf.CONFIG_SET("HAVE___THREAD"):
25             conf.DEFINE("HAVE_GCC_THREAD_LOCAL_STORAGE", 1)
26
27         # check HAVE_FUNCTION_ATTRIBUTE_FORMAT
28         conf.CHECK_CODE('''
29             void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
30
31             int main(void) {
32                 return 0;
33             }
34             ''',
35             'HAVE_FUNCTION_ATTRIBUTE_FORMAT',
36             addmain=False,
37             strict=True,
38             msg='Checking for printf format validation support')
39
40         conf.CHECK_HEADERS('security/pam_appl.h')
41         conf.CHECK_HEADERS('security/pam_modules.h')
42         conf.CHECK_HEADERS('security/pam_ext.h')
43
44         conf.CHECK_FUNCS_IN('pam_vsyslog',
45                             'pam',
46                             checklibc=False,
47                             headers='security/pam_ext.h')
48
49         conf.CHECK_FUNCS_IN('pam_syslog',
50                             'pam',
51                             checklibc=False,
52                             headers='security/pam_ext.h')
53
54         conf.CHECK_FUNCS_IN('pam_start_confdir',
55                             'pam',
56                             checklibc=False,
57                             headers='security/pam_appl.h')
58
59         conf.CHECK_C_PROTOTYPE('pam_vprompt',
60                                'int pam_vprompt(const pam_handle_t *_pamh, int _style, char **_resp, const char *_fmt, va_list _ap)',
61                                define='HAVE_PAM_VPROMPT_CONST', headers='stdio.h sys/types.h security/pam_appl.h security/pam_modules.h')
62
63         conf.CHECK_C_PROTOTYPE('pam_prompt',
64                                'int pam_prompt(const pam_handle_t *_pamh, int _style, char **_resp, const char *_fmt, ...)',
65                                define='HAVE_PAM_PROMPT_CONST', headers='stdio.h sys/types.h security/pam_appl.h security/pam_modules.h')
66
67         conf.CHECK_C_PROTOTYPE(
68             'pam_strerror',
69             'const char *pam_strerror(const pam_handle_t *pamh, int errnum)',
70             define='HAVE_PAM_STRERROR_CONST',
71             headers='''stdio.h sys/types.h security/pam_appl.h
72                        security/pam_modules.h''')
73
74         # Find the absolute path to libpam.so.0
75         libpam_path = find_library(['libpam.so.0', 'libpam.so'], conf.env.STANDARD_LIBPATH)
76         conf.DEFINE('PAM_LIBRARY', ('"%s"' % libpam_path ))
77
78         # Create full path to pam_wrapper
79         blddir = os.path.realpath(conf.bldnode.abspath())
80         libpam_wrapper_so_path = blddir + '/default/third_party/pam_wrapper/libpam-wrapper.so'
81         pam_set_items_so_path = blddir + '/default/third_party/pam_wrapper/libpam-set-items.so'
82
83     conf.DEFINE('LIBPAM_WRAPPER_SO_PATH', libpam_wrapper_so_path)
84     conf.DEFINE('PAM_SET_ITEMS_SO_PATH', pam_set_items_so_path)
85     conf.DEFINE('PAM_WRAPPER', 1)
86
87 def build(bld):
88     if not bld.CONFIG_SET("USING_SYSTEM_PAM_WRAPPER"):
89         # We need to do it this way or the library wont work.
90         # We need force_unversioned=True as symbol versioning
91         # breaks preloading!
92         bld.SAMBA_LIBRARY('pam_wrapper',
93                           source='pam_wrapper.c',
94                           deps='dl pthread',
95                           install=False,
96                           force_unversioned=True,
97                           realname='libpam-wrapper.so')
98
99         bld.SAMBA_SUBSYSTEM('libpamtest',
100                             source='libpamtest.c',
101                             deps='dl pam')
102
103         bld.SAMBA_LIBRARY('pam_set_items',
104                           source='modules/pam_set_items.c',
105                           deps='pam',
106                           install=False,
107                           force_unversioned=True,
108                           realname='pam_set_items.so')
109
110         pypamtest_cflags = ''
111         if bld.CONFIG_SET('HAVE_WNO_ERROR_DECLARATION_AFTER_STATEMENT'):
112             pypamtest_cflags = '-Wno-error=declaration-after-statement'
113
114         # Can be used to write pam tests in python
115         bld.SAMBA_PYTHON('pypamtest',
116                          source='python/pypamtest.c',
117                          cflags_end=pypamtest_cflags,
118                          deps='libpamtest',
119                          install=False)