2017-03-29 16:55:53 +03:00
#!/usr/bin/env python
import os
2021-10-28 11:50:30 +03:00
VERSION="1.1.4"
2017-03-29 16:55:53 +03:00
def find_library(library_names, lookup_paths):
for directory in lookup_paths:
for filename in library_names:
2018-05-19 15:57:01 +03:00
so_path = os.path.join(directory, filename)
if os.path.exists(so_path):
return so_path
2017-03-29 16:55:53 +03:00
return ''
def configure(conf):
2017-11-24 15:34:25 +03:00
if conf.CHECK_PAM_WRAPPER():
2017-03-29 16:55:53 +03:00
conf.DEFINE('USING_SYSTEM_PAM_WRAPPER', 1)
libpam_wrapper_so_path = 'libpam_wrapper.so'
2018-05-19 15:57:01 +03:00
pam_set_items_so_path = find_library(['pam_set_items.so'],
['/usr/lib64/pam_wrapper', '/usr/lib/pam_wrapper'])
2017-03-29 16:55:53 +03:00
else:
2018-07-18 09:54:22 +03:00
if conf.CONFIG_SET("HAVE___THREAD"):
conf.DEFINE("HAVE_GCC_THREAD_LOCAL_STORAGE", 1)
2017-03-29 16:55:53 +03:00
# check HAVE_FUNCTION_ATTRIBUTE_FORMAT
conf.CHECK_CODE('''
void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
int main(void) {
return 0;
}
''',
'HAVE_FUNCTION_ATTRIBUTE_FORMAT',
addmain=False,
2018-07-03 07:45:04 +03:00
strict=True,
2017-03-29 16:55:53 +03:00
msg='Checking for printf format validation support')
conf.CHECK_HEADERS('security/pam_appl.h')
conf.CHECK_HEADERS('security/pam_modules.h')
conf.CHECK_HEADERS('security/pam_ext.h')
conf.CHECK_FUNCS_IN('pam_vsyslog',
'pam',
checklibc=False,
headers='security/pam_ext.h')
conf.CHECK_FUNCS_IN('pam_syslog',
'pam',
checklibc=False,
headers='security/pam_ext.h')
2020-03-20 17:25:47 +03:00
conf.CHECK_FUNCS_IN('pam_start_confdir',
'pam',
checklibc=False,
headers='security/pam_appl.h')
2017-03-29 16:55:53 +03:00
conf.CHECK_C_PROTOTYPE('pam_vprompt',
'int pam_vprompt(const pam_handle_t *_pamh, int _style, char **_resp, const char *_fmt, va_list _ap)',
define='HAVE_PAM_VPROMPT_CONST', headers='stdio.h sys/types.h security/pam_appl.h security/pam_modules.h')
conf.CHECK_C_PROTOTYPE('pam_prompt',
'int pam_prompt(const pam_handle_t *_pamh, int _style, char **_resp, const char *_fmt, ...)',
define='HAVE_PAM_PROMPT_CONST', headers='stdio.h sys/types.h security/pam_appl.h security/pam_modules.h')
2017-05-01 18:56:50 +03:00
conf.CHECK_C_PROTOTYPE(
'pam_strerror',
'const char *pam_strerror(const pam_handle_t *pamh, int errnum)',
define='HAVE_PAM_STRERROR_CONST',
headers='''stdio.h sys/types.h security/pam_appl.h
security/pam_modules.h''')
2017-03-29 16:55:53 +03:00
# Find the absolute path to libpam.so.0
libpam_path = find_library(['libpam.so.0', 'libpam.so'], conf.env.STANDARD_LIBPATH)
conf.DEFINE('PAM_LIBRARY', ('"%s"' % libpam_path ))
# Create full path to pam_wrapper
2018-02-02 17:34:32 +03:00
blddir = os.path.realpath(conf.bldnode.abspath())
2017-11-24 15:34:25 +03:00
libpam_wrapper_so_path = blddir + '/default/third_party/pam_wrapper/libpam-wrapper.so'
2018-05-19 15:57:01 +03:00
pam_set_items_so_path = blddir + '/default/third_party/pam_wrapper/libpam-set-items.so'
2017-03-29 16:55:53 +03:00
conf.DEFINE('LIBPAM_WRAPPER_SO_PATH', libpam_wrapper_so_path)
2018-05-19 15:57:01 +03:00
conf.DEFINE('PAM_SET_ITEMS_SO_PATH', pam_set_items_so_path)
2017-03-29 16:55:53 +03:00
conf.DEFINE('PAM_WRAPPER', 1)
def build(bld):
if not bld.CONFIG_SET("USING_SYSTEM_PAM_WRAPPER"):
# We need to do it this way or the library wont work.
# Using private_library=True will add symbol version which
# breaks preloading!
bld.SAMBA_LIBRARY('pam_wrapper',
source='pam_wrapper.c',
2020-03-20 17:25:47 +03:00
deps='dl pthread',
2017-03-29 16:55:53 +03:00
install=False,
realname='libpam-wrapper.so')
2017-11-27 21:37:49 +03:00
bld.SAMBA_SUBSYSTEM('libpamtest',
source='libpamtest.c',
deps='dl pam')
2018-05-19 15:57:01 +03:00
bld.SAMBA_LIBRARY('pam_set_items',
source='modules/pam_set_items.c',
deps='pam',
install=False,
realname='pam_set_items.so')
2017-03-29 16:55:53 +03:00
# Can be used to write pam tests in python
2019-02-15 06:37:48 +03:00
bld.SAMBA_PYTHON('pypamtest',
source='python/pypamtest.c',
deps='libpamtest',
install=False)